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 11 times in this file.
Line | Code |
---|---|
16 |
|
17 | function WP_Widget_Pages() { |
18 | $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your blog’s WordPress Pages') ); |
19 | $this->WP_Widget('pages', __('Pages'), $widget_ops); |
20 | } |
21 |
|
22 | function widget( $args, $instance ) { |
23 | extract( $args ); |
24 |
|
25 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title']); |
26 | $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; |
27 | $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; |
28 |
|
29 | if ( $sortby == 'menu_order' ) |
30 | $sortby = 'menu_order, post_title'; |
31 |
|
32 | $out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) ); |
33 |
|
34 | if ( !empty( $out ) ) { |
Line | Code |
172 | class WP_Widget_Search extends WP_Widget { |
173 |
|
174 | function WP_Widget_Search() { |
175 | $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your blog") ); |
176 | $this->WP_Widget('search', __('Search'), $widget_ops); |
177 | } |
178 |
|
179 | function widget( $args, $instance ) { |
180 | extract($args); |
181 | $title = apply_filters('widget_title', $instance['title']); |
182 |
|
183 | echo $before_widget; |
184 | if ( $title ) |
185 | echo $before_title . $title . $after_title; |
186 |
|
187 | // Use current theme search form if it exists |
188 | get_search_form(); |
189 |
|
190 | echo $after_widget; |
Line | Code |
217 | function WP_Widget_Archives() { |
218 | $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your blog’s posts') ); |
219 | $this->WP_Widget('archives', __('Archives'), $widget_ops); |
220 | } |
221 |
|
222 | function widget( $args, $instance ) { |
223 | extract($args); |
224 | $c = $instance['count'] ? '1' : '0'; |
225 | $d = $instance['dropdown'] ? '1' : '0'; |
226 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title']); |
227 |
|
228 | echo $before_widget; |
229 | if ( $title ) |
230 | echo $before_title . $title . $after_title; |
231 |
|
232 | if ( $d ) { |
233 | ?> |
234 | <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> |
235 | <?php |
Line | Code |
280 | class WP_Widget_Meta extends WP_Widget { |
281 |
|
282 | function WP_Widget_Meta() { |
283 | $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") ); |
284 | $this->WP_Widget('meta', __('Meta'), $widget_ops); |
285 | } |
286 |
|
287 | function widget( $args, $instance ) { |
288 | extract($args); |
289 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title']); |
290 |
|
291 | echo $before_widget; |
292 | if ( $title ) |
293 | echo $before_title . $title . $after_title; |
294 | ?> |
295 | <ul> |
296 | <?php wp_register(); ?> |
297 | <li><?php wp_loginout(); ?></li> |
298 | <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 |
328 | class WP_Widget_Calendar extends WP_Widget { |
329 |
|
330 | function WP_Widget_Calendar() { |
331 | $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your blog’s posts') ); |
332 | $this->WP_Widget('calendar', __('Calendar'), $widget_ops); |
333 | } |
334 |
|
335 | function widget( $args, $instance ) { |
336 | extract($args); |
337 | $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title']); |
338 | echo $before_widget; |
339 | if ( $title ) |
340 | echo $before_title . $title . $after_title; |
341 | echo '<div id="calendar_wrap">'; |
342 | get_calendar(); |
343 | echo '</div>'; |
344 | echo $after_widget; |
345 | } |
346 |
|
Line | Code |
370 |
|
371 | function WP_Widget_Text() { |
372 | $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); |
373 | $control_ops = array('width' => 400, 'height' => 350); |
374 | $this->WP_Widget('text', __('Text'), $widget_ops, $control_ops); |
375 | } |
376 |
|
377 | function widget( $args, $instance ) { |
378 | extract($args); |
379 | $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance ); |
380 | $text = apply_filters( 'widget_text', $instance['text'], $instance ); |
381 | echo $before_widget; |
382 | if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
383 | <div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div> |
384 | <?php |
385 | echo $after_widget; |
386 | } |
387 |
|
388 | function update( $new_instance, $old_instance ) { |
Line | Code |
420 |
|
421 | function WP_Widget_Categories() { |
422 | $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); |
423 | $this->WP_Widget('categories', __('Categories'), $widget_ops); |
424 | } |
425 |
|
426 | function widget( $args, $instance ) { |
427 | extract( $args ); |
428 |
|
429 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title']); |
430 | $c = $instance['count'] ? '1' : '0'; |
431 | $h = $instance['hierarchical'] ? '1' : '0'; |
432 | $d = $instance['dropdown'] ? '1' : '0'; |
433 |
|
434 | echo $before_widget; |
435 | if ( $title ) |
436 | echo $before_title . $title . $after_title; |
437 |
|
438 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
Line | Code |
528 |
|
529 | if ( isset($cache[$args['widget_id']]) ) { |
530 | echo $cache[$args['widget_id']]; |
531 | return; |
532 | } |
533 |
|
534 | ob_start(); |
535 | extract($args); |
536 |
|
537 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); |
538 | if ( !$number = (int) $instance['number'] ) |
539 | $number = 10; |
540 | else if ( $number < 1 ) |
541 | $number = 1; |
542 | else if ( $number > 15 ) |
543 | $number = 15; |
544 |
|
545 | $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); |
546 | if ($r->have_posts()) : |
Line | Code |
619 |
|
620 | function flush_widget_cache() { |
621 | wp_cache_delete('recent_comments', 'widget'); |
622 | } |
623 |
|
624 | function widget( $args, $instance ) { |
625 | global $wpdb, $comments, $comment; |
626 |
|
627 | extract($args, EXTR_SKIP); |
628 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']); |
629 | if ( !$number = (int) $instance['number'] ) |
630 | $number = 5; |
631 | else if ( $number < 1 ) |
632 | $number = 1; |
633 | else if ( $number > 15 ) |
634 | $number = 15; |
635 |
|
636 | if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
637 | $comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' ORDER BY comment_date_gmt DESC LIMIT 15"); |
Line | Code |
715 | $title = esc_html(strip_tags($rss->get_title())); |
716 | $link = esc_url(strip_tags($rss->get_permalink())); |
717 | while ( stristr($link, 'http') != $link ) |
718 | $link = substr($link, 1); |
719 | } |
720 |
|
721 | if ( empty($title) ) |
722 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
723 |
|
724 | $title = apply_filters('widget_title', $title ); |
725 | $url = esc_url(strip_tags($url)); |
726 | $icon = includes_url('images/rss.png'); |
727 | if ( $title ) |
728 | $title = "<a class='rsswidget' href='$url' title='" . esc_attr(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>"; |
729 |
|
730 | echo $before_widget; |
731 | if ( $title ) |
732 | echo $before_title . $title . $after_title; |
733 | wp_widget_rss_output( $rss, $instance ); |
Line | Code |
968 | class WP_Widget_Tag_Cloud extends WP_Widget { |
969 |
|
970 | function WP_Widget_Tag_Cloud() { |
971 | $widget_ops = array( 'description' => __( "Your most used tags in cloud format") ); |
972 | $this->WP_Widget('tag_cloud', __('Tag Cloud'), $widget_ops); |
973 | } |
974 |
|
975 | function widget( $args, $instance ) { |
976 | extract($args); |
977 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title']); |
978 |
|
979 | echo $before_widget; |
980 | if ( $title ) |
981 | echo $before_title . $title . $after_title; |
982 | echo '<div>'; |
983 | wp_tag_cloud(apply_filters('widget_tag_cloud_args', array())); |
984 | echo "</div>\n"; |
985 | echo $after_widget; |
986 | } |