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:
parent
60e1dd409b
commit
8ee598169f
|
@ -95,11 +95,7 @@ wp_enqueue_script( 'common' );
|
||||||
// declared as globals here
|
// declared as globals here
|
||||||
global $pagenow, $hook_suffix, $plugin_page, $typenow, $taxnow;
|
global $pagenow, $hook_suffix, $plugin_page, $typenow, $taxnow;
|
||||||
|
|
||||||
$page_hook = '';
|
$page_hook = null;
|
||||||
$hook_suffix = '';
|
|
||||||
$plugin_page = '';
|
|
||||||
$typenow = '';
|
|
||||||
$taxnow = '';
|
|
||||||
|
|
||||||
$editing = false;
|
$editing = false;
|
||||||
|
|
||||||
|
@ -108,13 +104,15 @@ if ( isset( $_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'];
|
$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'];
|
$taxnow = $_REQUEST['taxonomy'];
|
||||||
}
|
else
|
||||||
|
$taxnow = '';
|
||||||
|
|
||||||
if ( WP_NETWORK_ADMIN )
|
if ( WP_NETWORK_ADMIN )
|
||||||
require(ABSPATH . 'wp-admin/network/menu.php');
|
require(ABSPATH . 'wp-admin/network/menu.php');
|
||||||
|
@ -153,12 +151,11 @@ if ( current_user_can( 'manage_options' ) ) {
|
||||||
*/
|
*/
|
||||||
do_action( 'admin_init' );
|
do_action( 'admin_init' );
|
||||||
|
|
||||||
if ( $plugin_page ) {
|
if ( isset($plugin_page) ) {
|
||||||
if ( $typenow ) {
|
if ( !empty($typenow) )
|
||||||
$the_parent = $pagenow . '?post_type=' . $typenow;
|
$the_parent = $pagenow . '?post_type=' . $typenow;
|
||||||
} else {
|
else
|
||||||
$the_parent = $pagenow;
|
$the_parent = $pagenow;
|
||||||
}
|
|
||||||
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
|
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
|
||||||
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
|
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
|
||||||
|
|
||||||
|
@ -176,18 +173,19 @@ if ( $plugin_page ) {
|
||||||
unset($the_parent);
|
unset($the_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $page_hook ) {
|
$hook_suffix = '';
|
||||||
|
if ( isset( $page_hook ) ) {
|
||||||
$hook_suffix = $page_hook;
|
$hook_suffix = $page_hook;
|
||||||
} elseif ( $plugin_page ) {
|
} elseif ( isset( $plugin_page ) ) {
|
||||||
$hook_suffix = $plugin_page;
|
$hook_suffix = $plugin_page;
|
||||||
} elseif ( $pagenow ) {
|
} elseif ( isset( $pagenow ) ) {
|
||||||
$hook_suffix = $pagenow;
|
$hook_suffix = $pagenow;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_current_screen();
|
set_current_screen();
|
||||||
|
|
||||||
// Handle plugin admin pages.
|
// Handle plugin admin pages.
|
||||||
if ( $plugin_page ) {
|
if ( isset($plugin_page) ) {
|
||||||
if ( $page_hook ) {
|
if ( $page_hook ) {
|
||||||
/**
|
/**
|
||||||
* Fires before a particular screen is loaded.
|
* Fires before a particular screen is loaded.
|
||||||
|
|
|
@ -1508,7 +1508,7 @@ function get_admin_page_parent( $parent = '' ) {
|
||||||
return $parent;
|
return $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $pagenow == 'admin.php' && $plugin_page ) {
|
if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
|
||||||
foreach ( (array)$menu as $parent_menu ) {
|
foreach ( (array)$menu as $parent_menu ) {
|
||||||
if ( $parent_menu[2] == $plugin_page ) {
|
if ( $parent_menu[2] == $plugin_page ) {
|
||||||
$parent_file = $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;
|
$parent_file = $pagenow;
|
||||||
if ( isset( $_wp_real_parent_file[$parent_file] ) )
|
if ( isset( $_wp_real_parent_file[$parent_file] ) )
|
||||||
$parent_file = $_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 ) {
|
foreach ( $submenu[$parent] as $submenu_array ) {
|
||||||
if ( isset( $_wp_real_parent_file[$parent] ) )
|
if ( isset( $_wp_real_parent_file[$parent] ) )
|
||||||
$parent = $_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;
|
$parent_file = $parent;
|
||||||
return $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;
|
$parent_file = $parent;
|
||||||
return $parent;
|
return $parent;
|
||||||
} elseif ( $plugin_page && ($plugin_page == $submenu_array[2] ) ) {
|
} elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
|
||||||
$parent_file = $parent;
|
$parent_file = $parent;
|
||||||
return $parent;
|
return $parent;
|
||||||
}
|
}
|
||||||
|
@ -1575,7 +1575,7 @@ function get_admin_page_title() {
|
||||||
if ( $menu_array[2] == $pagenow ) {
|
if ( $menu_array[2] == $pagenow ) {
|
||||||
$title = $menu_array[3];
|
$title = $menu_array[3];
|
||||||
return $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];
|
$title = $menu_array[3];
|
||||||
return $menu_array[3];
|
return $menu_array[3];
|
||||||
}
|
}
|
||||||
|
@ -1587,14 +1587,14 @@ function get_admin_page_title() {
|
||||||
} else {
|
} else {
|
||||||
foreach ( array_keys( $submenu ) as $parent ) {
|
foreach ( array_keys( $submenu ) as $parent ) {
|
||||||
foreach ( $submenu[$parent] as $submenu_array ) {
|
foreach ( $submenu[$parent] as $submenu_array ) {
|
||||||
if ( $plugin_page &&
|
if ( isset( $plugin_page ) &&
|
||||||
( $plugin_page == $submenu_array[2] ) &&
|
( $plugin_page == $submenu_array[2] ) &&
|
||||||
(
|
(
|
||||||
( $parent == $pagenow ) ||
|
( $parent == $pagenow ) ||
|
||||||
( $parent == $plugin_page ) ||
|
( $parent == $plugin_page ) ||
|
||||||
( $plugin_page == $hook ) ||
|
( $plugin_page == $hook ) ||
|
||||||
( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
|
( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
|
||||||
( $typenow && $parent == $pagenow . '?post_type=' . $typenow)
|
( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$title = $submenu_array[3];
|
$title = $submenu_array[3];
|
||||||
|
@ -1615,7 +1615,7 @@ function get_admin_page_title() {
|
||||||
}
|
}
|
||||||
if ( empty ( $title ) ) {
|
if ( empty ( $title ) ) {
|
||||||
foreach ( $menu as $menu_array ) {
|
foreach ( $menu as $menu_array ) {
|
||||||
if ( $plugin_page &&
|
if ( isset( $plugin_page ) &&
|
||||||
( $plugin_page == $menu_array[2] ) &&
|
( $plugin_page == $menu_array[2] ) &&
|
||||||
( $pagenow == 'admin.php' ) &&
|
( $pagenow == 'admin.php' ) &&
|
||||||
( $parent1 == $menu_array[2] ) )
|
( $parent1 == $menu_array[2] ) )
|
||||||
|
@ -1670,10 +1670,10 @@ function user_can_access_admin_page() {
|
||||||
|
|
||||||
$parent = get_admin_page_parent();
|
$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;
|
return false;
|
||||||
|
|
||||||
if ( $plugin_page ) {
|
if ( isset( $plugin_page ) ) {
|
||||||
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
|
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1688,25 +1688,25 @@ function user_can_access_admin_page() {
|
||||||
return false;
|
return false;
|
||||||
if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
|
if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
|
||||||
return false;
|
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;
|
return false;
|
||||||
if ( $plugin_page && isset( $_wp_menu_nopriv[$plugin_page] ) )
|
if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
|
||||||
return false;
|
return false;
|
||||||
foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
|
foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
|
||||||
if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
|
if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
|
||||||
return false;
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
if ( isset( $submenu[$parent] ) ) {
|
if ( isset( $submenu[$parent] ) ) {
|
||||||
foreach ( $submenu[$parent] as $submenu_array ) {
|
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] ))
|
if ( current_user_can( $submenu_array[1] ))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
|
|
@ -66,7 +66,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||||
$submenu_items = $submenu[$item[2]];
|
$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';
|
$class[] = ! empty( $submenu_items ) ? 'wp-has-current-submenu wp-menu-open' : 'current';
|
||||||
} else {
|
} else {
|
||||||
$class[] = 'wp-not-current-submenu';
|
$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 );
|
$menu_file = substr( $menu_file, 0, $pos );
|
||||||
|
|
||||||
// Handle current for post_type=post|page|foo pages, which won't match $self.
|
// 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 ( isset( $submenu_file ) ) {
|
||||||
if ( $submenu_file == $sub_item[2] )
|
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.
|
// 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.
|
// This allows plugin pages with the same hook to exist under different parents.
|
||||||
} elseif (
|
} elseif (
|
||||||
( ! $plugin_page && $self == $sub_item[2] ) ||
|
( ! isset( $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 ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false ) )
|
||||||
) {
|
) {
|
||||||
$class[] = 'current';
|
$class[] = 'current';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2576,7 +2576,7 @@ function is_plugin_page() {
|
||||||
|
|
||||||
global $plugin_page;
|
global $plugin_page;
|
||||||
|
|
||||||
if ( $plugin_page )
|
if ( isset($plugin_page) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue