Move current_screen setup before plugin page handling so it is defined for all cases. see #9674

git-svn-id: http://svn.automattic.com/wordpress/trunk@12731 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-15 20:21:18 +00:00
parent 432087e89e
commit e7bfd5f2dd
1 changed files with 43 additions and 41 deletions

View File

@ -82,8 +82,7 @@ require(ABSPATH . 'wp-admin/menu.php');
do_action('admin_init');
// Handle plugin admin pages.
if (isset($plugin_page)) {
if (isset($plugin_page) ) {
if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
// backwards compatibility for plugins using add_management_page
@ -97,7 +96,49 @@ if (isset($plugin_page)) {
exit;
}
}
}
$hook_suffix = '';
if ( isset($page_hook) )
$hook_suffix = $page_hook;
else if ( isset($plugin_page) )
$hook_suffix = $plugin_page;
else if ( isset($pagenow) )
$hook_suffix = $pagenow;
if ( isset($_GET['post_type']) )
$typenow = $_GET['post_type'];
else
$typenow = '';
// @todo validate typenow against post types.
/**
* Global object containing info about the current screen.
*/
$current_screen = $hook_suffix;
$current_screen = str_replace('.php', '', $current_screen);
$current_screen = str_replace('-new', '', $current_screen);
$current_screen = str_replace('-add', '', $current_screen);
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
$current_screen = (object) $current_screen;
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} else {
$typenow = '';
}
$current_screen = apply_filters('current_screen', $current_screen);
// Handle plugin admin pages.
if ( isset($plugin_page) ) {
if ( $page_hook ) {
do_action('load-' . $page_hook);
if (! isset($_GET['noheader']))
@ -177,43 +218,4 @@ if (isset($plugin_page)) {
if ( !empty($_REQUEST['action']) )
do_action('admin_action_' . $_REQUEST['action']);
$hook_suffix = '';
if ( isset($page_hook) )
$hook_suffix = $page_hook;
else if ( isset($plugin_page) )
$hook_suffix = $plugin_page;
else if ( isset($pagenow) )
$hook_suffix = $pagenow;
if ( isset($_GET['post_type']) )
$typenow = $_GET['post_type'];
else
$typenow = '';
// @todo validate typenow against post types.
/**
* Global object containing info about the current screen.
*/
$current_screen = $hook_suffix;
$current_screen = str_replace('.php', '', $current_screen);
$current_screen = str_replace('-new', '', $current_screen);
$current_screen = str_replace('-add', '', $current_screen);
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
$current_screen = (object) $current_screen;
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} else {
$typenow = '';
}
$current_screen = apply_filters('current_screen', $current_screen);
?>