Skip to:
Content

BuddyPress.org

Changeset 4309


Ignore:
Timestamp:
04/30/2011 10:41:47 AM (14 years ago)
Author:
djpaul
Message:

Deprecate bp_core_add_admin_menu_page() in favour of add_menu_page(). Fixes #3184

Location:
trunk/bp-core
Files:
3 edited

Legend:

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

    r4293 r4309  
    11391139}
    11401140
    1141 /**
    1142  * A better version of add_admin_menu_page() that allows positioning of menus.
    1143  *
    1144  * @package BuddyPress Core
    1145  */
    1146 function bp_core_update_add_admin_menu_page( $args = '' ) {
    1147     global $menu, $admin_page_hooks, $_registered_pages;
    1148 
    1149     $defaults = array(
    1150         'page_title' => '',
    1151         'menu_title' => '',
    1152         'capability' => 'manage_options',
    1153         'menu_slug'  => '',
    1154         'function'   => false,
    1155         'icon_url'   => false,
    1156         'position'   => 100
    1157     );
    1158 
    1159     $r = wp_parse_args( $args, $defaults );
    1160     extract( $r, EXTR_SKIP );
    1161 
    1162     if ( is_multisite() )
    1163         add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
    1164     else
    1165         add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
    1166 }
    1167 
    11681141function bp_core_wizard_message() {
    11691142    if ( isset( $_GET['updated'] ) )
     
    12271200
    12281201    // Add the administration tab under the "Site Admin" tab for site administrators
    1229     bp_core_update_add_admin_menu_page( array(
    1230         'menu_title' => __( 'BuddyPress', 'buddypress' ),
    1231         'page_title' => __( 'BuddyPress', 'buddypress' ),
    1232         'capability' => 'manage_options',
    1233         'menu_slug'  => 'bp-wizard',
    1234         'function'   => '',
    1235         'position'   => 3
    1236     ) );
    1237 
     1202    add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-wizard', '', '', 3 );
    12381203    $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
    12391204
  • trunk/bp-core/bp-core-functions.php

    r4308 r4309  
    194194
    195195    // Add the administration tab under the "Site Admin" tab for site administrators
    196     $hooks[] = bp_core_add_admin_menu_page( array(
    197         'menu_title' => __( 'BuddyPress', 'buddypress' ),
    198         'page_title' => __( 'BuddyPress', 'buddypress' ),
    199         'capability' => 'manage_options',
    200         'file'       => 'bp-general-settings',
    201         'function'   => 'bp_core_admin_component_setup',
    202         'position'   => 2
    203     ) );
     196    $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '', 2 );
    204197
    205198    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Components', 'buddypress' ), __( 'Components', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup'  );
     
    209202    foreach( $hooks as $hook )
    210203        add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    211 
    212204}
    213205add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_add_admin_menu', 9 );
     
    817809}
    818810add_action( 'wp_footer', 'bp_core_print_generation_time' );
    819 
    820 /**
    821  * A better version of add_admin_menu_page() that allows positioning of menus.
    822  *
    823  * @package BuddyPress Core
    824  */
    825 function bp_core_add_admin_menu_page( $args = '' ) {
    826     global $menu, $admin_page_hooks, $_registered_pages;
    827 
    828     $defaults = array(
    829         'page_title'   => '',
    830         'menu_title'   => '',
    831         'capability'   => 'manage_options',
    832         'file'         => false,
    833         'function'     => false,
    834         'icon_url'     => false,
    835         'position'     => 100
    836     );
    837 
    838     $r = wp_parse_args( $args, $defaults );
    839     extract( $r, EXTR_SKIP );
    840 
    841     $file                    = plugin_basename( $file );
    842     $admin_page_hooks[$file] = sanitize_title( $menu_title );
    843     $hookname                = get_plugin_page_hookname( $file, '' );
    844 
    845     if (!empty ( $function ) && !empty ( $hookname ))
    846         add_action( $hookname, $function );
    847 
    848     if ( empty( $icon_url ) )
    849         $icon_url = esc_url( admin_url( 'images/generic.png' ) );
    850     elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
    851         $icon_url = 'https://' . substr($icon_url, 7);
    852 
    853     do {
    854         $position++;
    855     } while ( !empty( $menu[$position] ) );
    856 
    857     $menu[$position] = array ( $menu_title, $capability, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
    858 
    859     $_registered_pages[$hookname] = true;
    860 
    861     return $hookname;
    862 }
    863811
    864812/**
  • trunk/bp-core/deprecated/1.3.php

    r4287 r4309  
    4949}
    5050
     51/** Admin ******************************************************************/
     52
     53/**
     54 * In BuddyPress 1.1 - 1.2.x, this function provided a better version of add_menu_page()
     55 * that allowed positioning of menus. Deprecated in 1.3 in favour of a WP core function.
     56 *
     57 * @deprecated 1.3
     58 * @deprecated Use add_menu_page().
     59 * @since 1.1
     60 */
     61function bp_core_add_admin_menu_page( $args = '' ) {
     62    $defaults = array(
     63        'page_title'   => '',
     64        'menu_title'   => '',
     65        'capability'   => 'manage_options',
     66        'file'         => '',
     67        'function'     => '',
     68        'icon_url'     => '',
     69        'position'     => 100
     70    );
     71
     72    $r = wp_parse_args( $args, $defaults );
     73    extract( $r, EXTR_SKIP );
     74
     75    _deprecated_function( __FUNCTION__, '1.3', 'Use add_menu_page()' );
     76    return add_menu_page( $page_title, $menu_title, $capability, $file, $function, $icon_url, $position );
     77}
     78
    5179/** Activity ******************************************************************/
    5280
Note: See TracChangeset for help on using the changeset viewer.