Docs: Improve documentation for the `__construct()`, `widget()`, `update()`, `form()`, and `_get_current_taxonomy()` methods in `WP_Widget_Categories`.

Props leemon.
Fixes #34018. See #34013.

Built from https://develop.svn.wordpress.org/trunk@34618


git-svn-id: http://core.svn.wordpress.org/trunk@34582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2015-09-27 01:04:25 +00:00
parent 192e7f8c61
commit e0d024b355
2 changed files with 33 additions and 12 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34617';
$wp_version = '4.4-alpha-34618';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -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