Make WordPress Core

Changeset 35278


Ignore:
Timestamp:
10/20/2015 04:56:57 AM (9 years ago)
Author:
wonderboymusic
Message:

Widgets: revert [34376] and [34386] as pertains to the Categories widget supporting custom taxonomies.

Punting on 4th down.

See #21165.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy-functions.php

    r35268 r35278  
    480480 * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories
    481481 * - singular_name - name for one object of this taxonomy. Default is Tag/Category
    482  * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'.
    483482 * - search_items - Default is Search Tags/Search Categories
    484483 * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
     
    521520        'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
    522521        'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
    523         'select_name' => array( null, __( 'Select Category' ) ),
    524522        'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
    525523        'popular_items' => array( __( 'Popular Tags' ), null ),
  • trunk/src/wp-includes/widgets/class-wp-widget-categories.php

    r34618 r35278  
    1212 *
    1313 * @since 2.8.0
    14  * @since 4.4.0 Added support for other taxonomies.
    1514 *
    1615 * @see WP_Widget
     
    4241        static $first_dropdown = true;
    4342
    44         $current_taxonomy = $this->_get_current_taxonomy( $instance );
    45 
    4643        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    4744        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
     
    5653        }
    5754
    58         $tax = get_taxonomy( $current_taxonomy );
    59 
    6055        $cat_args = array(
    6156            'orderby'      => 'name',
    6257            'show_count'   => $c,
    63             'hierarchical' => $h,
    64             'taxonomy'     => $current_taxonomy,
     58            'hierarchical' => $h
    6559        );
    6660
     
    7165            echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>';
    7266
    73             $cat_args['show_option_none'] = $tax->labels->select_name;
     67            $cat_args['show_option_none'] = __( 'Select Category' );
    7468            $cat_args['id'] = $dropdown_id;
    7569
     
    140134        $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
    141135        $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
    142         $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] );
    143136
    144137        return $instance;
     
    160153        $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
    161154        $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
    162         $current_taxonomy = $this->_get_current_taxonomy( $instance );
    163155        ?>
    164156        <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
    165157        <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    166 
    167         <p>
    168             <label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label>
    169             <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>">
    170             <?php foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) : ?>
    171                 <?php
    172                 if ( ! $taxonomy->hierarchical || empty( $taxonomy->labels->name ) ) :
    173                     continue;
    174                 endif;
    175                 ?>
    176                 <option value="<?php echo esc_attr( $taxonomy->name ); ?>" <?php selected( $taxonomy->name, $current_taxonomy ) ?>><?php echo esc_html( $taxonomy->labels->name ); ?></option>
    177             <?php endforeach; ?>
    178             </select>
    179         </p>
    180158
    181159        <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 ); ?> />
     
    190168    }
    191169
    192     /**
    193      * Retrieves the taxonomy for the current Categories widget instance.
    194      *
    195      * @since 4.4.0
    196      * @access public
    197      *
    198      * @param array $instance Current settings.
    199      * @return string Name of the current taxonomy if set, otherwise 'category'.
    200      */
    201     public function _get_current_taxonomy( $instance ) {
    202         if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) {
    203             return $instance['taxonomy'];
    204         }
    205         return 'category';
    206     }
    207170}
Note: See TracChangeset for help on using the changeset viewer.