From b32080c33282463f690fdf2d77d707b86a7babe8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 17 Apr 2022 14:41:08 +0000 Subject: [PATCH] Coding Standards: Use more descriptive variable names in `add_menu_classes()`. Follow-up to [9578], [53193], [53194]. See #54728. Built from https://develop.svn.wordpress.org/trunk@53195 git-svn-id: http://core.svn.wordpress.org/trunk@52784 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/menu.php | 35 ++++++++++++++++++----------------- wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/menu.php b/wp-admin/includes/menu.php index 27dd91540b..b26bc1e26c 100644 --- a/wp-admin/includes/menu.php +++ b/wp-admin/includes/menu.php @@ -214,38 +214,39 @@ function add_cssclass( $class_to_add, $classes ) { * @return array The array of administration menu items with the CSS classes added. */ function add_menu_classes( $menu ) { - $first = false; - $lastorder = false; - $i = 0; - $mc = count( $menu ); + $first_item = false; + $last_order = false; + $items_count = count( $menu ); + $i = 0; + foreach ( $menu as $order => $top ) { $i++; if ( 0 == $order ) { // Dashboard is always shown/single. $menu[0][4] = add_cssclass( 'menu-top-first', $top[4] ); - $lastorder = 0; + $last_order = 0; continue; } - if ( 0 === strpos( $top[2], 'separator' ) && false !== $lastorder ) { // If separator. - $first = true; - $c = $menu[ $lastorder ][4]; - $menu[ $lastorder ][4] = add_cssclass( 'menu-top-last', $c ); + if ( 0 === strpos( $top[2], 'separator' ) && false !== $last_order ) { // If separator. + $first_item = true; + $classes = $menu[ $last_order ][4]; + $menu[ $last_order ][4] = add_cssclass( 'menu-top-last', $classes ); continue; } - if ( $first ) { - $c = $menu[ $order ][4]; - $menu[ $order ][4] = add_cssclass( 'menu-top-first', $c ); - $first = false; + if ( $first_item ) { + $classes = $menu[ $order ][4]; + $menu[ $order ][4] = add_cssclass( 'menu-top-first', $classes ); + $first_item = false; } - if ( $mc == $i ) { // Last item. - $c = $menu[ $order ][4]; - $menu[ $order ][4] = add_cssclass( 'menu-top-last', $c ); + if ( $i == items_count ) { // Last item. + $classes = $menu[ $order ][4]; + $menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes ); } - $lastorder = $order; + $last_order = $order; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index c5dc5cc5b1..cfef869245 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta1-53194'; +$wp_version = '6.0-beta1-53195'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.