From 70689237f3bae4b770c0a3b0362bf1f33f2bd025 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 28 Oct 2015 18:06:24 +0000 Subject: [PATCH] Admin Menu: after [34861], prevent adjacent separators. Props johnjamesjacoby. Fixes #24104. Built from https://develop.svn.wordpress.org/trunk@35416 git-svn-id: http://core.svn.wordpress.org/trunk@35380 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/menu.php | 35 ++++++++++++++++++++--------------- wp-includes/version.php | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/wp-admin/includes/menu.php b/wp-admin/includes/menu.php index 26ce6f31e0..74804022b7 100644 --- a/wp-admin/includes/menu.php +++ b/wp-admin/includes/menu.php @@ -178,21 +178,6 @@ foreach ( $menu as $id => $data ) { } unset($id, $data, $subs, $first_sub); -// Remove any duplicated separators -$separator_found = false; -foreach ( $menu as $id => $data ) { - if ( false !== strpos( $data[4], 'wp-menu-separator' ) ) { - if ( ! $separator_found ) { - $separator_found = true; - } else { - unset($menu[$id]); - } - } else { - $separator_found = false; - } -} -unset($id, $data); - /** * * @param string $add @@ -318,6 +303,26 @@ if ( apply_filters( 'custom_menu_order', false ) ) { unset($menu_order, $default_menu_order); } +// Prevent adjacent separators +$prev_menu_was_separator = false; +foreach ( $menu as $id => $data ) { + if ( false === stristr( $data[4], 'wp-menu-separator' ) ) { + + // This item is not a separator, so falsey the toggler and do nothing + $prev_menu_was_separator = false; + } else { + + // The previous item was a separator, so unset this one + if ( true === $prev_menu_was_separator ) { + unset( $menu[ $id ] ); + } + + // This item is a separator, so truthy the toggler and move on + $prev_menu_was_separator = true; + } +} +unset( $id, $data, $prev_menu_was_separator ); + // Remove the last menu item if it is a separator. $last_menu_key = array_keys( $menu ); $last_menu_key = array_pop( $last_menu_key ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 78a00e65c9..63b903f6d0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta1-35415'; +$wp_version = '4.4-beta1-35416'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.