diff --git src/bp-members/bp-members-admin.php src/bp-members/bp-members-admin.php
index 44a56a134..1b80fe190 100644
|
|
|
10 | 10 | // Exit if accessed directly. |
11 | 11 | defined( 'ABSPATH' ) || exit; |
12 | 12 | |
| 13 | /** |
| 14 | * Is the Admin User's community profile enabled? |
| 15 | * |
| 16 | * @since 10.0.0 |
| 17 | * |
| 18 | * @return bool True if enabled. False otherwise. |
| 19 | */ |
| 20 | function bp_members_is_community_profile_enabled() { |
| 21 | /** |
| 22 | * Filter here to disable the Admin User's Community profile. |
| 23 | * |
| 24 | * @since 10.0.0 |
| 25 | * |
| 26 | * @param bool $value By default the Admin User's Community profile is enabled. |
| 27 | */ |
| 28 | return apply_filters( 'bp_members_is_community_profile_enabled', true ); |
| 29 | } |
| 30 | |
13 | 31 | // Load the BP Members admin. |
14 | 32 | add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) ); |
15 | 33 | |
diff --git src/bp-members/classes/class-bp-members-admin.php src/bp-members/classes/class-bp-members-admin.php
index 8027051b1..19ec1946b 100644
|
|
class BP_Members_Admin { |
170 | 170 | // Add menu item to all users menu. |
171 | 171 | add_action( 'admin_menu', array( $this, 'admin_menus' ), 5 ); |
172 | 172 | add_action( 'network_admin_menu', array( $this, 'admin_menus' ), 5 ); |
173 | | add_action( 'user_admin_menu', array( $this, 'user_profile_menu' ), 5 ); |
174 | 173 | |
175 | | // Create the Profile Navigation (Profile/Extended Profile). |
176 | | add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); |
177 | | add_action( 'show_user_profile', array( $this, 'profile_nav' ), 99, 1 ); |
| 174 | if ( bp_members_is_community_profile_enabled() ) { |
| 175 | add_action( 'user_admin_menu', array( $this, 'user_profile_menu' ), 5 ); |
178 | 176 | |
179 | | // Editing users of a specific site. |
180 | | add_action( "admin_head-site-users.php", array( $this, 'profile_admin_head' ) ); |
| 177 | // Create the Profile Navigation (Profile/Extended Profile). |
| 178 | add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); |
| 179 | add_action( 'show_user_profile', array( $this, 'profile_nav' ), 99, 1 ); |
| 180 | |
| 181 | // Editing users of a specific site. |
| 182 | add_action( "admin_head-site-users.php", array( $this, 'profile_admin_head' ) ); |
| 183 | } |
181 | 184 | |
182 | 185 | // Add a row action to users listing. |
183 | 186 | if ( bp_core_do_network_admin() ) { |
184 | | add_filter( 'ms_user_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
185 | | add_action( 'admin_init', array( $this, 'add_edit_profile_url_filter' ) ); |
186 | | add_action( 'wp_after_admin_bar_render', array( $this, 'remove_edit_profile_url_filter' ) ); |
| 187 | if ( bp_members_is_community_profile_enabled() ) { |
| 188 | add_filter( 'ms_user_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
| 189 | } |
| 190 | |
| 191 | add_action( 'admin_init', array( $this, 'add_edit_profile_url_filter' ) ); |
| 192 | add_action( 'wp_after_admin_bar_render', array( $this, 'remove_edit_profile_url_filter' ) ); |
187 | 193 | } |
188 | 194 | |
189 | 195 | // Add user row actions for single site. |
190 | | add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
| 196 | if ( bp_members_is_community_profile_enabled() ) { |
| 197 | add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
| 198 | } |
191 | 199 | |
192 | 200 | // Process changes to member type. |
193 | 201 | add_action( 'bp_members_admin_load', array( $this, 'process_member_type_update' ) ); |
… |
… |
class BP_Members_Admin { |
478 | 486 | // Setup the hooks array. |
479 | 487 | $hooks = array(); |
480 | 488 | |
481 | | // Manage user's profile. |
482 | | $hooks['user'] = $this->user_page = add_submenu_page( |
483 | | $this->user_profile . '.php', |
484 | | __( 'Edit Profile', 'buddypress' ), |
485 | | __( 'Edit Profile', 'buddypress' ), |
486 | | 'read', |
487 | | 'bp-profile-edit', |
488 | | array( $this, 'user_admin' ) |
489 | | ); |
| 489 | if ( bp_members_is_community_profile_enabled() ) { |
| 490 | // Manage user's profile. |
| 491 | $hooks['user'] = $this->user_page = add_submenu_page( |
| 492 | $this->user_profile . '.php', |
| 493 | __( 'Edit Profile', 'buddypress' ), |
| 494 | __( 'Edit Profile', 'buddypress' ), |
| 495 | 'read', |
| 496 | 'bp-profile-edit', |
| 497 | array( $this, 'user_admin' ) |
| 498 | ); |
| 499 | } |
490 | 500 | |
491 | 501 | // Only show sign-ups where they belong. |
492 | 502 | if ( ( ! bp_is_network_activated() && ! is_network_admin() ) || ( is_network_admin() && bp_is_network_activated() ) ) { |
… |
… |
class BP_Members_Admin { |
650 | 660 | return; |
651 | 661 | } |
652 | 662 | |
653 | | $min = bp_core_get_minified_asset_suffix(); |
654 | | $css = $this->css_url . "admin{$min}.css"; |
655 | | |
656 | | /** |
657 | | * Filters the CSS URL to enqueue in the Members admin area. |
658 | | * |
659 | | * @since 2.0.0 |
660 | | * |
661 | | * @param string $css URL to the CSS admin file to load. |
662 | | */ |
663 | | $css = apply_filters( 'bp_members_admin_css', $css ); |
664 | | |
665 | | wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() ); |
666 | | |
667 | | wp_style_add_data( 'bp-members-css', 'rtl', 'replace' ); |
668 | | if ( $min ) { |
669 | | wp_style_add_data( 'bp-members-css', 'suffix', $min ); |
670 | | } |
671 | | |
672 | | // Only load JavaScript for BuddyPress profile. |
673 | | if ( get_current_screen()->id == $this->user_page ) { |
674 | | $js = $this->js_url . "admin{$min}.js"; |
| 663 | if ( bp_members_is_community_profile_enabled() ) { |
| 664 | $min = bp_core_get_minified_asset_suffix(); |
| 665 | $css = $this->css_url . "admin{$min}.css"; |
675 | 666 | |
676 | 667 | /** |
677 | | * Filters the JS URL to enqueue in the Members admin area. |
| 668 | * Filters the CSS URL to enqueue in the Members admin area. |
678 | 669 | * |
679 | 670 | * @since 2.0.0 |
680 | 671 | * |
681 | | * @param string $js URL to the JavaScript admin file to load. |
| 672 | * @param string $css URL to the CSS admin file to load. |
682 | 673 | */ |
683 | | $js = apply_filters( 'bp_members_admin_js', $js ); |
684 | | wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); |
| 674 | $css = apply_filters( 'bp_members_admin_css', $css ); |
| 675 | |
| 676 | wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() ); |
| 677 | |
| 678 | wp_style_add_data( 'bp-members-css', 'rtl', 'replace' ); |
| 679 | if ( $min ) { |
| 680 | wp_style_add_data( 'bp-members-css', 'suffix', $min ); |
| 681 | } |
| 682 | |
| 683 | // Only load JavaScript for BuddyPress profile. |
| 684 | if ( get_current_screen()->id == $this->user_page ) { |
| 685 | $js = $this->js_url . "admin{$min}.js"; |
685 | 686 | |
686 | | if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) { |
687 | 687 | /** |
688 | | * Get Thickbox. |
| 688 | * Filters the JS URL to enqueue in the Members admin area. |
| 689 | * |
| 690 | * @since 2.0.0 |
689 | 691 | * |
690 | | * We cannot simply use add_thickbox() here as WordPress is not playing |
691 | | * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249 |
692 | | * Using media-upload might be interesting in the future for the send to editor stuff |
693 | | * and we make sure the tb_window is wide enough |
| 692 | * @param string $js URL to the JavaScript admin file to load. |
694 | 693 | */ |
695 | | wp_enqueue_style ( 'thickbox' ); |
696 | | wp_enqueue_script( 'media-upload' ); |
| 694 | $js = apply_filters( 'bp_members_admin_js', $js ); |
| 695 | wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); |
| 696 | |
| 697 | if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) { |
| 698 | /** |
| 699 | * Get Thickbox. |
| 700 | * |
| 701 | * We cannot simply use add_thickbox() here as WordPress is not playing |
| 702 | * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249 |
| 703 | * Using media-upload might be interesting in the future for the send to editor stuff |
| 704 | * and we make sure the tb_window is wide enough |
| 705 | */ |
| 706 | wp_enqueue_style ( 'thickbox' ); |
| 707 | wp_enqueue_script( 'media-upload' ); |
697 | 708 | |
698 | | // Get Avatar Uploader. |
699 | | bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' ); |
| 709 | // Get Avatar Uploader. |
| 710 | bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' ); |
| 711 | } |
700 | 712 | } |
701 | 713 | } |
702 | 714 | |
… |
… |
class BP_Members_Admin { |
1005 | 1017 | if ( true === $this->is_self_profile ) { |
1006 | 1018 | $title = __( 'Profile', 'buddypress' ); |
1007 | 1019 | } else { |
1008 | | $title = __( 'Edit User', 'buddypress' ); |
| 1020 | /* translators: %s: User's display name. */ |
| 1021 | $title = sprintf( __( 'Edit User %s', 'buddypress' ), $user->display_name ); |
1009 | 1022 | } |
1010 | 1023 | |
1011 | 1024 | // Construct URL for form. |
diff --git tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php
index cefd6cf3e..8fa55361c 100644
|
|
class BP_Tests_Core_Functions_BpCoreGetDirectoryPageIds extends BP_UnitTestCase |
292 | 292 | $this->markTestSkipped(); |
293 | 293 | } |
294 | 294 | |
| 295 | require BP_PLUGIN_DIR . 'bp-members/bp-members-admin.php'; |
| 296 | |
295 | 297 | // Emulate being in the admin area. |
296 | 298 | if ( ! class_exists( 'BP_Members_Admin', false ) ) { |
297 | 299 | require BP_PLUGIN_DIR . 'bp-members/classes/class-bp-members-admin.php'; |