After [31105], don't ditch the `isset()` calls for BC. Declare `$page_hook` as `null` so it is initialized for all execution paths but will still fail `isset()` checks.

Fixes #30958.

Built from https://develop.svn.wordpress.org/trunk@31106


git-svn-id: http://core.svn.wordpress.org/trunk@31087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-01-08 22:52:22 +00:00
parent 60e1dd409b
commit 8ee598169f
5 changed files with 39 additions and 41 deletions

View File

@ -95,26 +95,24 @@ wp_enqueue_script( 'common' );
// declared as globals here
global $pagenow, $hook_suffix, $plugin_page, $typenow, $taxnow;
$page_hook = '';
$hook_suffix = '';
$plugin_page = '';
$typenow = '';
$taxnow = '';
$page_hook = null;
$editing = false;
if ( isset( $_GET['page'] ) ) {
if ( isset($_GET['page']) ) {
$plugin_page = wp_unslash( $_GET['page'] );
$plugin_page = plugin_basename( $plugin_page );
$plugin_page = plugin_basename($plugin_page);
}
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
$typenow = $_REQUEST['post_type'];
}
else
$typenow = '';
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) {
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) )
$taxnow = $_REQUEST['taxonomy'];
}
else
$taxnow = '';
if ( WP_NETWORK_ADMIN )
require(ABSPATH . 'wp-admin/network/menu.php');
@ -153,12 +151,11 @@ if ( current_user_can( 'manage_options' ) ) {
*/
do_action( 'admin_init' );
if ( $plugin_page ) {
if ( $typenow ) {
if ( isset($plugin_page) ) {
if ( !empty($typenow) )
$the_parent = $pagenow . '?post_type=' . $typenow;
} else {
else
$the_parent = $pagenow;
}
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
@ -176,18 +173,19 @@ if ( $plugin_page ) {
unset($the_parent);
}
if ( $page_hook ) {
$hook_suffix = '';
if ( isset( $page_hook ) ) {
$hook_suffix = $page_hook;
} elseif ( $plugin_page ) {
} elseif ( isset( $plugin_page ) ) {
$hook_suffix = $plugin_page;
} elseif ( $pagenow ) {
} elseif ( isset( $pagenow ) ) {
$hook_suffix = $pagenow;
}
set_current_screen();
// Handle plugin admin pages.
if ( $plugin_page ) {
if ( isset($plugin_page) ) {
if ( $page_hook ) {
/**
* Fires before a particular screen is loaded.

View File

@ -1508,7 +1508,7 @@ function get_admin_page_parent( $parent = '' ) {
return $parent;
}
if ( $pagenow == 'admin.php' && $plugin_page ) {
if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
foreach ( (array)$menu as $parent_menu ) {
if ( $parent_menu[2] == $plugin_page ) {
$parent_file = $plugin_page;
@ -1525,7 +1525,7 @@ function get_admin_page_parent( $parent = '' ) {
}
}
if ( $plugin_page && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
$parent_file = $pagenow;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
@ -1536,13 +1536,13 @@ function get_admin_page_parent( $parent = '' ) {
foreach ( $submenu[$parent] as $submenu_array ) {
if ( isset( $_wp_real_parent_file[$parent] ) )
$parent = $_wp_real_parent_file[$parent];
if ( $typenow && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {
if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {
$parent_file = $parent;
return $parent;
} elseif ( $submenu_array[2] == $pagenow && ! $typenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
} elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
$parent_file = $parent;
return $parent;
} elseif ( $plugin_page && ($plugin_page == $submenu_array[2] ) ) {
} elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
$parent_file = $parent;
return $parent;
}
@ -1575,7 +1575,7 @@ function get_admin_page_title() {
if ( $menu_array[2] == $pagenow ) {
$title = $menu_array[3];
return $menu_array[3];
} elseif ( $plugin_page && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
} elseif ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
$title = $menu_array[3];
return $menu_array[3];
}
@ -1587,14 +1587,14 @@ function get_admin_page_title() {
} else {
foreach ( array_keys( $submenu ) as $parent ) {
foreach ( $submenu[$parent] as $submenu_array ) {
if ( $plugin_page &&
if ( isset( $plugin_page ) &&
( $plugin_page == $submenu_array[2] ) &&
(
( $parent == $pagenow ) ||
( $parent == $plugin_page ) ||
( $plugin_page == $hook ) ||
( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
( $typenow && $parent == $pagenow . '?post_type=' . $typenow)
( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow)
)
) {
$title = $submenu_array[3];
@ -1615,7 +1615,7 @@ function get_admin_page_title() {
}
if ( empty ( $title ) ) {
foreach ( $menu as $menu_array ) {
if ( $plugin_page &&
if ( isset( $plugin_page ) &&
( $plugin_page == $menu_array[2] ) &&
( $pagenow == 'admin.php' ) &&
( $parent1 == $menu_array[2] ) )
@ -1670,10 +1670,10 @@ function user_can_access_admin_page() {
$parent = get_admin_page_parent();
if ( ! $plugin_page && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
return false;
if ( $plugin_page ) {
if ( isset( $plugin_page ) ) {
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
return false;
@ -1688,25 +1688,25 @@ function user_can_access_admin_page() {
return false;
if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
return false;
if ( $plugin_page && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
return false;
if ( $plugin_page && isset( $_wp_menu_nopriv[$plugin_page] ) )
if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
return false;
foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
return false;
if ( $plugin_page && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
return false;
}
return true;
}
if ( $plugin_page && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
return false;
if ( isset( $submenu[$parent] ) ) {
foreach ( $submenu[$parent] as $submenu_array ) {
if ( $plugin_page && ( $submenu_array[2] == $plugin_page ) ) {
if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
if ( current_user_can( $submenu_array[1] ))
return true;
else

View File

@ -66,7 +66,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$submenu_items = $submenu[$item[2]];
}
if ( ( $parent_file && $item[2] == $parent_file ) || ( ! $typenow && $self == $item[2] ) ) {
if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) {
$class[] = ! empty( $submenu_items ) ? 'wp-has-current-submenu wp-menu-open' : 'current';
} else {
$class[] = 'wp-not-current-submenu';
@ -167,7 +167,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$menu_file = substr( $menu_file, 0, $pos );
// Handle current for post_type=post|page|foo pages, which won't match $self.
$self_type = $typenow ? $self . '?post_type=' . $typenow : 'nothing';
$self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
if ( isset( $submenu_file ) ) {
if ( $submenu_file == $sub_item[2] )
@ -175,8 +175,8 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
// If plugin_page is set the parent must either match the current page or not physically exist.
// This allows plugin pages with the same hook to exist under different parents.
} elseif (
( ! $plugin_page && $self == $sub_item[2] ) ||
( $plugin_page && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false ) )
( ! isset( $plugin_page ) && $self == $sub_item[2] ) ||
( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false ) )
) {
$class[] = 'current';
}

View File

@ -2576,7 +2576,7 @@ function is_plugin_page() {
global $plugin_page;
if ( $plugin_page )
if ( isset($plugin_page) )
return true;
return false;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31105';
$wp_version = '4.2-alpha-31106';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.