mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Coding Standards: Use strict comparison in some wp-admin files.
Props pikamander2, mukesh27, SergeyBiryukov. Fixes #49239. git-svn-id: https://develop.svn.wordpress.org/trunk@47785 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -88,7 +88,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
$submenu_items = $submenu[ $item[2] ];
|
||||
}
|
||||
|
||||
if ( ( $parent_file && $item[2] == $parent_file ) || ( empty( $typenow ) && $self == $item[2] ) ) {
|
||||
if ( ( $parent_file && $item[2] === $parent_file ) || ( empty( $typenow ) && $self === $item[2] ) ) {
|
||||
if ( ! empty( $submenu_items ) ) {
|
||||
$class[] = 'wp-has-current-submenu wp-menu-open';
|
||||
} else {
|
||||
@@ -154,10 +154,16 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
$menu_hook = get_plugin_page_hook( $submenu_items[0][2], $item[2] );
|
||||
$menu_file = $submenu_items[0][2];
|
||||
$pos = strpos( $menu_file, '?' );
|
||||
|
||||
if ( false !== $pos ) {
|
||||
$menu_file = substr( $menu_file, 0, $pos );
|
||||
}
|
||||
if ( ! empty( $menu_hook ) || ( ( 'index.php' != $submenu_items[0][2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
|
||||
|
||||
if ( ! empty( $menu_hook )
|
||||
|| ( ( 'index.php' !== $submenu_items[0][2] )
|
||||
&& file_exists( WP_PLUGIN_DIR . "/$menu_file" )
|
||||
&& ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
|
||||
) {
|
||||
$admin_is_parent = true;
|
||||
echo "<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style>$img</div><div class='wp-menu-name'>$title</div></a>";
|
||||
} else {
|
||||
@@ -167,10 +173,16 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
$menu_hook = get_plugin_page_hook( $item[2], 'admin.php' );
|
||||
$menu_file = $item[2];
|
||||
$pos = strpos( $menu_file, '?' );
|
||||
|
||||
if ( false !== $pos ) {
|
||||
$menu_file = substr( $menu_file, 0, $pos );
|
||||
}
|
||||
if ( ! empty( $menu_hook ) || ( ( 'index.php' != $item[2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
|
||||
|
||||
if ( ! empty( $menu_hook )
|
||||
|| ( ( 'index.php' !== $item[2] )
|
||||
&& file_exists( WP_PLUGIN_DIR . "/$menu_file" )
|
||||
&& ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
|
||||
) {
|
||||
$admin_is_parent = true;
|
||||
echo "\n\t<a href='admin.php?page={$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
|
||||
} else {
|
||||
@@ -192,14 +204,15 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
|
||||
$class = array();
|
||||
$aria_attributes = '';
|
||||
|
||||
if ( $first ) {
|
||||
$class[] = 'wp-first-item';
|
||||
$first = false;
|
||||
}
|
||||
|
||||
$menu_file = $item[2];
|
||||
$pos = strpos( $menu_file, '?' );
|
||||
|
||||
$pos = strpos( $menu_file, '?' );
|
||||
if ( false !== $pos ) {
|
||||
$menu_file = substr( $menu_file, 0, $pos );
|
||||
}
|
||||
@@ -208,15 +221,16 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
$self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
|
||||
|
||||
if ( isset( $submenu_file ) ) {
|
||||
if ( $submenu_file == $sub_item[2] ) {
|
||||
if ( $submenu_file === $sub_item[2] ) {
|
||||
$class[] = 'current';
|
||||
$aria_attributes .= ' aria-current="page"';
|
||||
}
|
||||
// If plugin_page is set the parent must either match the current page or not physically exist.
|
||||
// This allows plugin pages with the same hook to exist under different parents.
|
||||
} elseif (
|
||||
( ! isset( $plugin_page ) && $self == $sub_item[2] ) ||
|
||||
( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists( $menu_file ) === false ) )
|
||||
( ! isset( $plugin_page ) && $self === $sub_item[2] )
|
||||
|| ( isset( $plugin_page ) && $plugin_page === $sub_item[2]
|
||||
&& ( $item[2] === $self_type || $item[2] === $self || file_exists( $menu_file ) === false ) )
|
||||
) {
|
||||
$class[] = 'current';
|
||||
$aria_attributes .= ' aria-current="page"';
|
||||
@@ -237,7 +251,11 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
|
||||
$title = wptexturize( $sub_item[0] );
|
||||
|
||||
if ( ! empty( $menu_hook ) || ( ( 'index.php' != $sub_item[2] ) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) ) ) {
|
||||
if ( ! empty( $menu_hook )
|
||||
|| ( ( 'index.php' !== $sub_item[2] )
|
||||
&& file_exists( WP_PLUGIN_DIR . "/$sub_file" )
|
||||
&& ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) )
|
||||
) {
|
||||
// If admin.php is the current page or if the parent exists as a file in the plugins or admin directory.
|
||||
if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) ) {
|
||||
$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), $item[2] );
|
||||
|
||||
Reference in New Issue
Block a user