Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: widget_comments_args

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
679            extract($args, EXTR_SKIP);
680            $output = '';
681
682           $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
683           $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
684           $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
685           if ( ! $number )
686                 $number = 5;
687
688           $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
689           $output .= $before_widget;
690           if ( $title )
691                $output .= $before_title . $title . $after_title;
692
693           $output .= '<ul id="recentcomments">';
694           if ( $comments ) {
695                // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
696                $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
697                _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );