Changeset 3066362
- Timestamp:
- 04/07/2024 04:07:47 PM (2 years ago)
- Location:
- bp-custom-functionalities
- Files:
-
- 8 added
- 4 edited
-
tags/1.0.4 (added)
-
tags/1.0.4/BP Custom Functionalities.png (added)
-
tags/1.0.4/bp-custom-functionalities.php (added)
-
tags/1.0.4/languages (added)
-
tags/1.0.4/languages/bp-custom-functionalities.mo (added)
-
tags/1.0.4/languages/bp-custom-functionalities.pot (added)
-
tags/1.0.4/loader.php (added)
-
tags/1.0.4/readme.txt (added)
-
trunk/bp-custom-functionalities.php (modified) (3 diffs)
-
trunk/languages/bp-custom-functionalities.pot (modified) (2 diffs)
-
trunk/loader.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bp-custom-functionalities/trunk/bp-custom-functionalities.php
r2091807 r3066362 1 1 <?php 2 2 defined( 'ABSPATH' ) || exit; 3 3 4 add_action( 'admin_menu', 'bp_cfunc_plugin_menu' ); 4 5 5 function bp_cfunc_plugin_menu() { 6 add_options_page( 6 add_options_page( 7 7 'BP Custom Functionalities', 8 8 'BP Custom Functionalities', … … 13 13 } 14 14 15 function bp_cfunc_plugin_func() {16 $lock = get_option( 'ps_lock_bp', true);17 $exclevels = get_option( 'ps_exclude_levels', true);15 function bp_cfunc_plugin_func() { 16 $lock = get_option( 'ps_lock_bp', true ); 17 $exclevels = get_option( 'ps_exclude_levels', true ); 18 18 global $wp_roles; 19 $roles = $wp_roles->get_names();20 $excroles = get_option('ps_exclude_roles', true);21 $restrict_member = get_option('ps_restrict_member', true);22 $lock_bb = get_option('ps_lock_bb', true);19 $roles = $wp_roles->get_names(); 20 $excroles = get_option( 'ps_exclude_roles', true ); 21 $restrict_member = get_option( 'ps_restrict_member', true ); 22 $lock_bb = get_option( 'ps_lock_bb', true ); 23 23 ?> 24 24 <div class="wrap"> 25 <h2><?php _e( 'BP Custom Functionalities Settings','bp-custom-functionalities');?></h2>25 <h2><?php _e( 'BP Custom Functionalities Settings', 'bp-custom-functionalities' ); ?></h2> 26 26 <hr/> 27 27 <form method="post"> 28 <?php wp_nonce_field( basename( __FILE__), 'bp_cfunc_settings' );?>28 <?php wp_nonce_field( basename( __FILE__ ), 'bp_cfunc_settings' ); ?> 29 29 <table class="form-table"> 30 30 <tr> 31 <th scope="row"><?php _e('Lock BuddyPress For Guest Users','bp-custom-functionalities');?></th> 32 <td><input type="checkbox" name="ps_lock_bp" value="1" <?php if($lock): ?> checked <?php endif; ?>/></td> 31 <th scope="row"><?php _e( 'Lock BuddyPress For Guest Users', 'bp-custom-functionalities' );?></th> 32 <td><input type="checkbox" name="ps_lock_bp" value="1" <?php if ( $lock ) : ?> checked <?php endif; ?>/></td> 33 </tr> 34 <?php if ( class_exists( 'bbPress' ) ) : ?> 35 <tr> 36 <th scope="row"><?php _e( 'Lock bbPress For Guest Users', 'bp-custom-functionalities' ); ?></th> 37 <td><input type="checkbox" name="ps_lock_bb" value="1" <?php if ( $lock_bb ) : ?> checked <?php endif; ?>/></td> 33 38 34 39 </tr> 35 <?php if ( class_exists( 'bbPress' ) ) :?> 40 <?php endif; ?> 41 <?php 42 global $membership_levels; 43 if ( $membership_levels ) : 44 ?> 45 <tr> 46 <th scope="row"><?php _e( 'Restrict BuddyPress To Certain Membership levels', 'bp-custom-functionalities' ); ?></th> 47 <td> 48 <select style="width: 25%; font: inherit;" size="<?php echo count( $membership_levels ) + 1; ?>" name="ps_exclude_levels[]" multiple> 49 <option>--SELECT LEVELS--</option> 50 <?php foreach ( $membership_levels as $keys => $level ) { ?> 51 <option value="<?php echo $level->id; ?>" <?php if ( ! empty( $exclevels ) && is_array( $exclevels ) && in_array( $level->id, $exclevels ) ) : ?> selected <?php endif; ?>> 52 <?php echo $level->name; ?> 53 </option> 54 <?php } ?> 55 </select> 56 </td> 57 </tr> 58 <?php 59 endif; 60 ?> 36 61 <tr> 37 <th scope="row"><?php _e('Lock bbPress For Guest Users','bp-custom-functionalities');?></th> 38 <td><input type="checkbox" name="ps_lock_bb" value="1" <?php if($lock_bb): ?> checked <?php endif; ?>/></td> 39 40 </tr> 41 <?php endif;?> 42 <?php 43 global $membership_levels; 44 if($membership_levels): 45 ?> 46 <tr> 47 <th scope="row"><?php _e('Restrict BuddyPress To Certain Membership levels','bp-custom-functionalities');?></th> 62 <th scope="row"><?php _e( 'Restrict Members From Viewing Other Members Profile', 'bp-custom-functionalities' ); ?></th> 48 63 <td> 49 <select style="width: 25%; font: inherit;" size="<?php echo count($membership_levels)+1;?>" name="ps_exclude_levels[]" multiple> 50 <option>--SELECT LEVELS--</option> 51 <?php foreach($membership_levels as $keys => $level) { ?> 52 <option value="<?php echo $level->id;?>" <?php if( !empty($exclevels) && in_array($level->id, $exclevels)):?> selected <?php endif;?>> 53 <?php echo $level->name;?> 54 </option> 55 <?php }?> 56 </select> 57 </td> 58 </tr> 59 <?php endif;?> 60 <tr> 61 <th scope="row"><?php _e('Restrict Members From Viewing Other Members Profile','bp-custom-functionalities');?></th> 62 <td> 63 <input type="checkbox" name="ps_restrict_member" value="1" <?php if($restrict_member): ?> checked <?php endif; ?>/> 64 <input type="checkbox" name="ps_restrict_member" value="1" <?php if ( $restrict_member ): ?> checked <?php endif; ?>/> 64 65 </td> 65 66 </tr> 66 67 67 68 <tr> 68 <th scope="row"><?php _e( 'Exclude Roles From Members Directory','bp-custom-functionalities');?></th>69 <th scope="row"><?php _e( 'Exclude Roles From Members Directory', 'bp-custom-functionalities' ); ?></th> 69 70 <td> 70 <select style="width: 25%; font: inherit;" size="<?php echo count( $roles)+1;?>" name="ps_exclude_roles[]" multiple>71 <select style="width: 25%; font: inherit;" size="<?php echo count( $roles ) + 1; ?>" name="ps_exclude_roles[]" multiple> 71 72 <option>--SELECT ROLES--</option> 72 <?php foreach ($roles as $key => $role){ ?>73 <option value="<?php echo $key; ?>" <?php if( !empty($excroles) && is_array($excroles) && in_array($key, $excroles)):?> selected <?php endif;?>>74 <?php echo $role; ?>73 <?php foreach ( $roles as $key => $role ) { ?> 74 <option value="<?php echo $key; ?>" <?php if ( ! empty( $excroles ) && is_array( $excroles ) && in_array( $key, $excroles ) ): ?> selected <?php endif; ?>> 75 <?php echo $role; ?> 75 76 </option> 76 <?php } ?>77 <?php } ?> 77 78 </select> 78 79 </td> … … 85 86 } 86 87 87 add_action('admin_init','bp_cfunc_save_settings'); 88 function bp_cfunc_save_settings(){ 89 if(current_user_can('manage_options')){ 90 if(isset($_POST['save_ps_settings'])){ 91 if ( empty($_POST['bp_cfunc_settings']) || !wp_verify_nonce( $_POST['bp_cfunc_settings'], basename(__FILE__) ) ) return; 88 add_action( 'admin_init', 'bp_cfunc_save_settings' ); 89 function bp_cfunc_save_settings() { 90 if ( current_user_can( 'manage_options' ) ) { 91 if ( isset( $_POST['save_ps_settings'] ) ) { 92 if ( empty( $_POST['bp_cfunc_settings'] ) || ! wp_verify_nonce( $_POST[ 'bp_cfunc_settings' ], basename( __FILE__ ) ) ) return; 93 $lockbp = isset( $_POST['ps_lock_bp'] ) ? '1' : '0'; 94 update_option( 'ps_lock_bp', $lockbp, true ); 92 95 93 $lockb p = isset($_POST['ps_lock_bp']) ? '1' : '0';94 update_option( 'ps_lock_bp',$lockbp,true);96 $lockbb = isset( $_POST['ps_lock_bb'] ) ? '1' : '0'; 97 update_option( 'ps_lock_bb', $lockbb, true ); 95 98 96 $lockbb = isset($_POST['ps_lock_bb']) ? '1' : '0'; 97 update_option('ps_lock_bb',$lockbb,true); 99 $retrict_levels = isset( $_POST['ps_exclude_levels'] ) ? array_map( 'sanitize_text_field', $_POST['ps_exclude_levels'] ) : ''; 98 100 99 $retrict_levels = isset($_POST['ps_exclude_levels']) ? array_map( 'sanitize_text_field', $_POST['ps_exclude_levels'] ) : '';101 update_option( 'ps_exclude_levels', $retrict_levels, true ); 100 102 101 update_option('ps_exclude_levels',$retrict_levels ,true );103 $exclude_members = isset( $_POST['ps_exclude_roles'] ) ? array_map( 'sanitize_text_field', $_POST['ps_exclude_roles'] ) : ''; 102 104 103 $exclude_members = isset($_POST['ps_exclude_roles']) ? array_map( 'sanitize_text_field', $_POST['ps_exclude_roles']) : '';105 update_option( 'ps_exclude_roles', $exclude_members, true ); 104 106 105 update_option('ps_exclude_roles',$exclude_members,true); 106 107 $restrict_members = isset($_POST['ps_restrict_member']) ? '1' : '0'; 108 update_option('ps_restrict_member',$restrict_members,true); 107 $restrict_members = isset( $_POST['ps_restrict_member'] ) ? '1' : '0'; 108 update_option( 'ps_restrict_member', $restrict_members, true ); 109 109 } 110 110 } 111 111 } 112 ?> -
bp-custom-functionalities/trunk/languages/bp-custom-functionalities.pot
r1955356 r3066362 3 3 msgstr "" 4 4 "Project-Id-Version: BP Custom Functionalities 1.0.0\n" 5 "POT-Creation-Date: 20 18-10-09 04:07+0530\n"5 "POT-Creation-Date: 2024-04-07 21:33+0530\n" 6 6 "PO-Revision-Date: 2018-10-08 04:18+0530\n" 7 7 "Last-Translator: \n" … … 11 11 "Content-Type: text/plain; charset=UTF-8\n" 12 12 "Content-Transfer-Encoding: 8bit\n" 13 "X-Generator: Poedit 2.1.1\n" 13 "Plural-Forms: nplurals=2; plural=(n != 1);\n" 14 "X-Generator: Poedit 3.4.2\n" 14 15 "X-Poedit-Basepath: ..\n" 15 "Plural-Forms: nplurals=2; plural=(n != 1);\n"16 16 "X-Poedit-SourceCharset: UTF-8\n" 17 17 "X-Poedit-KeywordsList: __;_e\n" 18 18 "X-Poedit-SearchPath-0: .\n" 19 19 20 #: bp-custom-functionalities.php:2 420 #: bp-custom-functionalities.php:25 21 21 msgid "BP Custom Functionalities Settings" 22 22 msgstr "" 23 23 24 #: bp-custom-functionalities.php: 2924 #: bp-custom-functionalities.php:31 25 25 msgid "Lock BuddyPress For Guest Users" 26 26 msgstr "" 27 27 28 #: bp-custom-functionalities.php:38 28 #: bp-custom-functionalities.php:36 29 msgid "Lock bbPress For Guest Users" 30 msgstr "" 31 32 #: bp-custom-functionalities.php:46 29 33 msgid "Restrict BuddyPress To Certain Membership levels" 30 34 msgstr "" 31 35 32 #: bp-custom-functionalities.php: 5236 #: bp-custom-functionalities.php:62 33 37 msgid "Restrict Members From Viewing Other Members Profile" 34 38 msgstr "" 35 39 36 #: bp-custom-functionalities.php: 5940 #: bp-custom-functionalities.php:69 37 41 msgid "Exclude Roles From Members Directory" 38 42 msgstr "" 39 43 40 #: bp-custom-functionalities.php:74 41 msgid "For any custom development or support you can contact at <a href=\"https://prashantdev.wordpress.com/contact\">https://prashantdev.wordpress.com/contact</a>." 42 msgstr "" 43 44 #: loader.php:27 44 #: loader.php:26 45 45 msgid "BP Custom Functionalities requires BuddyPress to be active and running." 46 46 msgstr "" -
bp-custom-functionalities/trunk/loader.php
r2170237 r3066362 6 6 * Author: Prashant Singh 7 7 * Author URI: https://profiles.wordpress.org/prashantvatsh 8 * Version: 1.0. 38 * Version: 1.0.4 9 9 * Text Domain: bp-custom-functionalities 10 10 * License: GPLv2 or later … … 13 13 defined( 'ABSPATH' ) || exit; 14 14 15 16 add_action('plugins_loaded','bp_cfunc_check_is_buddypress'); 17 function bp_cfunc_check_is_buddypress(){ 18 if ( function_exists('bp_is_active') ) { 15 add_action( 'plugins_loaded', 'bp_cfunc_check_is_buddypress' ); 16 function bp_cfunc_check_is_buddypress() { 17 if ( function_exists( 'bp_is_active' ) ) { 19 18 require( dirname( __FILE__ ) . '/bp-custom-functionalities.php' ); 20 } else{19 } else { 21 20 add_action( 'admin_notices', 'bp_cfunc_buddypress_inactive__error' ); 22 21 } 23 22 } 24 23 25 function bp_cfunc_buddypress_inactive__error() {24 function bp_cfunc_buddypress_inactive__error() { 26 25 $class = 'notice notice-error'; 27 26 $message = __( 'BP Custom Functionalities requires BuddyPress to be active and running.', 'bp-custom-functionalities' ); 28 printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); 27 printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); 29 28 } 30 29 31 // Restrict BuddyPress 30 // Restrict BuddyPress. 32 31 function bp_cfunc_guest_redirect() { 33 $lock = get_option( 'ps_lock_bp', true);34 if ($lock){32 $lock = get_option( 'ps_lock_bp', true ); 33 if ( $lock ) { 35 34 global $bp; 36 35 if ( is_buddypress() || bp_is_user() ) { 37 if(!is_user_logged_in()) {38 wp_redirect(site_url());36 if ( ! is_user_logged_in() ) { 37 wp_redirect( site_url() ); 39 38 exit; 40 }41 }39 } 40 } 42 41 } 43 $lockbb = get_option('ps_lock_bb', true); 44 if($lockbb){ 42 43 $lockbb = get_option( 'ps_lock_bb', true ); 44 if ( $lockbb ) { 45 45 if ( is_bbpress() ) { 46 if(!is_user_logged_in()) {47 wp_redirect(site_url());46 if ( ! is_user_logged_in() ) { 47 wp_redirect( site_url() ); 48 48 exit; 49 }50 }49 } 50 } 51 51 } 52 52 } 53 add_ filter('get_header','bp_cfunc_guest_redirect',1);53 add_action( 'wp', 'bp_cfunc_guest_redirect', 1 ); 54 54 55 55 56 56 57 // Restrict Member's Profile57 // Restrict Member's Profile. 58 58 add_action( 'wp', 'bp_cfunc_member_redirect' ); 59 function bp_cfunc_member_redirect() {60 $restrict_profile = get_option( 'ps_restrict_member', true);61 if ($restrict_profile && bp_is_user()){59 function bp_cfunc_member_redirect() { 60 $restrict_profile = get_option( 'ps_restrict_member', true ); 61 if ( $restrict_profile && bp_is_user() ) { 62 62 global $bp; 63 $current_user_id = (int) trim($bp->loggedin_user->id); 64 $member_id = (int) trim($bp->displayed_user->id); 65 if (!current_user_can('manage_options') && $current_user_id !== $member_id) 66 { 67 wp_redirect(site_url()); 68 exit; 69 } 63 $current_user_id = (int) trim( $bp->loggedin_user->id ); 64 $member_id = (int) trim( $bp->displayed_user->id ); 65 if ( ! current_user_can( 'manage_options' ) && $current_user_id !== $member_id ) { 66 wp_redirect( site_url() ); 67 exit; 68 } 70 69 } 71 70 } 72 71 73 // Exclude User Roles From Member Directory74 add_action( 'bp_ajax_querystring','bp_cfunc_exclude_roles_members_dir',20,2);75 function bp_cfunc_exclude_roles_members_dir( $ps=false,$object=false){76 $exc_roles = get_option('ps_exclude_roles', true);77 $users=array();72 // Exclude User Roles From Member Directory. 73 add_action( 'bp_ajax_querystring', 'bp_cfunc_exclude_roles_members_dir', 20, 2 ); 74 function bp_cfunc_exclude_roles_members_dir( $ps = false, $object_name = false ) { 75 $exc_roles = get_option( 'ps_exclude_roles', true ); 76 $users = array(); 78 77 79 if(!empty($exc_roles)){80 foreach ($exc_roles as $key => $value) {81 $roles[] = $value;78 if ( ! empty( $exc_roles ) && is_array( $exc_roles ) ) { 79 foreach ( $exc_roles as $key => $value ) { 80 $roles[] = $value; 82 81 } 83 82 $users = get_users( array( 'role__in' => $roles, 'fields' => 'ID' ) ); 84 83 } 85 84 86 if($users){ 85 if ( $users ) { 86 if ( $object_name != 'members' ) 87 return $ps; 87 88 88 if($object!='members') 89 return $ps; 90 91 $excluded_user = implode(',',$users); 92 93 $args=wp_parse_args($ps); 94 95 if(!empty($args['user_id'])) 96 return $ps; 97 98 if(!empty($args['exclude'])) 99 $args['exclude']=$args['exclude'].','.$excluded_user; 100 else 101 $args['exclude']=$excluded_user; 102 103 $ps=build_query($args); 104 105 } 106 return $ps; 89 $excluded_user = implode( ',', $users ); 90 $args = wp_parse_args( $ps ); 91 92 if ( ! empty( $args['user_id'] ) ) 93 return $ps; 94 95 if ( ! empty( $args['exclude'] ) ) 96 $args['exclude'] = $args['exclude'] . ',' . $excluded_user; 97 else 98 $args['exclude'] = $excluded_user; 99 100 $ps = build_query( $args ); 101 } 102 return $ps; 107 103 } 108 104 105 // Restrict Membership levels From BuddyPress. 106 add_action( 'wp', 'bp_cfunc_restrict_levels' ); 107 function bp_cfunc_restrict_levels() { 108 global $bp, $membership_levels; 109 $exc_levels = get_option( 'ps_exclude_levels', true ); 110 if ( is_user_logged_in() && ! empty( $membership_levels ) && ! current_user_can( 'manage_options' ) ) { 111 if ( is_buddypress() || bp_is_user() ) { 112 global $current_user; 113 $current_user_membership_level = pmpro_getMembershipLevelForUser( $current_user->ID ); 114 if ( empty( $current_user_membership_level ) ) { 115 wp_redirect( site_url() ); 116 exit; 117 } 118 } 119 } 109 120 110 //Restrict Membership levels From BuddyPress 111 add_action('get_header','bp_cfunc_restrict_levels'); 112 function bp_cfunc_restrict_levels(){ 113 global $bp, $membership_levels; 114 $exc_levels = get_option('ps_exclude_levels', true); 115 if( is_user_logged_in() && !empty($membership_levels) && !current_user_can('manage_options')){ 116 117 if ( is_buddypress() || bp_is_user() ) { 118 global $current_user; 119 $current_user_membership_level = pmpro_getMembershipLevelForUser($current_user->ID); 120 if(empty($current_user_membership_level)){ 121 wp_redirect(site_url()); 122 exit; 123 } 124 } 125 126 } 127 128 if(!empty($exc_levels) && !empty($membership_levels)){ 129 121 if ( ! empty( $exc_levels ) && ! empty( $membership_levels ) && is_array( $exc_levels ) ) { 130 122 if ( is_buddypress() || bp_is_user() ) { 131 if(is_user_logged_in() && !current_user_can('manage_options')){132 global $current_user;133 $current_user_membership_level = pmpro_getMembershipLevelForUser( $current_user->ID);134 if(in_array($current_user_membership_level->ID, $exc_levels) ){135 wp_redirect(site_url());123 if ( is_user_logged_in() && ! current_user_can( 'manage_options' ) ) { 124 global $current_user; 125 $current_user_membership_level = pmpro_getMembershipLevelForUser( $current_user->ID ); 126 if ( in_array( $current_user_membership_level->ID, $exc_levels ) ) { 127 wp_redirect( site_url() ); 136 128 exit; 137 }138 }129 } 130 } 139 131 } 140 141 132 } 142 133 } 143 134 144 // Manage Members Count After Role Exclusion 145 function bp_cfunc_hide_get_total_filter($count){ 146 $exc_roles = get_option('ps_exclude_roles', true); 147 $users=array(); 135 // Manage Members Count After Role Exclusion. 136 function bp_cfunc_hide_get_total_filter( $count ) { 137 $exc_roles = get_option( 'ps_exclude_roles', true ); 138 $users = array(); 139 $roles = array(); 148 140 149 if(!empty($exc_roles)){150 foreach ($exc_roles as $key => $value) {151 $roles[] = $value;141 if ( ! empty( $exc_roles ) && is_array( $exc_roles ) ) { 142 foreach ( $exc_roles as $key => $value ) { 143 $roles[] = $value; 152 144 } 153 145 $users = get_users( array( 'role__in' => $roles, 'fields' => 'ID' ) ); 154 146 } 155 147 156 if ($users){157 $users_count = count( $users);158 $count = $count -$users_count;148 if ( $users ) { 149 $users_count = count( $users ); 150 $count = $count - $users_count; 159 151 } 160 return $count;152 return $count; 161 153 } 162 add_filter('bp_get_total_member_count','bp_cfunc_hide_get_total_filter'); 163 ?> 154 add_filter( 'bp_get_total_member_count', 'bp_cfunc_hide_get_total_filter' ); -
bp-custom-functionalities/trunk/readme.txt
r2170237 r3066362 1 1 === BP Custom Functionalities === 2 2 Contributors: prashantvatsh 3 Tags: buddypress, members directory, guest user restriction, bp lock, membership level buddypress restriction, pmpro, pmpro membership level, private profile, paid membership pro, lock bbpress, restrict buddypress, exclude member roles3 Tags: guest user restriction, pmpro membership level buddypress restriction, private profile, lock bbpress, exclude member roles 4 4 Requires at least: 4.9.0 5 Tested up to: 5.2.36 Stable tag: 1.0. 35 Tested up to: 6.5 6 Stable tag: 1.0.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 69 69 Fixed All Members Count Issue 70 70 71 = 1.0.4 = 72 Fixed comaptibility issues 73 71 74 == Upgrade Notice == 72 75 = Initial Release =
Note: See TracChangeset
for help on using the changeset viewer.