-
+ 438670B5C1C70F8178D4731A311ED8C0E12F4075EA7EAC3D0A8FCA957BBEF6B897C59B6601574A14FBB52EA5908EEE69F5958F33D9EF8F1B6CA56E93B07EFAD3
mp-wp/wp-admin/menu-header.php
(0 . 0)(1 . 147)
52842 <?php
52843 /**
52844 * Displays Administration Menu.
52845 *
52846 * @package WordPress
52847 * @subpackage Administration
52848 */
52849
52850 /**
52851 * The current page.
52852 *
52853 * @global string $self
52854 * @name $self
52855 * @var string
52856 */
52857 $self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
52858 $self = preg_replace('|^.*/plugins/|i', '', $self);
52859
52860 global $menu, $submenu, $parent_file; //For when admin-header is included from within a function.
52861
52862 get_admin_page_parent();
52863
52864 /**
52865 * Display menu.
52866 *
52867 * @access private
52868 * @since 2.7.0
52869 *
52870 * @param array $menu
52871 * @param array $submenu
52872 * @param bool $submenu_as_parent
52873 */
52874 function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
52875 global $self, $parent_file, $submenu_file, $plugin_page, $pagenow;
52876
52877 $first = true;
52878 // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
52879 foreach ( $menu as $key => $item ) {
52880 $admin_is_parent = false;
52881 $class = array();
52882 if ( $first ) {
52883 $class[] = 'wp-first-item';
52884 $first = false;
52885 }
52886 if ( !empty($submenu[$item[2]]) )
52887 $class[] = 'wp-has-submenu';
52888
52889 if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0 ) {
52890 if ( !empty($submenu[$item[2]]) )
52891 $class[] = 'wp-has-current-submenu wp-menu-open';
52892 else
52893 $class[] = 'current';
52894 }
52895
52896 if ( isset($item[4]) && ! empty($item[4]) )
52897 $class[] = $item[4];
52898
52899 $class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
52900 $tabindex = ' tabindex="1"';
52901 $id = isset($item[5]) && ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : '';
52902 $img = '';
52903 if ( isset($item[6]) && ! empty($item[6]) ) {
52904 if ( 'div' === $item[6] )
52905 $img = '<div class="wp-menu-image"><br /></div>';
52906 else
52907 $img = '<img class="wp-menu-image" src="' . $item[6] . '" alt="" />';
52908 }
52909 $toggle = '<div class="wp-menu-toggle"><br /></div>';
52910
52911 echo "\n\t<li$class$id>";
52912
52913 if ( false !== strpos($class, 'wp-menu-separator') ) {
52914 echo '<br />';
52915 } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) {
52916 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
52917 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
52918 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) {
52919 $admin_is_parent = true;
52920 echo "$img$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
52921 } else {
52922 echo "\n\t$img$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
52923 }
52924 } else if ( current_user_can($item[1]) ) {
52925 $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
52926 if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) {
52927 $admin_is_parent = true;
52928 echo "\n\t$img$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>";
52929 } else {
52930 echo "\n\t$img$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>";
52931 }
52932 }
52933
52934 if ( !empty($submenu[$item[2]]) ) {
52935 echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>";
52936 $first = true;
52937 foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) {
52938 if ( !current_user_can($sub_item[1]) )
52939 continue;
52940
52941 $class = array();
52942 if ( $first ) {
52943 $class[] = 'wp-first-item';
52944 $first = false;
52945 }
52946 if ( isset($submenu_file) ) {
52947 if ( $submenu_file == $sub_item[2] )
52948 $class[] = 'current';
52949 // If plugin_page is set the parent must either match the current page or not physically exist.
52950 // This allows plugin pages with the same hook to exist under different parents.
52951 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($item[2]) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {
52952 $class[] = 'current';
52953 }
52954
52955 $class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
52956
52957 $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
52958
52959 if ( file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") || ! empty($menu_hook) ) {
52960 // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
52961 $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($item[2]);
52962 if ( $parent_exists )
52963 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
52964 elseif ( 'admin.php' == $pagenow || !$parent_exists )
52965 echo "<li$class><a href='admin.php?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
52966 else
52967 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
52968 } else {
52969 echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
52970 }
52971 }
52972 echo "</ul></div>";
52973 }
52974 echo "</li>";
52975 }
52976 }
52977
52978 ?>
52979
52980 <ul id="adminmenu">
52981
52982 <?php
52983
52984 _wp_menu_output( $menu, $submenu );
52985 do_action( 'adminmenu' );
52986
52987 ?>
52988 </ul>