Make WordPress Core

Ticket #21165: 21165.5.diff

File 21165.5.diff, 4.5 KB (added by fonglh, 12 years ago)

Removed value of 'select_name' for category as it is the same as the default value

  • wp-includes/taxonomy.php

     
    385385 * Accepted keys of the label array in the taxonomy object:
    386386 * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories
    387387 * - singular_name - name for one object of this taxonomy. Default is Tag/Category
     388 * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'.
    388389 * - search_items - Default is Search Tags/Search Categories
    389390 * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
    390391 * - all_items - Default is All Tags/All Categories
     
    413414        $nohier_vs_hier_defaults = array(
    414415                'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
    415416                'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
     417                'select_name' => array( null, __( 'Select Category' ) ),
    416418                'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
    417419                'popular_items' => array( __( 'Popular Tags' ), null ),
    418420                'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
  • wp-includes/default-widgets.php

     
    446446
    447447        function widget( $args, $instance ) {
    448448                extract( $args );
    449 
     449                $current_taxonomy = $this->_get_current_taxonomy( $instance );
    450450                $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
    451451                $c = ! empty( $instance['count'] ) ? '1' : '0';
    452452                $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
     
    456456                if ( $title )
    457457                        echo $before_title . $title . $after_title;
    458458
    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);
    460460
    461461                if ( $d ) {
    462                         $cat_args['show_option_none'] = __('Select Category');
     462                        $cat_args['show_option_none'] = get_taxonomy( $current_taxonomy )->labels->select_name;
    463463                        wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
    464464?>
    465465
     
    496496                $instance['count'] = !empty($new_instance['count']) ? 1 : 0;
    497497                $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
    498498                $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
     499                $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] );
    499500
    500501                return $instance;
    501502        }
     
    507508                $count = isset($instance['count']) ? (bool) $instance['count'] :false;
    508509                $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
    509510                $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
     511                $current_taxonomy = $this->_get_current_taxonomy( $instance );
    510512?>
    511513                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
    512514                <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>
    513515
     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->hierarchical || 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
    514527                <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 ); ?> />
    515528                <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
    516529
     
    522535<?php
    523536        }
    524537
     538        function _get_current_taxonomy($instance) {
     539                if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) )
     540                        return $instance['taxonomy'];
     541
     542                return 'category';
     543        }
     544
     545
    525546}
    526547
    527548/**