Ticket #21165: 21165.diff
File 21165.diff, 3.2 KB (added by , 12 years ago) |
---|
-
wp-includes/default-widgets.php
446 446 447 447 function widget( $args, $instance ) { 448 448 extract( $args ); 449 449 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 450 450 $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base); 451 451 $c = ! empty( $instance['count'] ) ? '1' : '0'; 452 452 $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; … … 456 456 if ( $title ) 457 457 echo $before_title . $title . $after_title; 458 458 459 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h );459 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'taxonomy' => $current_taxonomy); 460 460 461 461 if ( $d ) { 462 $cat_args['show_option_none'] = __('Select Category');462 $cat_args['show_option_none'] = __('Select ') . get_taxonomy( $current_taxonomy )->labels->singular_name; 463 463 wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); 464 464 ?> 465 465 … … 496 496 $instance['count'] = !empty($new_instance['count']) ? 1 : 0; 497 497 $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; 498 498 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; 499 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); 499 500 500 501 return $instance; 501 502 } … … 507 508 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 508 509 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 509 510 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 511 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 510 512 ?> 511 513 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> 512 514 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p> 513 515 516 <p><label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>"><?php _e( 'Taxonomy:' ) ?></label> 517 <select class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>"> 518 <?php foreach ( get_taxonomies() as $taxonomy ) : 519 $tax = get_taxonomy( $taxonomy ); 520 if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ) 521 continue; 522 ?> 523 <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo $tax->labels->name; ?></option> 524 <?php endforeach; ?> 525 </select></p> 526 514 527 <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> /> 515 528 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> 516 529 … … 522 535 <?php 523 536 } 524 537 538 function _get_current_taxonomy($instance) { 539 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) 540 return $instance['taxonomy']; 541 542 return 'categories'; 543 } 544 545 525 546 } 526 547 527 548 /**