add_object_page()

git-svn-id: http://svn.automattic.com/wordpress/trunk@9537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-11-05 22:46:58 +00:00
parent 4f47d7e869
commit 908fbae34c
2 changed files with 25 additions and 0 deletions

View File

@ -557,6 +557,29 @@ function add_menu_page( $page_title, $menu_title, $access_level, $file, $functio
return $hookname; return $hookname;
} }
function add_object_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
global $menu, $admin_page_hooks, $_wp_last_object_menu;
$file = plugin_basename( $file );
$admin_page_hooks[$file] = sanitize_title( $menu_title );
$hookname = get_plugin_page_hookname( $file, '' );
if (!empty ( $function ) && !empty ( $hookname ))
add_action( $hookname, $function );
if ( empty($icon_url) )
$icon_url = 'images/menu/generic.png';
$menu[$_wp_last_object_menu][4] = ''; // Remove menu-top-last
$_wp_last_object_menu++;
$menu[$_wp_last_object_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top-last ' . $hookname, $hookname, $icon_url );
return $hookname;
}
function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) { function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) {
global $submenu; global $submenu;
global $menu; global $menu;

View File

@ -54,6 +54,8 @@ $menu[20] = array( __('Pages'), 'edit_pages', 'page-new.php', '', '', 'menu-page
$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top-last', 'menu-comments', 'images/menu/comments.png' ); $menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top-last', 'menu-comments', 'images/menu/comments.png' );
$submenu['edit-comments.php'][15] = array( __('Comments'), 'edit_posts', 'edit-comments.php' ); $submenu['edit-comments.php'][15] = array( __('Comments'), 'edit_posts', 'edit-comments.php' );
$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
$menu[29] = array( '', 'read', '', '', 'wp-menu-separator' ); $menu[29] = array( '', 'read', '', '', 'wp-menu-separator' );
$menu[30] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top-first', 'menu-appearance', 'images/menu/appearance.png' ); $menu[30] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top-first', 'menu-appearance', 'images/menu/appearance.png' );