Ticket #18650: 18650.8.patch
File 18650.8.patch, 2.9 KB (added by , 10 years ago) |
---|
-
src/wp-includes/default-widgets.php
279 279 /** This filter is documented in wp-includes/default-widgets.php */ 280 280 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base ); 281 281 282 $dropdown_id = "{$this->id_base}-dropdown-{$this->number}"; 283 282 284 echo $args['before_widget']; 283 285 if ( $title ) { 284 286 echo $args['before_title'] . $title . $args['after_title']; 287 288 if ( $d ) { 289 printf( '<label class="screen-reader-text" for="%s">%s</label>', esc_attr( $dropdown_id ), $title ); 290 } 285 291 } 286 292 287 293 if ( $d ) { 288 294 ?> 289 <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>295 <select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> 290 296 <?php 291 297 /** 292 298 * Filter the arguments for the Archives widget drop-down. … … 563 569 } 564 570 565 571 public function widget( $args, $instance ) { 572 static $first_dropdown = true; 566 573 567 574 /** This filter is documented in wp-includes/default-widgets.php */ 568 575 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); … … 571 578 $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; 572 579 $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; 573 580 581 if ( $d ) { 582 $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}"; 583 $first_dropdown = false; 584 } 585 574 586 echo $args['before_widget']; 575 587 if ( $title ) { 576 588 echo $args['before_title'] . $title . $args['after_title']; 589 590 if ( $d ) { 591 printf( '<label class="screen-reader-text" for="%s">%s</label>', esc_attr( $dropdown_id ), $title ); 592 } 577 593 } 578 594 579 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 595 $cat_args = array( 596 'orderby' => 'name', 597 'show_count' => $c, 598 'hierarchical' => $h 599 ); 580 600 581 601 if ( $d ) { 582 $cat_args['show_option_none'] = __('Select Category'); 602 $cat_args['show_option_none'] = __( 'Select Category' ); 603 $cat_args['id'] = $dropdown_id; 583 604 584 605 /** 585 606 * Filter the arguments for the Categories widget drop-down. … … 595 616 596 617 <script type='text/javascript'> 597 618 /* <![CDATA[ */ 598 var dropdown = document.getElementById("cat"); 619 (function() { 620 var dropdown = document.getElementById("<?php echo esc_js( $dropdown_id ); ?>"); 599 621 function onCatChange() { 600 622 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 601 623 location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; … … 602 624 } 603 625 } 604 626 dropdown.onchange = onCatChange; 627 })(); 605 628 /* ]]> */ 606 629 </script> 607 630