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

Props leemon.
Fixes #34016. See #34013.


git-svn-id: https://develop.svn.wordpress.org/trunk@34620 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes 2015-09-27 01:10:38 +00:00
parent 9909c7ff2b
commit 982d5b99ea

View File

@ -16,14 +16,26 @@
*/ */
class WP_Widget_Archives extends WP_Widget { class WP_Widget_Archives extends WP_Widget {
/**
* Sets up a new Archives widget instance.
*
* @since 2.8.0
* @access public
*/
public function __construct() { public function __construct() {
$widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') ); $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') );
parent::__construct('archives', __('Archives'), $widget_ops); parent::__construct('archives', __('Archives'), $widget_ops);
} }
/** /**
* @param array $args * Outputs the content for the current Archives widget instance.
* @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 Archives widget instance.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
$c = ! empty( $instance['count'] ) ? '1' : '0'; $c = ! empty( $instance['count'] ) ? '1' : '0';
@ -81,9 +93,7 @@ class WP_Widget_Archives extends WP_Widget {
<?php wp_get_archives( $dropdown_args ); ?> <?php wp_get_archives( $dropdown_args ); ?>
</select> </select>
<?php <?php } else { ?>
} else {
?>
<ul> <ul>
<?php <?php
/** /**
@ -108,9 +118,15 @@ class WP_Widget_Archives extends WP_Widget {
} }
/** /**
* @param array $new_instance * Handles updating settings for the current Archives widget instance.
* @param array $old_instance *
* @return array * @since 2.8.0
* @access public
*
* @param array $new_instance New settings for this instance as input by the user via
* WP_Widget_Archives::form().
* @param array $old_instance Old settings for this instance.
* @return array Updated settings to save.
*/ */
public function update( $new_instance, $old_instance ) { public function update( $new_instance, $old_instance ) {
$instance = $old_instance; $instance = $old_instance;
@ -123,7 +139,12 @@ class WP_Widget_Archives extends WP_Widget {
} }
/** /**
* @param array $instance * Outputs the settings form for the Archives widget.
*
* @since 2.8.0
* @access public
*
* @param array $instance Current settings.
*/ */
public function form( $instance ) { public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );