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']); |
| 380 | $text = apply_filters( 'widget_text', $instance['text'] ); |
| 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 |
| 526 | if ( !is_array($cache) ) |
| 527 | $cache = array(); |
| 528 | |
| 529 | if ( isset($cache[$args['widget_id']]) ) |
| 530 | return $cache[$args['widget_id']]; |
| 531 | |
| 532 | ob_start(); |
| 533 | extract($args); |
| 534 | |
| 535 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); |
| 536 | if ( !$number = (int) $instance['number'] ) |
| 537 | $number = 10; |
| 538 | else if ( $number < 1 ) |
| 539 | $number = 1; |
| 540 | else if ( $number > 15 ) |
| 541 | $number = 15; |
| 542 | |
| 543 | $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); |
| 544 | if ($r->have_posts()) : |
| Line | Code |
| 617 | |
| 618 | function flush_widget_cache() { |
| 619 | wp_cache_delete('recent_comments', 'widget'); |
| 620 | } |
| 621 | |
| 622 | function widget( $args, $instance ) { |
| 623 | global $wpdb, $comments, $comment; |
| 624 | |
| 625 | extract($args, EXTR_SKIP); |
| 626 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']); |
| 627 | if ( !$number = (int) $instance['number'] ) |
| 628 | $number = 5; |
| 629 | else if ( $number < 1 ) |
| 630 | $number = 1; |
| 631 | else if ( $number > 15 ) |
| 632 | $number = 15; |
| 633 | |
| 634 | if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
| 635 | $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); |
| Line | Code |
| 713 | $title = htmlentities(strip_tags($rss->get_title())); |
| 714 | $link = esc_url(strip_tags($rss->get_permalink())); |
| 715 | while ( stristr($link, 'http') != $link ) |
| 716 | $link = substr($link, 1); |
| 717 | } |
| 718 | |
| 719 | if ( empty($title) ) |
| 720 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
| 721 | |
| 722 | $title = apply_filters('widget_title', $title ); |
| 723 | $url = esc_url(strip_tags($url)); |
| 724 | $icon = includes_url('images/rss.png'); |
| 725 | if ( $title ) |
| 726 | $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>"; |
| 727 | |
| 728 | echo $before_widget; |
| 729 | if ( $title ) |
| 730 | echo $before_title . $title . $after_title; |
| 731 | wp_widget_rss_output( $rss, $instance ); |
| Line | Code |
| 958 | class WP_Widget_Tag_Cloud extends WP_Widget { |
| 959 | |
| 960 | function WP_Widget_Tag_Cloud() { |
| 961 | $widget_ops = array( 'description' => __( "Your most used tags in cloud format") ); |
| 962 | $this->WP_Widget('tag_cloud', __('Tag Cloud'), $widget_ops); |
| 963 | } |
| 964 | |
| 965 | function widget( $args, $instance ) { |
| 966 | extract($args); |
| 967 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title']); |
| 968 | |
| 969 | echo $before_widget; |
| 970 | if ( $title ) |
| 971 | echo $before_title . $title . $after_title; |
| 972 | echo '<div>'; |
| 973 | wp_tag_cloud(apply_filters('widget_tag_cloud_args', array())); |
| 974 | echo "</div>\n"; |
| 975 | echo $after_widget; |
| 976 | } |