WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[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 echo "\n\t<li$class$id>"; 73 74 if ( false !== strpos($class, 'wp-menu-separator') ) { 75 echo '<a class="separator" href="?unfoldmenu=1"><br /></a>'; 76 } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { 77 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 78 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 79 $menu_file = $submenu[$item[2]][0][2]; 80 if ( false !== $pos = strpos($menu_file, '?') ) 81 $menu_file = substr($menu_file, 0, $pos); 82 if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) { 83 $admin_is_parent = true; 84 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>"; 85 } else { 86 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>{$item[0]}</a>"; 87 } 88 } else if ( current_user_can($item[1]) ) { 89 $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); 90 $menu_file = $item[2]; 91 if ( false !== $pos = strpos($menu_file, '?') ) 92 $menu_file = substr($menu_file, 0, $pos); 93 if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) { 94 $admin_is_parent = true; 95 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>"; 96 } else { 97 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>"; 98 } 99 } 100 101 if ( !empty($submenu[$item[2]]) ) { 102 echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>"; 103 $first = true; 104 foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) { 105 if ( !current_user_can($sub_item[1]) ) 106 continue; 107 108 $class = array(); 109 if ( $first ) { 110 $class[] = 'wp-first-item'; 111 $first = false; 112 } 113 114 $menu_file = $item[2]; 115 116 if ( false !== $pos = strpos($menu_file, '?') ) 117 $menu_file = substr($menu_file, 0, $pos); 118 119 // Handle current for post_type=post|page|foo pages, which won't match $self. 120 if ( !empty($typenow) ) 121 $self_type = $self . '?post_type=' . $typenow; 122 else 123 $self_type = 'nothing'; 124 125 if ( isset($submenu_file) ) { 126 if ( $submenu_file == $sub_item[2] ) 127 $class[] = 'current'; 128 // If plugin_page is set the parent must either match the current page or not physically exist. 129 // This allows plugin pages with the same hook to exist under different parents. 130 } 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]) ) { 131 $class[] = 'current'; 132 } 133 134 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 135 136 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 137 $sub_file = $sub_item[2]; 138 if ( false !== $pos = strpos($sub_file, '?') ) 139 $sub_file = substr($sub_file, 0, $pos); 140 141 if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) { 142 // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir 143 if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) ) 144 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] ); 145 else 146 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' ); 147 $sub_item_url = esc_url($sub_item_url); 148 echo "<li$class><a href='$sub_item_url'$class$tabindex>{$sub_item[0]}</a></li>"; 149 } else { 150 echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 151 } 152 } 153 echo "</ul></div>"; 154 } 155 echo "</li>"; 156 } 157 } 158 159 ?> 160 161 <ul id="adminmenu"> 162 163 <?php 164 165 _wp_menu_output( $menu, $submenu ); 166 do_action( 'adminmenu' ); 167 168 ?> 169 </ul>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |