WordPress.org

Make WordPress Core

Changeset 31520


Ignore:
Timestamp:
02/23/15 16:31:31 (3 years ago)
Author:
SergeyBiryukov
Message:

Add missing labels to Archives and Categories dropdown widgets.

props joedolson, jlevandowski, DrewAPicture, SergeyBiryukov.
fixes #18650.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-widgets.php

    r31325 r31520  
    286286 
    287287        if ( $d ) { 
    288 ?> 
    289         <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> 
     288            $dropdown_id = "{$this->id_base}-dropdown-{$this->number}"; 
     289?> 
     290        <label class="screen-reader-text" for="<?php echo esc_attr( $dropdown_id ); ?>"><?php echo $title; ?></label> 
     291        <select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> 
    290292            <?php 
    291293            /** 
     
    577579        } 
    578580 
    579         $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 
     581        $cat_args = array( 
     582            'orderby'      => 'name', 
     583            'show_count'   => $c, 
     584            'hierarchical' => $h 
     585        ); 
    580586 
    581587        if ( $d ) { 
    582             $cat_args['show_option_none'] = __('Select Category'); 
     588            static $first_dropdown = true; 
     589 
     590            $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}"; 
     591            $first_dropdown = false; 
     592 
     593            echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; 
     594 
     595            $cat_args['show_option_none'] = __( 'Select Category' ); 
     596            $cat_args['id'] = $dropdown_id; 
    583597 
    584598            /** 
     
    596610<script type='text/javascript'> 
    597611/* <![CDATA[ */ 
    598     var dropdown = document.getElementById("cat"); 
     612(function() { 
     613    var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" ); 
    599614    function onCatChange() { 
    600         if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 
    601             location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; 
     615        if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { 
     616            location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value; 
    602617        } 
    603618    } 
    604619    dropdown.onchange = onCatChange; 
     620})(); 
    605621/* ]]> */ 
    606622</script> 
Note: See TracChangeset for help on using the changeset viewer.