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
This commit is contained in:
Scott Taylor 2015-10-28 18:06:24 +00:00
parent 34a9b6e428
commit 70689237f3
2 changed files with 21 additions and 16 deletions

View File

@ -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 );

View File

@ -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.