Skip to:
Content

BuddyPress.org

Ticket #9184: 9184.diff

File 9184.diff, 2.3 KB (added by johnjamesjacoby, 10 months ago)
  • src/bp-core/admin/bp-core-admin-functions.php

     
    2626 *
    2727 * The old "bp-general-settings" page was renamed "bp-components".
    2828 *
    29  * @since 1.6.0 
     29 * @since 1.6.0
    3030 *
    3131 * @global array $_parent_pages
    3232 * @global array $_registered_pages
     
    953953 * Add a separator to the WordPress admin menus.
    954954 *
    955955 * @since 1.7.0
     956 * @since 12.6.0 Added 'bp_admin_separator' filter.
     957 *
     958 * @global array $menu
    956959 */
    957960function bp_admin_separator() {
    958961
    959         // Bail if BuddyPress is not network activated and viewing network admin.
     962        // Default to always adding
     963        $add = true;
     964
     965        // Skip if BuddyPress is not network activated and viewing network admin.
    960966        if ( is_network_admin() && ! bp_is_network_activated() ) {
    961                 return;
     967                $add = false;
    962968        }
    963969
    964         // Bail if BuddyPress is network activated and viewing site admin.
     970        // Skip if BuddyPress is network activated and viewing site admin.
    965971        if ( ! is_network_admin() && bp_is_network_activated() ) {
    966                 return;
     972                $add = false;
    967973        }
    968974
    969975        // Prevent duplicate separators when no core menu items exist.
    970976        if ( ! bp_current_user_can( 'bp_moderate' ) ) {
    971                 return;
     977                $add = false;
    972978        }
    973979
    974         // Bail if there are no components with admin UI's. Hardcoded for now, until
    975         // there's a real API for determining this later.
     980        // Bail if there are no components with admin UI's.
    976981        if ( ! bp_is_active( 'activity' ) && ! bp_is_active( 'groups' ) ) {
     982                $add = false;
     983        }
     984
     985        // Force on Site Admin if BuddyPress Core post-types are registered
     986        if ( is_blog_admin() && bp_current_user_can( 'bp_moderate' ) ) {
     987
     988                // See: BP_Core::register_post_types()
     989                if ( post_type_exists( bp_get_email_post_type() ) || post_type_exists( 'buddypress' ) ) {
     990                        $add = true;
     991                }
     992        }
     993
     994        /**
     995         * Filters whether a top-level admin menu separator is added.
     996         *
     997         * @since 12.6.0
     998         *
     999         * @param bool $add Default true. May be false if nothing to separate.
     1000         */
     1001        $add = (bool) apply_filters( 'bp_admin_separator', $add );
     1002
     1003        // Bail if a separator is not necessary
     1004        if ( false === $add ) {
    9771005                return;
    9781006        }
    9791007
    9801008        global $menu;
    9811009
     1010        // Append a separator to the end of the global menu array
    9821011        $menu[] = array( '', 'read', 'separator-buddypress', '', 'wp-menu-separator buddypress' );
    9831012}