Make WordPress Core

Changeset 11582


Ignore:
Timestamp:
06/16/2009 05:11:53 PM (15 years ago)
Author:
ryan
Message:

Trim query strings from menu entries before seeing if a corresponding file exists. fixes #10132 for trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/menu-header.php

    r11118 r11582  
    7575            $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
    7676            $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
    77             if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") ) || !empty($menu_hook)) {
     77            $menu_file = $submenu[$item[2]][0][2];
     78            if ( false !== $pos = strpos($menu_file, '?') )
     79                $menu_file = substr($menu_file, 0, $pos);
     80            if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) {
    7881                $admin_is_parent = true;
    7982                echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
     
    8386        } else if ( current_user_can($item[1]) ) {
    8487            $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
    85             if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) {
     88            $menu_file = $item[2];
     89            if ( false !== $pos = strpos($menu_file, '?') )
     90                $menu_file = substr($menu_file, 0, $pos);
     91            if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) {
    8692                $admin_is_parent = true;
    8793                echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}'>$img</a></div>$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>";
     
    103109                    $first = false;
    104110                }
     111
     112                $menu_file = $item[2];
     113                if ( false !== $pos = strpos($menu_file, '?') )
     114                    $menu_file = substr($menu_file, 0, $pos);
     115
    105116                if ( isset($submenu_file) ) {
    106117                    if ( $submenu_file == $sub_item[2] )
     
    108119                // If plugin_page is set the parent must either match the current page or not physically exist.
    109120                // This allows plugin pages with the same hook to exist under different parents.
    110                 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($item[2]) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {
     121                } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {
    111122                    $class[] = 'current';
    112123                }
     
    115126
    116127                $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
     128                $sub_file = $sub_item[2];
     129                if ( false !== $pos = strpos($sub_file, '?') )
     130                    $sub_file = substr($sub_file, 0, $pos);
    117131
    118                 if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") ) || ! empty($menu_hook) ) {
     132                if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) {
    119133                    // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
    120                     $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($item[2]);
     134                   
     135                    $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($menu_file);
    121136                    if ( $parent_exists )
    122137                        echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
Note: See TracChangeset for help on using the changeset viewer.