Make WordPress Core

Changeset 27697


Ignore:
Timestamp:
03/25/2014 08:52:22 AM (10 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/default-widgets.php.

Props janw.oostendorp and kpdesign.
Fixes #25638.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-widgets.php

    r27691 r27697  
    2222        extract( $args );
    2323
    24         $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base);
     24        /**
     25         * Filter the widget title.
     26         *
     27         * @since 2.6.0
     28         *
     29         * @param string $title    The widget title. Default 'Pages'.
     30         * @param array  $instance An array of the widget's settings.
     31         * @param mixed  $id_base  The widget ID.
     32         */
     33        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
     34
    2535        $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    2636        $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
     
    2939            $sortby = 'menu_order, post_title';
    3040
    31         $out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) );
     41        /**
     42         * Filter the arguments for the Pages widget.
     43         *
     44         * @since 2.8.0
     45         *
     46         * @see wp_list_pages()
     47         *
     48         * @param array $args An array of arguments to retrieve the pages list.
     49         */
     50        $out = wp_list_pages( apply_filters( 'widget_pages_args', array(
     51            'title_li'    => '',
     52            'echo'        => 0,
     53            'sort_column' => $sortby,
     54            'exclude'     => $exclude
     55        ) ) );
    3256
    3357        if ( !empty( $out ) ) {
     
    108132
    109133        $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
    110         wp_list_bookmarks(apply_filters('widget_links_args', array(
     134
     135        /**
     136         * Filter the arguments for the Links widget.
     137         *
     138         * @since 2.6.0
     139         *
     140         * @see wp_list_bookmarks()
     141         *
     142         * @param array $args An array of arguments to retrieve the links list.
     143         */
     144        wp_list_bookmarks( apply_filters( 'widget_links_args', array(
    111145            'title_before' => $before_title, 'title_after' => $after_title,
    112146            'category_before' => $before_widget, 'category_after' => $after_widget,
     
    116150            'orderby' => $orderby, 'order' => $order,
    117151            'limit' => $limit,
    118         )));
     152        ) ) );
    119153    }
    120154
     
    197231    function widget( $args, $instance ) {
    198232        extract($args);
     233
     234        /** This filter is documented in wp-includes/default-widgets.php */
    199235        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    200236
     
    242278        $c = ! empty( $instance['count'] ) ? '1' : '0';
    243279        $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    244         $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base);
     280
     281        /** This filter is documented in wp-includes/default-widgets.php */
     282        $title = apply_filters( 'widget_title', empty($instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
    245283
    246284        echo $before_widget;
     
    250288        if ( $d ) {
    251289?>
    252         <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo esc_attr(__('Select Month')); ?></option> <?php wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c))); ?> </select>
     290        <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
     291            <option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
     292
     293            <?php
     294            /**
     295             * Filter the arguments for the Archives widget drop-down.
     296             *
     297             * @since 2.8.0
     298             *
     299             * @see wp_get_archives()
     300             *
     301             * @param array $args An array of Archives widget drop-down arguments.
     302             */
     303            wp_get_archives( apply_filters( 'widget_archives_dropdown_args', array(
     304                'type'            => 'monthly',
     305                'format'          => 'option',
     306                'show_post_count' => $c
     307            ) ) );
     308?>
     309        </select>
    253310<?php
    254311        } else {
    255312?>
    256313        <ul>
    257         <?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?>
     314<?php
     315        /**
     316         * Filter the arguments for the Archives widget.
     317         *
     318         * @since 2.8.0
     319         *
     320         * @see wp_get_archives()
     321         *
     322         * @param array $args An array of Archives option arguments.
     323         */
     324        wp_get_archives( apply_filters( 'widget_archives_args', array(
     325            'type'            => 'monthly',
     326            'show_post_count' => $c
     327        ) ) );
     328?>
    258329        </ul>
    259330<?php
     
    305376    function widget( $args, $instance ) {
    306377        extract($args);
    307         $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base);
     378
     379        /** This filter is documented in wp-includes/default-widgets.php */
     380        $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
    308381
    309382        echo $before_widget;
     
    316389            <li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
    317390            <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
    318             <?php echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
     391<?php
     392            /**
     393             * Filter the "Powered by WordPress" text in the Meta widget.
     394             *
     395             * @since 3.6.0
     396             *
     397             * @param string $title_text Default title text for the WordPress.org link.
     398             */
     399            echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
    319400                esc_url( __( 'https://wordpress.org/' ) ),
    320401                esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ),
    321402                _x( 'WordPress.org', 'meta widget link text' )
    322             ) ); ?>
    323             <?php wp_meta(); ?>
     403            ) );
     404
     405            wp_meta();
     406?>
    324407            </ul>
    325408<?php
     
    357440    function widget( $args, $instance ) {
    358441        extract($args);
    359         $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     442
     443        /** This filter is documented in wp-includes/default-widgets.php */
     444        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     445
    360446        echo $before_widget;
    361447        if ( $title )
     
    399485    function widget( $args, $instance ) {
    400486        extract($args);
     487
     488        /** This filter is documented in wp-includes/default-widgets.php */
    401489        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     490
     491        /**
     492         * Filter the content of the Text widget.
     493         *
     494         * @since 2.3.0
     495         *
     496         * @param string    $widget_text The widget content.
     497         * @param WP_Widget $instance    WP_Widget instance.
     498         */
    402499        $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
    403500        echo $before_widget;
     
    449546        extract( $args );
    450547
    451         $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
     548        /** This filter is documented in wp-includes/default-widgets.php */
     549        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
     550
    452551        $c = ! empty( $instance['count'] ) ? '1' : '0';
    453552        $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
     
    462561        if ( $d ) {
    463562            $cat_args['show_option_none'] = __('Select Category');
    464             wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
     563
     564            /**
     565             * Filter the arguments for the Categories widget drop-down.
     566             *
     567             * @since 2.8.0
     568             *
     569             * @see wp_dropdown_categories()
     570             *
     571             * @param array $cat_args An array of Categories widget drop-down arguments.
     572             */
     573            wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) );
    465574?>
    466575
     
    483592<?php
    484593        $cat_args['title_li'] = '';
    485         wp_list_categories(apply_filters('widget_categories_args', $cat_args));
     594
     595        /**
     596         * Filter the arguments for the Categories widget.
     597         *
     598         * @since 2.8.0
     599         *
     600         * @param array $cat_args An array of Categories widget options.
     601         */
     602        wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) );
    486603?>
    487604        </ul>
     
    561678
    562679        $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
     680
     681        /** This filter is documented in wp-includes/default-widgets.php */
    563682        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     683
    564684        $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    565685        if ( ! $number )
     
    567687        $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    568688
    569         $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) );
     689        /**
     690         * Filter the arguments for the Recent Posts widget.
     691         *
     692         * @since 3.4.0
     693         *
     694         * @see WP_Query::get_posts()
     695         *
     696         * @param array $args An array of arguments used to retrieve the recent posts.
     697         */
     698        $r = new WP_Query( apply_filters( 'widget_posts_args', array(
     699            'posts_per_page'      => $number,
     700            'no_found_rows'       => true,
     701            'post_status'         => 'publish',
     702            'ignore_sticky_posts' => true
     703        ) ) );
     704
    570705        if ($r->have_posts()) :
    571706?>
     
    649784
    650785    function recent_comments_style() {
     786
     787        /**
     788         * Filter the Recent Comments default widget styles.
     789         *
     790         * @since 3.1.0
     791         *
     792         * @param bool   $active  Whether the widget is active. Default true.
     793         * @param string $id_base The widget ID.
     794         */
    651795        if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
    652796            || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
     
    681825
    682826        $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
     827
     828        /** This filter is documented in wp-includes/default-widgets.php */
    683829        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     830
    684831        $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    685832        if ( ! $number )
    686833            $number = 5;
    687834
    688         $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
     835        /**
     836         * Filter the arguments for the Recent Comments widget.
     837         *
     838         * @since 3.4.0
     839         *
     840         * @see get_comments()
     841         *
     842         * @param array $comment_args An array of arguments used to retrieve the recent comments.
     843         */
     844        $comments = get_comments( apply_filters( 'widget_comments_args', array(
     845            'number'      => $number,
     846            'status'      => 'approve',
     847            'post_status' => 'publish'
     848        ) ) );
     849
    689850        $output .= $before_widget;
    690851        if ( $title )
     
    783944            $title = empty($desc) ? __('Unknown Feed') : $desc;
    784945
    785         $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     946        /** This filter is documented in wp-includes/default-widgets.php */
     947        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     948
    786949        $url = esc_url(strip_tags($url));
    787950        $icon = includes_url('images/rss.png');
     
    10551218            }
    10561219        }
    1057         $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     1220
     1221        /** This filter is documented in wp-includes/default-widgets.php */
     1222        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    10581223
    10591224        echo $before_widget;
     
    10611226            echo $before_title . $title . $after_title;
    10621227        echo '<div class="tagcloud">';
    1063         wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );
     1228
     1229        /**
     1230         * Filter the taxonomy used in the Tag Cloud widget.
     1231         *
     1232         * @since 2.8.0
     1233         * @since 3.0.0 Added taxonomy drop-down.
     1234         *
     1235         * @see wp_tag_cloud()
     1236         *
     1237         * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'.
     1238         */
     1239        wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
     1240            'taxonomy' => $current_taxonomy
     1241        ) ) );
     1242
    10641243        echo "</div>\n";
    10651244        echo $after_widget;
     
    11161295            return;
    11171296
     1297        /** This filter is documented in wp-includes/default-widgets.php */
    11181298        $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    11191299
     
    12061386    register_widget('WP_Nav_Menu_Widget');
    12071387
    1208     do_action('widgets_init');
     1388    /**
     1389     * Fires after all default WordPress widgets have been registered.
     1390     *
     1391     * @since 2.2.0
     1392     */
     1393    do_action( 'widgets_init' );
    12091394}
    12101395
Note: See TracChangeset for help on using the changeset viewer.