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 10 times in this file.
| Line | Code |
|---|---|
| 379 | return $defaults; |
| 380 | } |
| 381 | |
| 382 | /* Default Widgets */ |
| 383 | |
| 384 | function wp_widget_pages( $args ) { |
| 385 | extract( $args ); |
| 386 | $options = get_option( 'widget_pages' ); |
| 387 | |
| 388 | $title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']); |
| 389 | $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby']; |
| 390 | $exclude = empty( $options['exclude'] ) ? '' : $options['exclude']; |
| 391 | |
| 392 | if ( $sortby == 'menu_order' ) { |
| 393 | $sortby = 'menu_order, post_title'; |
| 394 | } |
| 395 | |
| 396 | $out = wp_list_pages( array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ); |
| 397 | |
| Line | Code |
| 478 | |
| 479 | echo $after_widget; |
| 480 | } |
| 481 | |
| 482 | function wp_widget_archives($args) { |
| 483 | extract($args); |
| 484 | $options = get_option('widget_archives'); |
| 485 | $c = $options['count'] ? '1' : '0'; |
| 486 | $d = $options['dropdown'] ? '1' : '0'; |
| 487 | $title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']); |
| 488 | |
| 489 | echo $before_widget; |
| 490 | echo $before_title . $title . $after_title; |
| 491 | |
| 492 | if($d) { |
| 493 | ?> |
| 494 | <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Month')); ?></option> <?php wp_get_archives("type=monthly&format=option&show_post_count=$c"); ?> </select> |
| 495 | <?php |
| 496 | } else { |
| Line | Code |
| 526 | <label for="archives-dropdown"><input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="archives-dropdown" name="archives-dropdown" /> <?php _e('Display as a drop down'); ?></label> |
| 527 | </p> |
| 528 | <input type="hidden" id="archives-submit" name="archives-submit" value="1" /> |
| 529 | <?php |
| 530 | } |
| 531 | |
| 532 | function wp_widget_meta($args) { |
| 533 | extract($args); |
| 534 | $options = get_option('widget_meta'); |
| 535 | $title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']); |
| 536 | ?> |
| 537 | <?php echo $before_widget; ?> |
| 538 | <?php echo $before_title . $title . $after_title; ?> |
| 539 | <ul> |
| 540 | <?php wp_register(); ?> |
| 541 | <li><?php wp_loginout(); ?></li> |
| 542 | <li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo attribute_escape(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
| 543 | <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo attribute_escape(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> |
| 544 | <li><a href="http://wordpress.org/" title="<?php echo attribute_escape(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li> |
| Line | Code |
| 560 | ?> |
| 561 | <p><label for="meta-title"><?php _e('Title:'); ?> <input class="widefat" id="meta-title" name="meta-title" type="text" value="<?php echo $title; ?>" /></label></p> |
| 562 | <input type="hidden" id="meta-submit" name="meta-submit" value="1" /> |
| 563 | <?php |
| 564 | } |
| 565 | |
| 566 | function wp_widget_calendar($args) { |
| 567 | extract($args); |
| 568 | $options = get_option('widget_calendar'); |
| 569 | $title = apply_filters('widget_title', $options['title']); |
| 570 | if ( empty($title) ) |
| 571 | $title = ' '; |
| 572 | echo $before_widget . $before_title . $title . $after_title; |
| 573 | echo '<div id="calendar_wrap">'; |
| 574 | get_calendar(); |
| 575 | echo '</div>'; |
| 576 | echo $after_widget; |
| 577 | } |
| 578 | function wp_widget_calendar_control() { |
| Line | Code |
| 597 | if ( is_numeric($widget_args) ) |
| 598 | $widget_args = array( 'number' => $widget_args ); |
| 599 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
| 600 | extract( $widget_args, EXTR_SKIP ); |
| 601 | |
| 602 | $options = get_option('widget_text'); |
| 603 | if ( !isset($options[$number]) ) |
| 604 | return; |
| 605 | |
| 606 | $title = apply_filters('widget_title', $options[$number]['title']); |
| 607 | $text = apply_filters( 'widget_text', $options[$number]['text'] ); |
| 608 | ?> |
| 609 | <?php echo $before_widget; ?> |
| 610 | <?php if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
| 611 | <div class="textwidget"><?php echo $text; ?></div> |
| 612 | <?php echo $after_widget; ?> |
| 613 | <?php |
| 614 | } |
| 615 | |
| Line | Code |
| 709 | |
| 710 | $options = get_option('widget_categories'); |
| 711 | if ( !isset($options[$number]) ) |
| 712 | return; |
| 713 | |
| 714 | $c = $options[$number]['count'] ? '1' : '0'; |
| 715 | $h = $options[$number]['hierarchical'] ? '1' : '0'; |
| 716 | $d = $options[$number]['dropdown'] ? '1' : '0'; |
| 717 | |
| 718 | $title = empty($options[$number]['title']) ? __('Categories') : apply_filters('widget_title', $options[$number]['title']); |
| 719 | |
| 720 | echo $before_widget; |
| 721 | echo $before_title . $title . $after_title; |
| 722 | |
| 723 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
| 724 | |
| 725 | if ( $d ) { |
| 726 | $cat_args['show_option_none'] = __('Select Category'); |
| 727 | wp_dropdown_categories($cat_args); |
| Line | Code |
| 898 | function wp_widget_recent_entries($args) { |
| 899 | if ( '%BEG_OF_TITLE%' != $args['before_title'] ) { |
| 900 | if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) |
| 901 | return print($output); |
| 902 | ob_start(); |
| 903 | } |
| 904 | |
| 905 | extract($args); |
| 906 | $options = get_option('widget_recent_entries'); |
| 907 | $title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']); |
| 908 | if ( !$number = (int) $options['number'] ) |
| 909 | $number = 10; |
| 910 | else if ( $number < 1 ) |
| 911 | $number = 1; |
| 912 | else if ( $number > 15 ) |
| 913 | $number = 15; |
| 914 | |
| 915 | $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish')); |
| 916 | if ($r->have_posts()) : |
| Line | Code |
| 963 | </p> |
| 964 | <input type="hidden" id="recent-entries-submit" name="recent-entries-submit" value="1" /> |
| 965 | <?php |
| 966 | } |
| 967 | |
| 968 | function wp_widget_recent_comments($args) { |
| 969 | global $wpdb, $comments, $comment; |
| 970 | extract($args, EXTR_SKIP); |
| 971 | $options = get_option('widget_recent_comments'); |
| 972 | $title = empty($options['title']) ? __('Recent Comments') : apply_filters('widget_title', $options['title']); |
| 973 | if ( !$number = (int) $options['number'] ) |
| 974 | $number = 5; |
| 975 | else if ( $number < 1 ) |
| 976 | $number = 1; |
| 977 | else if ( $number > 15 ) |
| 978 | $number = 15; |
| 979 | |
| 980 | if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
| 981 | $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number"); |
| Line | Code |
| 1069 | $link = substr($link, 1); |
| 1070 | $desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES))); |
| 1071 | $title = $options[$number]['title']; |
| 1072 | if ( empty($title) ) |
| 1073 | $title = htmlentities(strip_tags($rss->channel['title'])); |
| 1074 | if ( empty($title) ) |
| 1075 | $title = $desc; |
| 1076 | if ( empty($title) ) |
| 1077 | $title = __('Unknown Feed'); |
| 1078 | $title = apply_filters('widget_title', $title ); |
| 1079 | $url = clean_url(strip_tags($url)); |
| 1080 | if ( file_exists(dirname(__FILE__) . '/rss.png') ) |
| 1081 | $icon = str_replace(ABSPATH, site_url() . '/', dirname(__FILE__)) . '/rss.png'; |
| 1082 | else |
| 1083 | $icon = includes_url('images/rss.png'); |
| 1084 | $title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('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>"; |
| 1085 | |
| 1086 | echo $before_widget; |
| 1087 | echo $before_title . $title . $after_title; |
| Line | Code |
| 1362 | if ( !$id ) { |
| 1363 | wp_register_sidebar_widget( 'rss-1', $name, 'wp_widget_rss', $widget_ops, array( 'number' => -1 ) ); |
| 1364 | wp_register_widget_control( 'rss-1', $name, 'wp_widget_rss_control', $control_ops, array( 'number' => -1 ) ); |
| 1365 | } |
| 1366 | } |
| 1367 | |
| 1368 | function wp_widget_tag_cloud($args) { |
| 1369 | extract($args); |
| 1370 | $options = get_option('widget_tag_cloud'); |
| 1371 | $title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']); |
| 1372 | |
| 1373 | echo $before_widget; |
| 1374 | echo $before_title . $title . $after_title; |
| 1375 | wp_tag_cloud(); |
| 1376 | echo $after_widget; |
| 1377 | } |
| 1378 | |
| 1379 | function wp_widget_tag_cloud_control() { |
| 1380 | $options = $newoptions = get_option('widget_tag_cloud'); |