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 WP_Widget_Pages() { |
17 | $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your site’s WordPress Pages') ); |
18 | $this->WP_Widget('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 |
171 | class WP_Widget_Search extends WP_Widget { |
172 |
|
173 | function WP_Widget_Search() { |
174 | $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site") ); |
175 | $this->WP_Widget('search', __('Search'), $widget_ops); |
176 | } |
177 |
|
178 | function widget( $args, $instance ) { |
179 | extract($args); |
180 | $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
181 |
|
182 | echo $before_widget; |
183 | if ( $title ) |
184 | echo $before_title . $title . $after_title; |
185 |
|
186 | // Use current theme search form if it exists |
187 | get_search_form(); |
188 |
|
189 | echo $after_widget; |
Line | Code |
216 | function WP_Widget_Archives() { |
217 | $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s posts') ); |
218 | $this->WP_Widget('archives', __('Archives'), $widget_ops); |
219 | } |
220 |
|
221 | function widget( $args, $instance ) { |
222 | extract($args); |
223 | $c = $instance['count'] ? '1' : '0'; |
224 | $d = $instance['dropdown'] ? '1' : '0'; |
225 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base); |
226 |
|
227 | echo $before_widget; |
228 | if ( $title ) |
229 | echo $before_title . $title . $after_title; |
230 |
|
231 | if ( $d ) { |
232 | ?> |
233 | <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> |
234 | <?php |
Line | Code |
279 | class WP_Widget_Meta extends WP_Widget { |
280 |
|
281 | function WP_Widget_Meta() { |
282 | $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") ); |
283 | $this->WP_Widget('meta', __('Meta'), $widget_ops); |
284 | } |
285 |
|
286 | function widget( $args, $instance ) { |
287 | extract($args); |
288 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base); |
289 |
|
290 | echo $before_widget; |
291 | if ( $title ) |
292 | echo $before_title . $title . $after_title; |
293 | ?> |
294 | <ul> |
295 | <?php wp_register(); ?> |
296 | <li><?php wp_loginout(); ?></li> |
297 | <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 |
327 | class WP_Widget_Calendar extends WP_Widget { |
328 |
|
329 | function WP_Widget_Calendar() { |
330 | $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s posts') ); |
331 | $this->WP_Widget('calendar', __('Calendar'), $widget_ops); |
332 | } |
333 |
|
334 | function widget( $args, $instance ) { |
335 | extract($args); |
336 | $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base); |
337 | echo $before_widget; |
338 | if ( $title ) |
339 | echo $before_title . $title . $after_title; |
340 | echo '<div id="calendar_wrap">'; |
341 | get_calendar(); |
342 | echo '</div>'; |
343 | echo $after_widget; |
344 | } |
345 |
|
Line | Code |
369 |
|
370 | function WP_Widget_Text() { |
371 | $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); |
372 | $control_ops = array('width' => 400, 'height' => 350); |
373 | $this->WP_Widget('text', __('Text'), $widget_ops, $control_ops); |
374 | } |
375 |
|
376 | function widget( $args, $instance ) { |
377 | extract($args); |
378 | $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
379 | $text = apply_filters( 'widget_text', $instance['text'], $instance ); |
380 | echo $before_widget; |
381 | if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
382 | <div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div> |
383 | <?php |
384 | echo $after_widget; |
385 | } |
386 |
|
387 | function update( $new_instance, $old_instance ) { |
Line | Code |
419 |
|
420 | function WP_Widget_Categories() { |
421 | $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); |
422 | $this->WP_Widget('categories', __('Categories'), $widget_ops); |
423 | } |
424 |
|
425 | function widget( $args, $instance ) { |
426 | extract( $args ); |
427 |
|
428 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base); |
429 | $c = $instance['count'] ? '1' : '0'; |
430 | $h = $instance['hierarchical'] ? '1' : '0'; |
431 | $d = $instance['dropdown'] ? '1' : '0'; |
432 |
|
433 | echo $before_widget; |
434 | if ( $title ) |
435 | echo $before_title . $title . $after_title; |
436 |
|
437 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
Line | Code |
527 |
|
528 | if ( isset($cache[$args['widget_id']]) ) { |
529 | echo $cache[$args['widget_id']]; |
530 | return; |
531 | } |
532 |
|
533 | ob_start(); |
534 | extract($args); |
535 |
|
536 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); |
537 | if ( ! $number = absint( $instance['number'] ) ) |
538 | $number = 10; |
539 |
|
540 | $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); |
541 | if ($r->have_posts()) : |
542 | ?> |
543 | <?php echo $before_widget; ?> |
544 | <?php if ( $title ) echo $before_title . $title . $after_title; ?> |
545 | <ul> |
Line | Code |
629 | $cache = array(); |
630 |
|
631 | if ( isset( $cache[$args['widget_id']] ) ) { |
632 | echo $cache[$args['widget_id']]; |
633 | return; |
634 | } |
635 |
|
636 | extract($args, EXTR_SKIP); |
637 | $output = ''; |
638 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']); |
639 |
|
640 | if ( ! $number = absint( $instance['number'] ) ) |
641 | $number = 5; |
642 |
|
643 | $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) ); |
644 | $output .= $before_widget; |
645 | if ( $title ) |
646 | $output .= $before_title . $title . $after_title; |
647 |
|
Line | Code |
727 | $title = esc_html(strip_tags($rss->get_title())); |
728 | $link = esc_url(strip_tags($rss->get_permalink())); |
729 | while ( stristr($link, 'http') != $link ) |
730 | $link = substr($link, 1); |
731 | } |
732 |
|
733 | if ( empty($title) ) |
734 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
735 |
|
736 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
737 | $url = esc_url(strip_tags($url)); |
738 | $icon = includes_url('images/rss.png'); |
739 | if ( $title ) |
740 | $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>"; |
741 |
|
742 | echo $before_widget; |
743 | if ( $title ) |
744 | echo $before_title . $title . $after_title; |
745 | wp_widget_rss_output( $rss, $instance ); |
Line | Code |
997 | $title = $instance['title']; |
998 | } else { |
999 | if ( 'post_tag' == $current_taxonomy ) { |
1000 | $title = __('Tags'); |
1001 | } else { |
1002 | $tax = get_taxonomy($current_taxonomy); |
1003 | $title = $tax->labels->name; |
1004 | } |
1005 | } |
1006 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
1007 |
|
1008 | echo $before_widget; |
1009 | if ( $title ) |
1010 | echo $before_title . $title . $after_title; |
1011 | echo '<div class="tagcloud">'; |
1012 | wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); |
1013 | echo "</div>\n"; |
1014 | echo $after_widget; |
1015 | } |
Line | Code |
1058 | } |
1059 |
|
1060 | function widget($args, $instance) { |
1061 | // Get menu |
1062 | $nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] ); |
1063 |
|
1064 | if ( !$nav_menu ) |
1065 | return; |
1066 |
|
1067 | $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
1068 |
|
1069 | echo $args['before_widget']; |
1070 |
|
1071 | if ( !empty($instance['title']) ) |
1072 | echo $args['before_title'] . $instance['title'] . $args['after_title']; |
1073 |
|
1074 | wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); |
1075 |
|
1076 | echo $args['after_widget']; |