| [ Root ] [ Search ] [ Index ] |
PHP Cross Reference of WordPress 3.0.1Provided by Yoast |
[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 $self = preg_replace('|^.*/mu-plugins/|i', '', $self); 19 20 global $menu, $submenu, $parent_file; //For when admin-header is included from within a function. 21 $parent_file = apply_filters("parent_file", $parent_file); // For plugins to move submenu tabs around. 22 23 get_admin_page_parent(); 24 25 /** 26 * Display menu. 27 * 28 * @access private 29 * @since 2.7.0 30 * 31 * @param array $menu 32 * @param array $submenu 33 * @param bool $submenu_as_parent 34 */ 35 function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { 36 global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; 37 38 $first = true; 39 // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src 40 foreach ( $menu as $key => $item ) { 41 $admin_is_parent = false; 42 $class = array(); 43 if ( $first ) { 44 $class[] = 'wp-first-item'; 45 $first = false; 46 } 47 if ( !empty($submenu[$item[2]]) ) 48 $class[] = 'wp-has-submenu'; 49 50 if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && $self == $item[2] ) ) { 51 if ( !empty($submenu[$item[2]]) ) 52 $class[] = 'wp-has-current-submenu wp-menu-open'; 53 else 54 $class[] = 'current'; 55 } 56 57 if ( ! empty($item[4]) ) 58 $class[] = $item[4]; 59 60 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 61 $tabindex = ' tabindex="1"'; 62 $id = ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : ''; 63 $img = ''; 64 if ( ! empty($item[6]) ) { 65 if ( 'div' === $item[6] ) 66 $img = '<br />'; 67 else 68 $img = '<img src="' . $item[6] . '" alt="" />'; 69 } 70 $toggle = '<div class="wp-menu-toggle"><br /></div>'; 71 72 $title = wptexturize($item[0]); 73 74 echo "\n\t<li$class$id>"; 75 76 if ( false !== strpos($class, 'wp-menu-separator') ) { 77 echo '<a class="separator" href="?unfoldmenu=1"><br /></a>'; 78 } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { 79 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 80 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 81 $menu_file = $submenu[$item[2]][0][2]; 82 if ( false !== $pos = strpos($menu_file, '?') ) 83 $menu_file = substr($menu_file, 0, $pos); 84 if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) { 85 $admin_is_parent = true; 86 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>$title</a>"; 87 } else { 88 echo "\n\t<div class='wp-menu-image'><a href='{$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>"; 89 } 90 } else if ( current_user_can($item[1]) ) { 91 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 92 $menu_file = $item[2]; 93 if ( false !== $pos = strpos($menu_file, '?') ) 94 $menu_file = substr($menu_file, 0, $pos); 95 if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) { 96 $admin_is_parent = true; 97 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>"; 98 } else { 99 echo "\n\t<div class='wp-menu-image'><a href='{$item[2]}'>$img</a></div>$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>"; 100 } 101 } 102 103 if ( !empty($submenu[$item[2]]) ) { 104 echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>"; 105 $first = true; 106 foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) { 107 if ( !current_user_can($sub_item[1]) ) 108 continue; 109 110 $class = array(); 111 if ( $first ) { 112 $class[] = 'wp-first-item'; 113 $first = false; 114 } 115 116 $menu_file = $item[2]; 117 118 if ( false !== $pos = strpos($menu_file, '?') ) 119 $menu_file = substr($menu_file, 0, $pos); 120 121 // Handle current for post_type=post|page|foo pages, which won't match $self. 122 if ( !empty($typenow) ) 123 $self_type = $self . '?post_type=' . $typenow; 124 else 125 $self_type = 'nothing'; 126 127 if ( isset($submenu_file) ) { 128 if ( $submenu_file == $sub_item[2] ) 129 $class[] = 'current'; 130 // If plugin_page is set the parent must either match the current page or not physically exist. 131 // This allows plugin pages with the same hook to exist under different parents. 132 } 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]) ) { 133 $class[] = 'current'; 134 } 135 136 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 137 138 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 139 $sub_file = $sub_item[2]; 140 if ( false !== $pos = strpos($sub_file, '?') ) 141 $sub_file = substr($sub_file, 0, $pos); 142 143 $title = wptexturize($sub_item[0]); 144 145 if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) { 146 // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir 147 if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) ) 148 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] ); 149 else 150 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' ); 151 $sub_item_url = esc_url($sub_item_url); 152 echo "<li$class><a href='$sub_item_url'$class$tabindex>$title</a></li>"; 153 } else { 154 echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>$title</a></li>"; 155 } 156 } 157 echo "</ul></div>"; 158 } 159 echo "</li>"; 160 } 161 } 162 163 ?> 164 165 <ul id="adminmenu"> 166 167 <?php 168 169 _wp_menu_output( $menu, $submenu ); 170 do_action( 'adminmenu' ); 171 172 ?> 173 </ul>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Oct 14 05:12:05 2010 | Cross-referenced by PHPXref 0.7 |