Docs: Improve documentation for the __construct()
, widget()
, update()
, form()
, and _get_current_taxonomy()
methods in WP_Widget_Categories
.
Props leemon. Fixes #34018. See #34013. git-svn-id: https://develop.svn.wordpress.org/trunk@34618 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
aec4d6abe9
commit
b8264d11bc
@ -17,16 +17,26 @@
|
||||
*/
|
||||
class WP_Widget_Categories extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new Categories widget instance.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*/
|
||||
public function __construct() {
|
||||
$widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) );
|
||||
parent::__construct('categories', __('Categories'), $widget_ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar bool $first_dropdown
|
||||
* Outputs the content for the current Categories widget instance.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||
* 'before_widget', and 'after_widget'.
|
||||
* @param array $instance Settings for the current Categories widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
static $first_dropdown = true;
|
||||
@ -73,7 +83,7 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
* @param array $cat_args An array of Categories widget drop-down arguments.
|
||||
*/
|
||||
wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) );
|
||||
?>
|
||||
?>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/* <![CDATA[ */
|
||||
@ -113,9 +123,15 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $new_instance
|
||||
* @param array $old_instance
|
||||
* @return array
|
||||
* Handles updating settings for the current Categories widget instance.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via
|
||||
* WP_Widget::form().
|
||||
* @param array $old_instance Old settings for this instance.
|
||||
* @return array Updated settings to save.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
@ -129,7 +145,12 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $instance
|
||||
* Outputs the settings form for the Categories widget.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
//Defaults
|
||||
@ -139,7 +160,7 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : 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>
|
||||
<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>
|
||||
|
||||
@ -165,11 +186,11 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
|
||||
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
|
||||
<label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the taxonomy for the current widget instance.
|
||||
* Retrieves the taxonomy for the current Categories widget instance.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @access public
|
||||
|
Loading…
Reference in New Issue
Block a user