Make WordPress Core

Ticket #21064: 21064.2.patch

File 21064.2.patch, 3.8 KB (added by SergeyBiryukov, 13 years ago)
  • wp-includes/default-widgets.php

     
    561561                $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
    562562                if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
    563563                        $number = 10;
     564                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    564565
    565566                $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) );
    566567                if ($r->have_posts()) :
     
    568569                <?php echo $before_widget; ?>
    569570                <?php if ( $title ) echo $before_title . $title . $after_title; ?>
    570571                <ul>
    571                 <?php  while ($r->have_posts()) : $r->the_post(); ?>
    572                 <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li>
     572                <?php while ( $r->have_posts() ) : $r->the_post(); ?>
     573                        <li>
     574                                <a href="<?php the_permalink() ?>" title="<?php echo esc_attr( get_the_title() ? get_the_title() : get_the_ID() ); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a>
     575                        <?php if ( $show_date ) : ?>
     576                                <span class="post-date"><?php echo get_the_date(); ?></span>
     577                        <?php endif; ?>
     578                        </li>
    573579                <?php endwhile; ?>
    574580                </ul>
    575581                <?php echo $after_widget; ?>
     
    587593                $instance = $old_instance;
    588594                $instance['title'] = strip_tags($new_instance['title']);
    589595                $instance['number'] = (int) $new_instance['number'];
     596                $instance['show_date'] = (bool) $new_instance['show_date'];
    590597                $this->flush_widget_cache();
    591598
    592599                $alloptions = wp_cache_get( 'alloptions', 'options' );
     
    601608        }
    602609
    603610        function form( $instance ) {
    604                 $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
    605                 $number = isset($instance['number']) ? absint($instance['number']) : 5;
     611                $title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     612                $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
     613                $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
    606614?>
    607                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    608                 <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>
     615                <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
     616                <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>
    609617
    610                 <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
    611                 <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>
     618                <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
     619                <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>
     620
     621                <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' ); ?>" />
     622                <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></p>
    612623<?php
    613624        }
    614625}