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 |
|---|---|
| 664 | * |
| 665 | * @since 2.2.0 |
| 666 | * |
| 667 | * @param array $args Widget arguments. |
| 668 | */ |
| 669 | function wp_widget_pages( $args ) { |
| 670 | extract( $args ); |
| 671 | $options = get_option( 'widget_pages' ); |
| 672 | |
| 673 | $title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']); |
| 674 | $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby']; |
| 675 | $exclude = empty( $options['exclude'] ) ? '' : $options['exclude']; |
| 676 | |
| 677 | if ( $sortby == 'menu_order' ) { |
| 678 | $sortby = 'menu_order, post_title'; |
| 679 | } |
| 680 | |
| 681 | $out = wp_list_pages( array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ); |
| 682 | |
| Line | Code |
| 779 | * @since 2.2.0 |
| 780 | * |
| 781 | * @param array $args Widget arguments. |
| 782 | */ |
| 783 | function wp_widget_archives($args) { |
| 784 | extract($args); |
| 785 | $options = get_option('widget_archives'); |
| 786 | $c = $options['count'] ? '1' : '0'; |
| 787 | $d = $options['dropdown'] ? '1' : '0'; |
| 788 | $title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']); |
| 789 | |
| 790 | echo $before_widget; |
| 791 | echo $before_title . $title . $after_title; |
| 792 | |
| 793 | if($d) { |
| 794 | ?> |
| 795 | <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> |
| 796 | <?php |
| 797 | } else { |
| Line | Code |
| 841 | * Displays log in/out, RSS feed links, etc. |
| 842 | * |
| 843 | * @since 2.2.0 |
| 844 | * |
| 845 | * @param array $args Widget arguments. |
| 846 | */ |
| 847 | function wp_widget_meta($args) { |
| 848 | extract($args); |
| 849 | $options = get_option('widget_meta'); |
| 850 | $title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']); |
| 851 | ?> |
| 852 | <?php echo $before_widget; ?> |
| 853 | <?php echo $before_title . $title . $after_title; ?> |
| 854 | <ul> |
| 855 | <?php wp_register(); ?> |
| 856 | <li><?php wp_loginout(); ?></li> |
| 857 | <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> |
| 858 | <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> |
| 859 | <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 |
| 888 | * Display calendar widget. |
| 889 | * |
| 890 | * @since 2.2.0 |
| 891 | * |
| 892 | * @param array $args Widget arguments. |
| 893 | */ |
| 894 | function wp_widget_calendar($args) { |
| 895 | extract($args); |
| 896 | $options = get_option('widget_calendar'); |
| 897 | $title = apply_filters('widget_title', $options['title']); |
| 898 | if ( empty($title) ) |
| 899 | $title = ' '; |
| 900 | echo $before_widget . $before_title . $title . $after_title; |
| 901 | echo '<div id="calendar_wrap">'; |
| 902 | get_calendar(); |
| 903 | echo '</div>'; |
| 904 | echo $after_widget; |
| 905 | } |
| 906 | |
| Line | Code |
| 943 | if ( is_numeric($widget_args) ) |
| 944 | $widget_args = array( 'number' => $widget_args ); |
| 945 | $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); |
| 946 | extract( $widget_args, EXTR_SKIP ); |
| 947 | |
| 948 | $options = get_option('widget_text'); |
| 949 | if ( !isset($options[$number]) ) |
| 950 | return; |
| 951 | |
| 952 | $title = apply_filters('widget_title', $options[$number]['title']); |
| 953 | $text = apply_filters( 'widget_text', $options[$number]['text'] ); |
| 954 | ?> |
| 955 | <?php echo $before_widget; ?> |
| 956 | <?php if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
| 957 | <div class="textwidget"><?php echo $text; ?></div> |
| 958 | <?php echo $after_widget; ?> |
| 959 | <?php |
| 960 | } |
| 961 | |
| Line | Code |
| 1076 | |
| 1077 | $options = get_option('widget_categories'); |
| 1078 | if ( !isset($options[$number]) ) |
| 1079 | return; |
| 1080 | |
| 1081 | $c = $options[$number]['count'] ? '1' : '0'; |
| 1082 | $h = $options[$number]['hierarchical'] ? '1' : '0'; |
| 1083 | $d = $options[$number]['dropdown'] ? '1' : '0'; |
| 1084 | |
| 1085 | $title = empty($options[$number]['title']) ? __('Categories') : apply_filters('widget_title', $options[$number]['title']); |
| 1086 | |
| 1087 | echo $before_widget; |
| 1088 | echo $before_title . $title . $after_title; |
| 1089 | |
| 1090 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
| 1091 | |
| 1092 | if ( $d ) { |
| 1093 | $cat_args['show_option_none'] = __('Select Category'); |
| 1094 | wp_dropdown_categories($cat_args); |
| Line | Code |
| 1292 | function wp_widget_recent_entries($args) { |
| 1293 | if ( '%BEG_OF_TITLE%' != $args['before_title'] ) { |
| 1294 | if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) |
| 1295 | return print($output); |
| 1296 | ob_start(); |
| 1297 | } |
| 1298 | |
| 1299 | extract($args); |
| 1300 | $options = get_option('widget_recent_entries'); |
| 1301 | $title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']); |
| 1302 | if ( !$number = (int) $options['number'] ) |
| 1303 | $number = 10; |
| 1304 | else if ( $number < 1 ) |
| 1305 | $number = 1; |
| 1306 | else if ( $number > 15 ) |
| 1307 | $number = 15; |
| 1308 | |
| 1309 | $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); |
| 1310 | if ($r->have_posts()) : |
| Line | Code |
| 1374 | * |
| 1375 | * @since 2.2.0 |
| 1376 | * |
| 1377 | * @param array $args Widget arguments. |
| 1378 | */ |
| 1379 | function wp_widget_recent_comments($args) { |
| 1380 | global $wpdb, $comments, $comment; |
| 1381 | extract($args, EXTR_SKIP); |
| 1382 | $options = get_option('widget_recent_comments'); |
| 1383 | $title = empty($options['title']) ? __('Recent Comments') : apply_filters('widget_title', $options['title']); |
| 1384 | if ( !$number = (int) $options['number'] ) |
| 1385 | $number = 5; |
| 1386 | else if ( $number < 1 ) |
| 1387 | $number = 1; |
| 1388 | else if ( $number > 15 ) |
| 1389 | $number = 15; |
| 1390 | |
| 1391 | if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
| 1392 | $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number"); |
| Line | Code |
| 1509 | $link = substr($link, 1); |
| 1510 | $desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES))); |
| 1511 | $title = $options[$number]['title']; |
| 1512 | if ( empty($title) ) |
| 1513 | $title = htmlentities(strip_tags($rss->channel['title'])); |
| 1514 | if ( empty($title) ) |
| 1515 | $title = $desc; |
| 1516 | if ( empty($title) ) |
| 1517 | $title = __('Unknown Feed'); |
| 1518 | $title = apply_filters('widget_title', $title ); |
| 1519 | $url = clean_url(strip_tags($url)); |
| 1520 | if ( file_exists(dirname(__FILE__) . '/rss.png') ) |
| 1521 | $icon = str_replace(ABSPATH, site_url() . '/', dirname(__FILE__)) . '/rss.png'; |
| 1522 | else |
| 1523 | $icon = includes_url('images/rss.png'); |
| 1524 | $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>"; |
| 1525 | |
| 1526 | echo $before_widget; |
| 1527 | echo $before_title . $title . $after_title; |
| Line | Code |
| 1860 | * Display tag cloud widget. |
| 1861 | * |
| 1862 | * @since 2.3.0 |
| 1863 | * |
| 1864 | * @param array $args Widget arguments. |
| 1865 | */ |
| 1866 | function wp_widget_tag_cloud($args) { |
| 1867 | extract($args); |
| 1868 | $options = get_option('widget_tag_cloud'); |
| 1869 | $title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']); |
| 1870 | |
| 1871 | echo $before_widget; |
| 1872 | echo $before_title . $title . $after_title; |
| 1873 | wp_tag_cloud(); |
| 1874 | echo $after_widget; |
| 1875 | } |
| 1876 | |
| 1877 | /** |
| 1878 | * Manage WordPress Tag Cloud widget options. |