WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 12 times in this file.
Line | Code |
---|---|
15 |
|
16 | function __construct() { |
17 | $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your site’s WordPress Pages') ); |
18 | parent::__construct('pages', __('Pages'), $widget_ops); |
19 | } |
20 |
|
21 | function widget( $args, $instance ) { |
22 | extract( $args ); |
23 |
|
24 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base); |
25 | $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; |
26 | $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; |
27 |
|
28 | if ( $sortby == 'menu_order' ) |
29 | $sortby = 'menu_order, post_title'; |
30 |
|
31 | $out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) ); |
32 |
|
33 | if ( !empty( $out ) ) { |
Line | Code |
190 | class WP_Widget_Search extends WP_Widget { |
191 |
|
192 | function __construct() { |
193 | $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site") ); |
194 | parent::__construct('search', __('Search'), $widget_ops); |
195 | } |
196 |
|
197 | function widget( $args, $instance ) { |
198 | extract($args); |
199 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
200 |
|
201 | echo $before_widget; |
202 | if ( $title ) |
203 | echo $before_title . $title . $after_title; |
204 |
|
205 | // Use current theme search form if it exists |
206 | get_search_form(); |
207 |
|
208 | echo $after_widget; |
Line | Code |
235 | function __construct() { |
236 | $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s posts') ); |
237 | parent::__construct('archives', __('Archives'), $widget_ops); |
238 | } |
239 |
|
240 | function widget( $args, $instance ) { |
241 | extract($args); |
242 | $c = ! empty( $instance['count'] ) ? '1' : '0'; |
243 | $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
244 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base); |
245 |
|
246 | echo $before_widget; |
247 | if ( $title ) |
248 | echo $before_title . $title . $after_title; |
249 |
|
250 | if ( $d ) { |
251 | ?> |
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> |
253 | <?php |
Line | Code |
298 | class WP_Widget_Meta extends WP_Widget { |
299 |
|
300 | function __construct() { |
301 | $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") ); |
302 | parent::__construct('meta', __('Meta'), $widget_ops); |
303 | } |
304 |
|
305 | function widget( $args, $instance ) { |
306 | extract($args); |
307 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base); |
308 |
|
309 | echo $before_widget; |
310 | if ( $title ) |
311 | echo $before_title . $title . $after_title; |
312 | ?> |
313 | <ul> |
314 | <?php wp_register(); ?> |
315 | <li><?php wp_loginout(); ?></li> |
316 | <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> |
Line | Code |
349 | class WP_Widget_Calendar extends WP_Widget { |
350 |
|
351 | function __construct() { |
352 | $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s posts') ); |
353 | parent::__construct('calendar', __('Calendar'), $widget_ops); |
354 | } |
355 |
|
356 | function widget( $args, $instance ) { |
357 | extract($args); |
358 | $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
359 | echo $before_widget; |
360 | if ( $title ) |
361 | echo $before_title . $title . $after_title; |
362 | echo '<div id="calendar_wrap">'; |
363 | get_calendar(); |
364 | echo '</div>'; |
365 | echo $after_widget; |
366 | } |
367 |
|
Line | Code |
391 |
|
392 | function __construct() { |
393 | $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); |
394 | $control_ops = array('width' => 400, 'height' => 350); |
395 | parent::__construct('text', __('Text'), $widget_ops, $control_ops); |
396 | } |
397 |
|
398 | function widget( $args, $instance ) { |
399 | extract($args); |
400 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
401 | $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); |
402 | echo $before_widget; |
403 | if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
404 | <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> |
405 | <?php |
406 | echo $after_widget; |
407 | } |
408 |
|
409 | function update( $new_instance, $old_instance ) { |
Line | Code |
441 |
|
442 | function __construct() { |
443 | $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); |
444 | parent::__construct('categories', __('Categories'), $widget_ops); |
445 | } |
446 |
|
447 | function widget( $args, $instance ) { |
448 | extract( $args ); |
449 |
|
450 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base); |
451 | $c = ! empty( $instance['count'] ) ? '1' : '0'; |
452 | $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; |
453 | $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
454 |
|
455 | echo $before_widget; |
456 | if ( $title ) |
457 | echo $before_title . $title . $after_title; |
458 |
|
459 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
Line | Code |
552 |
|
553 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
554 | echo $cache[ $args['widget_id'] ]; |
555 | return; |
556 | } |
557 |
|
558 | ob_start(); |
559 | extract($args); |
560 |
|
561 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); |
562 | if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) |
563 | $number = 10; |
564 | $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; |
565 |
|
566 | $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 ) ) ); |
567 | if ($r->have_posts()) : |
568 | ?> |
569 | <?php echo $before_widget; ?> |
570 | <?php if ( $title ) echo $before_title . $title . $after_title; ?> |
Line | Code |
668 | $args['widget_id'] = $this->id; |
669 |
|
670 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
671 | echo $cache[ $args['widget_id'] ]; |
672 | return; |
673 | } |
674 |
|
675 | extract($args, EXTR_SKIP); |
676 | $output = ''; |
677 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base ); |
678 |
|
679 | if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) |
680 | $number = 5; |
681 |
|
682 | $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); |
683 | $output .= $before_widget; |
684 | if ( $title ) |
685 | $output .= $before_title . $title . $after_title; |
686 |
|
Line | Code |
770 | $title = esc_html(strip_tags($rss->get_title())); |
771 | $link = esc_url(strip_tags($rss->get_permalink())); |
772 | while ( stristr($link, 'http') != $link ) |
773 | $link = substr($link, 1); |
774 | } |
775 |
|
776 | if ( empty($title) ) |
777 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
778 |
|
779 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
780 | $url = esc_url(strip_tags($url)); |
781 | $icon = includes_url('images/rss.png'); |
782 | if ( $title ) |
783 | $title = "<a class='rsswidget' href='$url' title='" . esc_attr__( 'Syndicate this content' ) ."'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>"; |
784 |
|
785 | echo $before_widget; |
786 | if ( $title ) |
787 | echo $before_title . $title . $after_title; |
788 | wp_widget_rss_output( $rss, $instance ); |
Line | Code |
1038 | $title = $instance['title']; |
1039 | } else { |
1040 | if ( 'post_tag' == $current_taxonomy ) { |
1041 | $title = __('Tags'); |
1042 | } else { |
1043 | $tax = get_taxonomy($current_taxonomy); |
1044 | $title = $tax->labels->name; |
1045 | } |
1046 | } |
1047 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
1048 |
|
1049 | echo $before_widget; |
1050 | if ( $title ) |
1051 | echo $before_title . $title . $after_title; |
1052 | echo '<div class="tagcloud">'; |
1053 | wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); |
1054 | echo "</div>\n"; |
1055 | echo $after_widget; |
1056 | } |
Line | Code |
1099 | } |
1100 |
|
1101 | function widget($args, $instance) { |
1102 | // Get menu |
1103 | $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; |
1104 |
|
1105 | if ( !$nav_menu ) |
1106 | return; |
1107 |
|
1108 | $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
1109 |
|
1110 | echo $args['before_widget']; |
1111 |
|
1112 | if ( !empty($instance['title']) ) |
1113 | echo $args['before_title'] . $instance['title'] . $args['after_title']; |
1114 |
|
1115 | wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); |
1116 |
|
1117 | echo $args['after_widget']; |