Skip to:
Content

BuddyPress.org

Changeset 5406


Ignore:
Timestamp:
11/28/2011 10:30:03 PM (13 years ago)
Author:
djpaul
Message:

Relocates the top-level BuddyPress admin menu to under the Settings and Users menus. Maintains compatibility with third-party plugins that add their admin menus under the old top-level BP menu. See #3708.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/admin/bp-core-admin.php

    r5302 r5406  
    2929    $tabs = array(
    3030        '0' => array(
    31             'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-general-settings' ), 'admin.php' ) ),
     31            'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-general-config' ), 'admin.php' ) ),
    3232            'name' => __( 'Components', 'buddypress' )
    3333        ),
     
    6262    // Do other fun things
    6363    do_action( 'bp_admin_tabs' );
     64}
     65
     66/**
     67 * Generates markup for a fallback top-level BuddyPress menu page, if the site is running
     68 * a legacy plugin which hasn't been updated. If the site is up to date, this page
     69 * will never appear.
     70 *
     71 * @see bp_core_admin_backpat_menu()
     72 * @since 1.6
     73 * @todo Add convenience links into the markup once new positions are finalised.
     74 */
     75function bp_core_admin_backpat_page() {
     76?>
     77    <div class="wrap">
     78        <?php screen_icon( 'buddypress'); ?>
     79        <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
     80
     81        <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
     82        <p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href="%s">Users</a> menu.', 'buddpress' ), network_admin_url( 'options-general.php?page=bp-general-config' ), network_admin_url( 'users.php?page=bp-profile-setup' ) ); ?></p>
     83    </div>
     84<?php
    6485}
    6586
     
    218239        }
    219240
    220         $base_url = bp_get_admin_url(  add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), 'admin.php' ) );
     241        $base_url = bp_get_admin_url(  add_query_arg( array( 'page' => 'bp-general-config', 'updated' => 'true' ), 'admin.php' ) );
    221242
    222243        wp_redirect( $base_url );
  • trunk/bp-core/admin/bp-core-update.php

    r5329 r5406  
    193193
    194194                $step_count  = count( $this->steps ) - 1;
    195                 $wiz_or_set  = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard';
     195                $wiz_or_set  = $this->current_step >= $step_count ? 'bp-general-config' : 'bp-wizard';
    196196                $form_action = bp_core_update_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) );
    197197            ?>
     
    11341134
    11351135            // Redirect to the BuddyPress dashboard
    1136             $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-general-settings' ), network_admin_url( 'admin.php' ) ) : add_query_arg( array( 'page' => 'bp-general-settings' ), admin_url( 'admin.php' ) );
     1136            $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-general-config' ), network_admin_url( 'admin.php' ) ) : add_query_arg( array( 'page' => 'bp-general-config' ), admin_url( 'admin.php' ) );
    11371137
    11381138            wp_redirect( $redirect );
     
    13551355
    13561356        /* Settings Icon */
    1357         ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; }
    1358         ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
    1359         ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,
    1360         ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {
     1357        ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a img { display: none; }
     1358        ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     1359        ul#adminmenu li.toplevel_page_bp-general-config:hover .wp-menu-image a,
     1360        ul#adminmenu li.toplevel_page_bp-general-config.wp-has-current-submenu .wp-menu-image a {
    13611361            background-position: -1px 0;
    13621362        }
  • trunk/bp-core/bp-core-cssjs.php

    r5280 r5406  
    2323
    2424        /* Settings Icon */
    25         ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; }
    26         ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     25        ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a img,
     26        ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img {
     27            display: none;
     28        }
     29
     30        ul#adminmenu li.toplevel_page_bp-general-config .wp-menu-image a,
     31        ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a {
     32            background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px;
     33        }
     34
     35        ul#adminmenu li.toplevel_page_bp-general-config:hover .wp-menu-image a,
    2736        ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,
     37        ul#adminmenu li.toplevel_page_bp-general-config.wp-has-current-submenu .wp-menu-image a,
    2838        ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {
    2939            background-position: -1px 0;
  • trunk/bp-core/bp-core-functions.php

    r5404 r5406  
    285285
    286286/**
    287  * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    288  *
    289  * @package BuddyPress Core
    290  * @global object $bp Global BuddyPress settings object
    291  * @uses bp_current_user_can() returns true if the current user is a site admin, false if not
    292  * @uses add_submenu_page() WP function to add a submenu item
     287 * In BP 1.6, the top-level admin menu was removed. For backpat, this function
     288 * keeps the top-level menu if a plugin has registered a menu into the old
     289 * 'bp-general-settings' menu.
     290 *
     291 * The old "bp-general-settings" page was renamed "bp-general-config".
     292 *
     293 * @global array $_parent_pages
     294 * @global array $_registered_pages
     295 * @global array $submenu
     296 * @since 1.6
     297 */
     298function bp_core_admin_backpat_menu() {
     299    global $_parent_pages, $_registered_pages, $submenu;
     300
     301    if ( ! is_super_admin() )
     302        return;
     303
     304    // Don't do anything if a BP upgrade is in progress, or if the bp-wizard is in progress.
     305    if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE || empty( $submenu['bp-general-settings'] ) )
     306        return;
     307
     308    /**
     309     * By default, only the core "Help" submenu is added under the top-level BuddyPress menu.
     310     * This means that if no third-party plugins have registered their admin pages into the
     311     * 'bp-general-settings' menu, it will only contain one item. Kill it.
     312     */
     313    if ( 1 == count( $submenu['bp-general-settings'] ) ) {
     314        // This removes the top-level menu
     315        remove_submenu_page( 'bp-general-settings', 'bp-general-settings' );
     316        remove_menu_page( 'bp-general-settings' );
     317
     318        // These stop people accessing the URL directly
     319        unset( $_parent_pages['bp-general-settings'] );
     320        unset( $_registered_pages['toplevel_page_bp-general-settings'] );
     321    }
     322}
     323add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );
     324
     325/**
     326 * Registers BuddyPress' admin menus.
     327 *
     328 * @since 1.0
    293329 */
    294330function bp_core_add_admin_menu() {
    295     if ( !bp_current_user_can( 'bp_moderate' ) )
    296         return false;
    297 
    298     // Don't add this version of the admin menu if a BP upgrade is in progress
    299     // See bp_core_update_add_admin_menu()
     331    if ( ! bp_current_user_can( 'bp_moderate' ) )
     332        return;
     333
     334    /**
     335     * Don't add this version of the admin menu if a BP upgrade is in progress.
     336     * See bp_core_update_add_admin_menu().
     337     */
    300338    if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE )
    301         return false;
     339        return;
    302340
    303341    $hooks = array();
    304342
    305     // Add the administration tab under the "Site Admin" tab for site administrators
    306     $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '' );
    307     $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Components', 'buddypress' ), __( 'Components', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup'  );
    308     $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Pages',      'buddypress' ), __( 'Pages',      'buddypress' ), 'manage_options', 'bp-page-settings',    'bp_core_admin_page_setup'       );
    309     $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Settings',   'buddypress' ), __( 'Settings',   'buddypress' ), 'manage_options', 'bp-settings',         'bp_core_admin_settings'         );
    310 
    311     // Add a hook for css/js
    312     foreach( $hooks as $hook )
     343    // Changed in BP 1.6 . See bp_core_admin_backpat_menu()
     344    $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_backpat_menu', '' );
     345    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'BuddyPress Help', 'buddypress' ), __( 'Help', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_backpat_page' );
     346
     347    // Add the option pages
     348    $hooks[] = add_options_page( __( 'BuddyPress Components', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-config', 'bp_core_admin_component_setup' );
     349    $hooks[] = add_options_page( __( 'BuddyPress Pages', 'buddypress' ),      __( 'BuddyPress Pages', 'buddypress' ),      'manage_options', 'bp-page-settings',  'bp_core_admin_page_setup'      );
     350    $hooks[] = add_options_page( __( 'BuddyPress Settings', 'buddypress' ),   __( 'BuddyPress Settings', 'buddypress' ),   'manage_options', 'bp-settings',       'bp_core_admin_settings'        );
     351
     352    foreach( $hooks as $hook ) {
     353        // Add a hook for common BP admin CSS/JS scripts
    313354        add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
     355
     356        // Fudge the highlighted subnav item when on a BuddyPress admin page
     357        add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
     358    }
     359}
     360
     361/**
     362 * Tweak the Settings subnav menu to show only one BuddyPress menu item (Settings > BuddyPress).
     363 *
     364 * @since 1.6
     365 */
     366function bp_core_modify_admin_menu() {
     367    remove_submenu_page( 'options-general.php', 'bb-forums-setup' );
     368    remove_submenu_page( 'options-general.php', 'bp-page-settings' );
     369    remove_submenu_page( 'options-general.php', 'bp-settings' );
     370}
     371add_action( "admin_head", 'bp_core_modify_admin_menu', 999 );
     372
     373/**
     374 * This tells WP to highlight the Settings > BuddyPress menu item,
     375 * regardless of which actual BuddyPress admin screen we are on.
     376 *
     377 * The conditional prevents the behaviour when the user is viewing the
     378 * backpat "Help" page, the Activity page, or any third-party plugins.
     379 *
     380 * @global string $plugin_page
     381 * @global array $submenu
     382 * @since 1.6
     383 */
     384function bp_core_modify_admin_menu_highlight() {
     385    global $plugin_page, $submenu_file;
     386
     387    // This tweaks the Settings subnav menu to show only one BuddyPress menu item
     388    if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) )
     389        $submenu_file = 'bp-general-config';
    314390}
    315391
  • trunk/bp-forums/bp-forums-admin.php

    r5329 r5406  
    66    global $bp;
    77
    8     if ( !bp_current_user_can( 'bp_moderate' ) )
    9         return false;
    10 
    11     // Add the administration tab under the "Site Admin" tab for site administrators
    12     $hook = add_submenu_page( 'bp-general-settings', __( 'Forums', 'buddypress' ), __( 'Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
     8    if ( ! bp_current_user_can( 'bp_moderate' ) )
     9        return;
     10
     11    // Add the option pages
     12    $hook = add_options_page( __( 'BuddyPress Forums', 'buddypress' ), __( 'BuddyPress Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', 'bp_forums_bbpress_admin' );
     13
     14    // Add a hook for common BP admin CSS/JS scripts
    1315    add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
     16
     17    // Fudge the highlighted subnav item when on a BuddyPress admin page
     18    add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
    1419}
    1520add_action( bp_core_admin_hook(), 'bp_forums_add_admin_menu' );
  • trunk/bp-xprofile/bp-xprofile-admin.php

    r5329 r5406  
    2323        return false;
    2424
    25     $hook = add_submenu_page( 'bp-general-settings', __( 'Profile Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
     25    $hook = add_users_page( __( 'Profile Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
    2626
    2727    add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
     
    7272        <h2>
    7373
    74             <?php _e( 'Extended Profile Fields', 'buddypress'); ?>
     74            <?php _e( 'Profile Fields', 'buddypress'); ?>
    7575
    7676            <a id="add_group" class="button add-new-h2" href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Group', 'buddypress' ); ?></a>
Note: See TracChangeset for help on using the changeset viewer.