Widgets: revert [34376] and [34386] as pertains to the Categories widget supporting custom taxonomies.
Punting on 4th down. See #21165. Built from https://develop.svn.wordpress.org/trunk@35278 git-svn-id: http://core.svn.wordpress.org/trunk@35244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
62d8b8c5bc
commit
c5b6202dfa
|
@ -479,7 +479,6 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
|
||||||
*
|
*
|
||||||
* - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories
|
* - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories
|
||||||
* - singular_name - name for one object of this taxonomy. Default is Tag/Category
|
* - singular_name - name for one object of this taxonomy. Default is Tag/Category
|
||||||
* - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'.
|
|
||||||
* - search_items - Default is Search Tags/Search Categories
|
* - search_items - Default is Search Tags/Search Categories
|
||||||
* - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
|
* - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
|
||||||
* - all_items - Default is All Tags/All Categories
|
* - all_items - Default is All Tags/All Categories
|
||||||
|
@ -520,7 +519,6 @@ function get_taxonomy_labels( $tax ) {
|
||||||
$nohier_vs_hier_defaults = array(
|
$nohier_vs_hier_defaults = array(
|
||||||
'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
|
'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
|
||||||
'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
|
'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
|
||||||
'select_name' => array( null, __( 'Select Category' ) ),
|
|
||||||
'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
|
'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
|
||||||
'popular_items' => array( __( 'Popular Tags' ), null ),
|
'popular_items' => array( __( 'Popular Tags' ), null ),
|
||||||
'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
|
'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-35277';
|
$wp_version = '4.4-alpha-35278';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
* Core class used to implement a Categories widget.
|
* Core class used to implement a Categories widget.
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
* @since 4.4.0 Added support for other taxonomies.
|
|
||||||
*
|
*
|
||||||
* @see WP_Widget
|
* @see WP_Widget
|
||||||
*/
|
*/
|
||||||
|
@ -41,8 +40,6 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
public function widget( $args, $instance ) {
|
public function widget( $args, $instance ) {
|
||||||
static $first_dropdown = true;
|
static $first_dropdown = true;
|
||||||
|
|
||||||
$current_taxonomy = $this->_get_current_taxonomy( $instance );
|
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
|
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
|
||||||
|
|
||||||
|
@ -55,13 +52,10 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
echo $args['before_title'] . $title . $args['after_title'];
|
echo $args['before_title'] . $title . $args['after_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tax = get_taxonomy( $current_taxonomy );
|
|
||||||
|
|
||||||
$cat_args = array(
|
$cat_args = array(
|
||||||
'orderby' => 'name',
|
'orderby' => 'name',
|
||||||
'show_count' => $c,
|
'show_count' => $c,
|
||||||
'hierarchical' => $h,
|
'hierarchical' => $h
|
||||||
'taxonomy' => $current_taxonomy,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $d ) {
|
if ( $d ) {
|
||||||
|
@ -70,7 +64,7 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
|
|
||||||
echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>';
|
echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>';
|
||||||
|
|
||||||
$cat_args['show_option_none'] = $tax->labels->select_name;
|
$cat_args['show_option_none'] = __( 'Select Category' );
|
||||||
$cat_args['id'] = $dropdown_id;
|
$cat_args['id'] = $dropdown_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +133,6 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
$instance['count'] = !empty($new_instance['count']) ? 1 : 0;
|
$instance['count'] = !empty($new_instance['count']) ? 1 : 0;
|
||||||
$instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
|
$instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
|
||||||
$instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
|
$instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
|
||||||
$instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] );
|
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
@ -159,25 +152,10 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
$count = isset($instance['count']) ? (bool) $instance['count'] :false;
|
$count = isset($instance['count']) ? (bool) $instance['count'] :false;
|
||||||
$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
|
$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
|
||||||
$dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
|
$dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
|
||||||
$current_taxonomy = $this->_get_current_taxonomy( $instance );
|
|
||||||
?>
|
?>
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
|
||||||
<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>
|
<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>
|
||||||
|
|
||||||
<p>
|
|
||||||
<label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label>
|
|
||||||
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>">
|
|
||||||
<?php foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) : ?>
|
|
||||||
<?php
|
|
||||||
if ( ! $taxonomy->hierarchical || empty( $taxonomy->labels->name ) ) :
|
|
||||||
continue;
|
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
<option value="<?php echo esc_attr( $taxonomy->name ); ?>" <?php selected( $taxonomy->name, $current_taxonomy ) ?>><?php echo esc_html( $taxonomy->labels->name ); ?></option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<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 ); ?> />
|
<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 ); ?> />
|
||||||
<label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
|
<label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
|
||||||
|
|
||||||
|
@ -189,19 +167,4 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the taxonomy for the current Categories widget instance.
|
|
||||||
*
|
|
||||||
* @since 4.4.0
|
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @param array $instance Current settings.
|
|
||||||
* @return string Name of the current taxonomy if set, otherwise 'category'.
|
|
||||||
*/
|
|
||||||
public function _get_current_taxonomy( $instance ) {
|
|
||||||
if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) {
|
|
||||||
return $instance['taxonomy'];
|
|
||||||
}
|
|
||||||
return 'category';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue