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 |
| 171 | class WP_Widget_Search extends WP_Widget { |
| 172 | |
| 173 | function __construct() { |
| 174 | $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site") ); |
| 175 | parent::__construct('search', __('Search'), $widget_ops); |
| 176 | } |
| 177 | |
| 178 | function widget( $args, $instance ) { |
| 179 | extract($args); |
| 180 | $title = apply_filters( 'widget_title', empty( $instance['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 __construct() { |
| 217 | $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s posts') ); |
| 218 | parent::__construct('archives', __('Archives'), $widget_ops); |
| 219 | } |
| 220 | |
| 221 | function widget( $args, $instance ) { |
| 222 | extract($args); |
| 223 | $c = ! empty( $instance['count'] ) ? '1' : '0'; |
| 224 | $d = ! empty( $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 __construct() { |
| 282 | $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") ); |
| 283 | parent::__construct('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 __construct() { |
| 330 | $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s posts') ); |
| 331 | parent::__construct('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 __construct() { |
| 371 | $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); |
| 372 | $control_ops = array('width' => 400, 'height' => 350); |
| 373 | parent::__construct('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', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); |
| 380 | echo $before_widget; |
| 381 | if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
| 382 | <div class="textwidget"><?php echo !empty( $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 __construct() { |
| 421 | $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); |
| 422 | parent::__construct('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 = ! empty( $instance['count'] ) ? '1' : '0'; |
| 430 | $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; |
| 431 | $d = ! empty( $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 |
| 530 | |
| 531 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
| 532 | echo $cache[ $args['widget_id'] ]; |
| 533 | return; |
| 534 | } |
| 535 | |
| 536 | ob_start(); |
| 537 | extract($args); |
| 538 | |
| 539 | $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); |
| 540 | if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) |
| 541 | $number = 10; |
| 542 | |
| 543 | $r = new WP_Query(array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); |
| 544 | if ($r->have_posts()) : |
| 545 | ?> |
| 546 | <?php echo $before_widget; ?> |
| 547 | <?php if ( $title ) echo $before_title . $title . $after_title; ?> |
| 548 | <ul> |
| Line | Code |
| 635 | $args['widget_id'] = $this->id; |
| 636 | |
| 637 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
| 638 | echo $cache[ $args['widget_id'] ]; |
| 639 | return; |
| 640 | } |
| 641 | |
| 642 | extract($args, EXTR_SKIP); |
| 643 | $output = ''; |
| 644 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base ); |
| 645 | |
| 646 | if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) |
| 647 | $number = 5; |
| 648 | |
| 649 | $comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ); |
| 650 | $output .= $before_widget; |
| 651 | if ( $title ) |
| 652 | $output .= $before_title . $title . $after_title; |
| 653 | |
| Line | Code |
| 733 | $title = esc_html(strip_tags($rss->get_title())); |
| 734 | $link = esc_url(strip_tags($rss->get_permalink())); |
| 735 | while ( stristr($link, 'http') != $link ) |
| 736 | $link = substr($link, 1); |
| 737 | } |
| 738 | |
| 739 | if ( empty($title) ) |
| 740 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
| 741 | |
| 742 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
| 743 | $url = esc_url(strip_tags($url)); |
| 744 | $icon = includes_url('images/rss.png'); |
| 745 | if ( $title ) |
| 746 | $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>"; |
| 747 | |
| 748 | echo $before_widget; |
| 749 | if ( $title ) |
| 750 | echo $before_title . $title . $after_title; |
| 751 | wp_widget_rss_output( $rss, $instance ); |
| Line | Code |
| 1003 | $title = $instance['title']; |
| 1004 | } else { |
| 1005 | if ( 'post_tag' == $current_taxonomy ) { |
| 1006 | $title = __('Tags'); |
| 1007 | } else { |
| 1008 | $tax = get_taxonomy($current_taxonomy); |
| 1009 | $title = $tax->labels->name; |
| 1010 | } |
| 1011 | } |
| 1012 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
| 1013 | |
| 1014 | echo $before_widget; |
| 1015 | if ( $title ) |
| 1016 | echo $before_title . $title . $after_title; |
| 1017 | echo '<div class="tagcloud">'; |
| 1018 | wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); |
| 1019 | echo "</div>\n"; |
| 1020 | echo $after_widget; |
| 1021 | } |
| Line | Code |
| 1064 | } |
| 1065 | |
| 1066 | function widget($args, $instance) { |
| 1067 | // Get menu |
| 1068 | $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; |
| 1069 | |
| 1070 | if ( !$nav_menu ) |
| 1071 | return; |
| 1072 | |
| 1073 | $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
| 1074 | |
| 1075 | echo $args['before_widget']; |
| 1076 | |
| 1077 | if ( !empty($instance['title']) ) |
| 1078 | echo $args['before_title'] . $instance['title'] . $args['after_title']; |
| 1079 | |
| 1080 | wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); |
| 1081 | |
| 1082 | echo $args['after_widget']; |