Changeset 8691 for trunk/wp-admin/menu-header.php
- Timestamp:
- 08/20/2008 09:42:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/menu-header.php
r8645 r8691 21 21 get_admin_page_parent(); 22 22 23 // We're going to do this loop three times 24 ?> 23 function _wp_menu_output( &$menu, &$submenu, $submenu_as_parent = true ) { 24 global $self, $parent_file, $submenu_file, $plugin_page; 25 25 26 <ul id="dashmenu"> 27 <?php 28 foreach ( $menu as $key => $item ) { 29 if ( 3 < $key ) // get each menu item before 3 30 continue; 31 $class = ''; 32 // 0 = name, 1 = capability, 2 = file 33 if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; 26 $first = true; 27 // 0 = name, 1 = capability, 2 = file, 3 = class 28 foreach ( $menu as $key => $item ) { 29 $class = array(); 30 if ( $first ) { 31 $class[] = 'wp-first-item'; 32 $first = false; 33 } 34 if ( !empty($submenu[$item[2]]) ) 35 $class[] = 'wp-has-submenu'; 34 36 35 if ( !empty($submenu[$item[2]]) ) { 36 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 37 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 38 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) 39 echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 40 else 41 echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 42 } else if ( current_user_can($item[1]) ) { 43 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 44 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) 45 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 46 else 47 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; 48 } 49 } 50 do_action( 'dashmenu' ); 51 ?> 52 </ul> 37 if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0 ) { 38 if ( !empty($submenu[$item[2]]) ) 39 $class[] = 'wp-has-current-submenu wp-menu-open'; 40 else 41 $class[] = 'current'; 42 } 53 43 54 <ul id="adminmenu"> 55 <?php 56 foreach ( $menu as $key => $item ) { 57 if ( 5 > $key || $key > 25 ) // get each menu item before 3 58 continue; 44 if ( isset($item[3]) ) 45 $class[] = $item[3]; 59 46 60 $class ='';47 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 61 48 62 // 0 = name, 1 = capability, 2 = file 63 if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; 49 echo "\n\t<li$class>"; 64 50 65 if ( !empty($submenu[$item[2]]) ) { 66 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 67 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 68 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) 69 echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 70 else 71 echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 72 } else if ( current_user_can($item[1]) ) { 73 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 74 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) 75 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 76 else 77 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; 51 if ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { 52 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 53 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 54 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) 55 echo "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; 56 else 57 echo "\n\t<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; 58 } else if ( current_user_can($item[1]) ) { 59 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 60 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) 61 echo "\n\t<a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>"; 62 else 63 echo "\n\t<a href='{$item[2]}'$class>{$item[0]}</a>"; 64 } 65 66 if ( !empty($submenu[$item[2]]) ) { 67 echo "\n\t<ul class='wp-submenu'>"; 68 $first = true; 69 foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) { 70 if ( !current_user_can($sub_item[1]) ) 71 continue; 72 73 $class = array(); 74 if ( $first ) { 75 $class[] = 'wp-first-item'; 76 $first = false; 77 } 78 if ( isset($submenu_file) ) { 79 if ( $submenu_file == $sub_item[2] ) 80 $class[] = 'current'; 81 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2]) || (!isset($plugin_page) && $self == $sub_item[2]) ) { 82 $class[] = 'current'; 83 } 84 85 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 86 87 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 88 89 if ( file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") || ! empty($menu_hook) ) { 90 if ( 'admin.php' == $pagenow ) 91 echo "\n\t\t<li$class><a href='admin.php?page={$sub_item[2]}'$class>{$sub_item[0]}</a></li>"; 92 else 93 echo "\n\t\t<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class>{$sub_item[0]}</a></li>"; 94 } else { 95 echo "\n\t\t<li$class><a href='{$sub_item[2]}'$class>{$sub_item[0]}</a></li>"; 96 } 97 } 98 echo "\n\t</ul>"; 99 } 100 echo "</li>"; 78 101 } 79 102 } 80 103 81 foreach ( $menu as $key => $item ) { 82 if ( $key < 41 ) // there is a more efficient way to do this! 83 continue; 104 ?> 84 105 85 $class = ''; 106 <ul id="dashmenu" class="wp-menu"> 86 107 87 // 0 = name, 1 = capability, 2 = file 88 if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; 108 <?php 89 109 90 if ( !empty($submenu[$item[2]]) ) { 91 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 92 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 93 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) 94 echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 95 else 96 echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 97 } else if ( current_user_can($item[1]) ) { 98 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 99 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) 100 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 101 else 102 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; 103 } 104 } 110 _wp_menu_output( $top_menu, $top_submenu, false ); 111 do_action( 'dashmenu' ); 105 112 106 do_action( 'adminmenu' );107 113 ?> 108 </ul>109 114 110 <ul id="sidemenu">111 <?php112 $side_items = array();113 foreach ( $menu as $key => $item ) {114 if ( 26 > $key || $key > 40 )115 continue;116 115 117 $class = '';118 119 // 0 = name, 1 = capability, 2 = file120 if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';121 122 if ( !empty($submenu[$item[2]]) ) {123 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.124 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);125 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))126 $side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";127 else128 $side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";129 } else if ( current_user_can($item[1]) ) {130 $menu_hook = get_plugin_page_hook($item[2], 'admin.php');131 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )132 $side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>";133 else134 $side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>";135 }136 }137 echo implode(' </li>', $side_items) . '</li>';138 unset($side_items);139 do_action( 'sidemenu' );140 ?>141 116 </ul> 142 117 143 118 119 <ul id="adminmenu" class="wp-menu"> 120 121 <li class="write-new-button"><a class="button-secondary" href="post-new.php">Write New Post</a></li> 122 144 123 <?php 145 // Sub-menu146 if ( isset($submenu["$parent_file"]) ) :147 ?>148 <ul id="submenu">149 <?php150 foreach ($submenu["$parent_file"] as $item) :151 if ( !current_user_can($item[1]) )152 continue;153 124 154 if ( isset($submenu_file) ) { 155 if ( $submenu_file == $item[2] ) $class = ' class="current"'; 156 else $class = ''; 157 } else if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && $self == $item[2]) ) $class = ' class="current"'; 158 else $class = ''; 125 _wp_menu_output( $menu, $submenu ); 126 do_action( 'adminmenu' ); 159 127 160 $menu_hook = get_plugin_page_hook($item[2], $parent_file);161 162 if (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || ! empty($menu_hook)) {163 if ( 'admin.php' == $pagenow )164 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";165 else166 echo "\n\t<li><a href='{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";167 } else {168 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";169 }170 endforeach;171 128 ?> 172 129 130 173 131 </ul> 132 174 133 <?php 175 else :176 ?>177 <div id="minisub"></div>178 <?php179 180 endif;181 134 182 135 do_action('admin_notices');
Note: See TracChangeset
for help on using the changeset viewer.