| [ Index ] |
PHP Cross Reference of Wordpress 2.7.1 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Displays Administration Menu. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** 10 * The current page. 11 * 12 * @global string $self 13 * @name $self 14 * @var string 15 */ 16 $self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']); 17 $self = preg_replace('|^.*/plugins/|i', '', $self); 18 19 global $menu, $submenu, $parent_file; //For when admin-header is included from within a function. 20 21 get_admin_page_parent(); 22 23 /** 24 * Display menu. 25 * 26 * @access private 27 * @since 2.7.0 28 * 29 * @param array $menu 30 * @param array $submenu 31 * @param bool $submenu_as_parent 32 */ 33 function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { 34 global $self, $parent_file, $submenu_file, $plugin_page, $pagenow; 35 36 $first = true; 37 // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src 38 foreach ( $menu as $key => $item ) { 39 $admin_is_parent = false; 40 $class = array(); 41 if ( $first ) { 42 $class[] = 'wp-first-item'; 43 $first = false; 44 } 45 if ( !empty($submenu[$item[2]]) ) 46 $class[] = 'wp-has-submenu'; 47 48 if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0 ) { 49 if ( !empty($submenu[$item[2]]) ) 50 $class[] = 'wp-has-current-submenu wp-menu-open'; 51 else 52 $class[] = 'current'; 53 } 54 55 if ( isset($item[4]) && ! empty($item[4]) ) 56 $class[] = $item[4]; 57 58 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 59 $tabindex = ' tabindex="1"'; 60 $id = isset($item[5]) && ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : ''; 61 $img = ''; 62 if ( isset($item[6]) && ! empty($item[6]) ) { 63 if ( 'div' === $item[6] ) 64 $img = '<div class="wp-menu-image"><br /></div>'; 65 else 66 $img = '<img class="wp-menu-image" src="' . $item[6] . '" alt="" />'; 67 } 68 $toggle = '<div class="wp-menu-toggle"><br /></div>'; 69 70 echo "\n\t<li$class$id>"; 71 72 if ( false !== strpos($class, 'wp-menu-separator') ) { 73 echo '<br />'; 74 } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { 75 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 76 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 77 if ( ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") && ('index.php' != $submenu[$item[2]][0][2]) ) || !empty($menu_hook)) { 78 $admin_is_parent = true; 79 echo "$img$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>"; 80 } else { 81 echo "\n\t$img$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>"; 82 } 83 } else if ( current_user_can($item[1]) ) { 84 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 85 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) { 86 $admin_is_parent = true; 87 echo "\n\t$img$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>"; 88 } else { 89 echo "\n\t$img$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>"; 90 } 91 } 92 93 if ( !empty($submenu[$item[2]]) ) { 94 echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>"; 95 $first = true; 96 foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) { 97 if ( !current_user_can($sub_item[1]) ) 98 continue; 99 100 $class = array(); 101 if ( $first ) { 102 $class[] = 'wp-first-item'; 103 $first = false; 104 } 105 if ( isset($submenu_file) ) { 106 if ( $submenu_file == $sub_item[2] ) 107 $class[] = 'current'; 108 // If plugin_page is set the parent must either match the current page or not physically exist. 109 // 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]) ) { 111 $class[] = 'current'; 112 } 113 114 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 115 116 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 117 118 if ( ( file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") && ('index.php' != $sub_item[2]) ) || ! empty($menu_hook) ) { 119 // 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]); 121 if ( $parent_exists ) 122 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 123 elseif ( 'admin.php' == $pagenow || !$parent_exists ) 124 echo "<li$class><a href='admin.php?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 125 else 126 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 127 } else { 128 echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 129 } 130 } 131 echo "</ul></div>"; 132 } 133 echo "</li>"; 134 } 135 } 136 137 ?> 138 139 <ul id="adminmenu"> 140 141 <?php 142 143 _wp_menu_output( $menu, $submenu ); 144 do_action( 'adminmenu' ); 145 146 ?> 147 </ul>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Mar 23 16:23:02 2009 | Cross-referenced by PHPXref 0.7 |