Make WordPress Core


Ignore:
Timestamp:
01/13/2011 01:34:15 AM (15 years ago)
Author:
westi
Message:

Add unique ids as well as of classes in the admin bar to make it easier for plugins to extend.
Ensure we escape the classname.
Fixes #16211 props koopersmith.

File:
1 edited

Legend:

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

    r17269 r17279  
    114114    /* Helpers */
    115115    function recursive_render( $id, &$menu_item ) { ?>
    116         <?php $menuclass = ( ! empty( $menu_item['children'] ) ) ? 'menupop ' : ''; ?>
    117 
    118         <li class="<?php echo $menuclass . "ab-$id" ?><?php
    119             if ( ! empty( $menu_item['meta']['class'] ) ) :
    120                 echo ' ' . esc_attr( $menu_item['meta']['class'] );
    121             endif;
    122         ?>">
     116        <?php
     117        $is_parent =  ! empty( $menu_item['children'] );
     118       
     119        $menuclass = $is_parent ? 'menupop' : '';
     120        if ( ! empty( $menu_item['meta']['class'] ) )
     121            $menuclass .= ' ' . $menu_item['meta']['class'];
     122        ?>
     123
     124        <li id="<?php echo esc_attr( "wp-admin-bar-$id" ); ?>" class="<?php echo esc_attr( $menuclass ); ?>">
    123125            <a href="<?php echo esc_url( $menu_item['href'] ) ?>"<?php
    124126                if ( ! empty( $menu_item['meta']['onclick'] ) ) :
     
    134136            ?>><?php
    135137
    136             if ( ! empty( $menuclass ) ) :
     138            if ( $is_parent ) :
    137139                ?><span><?php
    138140            endif;
     
    140142            echo $menu_item['title'];
    141143
    142             if ( ! empty( $menuclass ) ) :
     144            if ( $is_parent ) :
    143145                ?></span><?php
    144146            endif;
     
    146148            ?></a>
    147149
    148             <?php if ( ! empty( $menu_item['children'] ) ) : ?>
     150            <?php if ( $is_parent ) : ?>
    149151            <ul>
    150152                <?php foreach ( $menu_item['children'] as $child_id => $child_menu_item ) : ?>
Note: See TracChangeset for help on using the changeset viewer.