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 |
|
565 | $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 ) ) ); |
566 | if ($r->have_posts()) : |
567 | ?> |
568 | <?php echo $before_widget; ?> |
569 | <?php if ( $title ) echo $before_title . $title . $after_title; ?> |
570 | <ul> |
Line | Code |
657 | $args['widget_id'] = $this->id; |
658 |
|
659 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
660 | echo $cache[ $args['widget_id'] ]; |
661 | return; |
662 | } |
663 |
|
664 | extract($args, EXTR_SKIP); |
665 | $output = ''; |
666 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base ); |
667 |
|
668 | if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) |
669 | $number = 5; |
670 |
|
671 | $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); |
672 | $output .= $before_widget; |
673 | if ( $title ) |
674 | $output .= $before_title . $title . $after_title; |
675 |
|
Line | Code |
755 | $title = esc_html(strip_tags($rss->get_title())); |
756 | $link = esc_url(strip_tags($rss->get_permalink())); |
757 | while ( stristr($link, 'http') != $link ) |
758 | $link = substr($link, 1); |
759 | } |
760 |
|
761 | if ( empty($title) ) |
762 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
763 |
|
764 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
765 | $url = esc_url(strip_tags($url)); |
766 | $icon = includes_url('images/rss.png'); |
767 | if ( $title ) |
768 | $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>"; |
769 |
|
770 | echo $before_widget; |
771 | if ( $title ) |
772 | echo $before_title . $title . $after_title; |
773 | wp_widget_rss_output( $rss, $instance ); |
Line | Code |
1023 | $title = $instance['title']; |
1024 | } else { |
1025 | if ( 'post_tag' == $current_taxonomy ) { |
1026 | $title = __('Tags'); |
1027 | } else { |
1028 | $tax = get_taxonomy($current_taxonomy); |
1029 | $title = $tax->labels->name; |
1030 | } |
1031 | } |
1032 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
1033 |
|
1034 | echo $before_widget; |
1035 | if ( $title ) |
1036 | echo $before_title . $title . $after_title; |
1037 | echo '<div class="tagcloud">'; |
1038 | wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); |
1039 | echo "</div>\n"; |
1040 | echo $after_widget; |
1041 | } |
Line | Code |
1084 | } |
1085 |
|
1086 | function widget($args, $instance) { |
1087 | // Get menu |
1088 | $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; |
1089 |
|
1090 | if ( !$nav_menu ) |
1091 | return; |
1092 |
|
1093 | $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
1094 |
|
1095 | echo $args['before_widget']; |
1096 |
|
1097 | if ( !empty($instance['title']) ) |
1098 | echo $args['before_title'] . $instance['title'] . $args['after_title']; |
1099 |
|
1100 | wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); |
1101 |
|
1102 | echo $args['after_widget']; |