Ticket #18650: 18650.3.patch
| File 18650.3.patch, 2.3 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/default-widgets.php
285 285 } 286 286 287 287 if ( $d ) { 288 $label_for = $this->id_base . '-dropdown-' . $this->number; 289 echo '<label class="screen-reader-text archives-label" for="' . esc_attr( $label_for ) . '">' . $title . '</label>'; 290 288 291 ?> 289 <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>292 <select id="<?php echo esc_attr( $label_for ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> 290 293 <?php 291 294 /** 292 295 * Filter the arguments for the Archives widget drop-down. … … 563 566 } 564 567 565 568 public function widget( $args, $instance ) { 566 569 567 570 /** This filter is documented in wp-includes/default-widgets.php */ 568 571 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); 569 572 … … 576 579 echo $args['before_title'] . $title . $args['after_title']; 577 580 } 578 581 579 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 582 $cat_args = array( 583 'orderby' => 'name', 584 'show_count' => $c, 585 'hierarchical' => $h 586 ); 580 587 581 588 if ( $d ) { 582 $cat_args['show_option_none'] = __('Select Category');589 static $first; 583 590 591 $id = isset( $first ) ? 'cat' : $args['widget_id'] . '-select'; 592 $first = false; 593 594 echo '<label class="screen-reader-text categories-label" for="' . esc_attr( $id ) . '">' . $title . '</label>'; 595 596 $cat_args['show_option_none'] = __( 'Select Category' ); 597 $cat_args['id'] = $id; 598 584 599 /** 585 600 * Filter the arguments for the Categories widget drop-down. 586 601 * … … 595 610 596 611 <script type='text/javascript'> 597 612 /* <![CDATA[ */ 598 var dropdown = document.getElementById("cat"); 613 (function() { 614 var dropdown = document.getElementById("<?php echo esc_js( $id ); ?>"); 599 615 function onCatChange() { 600 616 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 601 617 location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; … … 602 618 } 603 619 } 604 620 dropdown.onchange = onCatChange; 621 })(); 605 622 /* ]]> */ 606 623 </script> 607 624