Properly declare `$hook_suffix`, `$plugin_page`, `$typenow`, and `$taxnow` as globals in `wp-admin/admin.php`.
Fixes #30958. Built from https://develop.svn.wordpress.org/trunk@31105 git-svn-id: http://core.svn.wordpress.org/trunk@31086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
91297b7a30
commit
60e1dd409b
|
@ -90,22 +90,31 @@ $time_format = get_option('time_format');
|
|||
|
||||
wp_enqueue_script( 'common' );
|
||||
|
||||
// $pagenow is set in vars.php
|
||||
// The remaining variables are imported as globals elsewhere,
|
||||
// declared as globals here
|
||||
global $pagenow, $hook_suffix, $plugin_page, $typenow, $taxnow;
|
||||
|
||||
$page_hook = '';
|
||||
$hook_suffix = '';
|
||||
$plugin_page = '';
|
||||
$typenow = '';
|
||||
$taxnow = '';
|
||||
|
||||
$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');
|
||||
|
@ -144,11 +153,12 @@ if ( current_user_can( 'manage_options' ) ) {
|
|||
*/
|
||||
do_action( 'admin_init' );
|
||||
|
||||
if ( isset($plugin_page) ) {
|
||||
if ( !empty($typenow) )
|
||||
if ( $plugin_page ) {
|
||||
if ( $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);
|
||||
|
||||
|
@ -166,19 +176,18 @@ if ( isset($plugin_page) ) {
|
|||
unset($the_parent);
|
||||
}
|
||||
|
||||
$hook_suffix = '';
|
||||
if ( isset( $page_hook ) ) {
|
||||
if ( $page_hook ) {
|
||||
$hook_suffix = $page_hook;
|
||||
} elseif ( isset( $plugin_page ) ) {
|
||||
} elseif ( $plugin_page ) {
|
||||
$hook_suffix = $plugin_page;
|
||||
} elseif ( isset( $pagenow ) ) {
|
||||
} elseif ( $pagenow ) {
|
||||
$hook_suffix = $pagenow;
|
||||
}
|
||||
|
||||
set_current_screen();
|
||||
|
||||
// Handle plugin admin pages.
|
||||
if ( isset($plugin_page) ) {
|
||||
if ( $plugin_page ) {
|
||||
if ( $page_hook ) {
|
||||
/**
|
||||
* Fires before a particular screen is loaded.
|
||||
|
|
|
@ -1508,7 +1508,7 @@ function get_admin_page_parent( $parent = '' ) {
|
|||
return $parent;
|
||||
}
|
||||
|
||||
if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
|
||||
if ( $pagenow == 'admin.php' && $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 ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
|
||||
if ( $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 ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {
|
||||
if ( $typenow && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
} elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
|
||||
} elseif ( $submenu_array[2] == $pagenow && ! $typenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
} elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
|
||||
} elseif ( $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 ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
|
||||
} elseif ( $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 ( isset( $plugin_page ) &&
|
||||
if ( $plugin_page &&
|
||||
( $plugin_page == $submenu_array[2] ) &&
|
||||
(
|
||||
( $parent == $pagenow ) ||
|
||||
( $parent == $plugin_page ) ||
|
||||
( $plugin_page == $hook ) ||
|
||||
( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
|
||||
( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow)
|
||||
( $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 ( isset( $plugin_page ) &&
|
||||
if ( $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 ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
|
||||
if ( ! $plugin_page && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
|
||||
return false;
|
||||
|
||||
if ( isset( $plugin_page ) ) {
|
||||
if ( $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 ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
|
||||
if ( $plugin_page && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
|
||||
return false;
|
||||
if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
|
||||
if ( $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 ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
|
||||
if ( $plugin_page && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
|
||||
if ( $plugin_page && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
|
||||
return false;
|
||||
|
||||
if ( isset( $submenu[$parent] ) ) {
|
||||
foreach ( $submenu[$parent] as $submenu_array ) {
|
||||
if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
|
||||
if ( $plugin_page && ( $submenu_array[2] == $plugin_page ) ) {
|
||||
if ( current_user_can( $submenu_array[1] ))
|
||||
return true;
|
||||
else
|
||||
|
|
|
@ -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 ) || ( empty($typenow) && $self == $item[2] ) ) {
|
||||
if ( ( $parent_file && $item[2] == $parent_file ) || ( ! $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 = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
|
||||
$self_type = $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 (
|
||||
( ! 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 ) )
|
||||
( ! $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 ) )
|
||||
) {
|
||||
$class[] = 'current';
|
||||
}
|
||||
|
|
|
@ -2576,7 +2576,7 @@ function is_plugin_page() {
|
|||
|
||||
global $plugin_page;
|
||||
|
||||
if ( isset($plugin_page) )
|
||||
if ( $plugin_page )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31104';
|
||||
$wp_version = '4.2-alpha-31105';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue