diff options
author | Peter Wilson <peterwilsoncc@git.wordpress.org> | 2016-09-08 07:05:32 +0000 |
---|---|---|
committer | Peter Wilson <peterwilsoncc@git.wordpress.org> | 2016-09-08 07:05:32 +0000 |
commit | 7ed5f4f9d5baa89eaa570f4788fa219dbb8184ba (patch) | |
tree | 78caa6607528dbd0167ed3efe1c43a42de6052d8 /src/wp-includes/class-walker-nav-menu.php | |
parent | 3cc19c17f383e33663c9b64bf12b1e7842de1406 (diff) | |
download | wordpress-7ed5f4f9d5baa89eaa570f4788fa219dbb8184ba.tar.gz wordpress-7ed5f4f9d5baa89eaa570f4788fa219dbb8184ba.zip |
Menus: Fix notices thrown by classes extending `Walker_Nav_Menu`.
Methods in `Walker_Nav_Menu` can be called with multiple, incompatible `$args` objects so an `insset()` check is required to avoid throwing notices.
Introduced in [38523].
Fixes #35206.
git-svn-id: https://develop.svn.wordpress.org/trunk@38575 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/wp-includes/class-walker-nav-menu.php')
-rw-r--r-- | src/wp-includes/class-walker-nav-menu.php | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/wp-includes/class-walker-nav-menu.php b/src/wp-includes/class-walker-nav-menu.php index 13c9e6dd0a..4c1a1f2c91 100644 --- a/src/wp-includes/class-walker-nav-menu.php +++ b/src/wp-includes/class-walker-nav-menu.php @@ -50,12 +50,12 @@ class Walker_Nav_Menu extends Walker { * @param stdClass $args An object of wp_nav_menu() arguments. */ public function start_lvl( &$output, $depth = 0, $args = array() ) { - if ( 'preserve' === $args->item_spacing ) { - $t = "\t"; - $n = "\n"; - } else { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; + } else { + $t = "\t"; + $n = "\n"; } $indent = str_repeat( $t, $depth ); $output .= "{$n}{$indent}<ul class=\"sub-menu\">{$n}"; @@ -73,12 +73,12 @@ class Walker_Nav_Menu extends Walker { * @param stdClass $args An object of wp_nav_menu() arguments. */ public function end_lvl( &$output, $depth = 0, $args = array() ) { - if ( 'preserve' === $args->item_spacing ) { - $t = "\t"; - $n = "\n"; - } else { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; + } else { + $t = "\t"; + $n = "\n"; } $indent = str_repeat( $t, $depth ); $output .= "$indent</ul>{$n}"; @@ -99,12 +99,12 @@ class Walker_Nav_Menu extends Walker { * @param int $id Current item ID. */ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { - if ( 'preserve' === $args->item_spacing ) { - $t = "\t"; - $n = "\n"; - } else { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; + } else { + $t = "\t"; + $n = "\n"; } $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; @@ -237,12 +237,12 @@ class Walker_Nav_Menu extends Walker { * @param stdClass $args An object of wp_nav_menu() arguments. */ public function end_el( &$output, $item, $depth = 0, $args = array() ) { - if ( 'preserve' === $args->item_spacing ) { - $t = "\t"; - $n = "\n"; - } else { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; + } else { + $t = "\t"; + $n = "\n"; } $output .= "</li>{$n}"; } |