Make WordPress Core

Changeset 38575


Ignore:
Timestamp:
09/08/2016 07:05:32 AM (8 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-walker-nav-menu.php

    r38559 r38575  
    5151     */
    5252    public function start_lvl( &$output, $depth = 0, $args = array() ) {
    53         if ( 'preserve' === $args->item_spacing ) {
    54             $t = "\t";
    55             $n = "\n";
    56         } else {
    57             $t = '';
    58             $n = '';
     53        if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
     54            $t = '';
     55            $n = '';
     56        } else {
     57            $t = "\t";
     58            $n = "\n";
    5959        }
    6060        $indent = str_repeat( $t, $depth );
     
    7474     */
    7575    public function end_lvl( &$output, $depth = 0, $args = array() ) {
    76         if ( 'preserve' === $args->item_spacing ) {
    77             $t = "\t";
    78             $n = "\n";
    79         } else {
    80             $t = '';
    81             $n = '';
     76        if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
     77            $t = '';
     78            $n = '';
     79        } else {
     80            $t = "\t";
     81            $n = "\n";
    8282        }
    8383        $indent = str_repeat( $t, $depth );
     
    100100     */
    101101    public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
    102         if ( 'preserve' === $args->item_spacing ) {
    103             $t = "\t";
    104             $n = "\n";
    105         } else {
    106             $t = '';
    107             $n = '';
     102        if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
     103            $t = '';
     104            $n = '';
     105        } else {
     106            $t = "\t";
     107            $n = "\n";
    108108        }
    109109        $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
     
    238238     */
    239239    public function end_el( &$output, $item, $depth = 0, $args = array() ) {
    240         if ( 'preserve' === $args->item_spacing ) {
    241             $t = "\t";
    242             $n = "\n";
    243         } else {
    244             $t = '';
    245             $n = '';
     240        if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
     241            $t = '';
     242            $n = '';
     243        } else {
     244            $t = "\t";
     245            $n = "\n";
    246246        }
    247247        $output .= "</li>{$n}";
Note: See TracChangeset for help on using the changeset viewer.