Require all plugin page requests (?page=) to be for registered plugins pages. Provides CYA for plugins that don't do enough cap checking. action requests not bound to a plugin page still go through.
git-svn-id: https://develop.svn.wordpress.org/trunk@11595 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1fc90bfc94
commit
8bc92a8d4f
|
@ -585,7 +585,7 @@ function uninstall_plugin($plugin) {
|
||||||
//
|
//
|
||||||
|
|
||||||
function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '' ) {
|
function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '' ) {
|
||||||
global $menu, $admin_page_hooks;
|
global $menu, $admin_page_hooks, $_registered_pages;
|
||||||
|
|
||||||
$file = plugin_basename( $file );
|
$file = plugin_basename( $file );
|
||||||
|
|
||||||
|
@ -602,11 +602,13 @@ function add_menu_page( $page_title, $menu_title, $access_level, $file, $functio
|
||||||
|
|
||||||
$menu[] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
|
$menu[] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
|
||||||
|
|
||||||
|
$_registered_pages[$hookname] = true;
|
||||||
|
|
||||||
return $hookname;
|
return $hookname;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_object_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
|
function add_object_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
|
||||||
global $menu, $admin_page_hooks, $_wp_last_object_menu;
|
global $menu, $admin_page_hooks, $_wp_last_object_menu, $_registered_pages;
|
||||||
|
|
||||||
$file = plugin_basename( $file );
|
$file = plugin_basename( $file );
|
||||||
|
|
||||||
|
@ -623,11 +625,13 @@ function add_object_page( $page_title, $menu_title, $access_level, $file, $funct
|
||||||
|
|
||||||
$menu[$_wp_last_object_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
|
$menu[$_wp_last_object_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
|
||||||
|
|
||||||
|
$_registered_pages[$hookname] = true;
|
||||||
|
|
||||||
return $hookname;
|
return $hookname;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_utility_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
|
function add_utility_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
|
||||||
global $menu, $admin_page_hooks, $_wp_last_utility_menu;
|
global $menu, $admin_page_hooks, $_wp_last_utility_menu, $_registered_pages;
|
||||||
|
|
||||||
$file = plugin_basename( $file );
|
$file = plugin_basename( $file );
|
||||||
|
|
||||||
|
@ -646,6 +650,8 @@ function add_utility_page( $page_title, $menu_title, $access_level, $file, $func
|
||||||
|
|
||||||
$menu[$_wp_last_utility_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
|
$menu[$_wp_last_utility_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
|
||||||
|
|
||||||
|
$_registered_pages[$hookname] = true;
|
||||||
|
|
||||||
return $hookname;
|
return $hookname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,6 +660,7 @@ function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $fi
|
||||||
global $menu;
|
global $menu;
|
||||||
global $_wp_real_parent_file;
|
global $_wp_real_parent_file;
|
||||||
global $_wp_submenu_nopriv;
|
global $_wp_submenu_nopriv;
|
||||||
|
global $_registered_pages;
|
||||||
|
|
||||||
$file = plugin_basename( $file );
|
$file = plugin_basename( $file );
|
||||||
|
|
||||||
|
@ -683,6 +690,8 @@ function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $fi
|
||||||
if (!empty ( $function ) && !empty ( $hookname ))
|
if (!empty ( $function ) && !empty ( $hookname ))
|
||||||
add_action( $hookname, $function );
|
add_action( $hookname, $function );
|
||||||
|
|
||||||
|
$_registered_pages[$hookname] = true;
|
||||||
|
|
||||||
return $hookname;
|
return $hookname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,15 +928,22 @@ function user_can_access_admin_page() {
|
||||||
global $_wp_menu_nopriv;
|
global $_wp_menu_nopriv;
|
||||||
global $_wp_submenu_nopriv;
|
global $_wp_submenu_nopriv;
|
||||||
global $plugin_page;
|
global $plugin_page;
|
||||||
|
global $_registered_pages;
|
||||||
|
|
||||||
$parent = get_admin_page_parent();
|
$parent = get_admin_page_parent();
|
||||||
|
|
||||||
if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
|
if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
|
if ( isset( $plugin_page ) ) {
|
||||||
|
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
$hookname = get_plugin_page_hookname($plugin_page, $parent);
|
||||||
|
if ( !isset($_registered_pages[$hookname]) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( empty( $parent) ) {
|
if ( empty( $parent) ) {
|
||||||
if ( isset( $_wp_menu_nopriv[$pagenow] ) )
|
if ( isset( $_wp_menu_nopriv[$pagenow] ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue