Skip to:
Content

BuddyPress.org


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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/**
Note: See TracChangeset for help on using the changeset viewer.