14 class WP_Widget_Pages extends WP_Widget {
16 function __construct() {
17 $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'A list of your site’s Pages.') );
18 parent::__construct('pages', __('Pages'), $widget_ops);
21 function widget( $args, $instance ) {
25 * Filter the widget title.
29 * @param string $title The widget title. Default 'Pages'.
30 * @param array $instance An array of the widget's settings.
31 * @param mixed $id_base The widget ID.
33 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
35 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
36 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
38 if ( $sortby == 'menu_order' )
39 $sortby = 'menu_order, post_title';
42 * Filter the arguments for the Pages widget.
46 * @see wp_list_pages()
48 * @param array $args An array of arguments to retrieve the pages list.
50 $out = wp_list_pages( apply_filters( 'widget_pages_args', array(
53 'sort_column' => $sortby,
57 if ( !empty( $out ) ) {
60 echo $before_title . $title . $after_title;
70 function update( $new_instance, $old_instance ) {
71 $instance = $old_instance;
72 $instance['title'] = strip_tags($new_instance['title']);
73 if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
74 $instance['sortby'] = $new_instance['sortby'];
76 $instance['sortby'] = 'menu_order';
79 $instance['exclude'] = strip_tags( $new_instance['exclude'] );
84 function form( $instance ) {
86 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
87 $title = esc_attr( $instance['title'] );
88 $exclude = esc_attr( $instance['exclude'] );
90 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
92 <label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?></label>
93 <select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">
94 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
95 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
96 <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
100 <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
102 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
114 class WP_Widget_Links extends WP_Widget {
116 function __construct() {
117 $widget_ops = array('description' => __( "Your blogroll" ) );
118 parent::__construct('links', __('Links'), $widget_ops);
121 function widget( $args, $instance ) {
122 extract($args, EXTR_SKIP);
124 $show_description = isset($instance['description']) ? $instance['description'] : false;
125 $show_name = isset($instance['name']) ? $instance['name'] : false;
126 $show_rating = isset($instance['rating']) ? $instance['rating'] : false;
127 $show_images = isset($instance['images']) ? $instance['images'] : true;
128 $category = isset($instance['category']) ? $instance['category'] : false;
129 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
130 $order = $orderby == 'rating' ? 'DESC' : 'ASC';
131 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
133 $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
136 * Filter the arguments for the Links widget.
140 * @see wp_list_bookmarks()
142 * @param array $args An array of arguments to retrieve the links list.
144 wp_list_bookmarks( apply_filters( 'widget_links_args', array(
145 'title_before' => $before_title, 'title_after' => $after_title,
146 'category_before' => $before_widget, 'category_after' => $after_widget,
147 'show_images' => $show_images, 'show_description' => $show_description,
148 'show_name' => $show_name, 'show_rating' => $show_rating,
149 'category' => $category, 'class' => 'linkcat widget',
150 'orderby' => $orderby, 'order' => $order,
155 function update( $new_instance, $old_instance ) {
156 $new_instance = (array) $new_instance;
157 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );
158 foreach ( $instance as $field => $val ) {
159 if ( isset($new_instance[$field]) )
160 $instance[$field] = 1;
163 $instance['orderby'] = 'name';
164 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
165 $instance['orderby'] = $new_instance['orderby'];
167 $instance['category'] = intval( $new_instance['category'] );
168 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
173 function form( $instance ) {
176 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
177 $link_cats = get_terms( 'link_category' );
178 if ( ! $limit = intval( $instance['limit'] ) )
182 <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>
183 <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
184 <option value=""><?php _ex('All Links', 'links widget'); ?></option>
186 foreach ( $link_cats as $link_cat ) {
187 echo '<option value="' . intval( $link_cat->term_id ) . '"'
188 . selected( $instance['category'], $link_cat->term_id, false )
189 . '>' . $link_cat->name . "</option>\n";
193 <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>
194 <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
195 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>
196 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>
197 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>
198 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option>
202 <input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />
203 <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
204 <input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />
205 <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
206 <input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />
207 <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
208 <input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />
209 <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
212 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>
213 <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
220 * Search widget class
224 class WP_Widget_Search extends WP_Widget {
226 function __construct() {
227 $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site.") );
228 parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
231 function widget( $args, $instance ) {
234 /** This filter is documented in wp-includes/default-widgets.php */
235 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
239 echo $before_title . $title . $after_title;
241 // Use current theme search form if it exists
247 function form( $instance ) {
248 $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
249 $title = $instance['title'];
251 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
255 function update( $new_instance, $old_instance ) {
256 $instance = $old_instance;
257 $new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
258 $instance['title'] = strip_tags($new_instance['title']);
265 * Archives widget class
269 class WP_Widget_Archives extends WP_Widget {
271 function __construct() {
272 $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') );
273 parent::__construct('archives', __('Archives'), $widget_ops);
276 function widget( $args, $instance ) {
278 $c = ! empty( $instance['count'] ) ? '1' : '0';
279 $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
281 /** This filter is documented in wp-includes/default-widgets.php */
282 $title = apply_filters( 'widget_title', empty($instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
286 echo $before_title . $title . $after_title;
290 <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
291 <option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
295 * Filter the arguments for the Archives widget drop-down.
299 * @see wp_get_archives()
301 * @param array $args An array of Archives widget drop-down arguments.
303 wp_get_archives( apply_filters( 'widget_archives_dropdown_args', array(
305 'format' => 'option',
306 'show_post_count' => $c
316 * Filter the arguments for the Archives widget.
320 * @see wp_get_archives()
322 * @param array $args An array of Archives option arguments.
324 wp_get_archives( apply_filters( 'widget_archives_args', array(
326 'show_post_count' => $c
336 function update( $new_instance, $old_instance ) {
337 $instance = $old_instance;
338 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
339 $instance['title'] = strip_tags($new_instance['title']);
340 $instance['count'] = $new_instance['count'] ? 1 : 0;
341 $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
346 function form( $instance ) {
347 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
348 $title = strip_tags($instance['title']);
349 $count = $instance['count'] ? 'checked="checked"' : '';
350 $dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
352 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
354 <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label>
356 <input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label>
365 * Displays log in/out, RSS feed links, etc.
369 class WP_Widget_Meta extends WP_Widget {
371 function __construct() {
372 $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") );
373 parent::__construct('meta', __('Meta'), $widget_ops);
376 function widget( $args, $instance ) {
379 /** This filter is documented in wp-includes/default-widgets.php */
380 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
384 echo $before_title . $title . $after_title;
387 <?php wp_register(); ?>
388 <li><?php wp_loginout(); ?></li>
389 <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>
390 <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
393 * Filter the "Powered by WordPress" text in the Meta widget.
397 * @param string $title_text Default title text for the WordPress.org link.
399 echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
400 esc_url( __( 'https://wordpress.org/' ) ),
401 esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ),
402 _x( 'WordPress.org', 'meta widget link text' )
412 function update( $new_instance, $old_instance ) {
413 $instance = $old_instance;
414 $instance['title'] = strip_tags($new_instance['title']);
419 function form( $instance ) {
420 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
421 $title = strip_tags($instance['title']);
423 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
429 * Calendar widget class
433 class WP_Widget_Calendar extends WP_Widget {
435 function __construct() {
436 $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.') );
437 parent::__construct('calendar', __('Calendar'), $widget_ops);
440 function widget( $args, $instance ) {
443 /** This filter is documented in wp-includes/default-widgets.php */
444 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
448 echo $before_title . $title . $after_title;
449 echo '<div id="calendar_wrap">';
455 function update( $new_instance, $old_instance ) {
456 $instance = $old_instance;
457 $instance['title'] = strip_tags($new_instance['title']);
462 function form( $instance ) {
463 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
464 $title = strip_tags($instance['title']);
466 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
467 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
477 class WP_Widget_Text extends WP_Widget {
479 function __construct() {
480 $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.'));
481 $control_ops = array('width' => 400, 'height' => 350);
482 parent::__construct('text', __('Text'), $widget_ops, $control_ops);
485 function widget( $args, $instance ) {
488 /** This filter is documented in wp-includes/default-widgets.php */
489 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
492 * Filter the content of the Text widget.
496 * @param string $widget_text The widget content.
497 * @param WP_Widget $instance WP_Widget instance.
499 $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
501 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
502 <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
507 function update( $new_instance, $old_instance ) {
508 $instance = $old_instance;
509 $instance['title'] = strip_tags($new_instance['title']);
510 if ( current_user_can('unfiltered_html') )
511 $instance['text'] = $new_instance['text'];
513 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
514 $instance['filter'] = isset($new_instance['filter']);
518 function form( $instance ) {
519 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
520 $title = strip_tags($instance['title']);
521 $text = esc_textarea($instance['text']);
523 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
524 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
526 <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
528 <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
534 * Categories widget class
538 class WP_Widget_Categories extends WP_Widget {
540 function __construct() {
541 $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) );
542 parent::__construct('categories', __('Categories'), $widget_ops);
545 function widget( $args, $instance ) {
548 /** This filter is documented in wp-includes/default-widgets.php */
549 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
551 $c = ! empty( $instance['count'] ) ? '1' : '0';
552 $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
553 $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
557 echo $before_title . $title . $after_title;
559 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
562 $cat_args['show_option_none'] = __('Select Category');
565 * Filter the arguments for the Categories widget drop-down.
569 * @see wp_dropdown_categories()
571 * @param array $cat_args An array of Categories widget drop-down arguments.
573 wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) );
576 <script type='text/javascript'>
578 var dropdown = document.getElementById("cat");
579 function onCatChange() {
580 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
581 location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
584 dropdown.onchange = onCatChange;
593 $cat_args['title_li'] = '';
596 * Filter the arguments for the Categories widget.
600 * @param array $cat_args An array of Categories widget options.
602 wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) );
611 function update( $new_instance, $old_instance ) {
612 $instance = $old_instance;
613 $instance['title'] = strip_tags($new_instance['title']);
614 $instance['count'] = !empty($new_instance['count']) ? 1 : 0;
615 $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
616 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
621 function form( $instance ) {
623 $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
624 $title = esc_attr( $instance['title'] );
625 $count = isset($instance['count']) ? (bool) $instance['count'] :false;
626 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
627 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
629 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
630 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
632 <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
633 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
635 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
636 <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
638 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
639 <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
646 * Recent_Posts widget class
650 class WP_Widget_Recent_Posts extends WP_Widget {
652 function __construct() {
653 $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site’s most recent Posts.") );
654 parent::__construct('recent-posts', __('Recent Posts'), $widget_ops);
655 $this->alt_option_name = 'widget_recent_entries';
657 add_action( 'save_post', array($this, 'flush_widget_cache') );
658 add_action( 'deleted_post', array($this, 'flush_widget_cache') );
659 add_action( 'switch_theme', array($this, 'flush_widget_cache') );
662 function widget($args, $instance) {
664 if ( ! $this->is_preview() ) {
665 $cache = wp_cache_get( 'widget_recent_posts', 'widget' );
668 if ( ! is_array( $cache ) ) {
672 if ( ! isset( $args['widget_id'] ) ) {
673 $args['widget_id'] = $this->id;
676 if ( isset( $cache[ $args['widget_id'] ] ) ) {
677 echo $cache[ $args['widget_id'] ];
684 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
686 /** This filter is documented in wp-includes/default-widgets.php */
687 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
689 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
692 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
695 * Filter the arguments for the Recent Posts widget.
699 * @see WP_Query::get_posts()
701 * @param array $args An array of arguments used to retrieve the recent posts.
703 $r = new WP_Query( apply_filters( 'widget_posts_args', array(
704 'posts_per_page' => $number,
705 'no_found_rows' => true,
706 'post_status' => 'publish',
707 'ignore_sticky_posts' => true
710 if ($r->have_posts()) :
712 <?php echo $before_widget; ?>
713 <?php if ( $title ) echo $before_title . $title . $after_title; ?>
715 <?php while ( $r->have_posts() ) : $r->the_post(); ?>
717 <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a>
718 <?php if ( $show_date ) : ?>
719 <span class="post-date"><?php echo get_the_date(); ?></span>
724 <?php echo $after_widget; ?>
726 // Reset the global $the_post as this query will have stomped on it
731 if ( ! $this->is_preview() ) {
732 $cache[ $args['widget_id'] ] = ob_get_flush();
733 wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
739 function update( $new_instance, $old_instance ) {
740 $instance = $old_instance;
741 $instance['title'] = strip_tags($new_instance['title']);
742 $instance['number'] = (int) $new_instance['number'];
743 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;
744 $this->flush_widget_cache();
746 $alloptions = wp_cache_get( 'alloptions', 'options' );
747 if ( isset($alloptions['widget_recent_entries']) )
748 delete_option('widget_recent_entries');
753 function flush_widget_cache() {
754 wp_cache_delete('widget_recent_posts', 'widget');
757 function form( $instance ) {
758 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
759 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
760 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
762 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
763 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
765 <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
766 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
768 <p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
769 <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p>
775 * Recent_Comments widget class
779 class WP_Widget_Recent_Comments extends WP_Widget {
781 function __construct() {
782 $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site’s most recent comments.' ) );
783 parent::__construct('recent-comments', __('Recent Comments'), $widget_ops);
784 $this->alt_option_name = 'widget_recent_comments';
786 if ( is_active_widget(false, false, $this->id_base) )
787 add_action( 'wp_head', array($this, 'recent_comments_style') );
789 add_action( 'comment_post', array($this, 'flush_widget_cache') );
790 add_action( 'edit_comment', array($this, 'flush_widget_cache') );
791 add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
794 function recent_comments_style() {
797 * Filter the Recent Comments default widget styles.
801 * @param bool $active Whether the widget is active. Default true.
802 * @param string $id_base The widget ID.
804 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
805 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
808 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
812 function flush_widget_cache() {
813 wp_cache_delete('widget_recent_comments', 'widget');
816 function widget( $args, $instance ) {
817 global $comments, $comment;
820 if ( ! $this->is_preview() ) {
821 $cache = wp_cache_get('widget_recent_comments', 'widget');
823 if ( ! is_array( $cache ) ) {
827 if ( ! isset( $args['widget_id'] ) )
828 $args['widget_id'] = $this->id;
830 if ( isset( $cache[ $args['widget_id'] ] ) ) {
831 echo $cache[ $args['widget_id'] ];
835 extract($args, EXTR_SKIP);
838 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
840 /** This filter is documented in wp-includes/default-widgets.php */
841 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
843 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
848 * Filter the arguments for the Recent Comments widget.
852 * @see get_comments()
854 * @param array $comment_args An array of arguments used to retrieve the recent comments.
856 $comments = get_comments( apply_filters( 'widget_comments_args', array(
858 'status' => 'approve',
859 'post_status' => 'publish'
862 $output .= $before_widget;
864 $output .= $before_title . $title . $after_title;
866 $output .= '<ul id="recentcomments">';
868 // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
869 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
870 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
872 foreach ( (array) $comments as $comment) {
873 $output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
877 $output .= $after_widget;
881 if ( ! $this->is_preview() ) {
882 $cache[ $args['widget_id'] ] = $output;
883 wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
887 function update( $new_instance, $old_instance ) {
888 $instance = $old_instance;
889 $instance['title'] = strip_tags($new_instance['title']);
890 $instance['number'] = absint( $new_instance['number'] );
891 $this->flush_widget_cache();
893 $alloptions = wp_cache_get( 'alloptions', 'options' );
894 if ( isset($alloptions['widget_recent_comments']) )
895 delete_option('widget_recent_comments');
900 function form( $instance ) {
901 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
902 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
904 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
905 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
907 <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
908 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
918 class WP_Widget_RSS extends WP_Widget {
920 function __construct() {
921 $widget_ops = array( 'description' => __('Entries from any RSS or Atom feed.') );
922 $control_ops = array( 'width' => 400, 'height' => 200 );
923 parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops );
926 function widget($args, $instance) {
928 if ( isset($instance['error']) && $instance['error'] )
931 extract($args, EXTR_SKIP);
933 $url = ! empty( $instance['url'] ) ? $instance['url'] : '';
934 while ( stristr($url, 'http') != $url )
935 $url = substr($url, 1);
940 // self-url destruction sequence
941 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) )
944 $rss = fetch_feed($url);
945 $title = $instance['title'];
949 if ( ! is_wp_error($rss) ) {
950 $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
952 $title = esc_html(strip_tags($rss->get_title()));
953 $link = esc_url(strip_tags($rss->get_permalink()));
954 while ( stristr($link, 'http') != $link )
955 $link = substr($link, 1);
959 $title = empty($desc) ? __('Unknown Feed') : $desc;
961 /** This filter is documented in wp-includes/default-widgets.php */
962 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
964 $url = esc_url(strip_tags($url));
965 $icon = includes_url('images/rss.png');
967 $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>";
971 echo $before_title . $title . $after_title;
972 wp_widget_rss_output( $rss, $instance );
975 if ( ! is_wp_error($rss) )
980 function update($new_instance, $old_instance) {
981 $testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
982 return wp_widget_rss_process( $new_instance, $testurl );
985 function form($instance) {
987 if ( empty($instance) )
988 $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
989 $instance['number'] = $this->number;
991 wp_widget_rss_form( $instance );
996 * Display the RSS entries in a list.
1000 * @param string|array|object $rss RSS url.
1001 * @param array $args Widget arguments.
1003 function wp_widget_rss_output( $rss, $args = array() ) {
1004 if ( is_string( $rss ) ) {
1005 $rss = fetch_feed($rss);
1006 } elseif ( is_array($rss) && isset($rss['url']) ) {
1008 $rss = fetch_feed($rss['url']);
1009 } elseif ( !is_object($rss) ) {
1013 if ( is_wp_error($rss) ) {
1014 if ( is_admin() || current_user_can('manage_options') )
1015 echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
1019 $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 );
1020 $args = wp_parse_args( $args, $default_args );
1021 extract( $args, EXTR_SKIP );
1023 $items = (int) $items;
1024 if ( $items < 1 || 20 < $items )
1026 $show_summary = (int) $show_summary;
1027 $show_author = (int) $show_author;
1028 $show_date = (int) $show_date;
1030 if ( !$rss->get_item_quantity() ) {
1031 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
1038 foreach ( $rss->get_items(0, $items) as $item ) {
1039 $link = $item->get_link();
1040 while ( stristr($link, 'http') != $link )
1041 $link = substr($link, 1);
1042 $link = esc_url(strip_tags($link));
1043 $title = esc_attr(strip_tags($item->get_title()));
1044 if ( empty($title) )
1045 $title = __('Untitled');
1047 $desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
1048 $desc = esc_attr( strip_tags( $desc ) );
1049 $desc = trim( str_replace( array( "\n", "\r" ), ' ', $desc ) );
1050 $desc = wp_html_excerpt( $desc, 360 );
1053 if ( $show_summary ) {
1056 // Append ellipsis. Change existing [...] to […].
1057 if ( '[...]' == substr( $summary, -5 ) ) {
1058 $summary = substr( $summary, 0, -5 ) . '[…]';
1059 } elseif ( '[…]' != substr( $summary, -10 ) && $desc !== $summary ) {
1060 $summary .= ' […]';
1063 $summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
1068 $date = $item->get_date( 'U' );
1071 $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
1076 if ( $show_author ) {
1077 $author = $item->get_author();
1078 if ( is_object($author) ) {
1079 $author = $author->get_name();
1080 $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
1084 if ( $link == '' ) {
1085 echo "<li>$title{$date}{$summary}{$author}</li>";
1086 } elseif ( $show_summary ) {
1087 echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>";
1089 echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$author}</li>";
1098 * Display RSS widget options form.
1100 * The options for what fields are displayed for the RSS form are all booleans
1101 * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
1106 * @param array|string $args Values for input fields.
1107 * @param array $inputs Override default display options.
1109 function wp_widget_rss_form( $args, $inputs = null ) {
1111 $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
1112 $inputs = wp_parse_args( $inputs, $default_inputs );
1114 extract( $inputs, EXTR_SKIP );
1116 $number = esc_attr( $number );
1117 $title = esc_attr( $title );
1118 $url = esc_url( $url );
1119 $items = (int) $items;
1120 if ( $items < 1 || 20 < $items )
1122 $show_summary = (int) $show_summary;
1123 $show_author = (int) $show_author;
1124 $show_date = (int) $show_date;
1126 if ( !empty($error) )
1127 echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>';
1129 if ( $inputs['url'] ) :
1131 <p><label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?></label>
1132 <input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" /></p>
1133 <?php endif; if ( $inputs['title'] ) : ?>
1134 <p><label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?></label>
1135 <input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /></p>
1136 <?php endif; if ( $inputs['items'] ) : ?>
1137 <p><label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?></label>
1138 <select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
1140 for ( $i = 1; $i <= 20; ++$i )
1141 echo "<option value='$i' " . selected( $items, $i, false ) . ">$i</option>";
1144 <?php endif; if ( $inputs['show_summary'] ) : ?>
1145 <p><input id="rss-show-summary-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_summary]" type="checkbox" value="1" <?php if ( $show_summary ) echo 'checked="checked"'; ?>/>
1146 <label for="rss-show-summary-<?php echo $number; ?>"><?php _e('Display item content?'); ?></label></p>
1147 <?php endif; if ( $inputs['show_author'] ) : ?>
1148 <p><input id="rss-show-author-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_author]" type="checkbox" value="1" <?php if ( $show_author ) echo 'checked="checked"'; ?>/>
1149 <label for="rss-show-author-<?php echo $number; ?>"><?php _e('Display item author if available?'); ?></label></p>
1150 <?php endif; if ( $inputs['show_date'] ) : ?>
1151 <p><input id="rss-show-date-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_date]" type="checkbox" value="1" <?php if ( $show_date ) echo 'checked="checked"'; ?>/>
1152 <label for="rss-show-date-<?php echo $number; ?>"><?php _e('Display item date?'); ?></label></p>
1155 foreach ( array_keys($default_inputs) as $input ) :
1156 if ( 'hidden' === $inputs[$input] ) :
1157 $id = str_replace( '_', '-', $input );
1159 <input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][<?php echo $input; ?>]" value="<?php echo $$input; ?>" />
1166 * Process RSS feed widget data and optionally retrieve feed items.
1168 * The feed widget can not have more than 20 items or it will reset back to the
1169 * default, which is 10.
1171 * The resulting array has the feed title, feed url, feed link (from channel),
1172 * feed items, error (if any), and whether to show summary, author, and date.
1173 * All respectively in the order of the array elements.
1177 * @param array $widget_rss RSS widget feed data. Expects unescaped data.
1178 * @param bool $check_feed Optional, default is true. Whether to check feed for errors.
1181 function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
1182 $items = (int) $widget_rss['items'];
1183 if ( $items < 1 || 20 < $items )
1185 $url = esc_url_raw( strip_tags( $widget_rss['url'] ) );
1186 $title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
1187 $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
1188 $show_author = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] :0;
1189 $show_date = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
1191 if ( $check_feed ) {
1192 $rss = fetch_feed($url);
1195 if ( is_wp_error($rss) ) {
1196 $error = $rss->get_error_message();
1198 $link = esc_url(strip_tags($rss->get_permalink()));
1199 while ( stristr($link, 'http') != $link )
1200 $link = substr($link, 1);
1207 return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
1211 * Tag cloud widget class
1215 class WP_Widget_Tag_Cloud extends WP_Widget {
1217 function __construct() {
1218 $widget_ops = array( 'description' => __( "A cloud of your most used tags.") );
1219 parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops);
1222 function widget( $args, $instance ) {
1224 $current_taxonomy = $this->_get_current_taxonomy($instance);
1225 if ( !empty($instance['title']) ) {
1226 $title = $instance['title'];
1228 if ( 'post_tag' == $current_taxonomy ) {
1229 $title = __('Tags');
1231 $tax = get_taxonomy($current_taxonomy);
1232 $title = $tax->labels->name;
1236 /** This filter is documented in wp-includes/default-widgets.php */
1237 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
1239 echo $before_widget;
1241 echo $before_title . $title . $after_title;
1242 echo '<div class="tagcloud">';
1245 * Filter the taxonomy used in the Tag Cloud widget.
1248 * @since 3.0.0 Added taxonomy drop-down.
1250 * @see wp_tag_cloud()
1252 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'.
1254 wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
1255 'taxonomy' => $current_taxonomy
1262 function update( $new_instance, $old_instance ) {
1263 $instance['title'] = strip_tags(stripslashes($new_instance['title']));
1264 $instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
1268 function form( $instance ) {
1269 $current_taxonomy = $this->_get_current_taxonomy($instance);
1271 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
1272 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
1273 <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>
1274 <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">
1275 <?php foreach ( get_taxonomies() as $taxonomy ) :
1276 $tax = get_taxonomy($taxonomy);
1277 if ( !$tax->show_tagcloud || empty($tax->labels->name) )
1280 <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>
1281 <?php endforeach; ?>
1285 function _get_current_taxonomy($instance) {
1286 if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
1287 return $instance['taxonomy'];
1294 * Navigation Menu widget class
1298 class WP_Nav_Menu_Widget extends WP_Widget {
1300 function __construct() {
1301 $widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') );
1302 parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
1305 function widget($args, $instance) {
1307 $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
1312 /** This filter is documented in wp-includes/default-widgets.php */
1313 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
1315 echo $args['before_widget'];
1317 if ( !empty($instance['title']) )
1318 echo $args['before_title'] . $instance['title'] . $args['after_title'];
1320 wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
1322 echo $args['after_widget'];
1325 function update( $new_instance, $old_instance ) {
1326 $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
1327 $instance['nav_menu'] = (int) $new_instance['nav_menu'];
1331 function form( $instance ) {
1332 $title = isset( $instance['title'] ) ? $instance['title'] : '';
1333 $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
1336 $menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
1338 // If no menus exists, direct the user to go and create some.
1340 echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
1345 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
1346 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
1349 <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
1350 <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
1351 <option value="0"><?php _e( '— Select —' ) ?></option>
1353 foreach ( $menus as $menu ) {
1354 echo '<option value="' . $menu->term_id . '"'
1355 . selected( $nav_menu, $menu->term_id, false )
1356 . '>'. esc_html( $menu->name ) . '</option>';
1366 * Register all of the default WordPress widgets on startup.
1368 * Calls 'widgets_init' action after all of the WordPress widgets have been
1373 function wp_widgets_init() {
1374 if ( !is_blog_installed() )
1377 register_widget('WP_Widget_Pages');
1379 register_widget('WP_Widget_Calendar');
1381 register_widget('WP_Widget_Archives');
1383 if ( get_option( 'link_manager_enabled' ) )
1384 register_widget('WP_Widget_Links');
1386 register_widget('WP_Widget_Meta');
1388 register_widget('WP_Widget_Search');
1390 register_widget('WP_Widget_Text');
1392 register_widget('WP_Widget_Categories');
1394 register_widget('WP_Widget_Recent_Posts');
1396 register_widget('WP_Widget_Recent_Comments');
1398 register_widget('WP_Widget_RSS');
1400 register_widget('WP_Widget_Tag_Cloud');
1402 register_widget('WP_Nav_Menu_Widget');
1405 * Fires after all default WordPress widgets have been registered.
1409 do_action( 'widgets_init' );
1412 add_action('init', 'wp_widgets_init', 1);