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