Make WordPress Core

Changeset 21193


Ignore:
Timestamp:
06/30/2012 11:47:21 AM (12 years ago)
Author:
nacin
Message:

Don't output empty class names or ones with leading/trailing spaces. props MattyRob for the initial patch. fixes #20698.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-admin-bar.php

    r20417 r21193  
    238238            if ( $node->type == 'group' ) {
    239239                if ( empty( $node->meta['class'] ) )
    240                     $node->meta['class'] = '';
    241                 $node->meta['class'] .= ' ' . $group_class;
     240                    $node->meta['class'] = $group_class;
     241                else
     242                    $node->meta['class'] .= ' ' . $group_class;
    242243            }
    243244
     
    368369            return;
    369370
    370         $class = empty( $node->meta['class'] ) ? '' : $node->meta['class'];
    371 
    372         ?><ul id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>" class="<?php echo esc_attr( $class ); ?>"><?php
     371        if ( ! empty( $node->meta['class'] ) )
     372            $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"';
     373        else
     374            $class = '';
     375
     376        ?><ul id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $class; ?>><?php
    373377            foreach ( $node->children as $item ) {
    374378                $this->_render_item( $item );
     
    390394
    391395        if ( $is_parent ) {
    392             $menuclass = 'menupop';
     396            $menuclass = 'menupop ';
    393397            $aria_attributes .= ' aria-haspopup="true"';
    394398        }
    395399
    396400        if ( ! empty( $node->meta['class'] ) )
    397             $menuclass .= ' ' . $node->meta['class'];
     401            $menuclass .= $node->meta['class'];
     402
     403        if ( $menuclass )
     404            $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
    398405
    399406        ?>
    400407
    401         <li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>" class="<?php echo esc_attr( $menuclass ); ?>"><?php
     408        <li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php
    402409            if ( $has_link ):
    403410                ?><a class="ab-item" <?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php
Note: See TracChangeset for help on using the changeset viewer.