Skip to:
Content

BuddyPress.org

Changeset 13956


Ignore:
Timestamp:
07/09/2024 01:16:26 AM (9 months ago)
Author:
imath
Message:

Avoid the BP Email menu to be grouped with bbPress menu items

In multisite configs & when BuddyPress is network activated, make sure to add an admin menu separator before the BP Email menu in the site admin menu so that it is not grouped with another plugin's admin menu items.

Props johnjamesjacoby

See #9184 (branch 14.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/14.0/src/bp-core/admin/bp-core-admin-functions.php

    r13946 r13956  
    985985 *
    986986 * @since 1.7.0
     987 * @since 14.0.0 Added 'bp_admin_separator' filter.
     988 *
     989 * @global array $menu
    987990 */
    988991function bp_admin_separator() {
    989992
    990     // Bail if BuddyPress is not network activated and viewing network admin.
     993    // Default to always adding
     994    $add = true;
     995
     996    // Skip if BuddyPress is not network activated and viewing network admin.
    991997    if ( is_network_admin() && ! bp_is_network_activated() ) {
    992         return;
    993     }
    994 
    995     // Bail if BuddyPress is network activated and viewing site admin.
     998        $add = false;
     999    }
     1000
     1001    // Skip if BuddyPress is network activated and viewing site admin.
    9961002    if ( ! is_network_admin() && bp_is_network_activated() ) {
    997         return;
     1003        $add = false;
    9981004    }
    9991005
    10001006    // Prevent duplicate separators when no core menu items exist.
    10011007    if ( ! bp_current_user_can( 'bp_moderate' ) ) {
     1008        $add = false;
     1009    }
     1010
     1011    // Bail if there are no components with admin UI's.
     1012    if ( ! bp_is_active( 'activity' ) && ! bp_is_active( 'groups' ) ) {
     1013        $add = false;
     1014    }
     1015
     1016    // Force on Site Admin if BuddyPress Core post-types are registered
     1017    if ( is_blog_admin() && bp_current_user_can( 'bp_moderate' ) ) {
     1018
     1019        // See: BP_Core::register_post_types()
     1020        if ( post_type_exists( bp_get_email_post_type() ) || post_type_exists( 'buddypress' ) ) {
     1021            $add = true;
     1022        }
     1023    }
     1024
     1025    /**
     1026     * Filters whether a top-level admin menu separator is added.
     1027     *
     1028     * @since 14.0.0
     1029     *
     1030     * @param bool $add Default true. May be false if nothing to separate.
     1031     */
     1032    $add = (bool) apply_filters( 'bp_admin_separator', $add );
     1033
     1034    // Bail if a separator is not necessary
     1035    if ( false === $add ) {
    10021036        return;
    10031037    }
    10041038
    1005     // Bail if there are no components with admin UI's. Hardcoded for now, until
    1006     // there's a real API for determining this later.
    1007     if ( ! bp_is_active( 'activity' ) && ! bp_is_active( 'groups' ) ) {
    1008         return;
    1009     }
    1010 
    10111039    global $menu;
    10121040
     1041    // Append a separator to the end of the global menu array
    10131042    $menu[] = array( '', 'read', 'separator-buddypress', '', 'wp-menu-separator buddypress' );
    10141043}
Note: See TracChangeset for help on using the changeset viewer.