~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-includes/default-widgets.php

  • Committer: Andrew Glen-Young
  • Date: 2011-03-08 14:47:51 UTC
  • Revision ID: andrew.glen-young@canonical.com-20110308144751-1n6spqgayztf9h77
[AGY] import 3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
 
3
2
/**
4
3
 * Default Widgets
5
4
 *
262
261
?>
263
262
                <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>
264
263
                <p>
 
264
                        <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>
 
265
                        <br/>
265
266
                        <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>
266
 
                        <br />
267
 
                        <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 a drop down'); ?></label>
268
267
                </p>
269
268
<?php
270
269
        }
399
398
        function form( $instance ) {
400
399
                $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
401
400
                $title = strip_tags($instance['title']);
402
 
                $text = format_to_edit($instance['text']);
 
401
                $text = esc_textarea($instance['text']);
403
402
?>
404
403
                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
405
404
                <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>
491
490
                <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>
492
491
 
493
492
                <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 ); ?> />
494
 
                <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Show as dropdown' ); ?></label><br />
 
493
                <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
495
494
 
496
495
                <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
497
496
                <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
535
534
                extract($args);
536
535
 
537
536
                $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
538
 
                if ( !$number = (int) $instance['number'] )
539
 
                        $number = 10;
540
 
                else if ( $number < 1 )
541
 
                        $number = 1;
542
 
                else if ( $number > 15 )
543
 
                        $number = 15;
 
537
                if ( ! $number = absint( $instance['number'] ) )
 
538
                        $number = 10;
544
539
 
545
 
                $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1));
 
540
                $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
546
541
                if ($r->have_posts()) :
547
542
?>
548
543
                <?php echo $before_widget; ?>
582
577
 
583
578
        function form( $instance ) {
584
579
                $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
585
 
                if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
586
 
                        $number = 5;
 
580
                $number = isset($instance['number']) ? absint($instance['number']) : 5;
587
581
?>
588
582
                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
589
583
                <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>
613
607
                add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') );
614
608
        }
615
609
 
616
 
        function recent_comments_style() { ?>
 
610
        function recent_comments_style() {
 
611
                if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
 
612
                        || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
 
613
                        return;
 
614
                ?>
617
615
        <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
618
616
<?php
619
617
        }
639
637
                $output = '';
640
638
                $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
641
639
 
642
 
                if ( ! $number = (int) $instance['number'] )
 
640
                if ( ! $number = absint( $instance['number'] ) )
643
641
                        $number = 5;
644
 
                else if ( $number < 1 )
645
 
                        $number = 1;
646
642
 
647
643
                $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) );
648
644
                $output .= $before_widget;
666
662
        function update( $new_instance, $old_instance ) {
667
663
                $instance = $old_instance;
668
664
                $instance['title'] = strip_tags($new_instance['title']);
669
 
                $instance['number'] = (int) $new_instance['number'];
 
665
                $instance['number'] = absint( $new_instance['number'] );
670
666
                $this->flush_widget_cache();
671
667
 
672
668
                $alloptions = wp_cache_get( 'alloptions', 'options' );
716
712
                if ( empty($url) )
717
713
                        return;
718
714
 
 
715
                // self-url destruction sequence
 
716
                if ( $url == site_url() || $url == home_url() )
 
717
                        return;
 
718
 
719
719
                $rss = fetch_feed($url);
720
720
                $title = $instance['title'];
721
721
                $desc = '';
836
836
 
837
837
                $date = '';
838
838
                if ( $show_date ) {
839
 
                        $date = $item->get_date();
 
839
                        $date = $item->get_date( 'U' );
840
840
 
841
841
                        if ( $date ) {
842
 
                                if ( $date_stamp = strtotime( $date ) )
843
 
                                        $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
844
 
                                else
845
 
                                        $date = '';
 
842
                                $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
846
843
                        }
847
844
                }
848
845
 
1011
1008
                echo $before_widget;
1012
1009
                if ( $title )
1013
1010
                        echo $before_title . $title . $after_title;
1014
 
                echo '<div>';
 
1011
                echo '<div class="tagcloud">';
1015
1012
                wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );
1016
1013
                echo "</div>\n";
1017
1014
                echo $after_widget;