Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r41955 r42343  
    3535     * @see Walker::$db_fields
    3636     */
    37     public $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
     37    public $db_fields = array(
     38        'parent' => 'menu_item_parent',
     39        'id'     => 'db_id',
     40    );
    3841
    3942    /**
     
    9598            $n = "\n";
    9699        }
    97         $indent = str_repeat( $t, $depth );
     100        $indent  = str_repeat( $t, $depth );
    98101        $output .= "$indent</ul>{$n}";
    99102    }
     
    123126        $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
    124127
    125         $classes = empty( $item->classes ) ? array() : (array) $item->classes;
     128        $classes   = empty( $item->classes ) ? array() : (array) $item->classes;
    126129        $classes[] = 'menu-item-' . $item->ID;
    127130
     
    162165         * @param int      $depth   Depth of menu item. Used for padding.
    163166         */
    164         $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth );
     167        $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
    165168        $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
    166169
    167         $output .= $indent . '<li' . $id . $class_names .'>';
    168 
    169         $atts = array();
     170        $output .= $indent . '<li' . $id . $class_names . '>';
     171
     172        $atts           = array();
    170173        $atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
    171         $atts['target'] = ! empty( $item->target )     ? $item->target    : '';
    172         $atts['rel']    = ! empty( $item->xfn )        ? $item->xfn        : '';
    173         $atts['href']   = ! empty( $item->url )        ? $item->url        : '';
     174        $atts['target'] = ! empty( $item->target ) ? $item->target : '';
     175        $atts['rel']    = ! empty( $item->xfn ) ? $item->xfn : '';
     176        $atts['href']   = ! empty( $item->url ) ? $item->url : '';
    174177
    175178        /**
     
    196199        foreach ( $atts as $attr => $value ) {
    197200            if ( ! empty( $value ) ) {
    198                 $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
     201                $value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
    199202                $attributes .= ' ' . $attr . '="' . $value . '"';
    200203            }
     
    216219        $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
    217220
    218         $item_output = $args->before;
    219         $item_output .= '<a'. $attributes .'>';
     221        $item_output  = $args->before;
     222        $item_output .= '<a' . $attributes . '>';
    220223        $item_output .= $args->link_before . $title . $args->link_after;
    221224        $item_output .= '</a>';
Note: See TracChangeset for help on using the changeset viewer.