14
class WP_Widget_Pages extends WP_Widget {
16
public 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
public function widget( $args, $instance ) {
24
* Filter the widget title.
28
* @param string $title The widget title. Default 'Pages'.
29
* @param array $instance An array of the widget's settings.
30
* @param mixed $id_base The widget ID.
32
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
34
$sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
35
$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
37
if ( $sortby == 'menu_order' )
38
$sortby = 'menu_order, post_title';
41
* Filter the arguments for the Pages widget.
45
* @see wp_list_pages()
47
* @param array $args An array of arguments to retrieve the pages list.
49
$out = wp_list_pages( apply_filters( 'widget_pages_args', array(
52
'sort_column' => $sortby,
56
if ( ! empty( $out ) ) {
57
echo $args['before_widget'];
59
echo $args['before_title'] . $title . $args['after_title'];
66
echo $args['after_widget'];
70
public 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
public 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
public function __construct() {
117
$widget_ops = array('description' => __( "Your blogroll" ) );
118
parent::__construct('links', __('Links'), $widget_ops);
121
public function widget( $args, $instance ) {
123
$show_description = isset($instance['description']) ? $instance['description'] : false;
124
$show_name = isset($instance['name']) ? $instance['name'] : false;
125
$show_rating = isset($instance['rating']) ? $instance['rating'] : false;
126
$show_images = isset($instance['images']) ? $instance['images'] : true;
127
$category = isset($instance['category']) ? $instance['category'] : false;
128
$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
129
$order = $orderby == 'rating' ? 'DESC' : 'ASC';
130
$limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
132
$before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] );
135
* Filter the arguments for the Links widget.
139
* @see wp_list_bookmarks()
141
* @param array $args An array of arguments to retrieve the links list.
143
wp_list_bookmarks( apply_filters( 'widget_links_args', array(
144
'title_before' => $args['before_title'], 'title_after' => $args['after_title'],
145
'category_before' => $before_widget, 'category_after' => $args['after_widget'],
146
'show_images' => $show_images, 'show_description' => $show_description,
147
'show_name' => $show_name, 'show_rating' => $show_rating,
148
'category' => $category, 'class' => 'linkcat widget',
149
'orderby' => $orderby, 'order' => $order,
154
public function update( $new_instance, $old_instance ) {
155
$new_instance = (array) $new_instance;
156
$instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );
157
foreach ( $instance as $field => $val ) {
158
if ( isset($new_instance[$field]) )
159
$instance[$field] = 1;
162
$instance['orderby'] = 'name';
163
if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
164
$instance['orderby'] = $new_instance['orderby'];
166
$instance['category'] = intval( $new_instance['category'] );
167
$instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
172
public function form( $instance ) {
175
$instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
176
$link_cats = get_terms( 'link_category' );
177
if ( ! $limit = intval( $instance['limit'] ) )
181
<label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>
182
<select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
183
<option value=""><?php _ex('All Links', 'links widget'); ?></option>
185
foreach ( $link_cats as $link_cat ) {
186
echo '<option value="' . intval( $link_cat->term_id ) . '"'
187
. selected( $instance['category'], $link_cat->term_id, false )
188
. '>' . $link_cat->name . "</option>\n";
192
<label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>
193
<select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
194
<option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>
195
<option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>
196
<option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>
197
<option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option>
201
<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'); ?>" />
202
<label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
203
<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'); ?>" />
204
<label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
205
<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'); ?>" />
206
<label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
207
<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'); ?>" />
208
<label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
211
<label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>
212
<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" />
219
* Search widget class
223
class WP_Widget_Search extends WP_Widget {
225
public function __construct() {
226
$widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site.") );
227
parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
230
public function widget( $args, $instance ) {
232
/** This filter is documented in wp-includes/default-widgets.php */
233
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
235
echo $args['before_widget'];
237
echo $args['before_title'] . $title . $args['after_title'];
240
// Use current theme search form if it exists
243
echo $args['after_widget'];
246
public function form( $instance ) {
247
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
248
$title = $instance['title'];
250
<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>
254
public function update( $new_instance, $old_instance ) {
255
$instance = $old_instance;
256
$new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
257
$instance['title'] = strip_tags($new_instance['title']);
264
* Archives widget class
268
class WP_Widget_Archives extends WP_Widget {
270
public function __construct() {
271
$widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') );
272
parent::__construct('archives', __('Archives'), $widget_ops);
275
public function widget( $args, $instance ) {
276
$c = ! empty( $instance['count'] ) ? '1' : '0';
277
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
279
/** This filter is documented in wp-includes/default-widgets.php */
280
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
282
echo $args['before_widget'];
284
echo $args['before_title'] . $title . $args['after_title'];
289
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
290
<option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
294
* Filter the arguments for the Archives widget drop-down.
298
* @see wp_get_archives()
300
* @param array $args An array of Archives widget drop-down arguments.
302
wp_get_archives( apply_filters( 'widget_archives_dropdown_args', array(
304
'format' => 'option',
305
'show_post_count' => $c
315
* Filter the arguments for the Archives widget.
319
* @see wp_get_archives()
321
* @param array $args An array of Archives option arguments.
323
wp_get_archives( apply_filters( 'widget_archives_args', array(
325
'show_post_count' => $c
332
echo $args['after_widget'];
335
public function update( $new_instance, $old_instance ) {
336
$instance = $old_instance;
337
$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
338
$instance['title'] = strip_tags($new_instance['title']);
339
$instance['count'] = $new_instance['count'] ? 1 : 0;
340
$instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
345
public function form( $instance ) {
346
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
347
$title = strip_tags($instance['title']);
348
$count = $instance['count'] ? 'checked="checked"' : '';
349
$dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
351
<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>
353
<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>
355
<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>
364
* Displays log in/out, RSS feed links, etc.
368
class WP_Widget_Meta extends WP_Widget {
370
public function __construct() {
371
$widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") );
372
parent::__construct('meta', __('Meta'), $widget_ops);
375
public function widget( $args, $instance ) {
377
/** This filter is documented in wp-includes/default-widgets.php */
378
$title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
380
echo $args['before_widget'];
382
echo $args['before_title'] . $title . $args['after_title'];
386
<?php wp_register(); ?>
387
<li><?php wp_loginout(); ?></li>
388
<li><a href="<?php bloginfo('rss2_url'); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
389
<li><a href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
392
* Filter the "Powered by WordPress" text in the Meta widget.
396
* @param string $title_text Default title text for the WordPress.org link.
398
echo apply_filters( 'widget_meta_poweredby', sprintf( '<li><a href="%s" title="%s">%s</a></li>',
399
esc_url( __( 'https://wordpress.org/' ) ),
400
esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ),
401
_x( 'WordPress.org', 'meta widget link text' )
408
echo $args['after_widget'];
411
public function update( $new_instance, $old_instance ) {
412
$instance = $old_instance;
413
$instance['title'] = strip_tags($new_instance['title']);
418
public function form( $instance ) {
419
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
420
$title = strip_tags($instance['title']);
422
<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>
428
* Calendar widget class
432
class WP_Widget_Calendar extends WP_Widget {
434
public function __construct() {
435
$widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.') );
436
parent::__construct('calendar', __('Calendar'), $widget_ops);
439
public function widget( $args, $instance ) {
441
/** This filter is documented in wp-includes/default-widgets.php */
442
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
444
echo $args['before_widget'];
446
echo $args['before_title'] . $title . $args['after_title'];
448
echo '<div id="calendar_wrap">';
451
echo $args['after_widget'];
454
public function update( $new_instance, $old_instance ) {
455
$instance = $old_instance;
456
$instance['title'] = strip_tags($new_instance['title']);
461
public function form( $instance ) {
462
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
463
$title = strip_tags($instance['title']);
465
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
466
<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>
476
class WP_Widget_Text extends WP_Widget {
478
public function __construct() {
479
$widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.'));
480
$control_ops = array('width' => 400, 'height' => 350);
481
parent::__construct('text', __('Text'), $widget_ops, $control_ops);
484
public function widget( $args, $instance ) {
486
/** This filter is documented in wp-includes/default-widgets.php */
487
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
490
* Filter the content of the Text widget.
494
* @param string $widget_text The widget content.
495
* @param WP_Widget $instance WP_Widget instance.
497
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
498
echo $args['before_widget'];
499
if ( ! empty( $title ) ) {
500
echo $args['before_title'] . $title . $args['after_title'];
502
<div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
504
echo $args['after_widget'];
507
public 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
public 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
public function __construct() {
541
$widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) );
542
parent::__construct('categories', __('Categories'), $widget_ops);
545
public function widget( $args, $instance ) {
547
/** This filter is documented in wp-includes/default-widgets.php */
548
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
550
$c = ! empty( $instance['count'] ) ? '1' : '0';
551
$h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
552
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
554
echo $args['before_widget'];
556
echo $args['before_title'] . $title . $args['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 ) );
608
echo $args['after_widget'];
611
public 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
public 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
public 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
public 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'] ];
683
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
685
/** This filter is documented in wp-includes/default-widgets.php */
686
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
688
$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
691
$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
694
* Filter the arguments for the Recent Posts widget.
698
* @see WP_Query::get_posts()
700
* @param array $args An array of arguments used to retrieve the recent posts.
702
$r = new WP_Query( apply_filters( 'widget_posts_args', array(
703
'posts_per_page' => $number,
704
'no_found_rows' => true,
705
'post_status' => 'publish',
706
'ignore_sticky_posts' => true
709
if ($r->have_posts()) :
711
<?php echo $args['before_widget']; ?>
712
<?php if ( $title ) {
713
echo $args['before_title'] . $title . $args['after_title'];
716
<?php while ( $r->have_posts() ) : $r->the_post(); ?>
718
<a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a>
719
<?php if ( $show_date ) : ?>
720
<span class="post-date"><?php echo get_the_date(); ?></span>
725
<?php echo $args['after_widget']; ?>
727
// Reset the global $the_post as this query will have stomped on it
732
if ( ! $this->is_preview() ) {
733
$cache[ $args['widget_id'] ] = ob_get_flush();
734
wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
740
public function update( $new_instance, $old_instance ) {
741
$instance = $old_instance;
742
$instance['title'] = strip_tags($new_instance['title']);
743
$instance['number'] = (int) $new_instance['number'];
744
$instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;
745
$this->flush_widget_cache();
747
$alloptions = wp_cache_get( 'alloptions', 'options' );
748
if ( isset($alloptions['widget_recent_entries']) )
749
delete_option('widget_recent_entries');
754
public function flush_widget_cache() {
755
wp_cache_delete('widget_recent_posts', 'widget');
758
public function form( $instance ) {
759
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
760
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
761
$show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
763
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
764
<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>
766
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
767
<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>
769
<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' ); ?>" />
770
<label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p>
776
* Recent_Comments widget class
780
class WP_Widget_Recent_Comments extends WP_Widget {
782
public function __construct() {
783
$widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site’s most recent comments.' ) );
784
parent::__construct('recent-comments', __('Recent Comments'), $widget_ops);
785
$this->alt_option_name = 'widget_recent_comments';
787
if ( is_active_widget(false, false, $this->id_base) )
788
add_action( 'wp_head', array($this, 'recent_comments_style') );
790
add_action( 'comment_post', array($this, 'flush_widget_cache') );
791
add_action( 'edit_comment', array($this, 'flush_widget_cache') );
792
add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
795
public function recent_comments_style() {
798
* Filter the Recent Comments default widget styles.
802
* @param bool $active Whether the widget is active. Default true.
803
* @param string $id_base The widget ID.
805
if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
806
|| ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
809
<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
813
public function flush_widget_cache() {
814
wp_cache_delete('widget_recent_comments', 'widget');
817
public function widget( $args, $instance ) {
818
global $comments, $comment;
821
if ( ! $this->is_preview() ) {
822
$cache = wp_cache_get('widget_recent_comments', 'widget');
824
if ( ! is_array( $cache ) ) {
828
if ( ! isset( $args['widget_id'] ) )
829
$args['widget_id'] = $this->id;
831
if ( isset( $cache[ $args['widget_id'] ] ) ) {
832
echo $cache[ $args['widget_id'] ];
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 .= $args['before_widget'];
864
$output .= $args['before_title'] . $title . $args['after_title'];
867
$output .= '<ul id="recentcomments">';
869
// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
870
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
871
_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
873
foreach ( (array) $comments as $comment) {
874
$output .= '<li class="recentcomments">';
875
/* translators: comments widget: 1: comment author, 2: post link */
876
$output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
877
'<span class="comment-author-link">' . get_comment_author_link() . '</span>',
878
'<a href="' . esc_url( get_comment_link( $comment->comment_ID ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>'
884
$output .= $args['after_widget'];
888
if ( ! $this->is_preview() ) {
889
$cache[ $args['widget_id'] ] = $output;
890
wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
894
public function update( $new_instance, $old_instance ) {
895
$instance = $old_instance;
896
$instance['title'] = strip_tags($new_instance['title']);
897
$instance['number'] = absint( $new_instance['number'] );
898
$this->flush_widget_cache();
900
$alloptions = wp_cache_get( 'alloptions', 'options' );
901
if ( isset($alloptions['widget_recent_comments']) )
902
delete_option('widget_recent_comments');
907
public function form( $instance ) {
908
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
909
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
911
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
912
<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>
914
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
915
<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>
925
class WP_Widget_RSS extends WP_Widget {
927
public function __construct() {
928
$widget_ops = array( 'description' => __('Entries from any RSS or Atom feed.') );
929
$control_ops = array( 'width' => 400, 'height' => 200 );
930
parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops );
933
public function widget($args, $instance) {
935
if ( isset($instance['error']) && $instance['error'] )
938
$url = ! empty( $instance['url'] ) ? $instance['url'] : '';
939
while ( stristr($url, 'http') != $url )
940
$url = substr($url, 1);
945
// self-url destruction sequence
946
if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) )
949
$rss = fetch_feed($url);
950
$title = $instance['title'];
954
if ( ! is_wp_error($rss) ) {
955
$desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
957
$title = esc_html(strip_tags($rss->get_title()));
958
$link = esc_url(strip_tags($rss->get_permalink()));
959
while ( stristr($link, 'http') != $link )
960
$link = substr($link, 1);
964
$title = empty($desc) ? __('Unknown Feed') : $desc;
966
/** This filter is documented in wp-includes/default-widgets.php */
967
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
969
$url = esc_url(strip_tags($url));
970
$icon = includes_url('images/rss.png');
972
$title = "<a class='rsswidget' href='$url'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link'>$title</a>";
974
echo $args['before_widget'];
976
echo $args['before_title'] . $title . $args['after_title'];
978
wp_widget_rss_output( $rss, $instance );
979
echo $args['after_widget'];
981
if ( ! is_wp_error($rss) )
986
public function update($new_instance, $old_instance) {
987
$testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
988
return wp_widget_rss_process( $new_instance, $testurl );
991
public function form($instance) {
993
if ( empty($instance) )
994
$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
995
$instance['number'] = $this->number;
997
wp_widget_rss_form( $instance );
1002
* Display the RSS entries in a list.
1006
* @param string|array|object $rss RSS url.
1007
* @param array $args Widget arguments.
1009
function wp_widget_rss_output( $rss, $args = array() ) {
1010
if ( is_string( $rss ) ) {
1011
$rss = fetch_feed($rss);
1012
} elseif ( is_array($rss) && isset($rss['url']) ) {
1014
$rss = fetch_feed($rss['url']);
1015
} elseif ( !is_object($rss) ) {
1019
if ( is_wp_error($rss) ) {
1020
if ( is_admin() || current_user_can('manage_options') )
1021
echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
1025
$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 );
1026
$args = wp_parse_args( $args, $default_args );
1028
$items = (int) $args['items'];
1029
if ( $items < 1 || 20 < $items )
1031
$show_summary = (int) $args['show_summary'];
1032
$show_author = (int) $args['show_author'];
1033
$show_date = (int) $args['show_date'];
1035
if ( !$rss->get_item_quantity() ) {
1036
echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
1043
foreach ( $rss->get_items( 0, $items ) as $item ) {
1044
$link = $item->get_link();
1045
while ( stristr( $link, 'http' ) != $link ) {
1046
$link = substr( $link, 1 );
1048
$link = esc_url( strip_tags( $link ) );
1050
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
1051
if ( empty( $title ) ) {
1052
$title = __( 'Untitled' );
1055
$desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
1056
$desc = esc_attr( wp_trim_words( $desc, 55, ' […]' ) );
1059
if ( $show_summary ) {
1062
// Change existing [...] to […].
1063
if ( '[...]' == substr( $summary, -5 ) ) {
1064
$summary = substr( $summary, 0, -5 ) . '[…]';
1067
$summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
1072
$date = $item->get_date( 'U' );
1075
$date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
1080
if ( $show_author ) {
1081
$author = $item->get_author();
1082
if ( is_object($author) ) {
1083
$author = $author->get_name();
1084
$author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
1088
if ( $link == '' ) {
1089
echo "<li>$title{$date}{$summary}{$author}</li>";
1090
} elseif ( $show_summary ) {
1091
echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>";
1093
echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$author}</li>";
1102
* Display RSS widget options form.
1104
* The options for what fields are displayed for the RSS form are all booleans
1105
* and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
1110
* @param array|string $args Values for input fields.
1111
* @param array $inputs Override default display options.
1113
function wp_widget_rss_form( $args, $inputs = null ) {
1114
$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
1115
$inputs = wp_parse_args( $inputs, $default_inputs );
1117
$args['number'] = esc_attr( $args['number'] );
1118
$args['title'] = isset( $args['title'] ) ? esc_attr( $args['title'] ) : '';
1119
$args['url'] = isset( $args['url'] ) ? esc_url( $args['url'] ) : '';
1120
$args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;
1122
if ( $args['items'] < 1 || 20 < $args['items'] ) {
1123
$args['items'] = 10;
1126
$args['show_summary'] = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary'];
1127
$args['show_author'] = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author'];
1128
$args['show_date'] = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date'];
1130
if ( ! empty( $args['error'] ) ) {
1131
echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), $args['error'] ) . '</strong></p>';
1134
if ( $inputs['url'] ) :
1136
<p><label for="rss-url-<?php echo $args['number']; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label>
1137
<input class="widefat" id="rss-url-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][url]" type="text" value="<?php echo $args['url']; ?>" /></p>
1138
<?php endif; if ( $inputs['title'] ) : ?>
1139
<p><label for="rss-title-<?php echo $args['number']; ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label>
1140
<input class="widefat" id="rss-title-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][title]" type="text" value="<?php echo $args['title']; ?>" /></p>
1141
<?php endif; if ( $inputs['items'] ) : ?>
1142
<p><label for="rss-items-<?php echo $args['number']; ?>"><?php _e( 'How many items would you like to display?' ); ?></label>
1143
<select id="rss-items-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][items]">
1145
for ( $i = 1; $i <= 20; ++$i ) {
1146
echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";
1150
<?php endif; if ( $inputs['show_summary'] ) : ?>
1151
<p><input id="rss-show-summary-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> />
1152
<label for="rss-show-summary-<?php echo $args['number']; ?>"><?php _e( 'Display item content?' ); ?></label></p>
1153
<?php endif; if ( $inputs['show_author'] ) : ?>
1154
<p><input id="rss-show-author-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> />
1155
<label for="rss-show-author-<?php echo $args['number']; ?>"><?php _e( 'Display item author if available?' ); ?></label></p>
1156
<?php endif; if ( $inputs['show_date'] ) : ?>
1157
<p><input id="rss-show-date-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>
1158
<label for="rss-show-date-<?php echo $args['number']; ?>"><?php _e( 'Display item date?' ); ?></label></p>
1161
foreach ( array_keys($default_inputs) as $input ) :
1162
if ( 'hidden' === $inputs[$input] ) :
1163
$id = str_replace( '_', '-', $input );
1165
<input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][<?php echo $input; ?>]" value="<?php echo $args[ $input ]; ?>" />
1172
* Process RSS feed widget data and optionally retrieve feed items.
1174
* The feed widget can not have more than 20 items or it will reset back to the
1175
* default, which is 10.
1177
* The resulting array has the feed title, feed url, feed link (from channel),
1178
* feed items, error (if any), and whether to show summary, author, and date.
1179
* All respectively in the order of the array elements.
1183
* @param array $widget_rss RSS widget feed data. Expects unescaped data.
1184
* @param bool $check_feed Optional, default is true. Whether to check feed for errors.
1187
function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
1188
$items = (int) $widget_rss['items'];
1189
if ( $items < 1 || 20 < $items )
1191
$url = esc_url_raw( strip_tags( $widget_rss['url'] ) );
1192
$title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
1193
$show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
1194
$show_author = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] :0;
1195
$show_date = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
1197
if ( $check_feed ) {
1198
$rss = fetch_feed($url);
1201
if ( is_wp_error($rss) ) {
1202
$error = $rss->get_error_message();
1204
$link = esc_url(strip_tags($rss->get_permalink()));
1205
while ( stristr($link, 'http') != $link )
1206
$link = substr($link, 1);
1213
return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
1217
* Tag cloud widget class
1221
class WP_Widget_Tag_Cloud extends WP_Widget {
1223
public function __construct() {
1224
$widget_ops = array( 'description' => __( "A cloud of your most used tags.") );
1225
parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops);
1228
public function widget( $args, $instance ) {
1229
$current_taxonomy = $this->_get_current_taxonomy($instance);
1230
if ( !empty($instance['title']) ) {
1231
$title = $instance['title'];
1233
if ( 'post_tag' == $current_taxonomy ) {
1234
$title = __('Tags');
1236
$tax = get_taxonomy($current_taxonomy);
1237
$title = $tax->labels->name;
1241
/** This filter is documented in wp-includes/default-widgets.php */
1242
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
1244
echo $args['before_widget'];
1246
echo $args['before_title'] . $title . $args['after_title'];
1248
echo '<div class="tagcloud">';
1251
* Filter the taxonomy used in the Tag Cloud widget.
1254
* @since 3.0.0 Added taxonomy drop-down.
1256
* @see wp_tag_cloud()
1258
* @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'.
1260
wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
1261
'taxonomy' => $current_taxonomy
1265
echo $args['after_widget'];
1268
public function update( $new_instance, $old_instance ) {
1269
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
1270
$instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
1274
public function form( $instance ) {
1275
$current_taxonomy = $this->_get_current_taxonomy($instance);
1277
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
1278
<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>
1279
<p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>
1280
<select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">
1281
<?php foreach ( get_taxonomies() as $taxonomy ) :
1282
$tax = get_taxonomy($taxonomy);
1283
if ( !$tax->show_tagcloud || empty($tax->labels->name) )
1286
<option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>
1287
<?php endforeach; ?>
1291
public function _get_current_taxonomy($instance) {
1292
if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
1293
return $instance['taxonomy'];
1300
* Navigation Menu widget class
1304
class WP_Nav_Menu_Widget extends WP_Widget {
1306
public function __construct() {
1307
$widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') );
1308
parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
1311
public function widget($args, $instance) {
1313
$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
1318
/** This filter is documented in wp-includes/default-widgets.php */
1319
$instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
1321
echo $args['before_widget'];
1323
if ( !empty($instance['title']) )
1324
echo $args['before_title'] . $instance['title'] . $args['after_title'];
1326
wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
1328
echo $args['after_widget'];
1331
public function update( $new_instance, $old_instance ) {
1332
$instance = array();
1333
if ( ! empty( $new_instance['title'] ) ) {
1334
$instance['title'] = strip_tags( stripslashes($new_instance['title']) );
1336
if ( ! empty( $new_instance['nav_menu'] ) ) {
1337
$instance['nav_menu'] = (int) $new_instance['nav_menu'];
1342
public function form( $instance ) {
1343
$title = isset( $instance['title'] ) ? $instance['title'] : '';
1344
$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
1347
$menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
1349
// If no menus exists, direct the user to go and create some.
1351
echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
1356
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
1357
<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; ?>" />
1360
<label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
1361
<select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
1362
<option value="0"><?php _e( '— Select —' ) ?></option>
1364
foreach ( $menus as $menu ) {
1365
echo '<option value="' . $menu->term_id . '"'
1366
. selected( $nav_menu, $menu->term_id, false )
1367
. '>'. esc_html( $menu->name ) . '</option>';
1377
* Register all of the default WordPress widgets on startup.
1379
* Calls 'widgets_init' action after all of the WordPress widgets have been
1384
function wp_widgets_init() {
1385
if ( !is_blog_installed() )
1388
register_widget('WP_Widget_Pages');
1390
register_widget('WP_Widget_Calendar');
1392
register_widget('WP_Widget_Archives');
1394
if ( get_option( 'link_manager_enabled' ) )
1395
register_widget('WP_Widget_Links');
1397
register_widget('WP_Widget_Meta');
1399
register_widget('WP_Widget_Search');
1401
register_widget('WP_Widget_Text');
1403
register_widget('WP_Widget_Categories');
1405
register_widget('WP_Widget_Recent_Posts');
1407
register_widget('WP_Widget_Recent_Comments');
1409
register_widget('WP_Widget_RSS');
1411
register_widget('WP_Widget_Tag_Cloud');
1413
register_widget('WP_Nav_Menu_Widget');
1416
* Fires after all default WordPress widgets have been registered.
1420
do_action( 'widgets_init' );
1423
add_action('init', 'wp_widgets_init', 1);