Prevent plugins with certain filenames from breaking links in the admin menu. props lightningspirit. fixes #22079.

git-svn-id: https://develop.svn.wordpress.org/trunk@23656 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2013-03-09 02:48:49 +00:00
parent 44e0f5ff09
commit d25b3c5c19
1 changed files with 6 additions and 6 deletions

View File

@ -87,7 +87,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$menu_file = $submenu_items[0][2]; $menu_file = $submenu_items[0][2];
if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
$menu_file = substr( $menu_file, 0, $pos ); $menu_file = substr( $menu_file, 0, $pos );
if ( ! empty( $menu_hook ) || ( ('index.php' != $submenu_items[0][2]) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) ) ) { if ( ! empty( $menu_hook ) || ( ( 'index.php' != $submenu_items[0][2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
$admin_is_parent = true; $admin_is_parent = true;
echo "<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image'>$img</div><div class='wp-menu-name'>$title</div></a>"; echo "<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image'>$img</div><div class='wp-menu-name'>$title</div></a>";
} else { } else {
@ -98,7 +98,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$menu_file = $item[2]; $menu_file = $item[2];
if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
$menu_file = substr( $menu_file, 0, $pos ); $menu_file = substr( $menu_file, 0, $pos );
if ( ! empty( $menu_hook ) || ( ('index.php' != $item[2]) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) ) ) { if ( ! empty( $menu_hook ) || ( ( 'index.php' != $item[2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
$admin_is_parent = true; $admin_is_parent = true;
echo "\n\t<a href='admin.php?page={$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image'>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>"; echo "\n\t<a href='admin.php?page={$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image'>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
} else { } else {
@ -150,12 +150,12 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$title = wptexturize($sub_item[0]); $title = wptexturize($sub_item[0]);
if ( ! empty( $menu_hook ) || ( ('index.php' != $sub_item[2]) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) ) ) { if ( ! empty( $menu_hook ) || ( ( 'index.php' != $sub_item[2] ) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) ) ) {
// If admin.php is the current page or if the parent exists as a file in the plugins or admin dir // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) ) if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) )
$sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] ); $sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), $item[2] );
else else
$sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' ); $sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), 'admin.php' );
$sub_item_url = esc_url( $sub_item_url ); $sub_item_url = esc_url( $sub_item_url );
echo "<li$class><a href='$sub_item_url'$class>$title</a></li>"; echo "<li$class><a href='$sub_item_url'$class>$title</a></li>";