Skip to:
Content

BuddyPress.org

Ticket #8479: 8479.patch

File 8479.patch, 8.6 KB (added by imath, 3 years ago)
  • src/bp-members/bp-members-admin.php

    diff --git src/bp-members/bp-members-admin.php src/bp-members/bp-members-admin.php
    index 44a56a134..1b80fe190 100644
     
    1010// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
    1212
     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 */
     20function 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
    1331// Load the BP Members admin.
    1432add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) );
    1533
  • src/bp-members/classes/class-bp-members-admin.php

    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 { 
    170170                // Add menu item to all users menu.
    171171                add_action( 'admin_menu',               array( $this, 'admin_menus'       ), 5     );
    172172                add_action( 'network_admin_menu',       array( $this, 'admin_menus'       ), 5     );
    173                 add_action( 'user_admin_menu',          array( $this, 'user_profile_menu' ), 5     );
    174173
    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     );
    178176
    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                }
    181184
    182185                // Add a row action to users listing.
    183186                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' ) );
    187193                }
    188194
    189195                // 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                }
    191199
    192200                // Process changes to member type.
    193201                add_action( 'bp_members_admin_load', array( $this, 'process_member_type_update' ) );
    class BP_Members_Admin { 
    478486                // Setup the hooks array.
    479487                $hooks = array();
    480488
    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                }
    490500
    491501                // Only show sign-ups where they belong.
    492502                if ( ( ! bp_is_network_activated() && ! is_network_admin() ) || ( is_network_admin() && bp_is_network_activated() ) ) {
    class BP_Members_Admin { 
    650660                        return;
    651661                }
    652662
    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";
    675666
    676667                        /**
    677                          * Filters the JS URL to enqueue in the Members admin area.
     668                         * Filters the CSS URL to enqueue in the Members admin area.
    678669                         *
    679670                         * @since 2.0.0
    680671                         *
    681                          * @param string $js URL to the JavaScript admin file to load.
     672                         * @param string $css URL to the CSS admin file to load.
    682673                         */
    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";
    685686
    686                         if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) {
    687687                                /**
    688                                  * Get Thickbox.
     688                                 * Filters the JS URL to enqueue in the Members admin area.
     689                                 *
     690                                 * @since 2.0.0
    689691                                 *
    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.
    694693                                 */
    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' );
    697708
    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                                }
    700712                        }
    701713                }
    702714
    class BP_Members_Admin { 
    10051017                if ( true === $this->is_self_profile ) {
    10061018                        $title = __( 'Profile',   'buddypress' );
    10071019                } else {
    1008                         $title = __( 'Edit User', 'buddypress' );
     1020                        /* translators: %s: User's display name. */
     1021                        $title = sprintf( __( 'Edit User %s', 'buddypress' ), $user->display_name );
    10091022                }
    10101023
    10111024                // Construct URL for form.
  • tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php

    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 
    292292                        $this->markTestSkipped();
    293293                }
    294294
     295                require BP_PLUGIN_DIR . 'bp-members/bp-members-admin.php';
     296
    295297                // Emulate being in the admin area.
    296298                if ( ! class_exists( 'BP_Members_Admin', false ) ) {
    297299                        require BP_PLUGIN_DIR . 'bp-members/classes/class-bp-members-admin.php';