| [ Root ] [ Search ] [ Index ] |
PHP Cross Reference of WordPress MU 2.9.2Provided 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; 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 ) || strcmp($self, $item[2]) == 0 ) { 51 if ( !empty($submenu[$item[2]]) ) 52 $class[] = 'wp-has-current-submenu wp-menu-open'; 53 else 54 $class[] = 'current'; 55 } 56 57 if ( isset($item[4]) && ! empty($item[4]) ) 58 $class[] = $item[4]; 59 60 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 61 $tabindex = ' tabindex="1"'; 62 $id = isset($item[5]) && ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : ''; 63 $img = ''; 64 if ( isset($item[6]) && ! 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") || file_exists( WPMU_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") || file_exists(WPMU_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 if ( false !== $pos = strpos($menu_file, '?') ) 116 $menu_file = substr($menu_file, 0, $pos); 117 118 if ( isset($submenu_file) ) { 119 if ( $submenu_file == $sub_item[2] ) 120 $class[] = 'current'; 121 // If plugin_page is set the parent must either match the current page or not physically exist. 122 // This allows plugin pages with the same hook to exist under different parents. 123 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) { 124 $class[] = 'current'; 125 } 126 127 $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; 128 129 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); 130 $sub_file = $sub_item[2]; 131 if ( false !== $pos = strpos($sub_file, '?') ) 132 $sub_file = substr($sub_file, 0, $pos); 133 134 if ( ( ('index.php' != $sub_item[2]) && ( file_exists(WP_PLUGIN_DIR . "/$sub_file") || file_exists( WPMU_PLUGIN_DIR . "/$sub_file") ) ) || ! empty($menu_hook) ) { 135 // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir 136 137 $parent_exists = (!$admin_is_parent && ((file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || ( file_exists( WPMU_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WPMU_PLUGIN_DIR . "/{$item[2]}" ) ) ) ) || file_exists($menu_file); 138 if ( $parent_exists ) 139 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 140 elseif ( 'admin.php' == $pagenow || !$parent_exists ) 141 echo "<li$class><a href='admin.php?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 142 else 143 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 144 } else { 145 echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 146 } 147 } 148 echo "</ul></div>"; 149 } 150 echo "</li>"; 151 } 152 } 153 154 ?> 155 156 <ul id="adminmenu"> 157 158 <?php 159 160 _wp_menu_output( $menu, $submenu ); 161 do_action( 'adminmenu' ); 162 163 ?> 164 </ul>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon May 3 12:25:32 2010 | Cross-referenced by PHPXref 0.7 |