Edit File by line
/home/barbar84/public_h.../wp-admin
File: menu-header.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Displays Administration Menu.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* The current page.
[9] Fix | Delete
*
[10] Fix | Delete
* @global string $self
[11] Fix | Delete
*/
[12] Fix | Delete
$self = preg_replace( '|^.*/wp-admin/network/|i', '', $_SERVER['PHP_SELF'] );
[13] Fix | Delete
$self = preg_replace( '|^.*/wp-admin/|i', '', $self );
[14] Fix | Delete
$self = preg_replace( '|^.*/plugins/|i', '', $self );
[15] Fix | Delete
$self = preg_replace( '|^.*/mu-plugins/|i', '', $self );
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* For when admin-header is included from within a function.
[19] Fix | Delete
*
[20] Fix | Delete
* @global array $menu
[21] Fix | Delete
* @global array $submenu
[22] Fix | Delete
* @global string $parent_file
[23] Fix | Delete
* @global string $submenu_file
[24] Fix | Delete
*/
[25] Fix | Delete
global $menu, $submenu, $parent_file, $submenu_file;
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Filters the parent file of an admin menu sub-menu item.
[29] Fix | Delete
*
[30] Fix | Delete
* Allows plugins to move sub-menu items around.
[31] Fix | Delete
*
[32] Fix | Delete
* @since MU (3.0.0)
[33] Fix | Delete
*
[34] Fix | Delete
* @param string $parent_file The parent file.
[35] Fix | Delete
*/
[36] Fix | Delete
$parent_file = apply_filters( 'parent_file', $parent_file );
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Filters the file of an admin menu sub-menu item.
[40] Fix | Delete
*
[41] Fix | Delete
* @since 4.4.0
[42] Fix | Delete
*
[43] Fix | Delete
* @param string $submenu_file The submenu file.
[44] Fix | Delete
* @param string $parent_file The submenu item's parent file.
[45] Fix | Delete
*/
[46] Fix | Delete
$submenu_file = apply_filters( 'submenu_file', $submenu_file, $parent_file );
[47] Fix | Delete
[48] Fix | Delete
get_admin_page_parent();
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Display menu.
[52] Fix | Delete
*
[53] Fix | Delete
* @access private
[54] Fix | Delete
* @since 2.7.0
[55] Fix | Delete
*
[56] Fix | Delete
* @global string $self
[57] Fix | Delete
* @global string $parent_file
[58] Fix | Delete
* @global string $submenu_file
[59] Fix | Delete
* @global string $plugin_page
[60] Fix | Delete
* @global string $typenow
[61] Fix | Delete
*
[62] Fix | Delete
* @param array $menu
[63] Fix | Delete
* @param array $submenu
[64] Fix | Delete
* @param bool $submenu_as_parent
[65] Fix | Delete
*/
[66] Fix | Delete
function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
[67] Fix | Delete
global $self, $parent_file, $submenu_file, $plugin_page, $typenow;
[68] Fix | Delete
[69] Fix | Delete
$first = true;
[70] Fix | Delete
// 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes, 5 = hookname, 6 = icon_url.
[71] Fix | Delete
foreach ( $menu as $key => $item ) {
[72] Fix | Delete
$admin_is_parent = false;
[73] Fix | Delete
$class = array();
[74] Fix | Delete
$aria_attributes = '';
[75] Fix | Delete
$aria_hidden = '';
[76] Fix | Delete
$is_separator = false;
[77] Fix | Delete
[78] Fix | Delete
if ( $first ) {
[79] Fix | Delete
$class[] = 'wp-first-item';
[80] Fix | Delete
$first = false;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
$submenu_items = array();
[84] Fix | Delete
if ( ! empty( $submenu[ $item[2] ] ) ) {
[85] Fix | Delete
$class[] = 'wp-has-submenu';
[86] Fix | Delete
$submenu_items = $submenu[ $item[2] ];
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if ( ( $parent_file && $item[2] === $parent_file ) || ( empty( $typenow ) && $self === $item[2] ) ) {
[90] Fix | Delete
if ( ! empty( $submenu_items ) ) {
[91] Fix | Delete
$class[] = 'wp-has-current-submenu wp-menu-open';
[92] Fix | Delete
} else {
[93] Fix | Delete
$class[] = 'current';
[94] Fix | Delete
$aria_attributes .= 'aria-current="page"';
[95] Fix | Delete
}
[96] Fix | Delete
} else {
[97] Fix | Delete
$class[] = 'wp-not-current-submenu';
[98] Fix | Delete
if ( ! empty( $submenu_items ) ) {
[99] Fix | Delete
$aria_attributes .= 'aria-haspopup="true"';
[100] Fix | Delete
}
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
if ( ! empty( $item[4] ) ) {
[104] Fix | Delete
$class[] = esc_attr( $item[4] );
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
$class = $class ? ' class="' . implode( ' ', $class ) . '"' : '';
[108] Fix | Delete
$id = ! empty( $item[5] ) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : '';
[109] Fix | Delete
$img = '';
[110] Fix | Delete
$img_style = '';
[111] Fix | Delete
$img_class = ' dashicons-before';
[112] Fix | Delete
[113] Fix | Delete
if ( false !== strpos( $class, 'wp-menu-separator' ) ) {
[114] Fix | Delete
$is_separator = true;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
/*
[118] Fix | Delete
* If the string 'none' (previously 'div') is passed instead of a URL, don't output
[119] Fix | Delete
* the default menu image so an icon can be added to div.wp-menu-image as background
[120] Fix | Delete
* with CSS. Dashicons and base64-encoded data:image/svg_xml URIs are also handled
[121] Fix | Delete
* as special cases.
[122] Fix | Delete
*/
[123] Fix | Delete
if ( ! empty( $item[6] ) ) {
[124] Fix | Delete
$img = '<img src="' . $item[6] . '" alt="" />';
[125] Fix | Delete
[126] Fix | Delete
if ( 'none' === $item[6] || 'div' === $item[6] ) {
[127] Fix | Delete
$img = '<br />';
[128] Fix | Delete
} elseif ( 0 === strpos( $item[6], 'data:image/svg+xml;base64,' ) ) {
[129] Fix | Delete
$img = '<br />';
[130] Fix | Delete
$img_style = ' style="background-image:url(\'' . esc_attr( $item[6] ) . '\')"';
[131] Fix | Delete
$img_class = ' svg';
[132] Fix | Delete
} elseif ( 0 === strpos( $item[6], 'dashicons-' ) ) {
[133] Fix | Delete
$img = '<br />';
[134] Fix | Delete
$img_class = ' dashicons-before ' . sanitize_html_class( $item[6] );
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
$arrow = '<div class="wp-menu-arrow"><div></div></div>';
[138] Fix | Delete
[139] Fix | Delete
$title = wptexturize( $item[0] );
[140] Fix | Delete
[141] Fix | Delete
// Hide separators from screen readers.
[142] Fix | Delete
if ( $is_separator ) {
[143] Fix | Delete
$aria_hidden = ' aria-hidden="true"';
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
echo "\n\t<li$class$id$aria_hidden>";
[147] Fix | Delete
[148] Fix | Delete
if ( $is_separator ) {
[149] Fix | Delete
echo '<div class="separator"></div>';
[150] Fix | Delete
} elseif ( $submenu_as_parent && ! empty( $submenu_items ) ) {
[151] Fix | Delete
$submenu_items = array_values( $submenu_items ); // Re-index.
[152] Fix | Delete
$menu_hook = get_plugin_page_hook( $submenu_items[0][2], $item[2] );
[153] Fix | Delete
$menu_file = $submenu_items[0][2];
[154] Fix | Delete
$pos = strpos( $menu_file, '?' );
[155] Fix | Delete
[156] Fix | Delete
if ( false !== $pos ) {
[157] Fix | Delete
$menu_file = substr( $menu_file, 0, $pos );
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
if ( ! empty( $menu_hook )
[161] Fix | Delete
|| ( ( 'index.php' !== $submenu_items[0][2] )
[162] Fix | Delete
&& file_exists( WP_PLUGIN_DIR . "/$menu_file" )
[163] Fix | Delete
&& ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
[164] Fix | Delete
) {
[165] Fix | Delete
$admin_is_parent = true;
[166] Fix | Delete
echo "<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style aria-hidden='true'>$img</div><div class='wp-menu-name'>$title</div></a>";
[167] Fix | Delete
} else {
[168] Fix | Delete
echo "\n\t<a href='{$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style aria-hidden='true'>$img</div><div class='wp-menu-name'>$title</div></a>";
[169] Fix | Delete
}
[170] Fix | Delete
} elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
[171] Fix | Delete
$menu_hook = get_plugin_page_hook( $item[2], 'admin.php' );
[172] Fix | Delete
$menu_file = $item[2];
[173] Fix | Delete
$pos = strpos( $menu_file, '?' );
[174] Fix | Delete
[175] Fix | Delete
if ( false !== $pos ) {
[176] Fix | Delete
$menu_file = substr( $menu_file, 0, $pos );
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
if ( ! empty( $menu_hook )
[180] Fix | Delete
|| ( ( 'index.php' !== $item[2] )
[181] Fix | Delete
&& file_exists( WP_PLUGIN_DIR . "/$menu_file" )
[182] Fix | Delete
&& ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
[183] Fix | Delete
) {
[184] Fix | Delete
$admin_is_parent = true;
[185] Fix | Delete
echo "\n\t<a href='admin.php?page={$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style aria-hidden='true'>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
[186] Fix | Delete
} else {
[187] Fix | Delete
echo "\n\t<a href='{$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style aria-hidden='true'>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
[188] Fix | Delete
}
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
if ( ! empty( $submenu_items ) ) {
[192] Fix | Delete
echo "\n\t<ul class='wp-submenu wp-submenu-wrap'>";
[193] Fix | Delete
echo "<li class='wp-submenu-head' aria-hidden='true'>{$item[0]}</li>";
[194] Fix | Delete
[195] Fix | Delete
$first = true;
[196] Fix | Delete
[197] Fix | Delete
// 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes.
[198] Fix | Delete
foreach ( $submenu_items as $sub_key => $sub_item ) {
[199] Fix | Delete
if ( ! current_user_can( $sub_item[1] ) ) {
[200] Fix | Delete
continue;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
$class = array();
[204] Fix | Delete
$aria_attributes = '';
[205] Fix | Delete
[206] Fix | Delete
if ( $first ) {
[207] Fix | Delete
$class[] = 'wp-first-item';
[208] Fix | Delete
$first = false;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
$menu_file = $item[2];
[212] Fix | Delete
$pos = strpos( $menu_file, '?' );
[213] Fix | Delete
[214] Fix | Delete
if ( false !== $pos ) {
[215] Fix | Delete
$menu_file = substr( $menu_file, 0, $pos );
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
// Handle current for post_type=post|page|foo pages, which won't match $self.
[219] Fix | Delete
$self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
[220] Fix | Delete
[221] Fix | Delete
if ( isset( $submenu_file ) ) {
[222] Fix | Delete
if ( $submenu_file === $sub_item[2] ) {
[223] Fix | Delete
$class[] = 'current';
[224] Fix | Delete
$aria_attributes .= ' aria-current="page"';
[225] Fix | Delete
}
[226] Fix | Delete
// If plugin_page is set the parent must either match the current page or not physically exist.
[227] Fix | Delete
// This allows plugin pages with the same hook to exist under different parents.
[228] Fix | Delete
} elseif (
[229] Fix | Delete
( ! isset( $plugin_page ) && $self === $sub_item[2] )
[230] Fix | Delete
|| ( isset( $plugin_page ) && $plugin_page === $sub_item[2]
[231] Fix | Delete
&& ( $item[2] === $self_type || $item[2] === $self || file_exists( $menu_file ) === false ) )
[232] Fix | Delete
) {
[233] Fix | Delete
$class[] = 'current';
[234] Fix | Delete
$aria_attributes .= ' aria-current="page"';
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
if ( ! empty( $sub_item[4] ) ) {
[238] Fix | Delete
$class[] = esc_attr( $sub_item[4] );
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
$class = $class ? ' class="' . implode( ' ', $class ) . '"' : '';
[242] Fix | Delete
[243] Fix | Delete
$menu_hook = get_plugin_page_hook( $sub_item[2], $item[2] );
[244] Fix | Delete
$sub_file = $sub_item[2];
[245] Fix | Delete
$pos = strpos( $sub_file, '?' );
[246] Fix | Delete
if ( false !== $pos ) {
[247] Fix | Delete
$sub_file = substr( $sub_file, 0, $pos );
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
$title = wptexturize( $sub_item[0] );
[251] Fix | Delete
[252] Fix | Delete
if ( ! empty( $menu_hook )
[253] Fix | Delete
|| ( ( 'index.php' !== $sub_item[2] )
[254] Fix | Delete
&& file_exists( WP_PLUGIN_DIR . "/$sub_file" )
[255] Fix | Delete
&& ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) )
[256] Fix | Delete
) {
[257] Fix | Delete
// If admin.php is the current page or if the parent exists as a file in the plugins or admin directory.
[258] Fix | Delete
if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) ) {
[259] Fix | Delete
$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), $item[2] );
[260] Fix | Delete
} else {
[261] Fix | Delete
$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), 'admin.php' );
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
$sub_item_url = esc_url( $sub_item_url );
[265] Fix | Delete
echo "<li$class><a href='$sub_item_url'$class$aria_attributes>$title</a></li>";
[266] Fix | Delete
} else {
[267] Fix | Delete
echo "<li$class><a href='{$sub_item[2]}'$class$aria_attributes>$title</a></li>";
[268] Fix | Delete
}
[269] Fix | Delete
}
[270] Fix | Delete
echo '</ul>';
[271] Fix | Delete
}
[272] Fix | Delete
echo '</li>';
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
echo '<li id="collapse-menu" class="hide-if-no-js">' .
[276] Fix | Delete
'<button type="button" id="collapse-button" aria-label="' . esc_attr__( 'Collapse Main menu' ) . '" aria-expanded="true">' .
[277] Fix | Delete
'<span class="collapse-button-icon" aria-hidden="true"></span>' .
[278] Fix | Delete
'<span class="collapse-button-label">' . __( 'Collapse menu' ) . '</span>' .
[279] Fix | Delete
'</button></li>';
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
?>
[283] Fix | Delete
[284] Fix | Delete
<div id="adminmenumain" role="navigation" aria-label="<?php esc_attr_e( 'Main menu' ); ?>">
[285] Fix | Delete
<a href="#wpbody-content" class="screen-reader-shortcut"><?php _e( 'Skip to main content' ); ?></a>
[286] Fix | Delete
<a href="#wp-toolbar" class="screen-reader-shortcut"><?php _e( 'Skip to toolbar' ); ?></a>
[287] Fix | Delete
<div id="adminmenuback"></div>
[288] Fix | Delete
<div id="adminmenuwrap">
[289] Fix | Delete
<ul id="adminmenu">
[290] Fix | Delete
[291] Fix | Delete
<?php
[292] Fix | Delete
[293] Fix | Delete
_wp_menu_output( $menu, $submenu );
[294] Fix | Delete
/**
[295] Fix | Delete
* Fires after the admin menu has been output.
[296] Fix | Delete
*
[297] Fix | Delete
* @since 2.5.0
[298] Fix | Delete
*/
[299] Fix | Delete
do_action( 'adminmenu' );
[300] Fix | Delete
[301] Fix | Delete
?>
[302] Fix | Delete
</ul>
[303] Fix | Delete
</div>
[304] Fix | Delete
</div>
[305] Fix | Delete
[306] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function