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 |
| 350 | class WP_Widget_Calendar extends WP_Widget { |
| 351 | |
| 352 | function __construct() { |
| 353 | $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s posts') ); |
| 354 | parent::__construct('calendar', __('Calendar'), $widget_ops); |
| 355 | } |
| 356 | |
| 357 | function widget( $args, $instance ) { |
| 358 | extract($args); |
| 359 | $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
| 360 | echo $before_widget; |
| 361 | if ( $title ) |
| 362 | echo $before_title . $title . $after_title; |
| 363 | echo '<div id="calendar_wrap">'; |
| 364 | get_calendar(); |
| 365 | echo '</div>'; |
| 366 | echo $after_widget; |
| 367 | } |
| 368 | |
| Line | Code |
| 392 | |
| 393 | function __construct() { |
| 394 | $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); |
| 395 | $control_ops = array('width' => 400, 'height' => 350); |
| 396 | parent::__construct('text', __('Text'), $widget_ops, $control_ops); |
| 397 | } |
| 398 | |
| 399 | function widget( $args, $instance ) { |
| 400 | extract($args); |
| 401 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
| 402 | $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); |
| 403 | echo $before_widget; |
| 404 | if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
| 405 | <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> |
| 406 | <?php |
| 407 | echo $after_widget; |
| 408 | } |
| 409 | |
| 410 | function update( $new_instance, $old_instance ) { |
| Line | Code |
| 442 | |
| 443 | function __construct() { |
| 444 | $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); |
| 445 | parent::__construct('categories', __('Categories'), $widget_ops); |
| 446 | } |
| 447 | |
| 448 | function widget( $args, $instance ) { |
| 449 | extract( $args ); |
| 450 | |
| 451 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base); |
| 452 | $c = ! empty( $instance['count'] ) ? '1' : '0'; |
| 453 | $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; |
| 454 | $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
| 455 | |
| 456 | echo $before_widget; |
| 457 | if ( $title ) |
| 458 | echo $before_title . $title . $after_title; |
| 459 | |
| 460 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
| Line | Code |
| 554 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
| 555 | echo $cache[ $args['widget_id'] ]; |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | ob_start(); |
| 560 | extract($args); |
| 561 | |
| 562 | $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); |
| 563 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
| 564 | $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 10; |
| 565 | if ( ! $number ) |
| 566 | $number = 10; |
| 567 | $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; |
| 568 | |
| 569 | $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 ) ) ); |
| 570 | if ($r->have_posts()) : |
| 571 | ?> |
| 572 | <?php echo $before_widget; ?> |
| Line | Code |
| 674 | if ( isset( $cache[ $args['widget_id'] ] ) ) { |
| 675 | echo $cache[ $args['widget_id'] ]; |
| 676 | return; |
| 677 | } |
| 678 | |
| 679 | extract($args, EXTR_SKIP); |
| 680 | $output = ''; |
| 681 | |
| 682 | $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); |
| 683 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
| 684 | $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
| 685 | if ( ! $number ) |
| 686 | $number = 5; |
| 687 | |
| 688 | $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); |
| 689 | $output .= $before_widget; |
| 690 | if ( $title ) |
| 691 | $output .= $before_title . $title . $after_title; |
| 692 | |
| Line | Code |
| 776 | $title = esc_html(strip_tags($rss->get_title())); |
| 777 | $link = esc_url(strip_tags($rss->get_permalink())); |
| 778 | while ( stristr($link, 'http') != $link ) |
| 779 | $link = substr($link, 1); |
| 780 | } |
| 781 | |
| 782 | if ( empty($title) ) |
| 783 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
| 784 | |
| 785 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
| 786 | $url = esc_url(strip_tags($url)); |
| 787 | $icon = includes_url('images/rss.png'); |
| 788 | if ( $title ) |
| 789 | $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>"; |
| 790 | |
| 791 | echo $before_widget; |
| 792 | if ( $title ) |
| 793 | echo $before_title . $title . $after_title; |
| 794 | wp_widget_rss_output( $rss, $instance ); |
| Line | Code |
| 1044 | $title = $instance['title']; |
| 1045 | } else { |
| 1046 | if ( 'post_tag' == $current_taxonomy ) { |
| 1047 | $title = __('Tags'); |
| 1048 | } else { |
| 1049 | $tax = get_taxonomy($current_taxonomy); |
| 1050 | $title = $tax->labels->name; |
| 1051 | } |
| 1052 | } |
| 1053 | $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
| 1054 | |
| 1055 | echo $before_widget; |
| 1056 | if ( $title ) |
| 1057 | echo $before_title . $title . $after_title; |
| 1058 | echo '<div class="tagcloud">'; |
| 1059 | wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); |
| 1060 | echo "</div>\n"; |
| 1061 | echo $after_widget; |
| 1062 | } |
| Line | Code |
| 1105 | } |
| 1106 | |
| 1107 | function widget($args, $instance) { |
| 1108 | // Get menu |
| 1109 | $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; |
| 1110 | |
| 1111 | if ( !$nav_menu ) |
| 1112 | return; |
| 1113 | |
| 1114 | $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
| 1115 | |
| 1116 | echo $args['before_widget']; |
| 1117 | |
| 1118 | if ( !empty($instance['title']) ) |
| 1119 | echo $args['before_title'] . $instance['title'] . $args['after_title']; |
| 1120 | |
| 1121 | wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); |
| 1122 | |
| 1123 | echo $args['after_widget']; |