Changeset 18792
- Timestamp:
- 09/27/2011 10:22:58 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/menu-header.php
r18621 r18792 45 45 $admin_is_parent = false; 46 46 $class = array(); 47 47 48 if ( $first ) { 48 49 $class[] = 'wp-first-item'; 49 50 $first = false; 50 51 } 51 if ( !empty($submenu[$item[2]]) ) { 52 53 $submenu_items = false; 54 if ( ! empty( $submenu[$item[2]] ) ) { 52 55 $class[] = 'wp-has-submenu'; 56 $submenu_items = $submenu[$item[2]]; 53 57 $menu_setting_increment++; 54 58 } 55 59 56 60 if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) { 57 if ( !empty($submenu[$item[2]]) ) 58 $class[] = 'wp-has-current-submenu wp-menu-open'; 59 else 60 $class[] = 'current'; 61 $class[] = ! empty( $submenu_items ) ? 'wp-has-current-submenu wp-menu-open' : 'current'; 61 62 } else { 62 63 $class[] = 'wp-not-current-submenu'; 63 64 } 64 65 65 if ( ! empty( $item[4]) )66 if ( ! empty( $item[4] ) ) 66 67 $class[] = $item[4]; 67 68 68 69 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 69 70 $tabindex = ' tabindex="1"'; 70 $id = ! empty( $item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : '';71 $id = ! empty( $item[5] ) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : ''; 71 72 $img = ''; 72 if ( ! empty($item[6]) ) { 73 if ( 'div' === $item[6] ) 74 $img = '<br />'; 75 else 76 $img = '<img src="' . $item[6] . '" alt="" />'; 77 } 73 if ( ! empty( $item[6] ) ) 74 $img = ( 'div' === $item[6] ) ? '<br />' : '<img src="' . $item[6] . '" alt="" />'; 78 75 $arrow = '<div class="wp-menu-arrow"><div></div></div>'; 79 76 80 $title = wptexturize( $item[0]);77 $title = wptexturize( $item[0] ); 81 78 82 79 echo "\n\t<li$class$id>"; … … 84 81 if ( false !== strpos( $class, 'wp-menu-separator' ) ) { 85 82 echo '<div class="separator"></div>'; 86 } elseif ( $submenu_as_parent && ! empty($submenu[$item[2]]) ) {87 $submenu [$item[2]] = array_values($submenu[$item[2]]); // Re-index.88 $menu_hook = get_plugin_page_hook( $submenu[$item[2]][0][2], $item[2]);89 $menu_file = $submenu [$item[2]][0][2];90 if ( false !== $pos = strpos($menu_file, '?') )91 $menu_file = substr( $menu_file, 0, $pos);92 if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) {83 } elseif ( $submenu_as_parent && ! empty( $submenu_items ) ) { 84 $submenu_items = array_values( $submenu_items ); // Re-index. 85 $menu_hook = get_plugin_page_hook( $submenu_items[0][2], $item[2] ); 86 $menu_file = $submenu_items[0][2]; 87 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) 88 $menu_file = substr( $menu_file, 0, $pos ); 89 if ( ! empty( $menu_hook ) || ( ('index.php' != $submenu_items[0][2]) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) ) ) { 93 90 $admin_is_parent = true; 94 echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu [$item[2]][0][2]}'>$img</a></div>$arrow<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>";91 echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu_items[0][2]}'>$img</a></div>$arrow<a href='admin.php?page={$submenu_items[0][2]}'$class$tabindex>$title</a>"; 95 92 } else { 96 echo "\n\t<div class='wp-menu-image'><a href='{$submenu [$item[2]][0][2]}'>$img</a></div>$arrow<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>";93 echo "\n\t<div class='wp-menu-image'><a href='{$submenu_items[0][2]}'>$img</a></div>$arrow<a href='{$submenu_items[0][2]}'$class$tabindex>$title</a>"; 97 94 } 98 } else if ( !empty($item[2]) && current_user_can($item[1]) ) {99 $menu_hook = get_plugin_page_hook( $item[2], 'admin.php');95 } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) { 96 $menu_hook = get_plugin_page_hook( $item[2], 'admin.php' ); 100 97 $menu_file = $item[2]; 101 if ( false !== $pos = strpos($menu_file, '?') )102 $menu_file = substr( $menu_file, 0, $pos);103 if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) {98 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) 99 $menu_file = substr( $menu_file, 0, $pos ); 100 if ( ! empty( $menu_hook ) || ( ('index.php' != $item[2]) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) ) ) { 104 101 $admin_is_parent = true; 105 102 echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}'>$img</a></div>$arrow<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>"; … … 109 106 } 110 107 111 if ( ! empty($submenu[$item[2]]) ) {108 if ( ! empty( $submenu_items ) ) { 112 109 echo "\n\t<div class='wp-submenu'><div class='wp-submenu-wrap'>"; 113 110 echo "<div class='wp-submenu-head'>{$item[0]}</div><ul>"; 114 111 $first = true; 115 foreach ( $submenu [$item[2]]as $sub_key => $sub_item ) {116 if ( ! current_user_can($sub_item[1]) )112 foreach ( $submenu_items as $sub_key => $sub_item ) { 113 if ( ! current_user_can( $sub_item[1] ) ) 117 114 continue; 118 115 … … 125 122 $menu_file = $item[2]; 126 123 127 if ( false !== $pos = strpos($menu_file, '?') )128 $menu_file = substr( $menu_file, 0, $pos);124 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) 125 $menu_file = substr( $menu_file, 0, $pos ); 129 126 130 127 // Handle current for post_type=post|page|foo pages, which won't match $self. 131 if ( !empty($typenow) ) 132 $self_type = $self . '?post_type=' . $typenow; 133 else 134 $self_type = 'nothing'; 128 $self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing'; 135 129 136 if ( isset($submenu_file) ) { 137 if ( $submenu_file == $sub_item[2] ) 138 $class[] = 'current'; 130 if ( isset( $submenu_file ) && $submenu_file == $sub_item[2] ) { 131 $class[] = 'current'; 139 132 // If plugin_page is set the parent must either match the current page or not physically exist. 140 133 // This allows plugin pages with the same hook to exist under different parents. 141 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self) || ($item[2] == $self_type))) || (!isset($plugin_page) && $self == $sub_item[2]) ) { 134 } else if ( 135 ( ! isset( $plugin_page ) && $self == $sub_item[2] ) || 136 ( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false ) ) 137 ) { 142 138 $class[] = 'current'; 143 139 } … … 147 143 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 148 144 $sub_file = $sub_item[2]; 149 if ( false !== $pos = strpos($sub_file, '?') )145 if ( false !== ( $pos = strpos( $sub_file, '?' ) ) ) 150 146 $sub_file = substr($sub_file, 0, $pos); 151 147 152 148 $title = wptexturize($sub_item[0]); 153 149 154 if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) {150 if ( ! empty( $menu_hook ) || ( ('index.php' != $sub_item[2]) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) ) ) { 155 151 // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir 156 152 if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) ) … … 158 154 else 159 155 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' ); 160 $sub_item_url = esc_url($sub_item_url); 156 157 $sub_item_url = esc_url( $sub_item_url ); 161 158 echo "<li$class><a href='$sub_item_url'$class$tabindex>$title</a></li>"; 162 159 } else {
Note: See TracChangeset
for help on using the changeset viewer.