Changeset 21935 for trunk/wp-includes/default-widgets.php
- Timestamp:
- 09/21/2012 10:05:54 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/default-widgets.php
r21867 r21935 562 562 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) 563 563 $number = 10; 564 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 564 565 565 566 $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 ) ) ); … … 569 570 <?php if ( $title ) echo $before_title . $title . $after_title; ?> 570 571 <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> 573 579 <?php endwhile; ?> 574 580 </ul> … … 588 594 $instance['title'] = strip_tags($new_instance['title']); 589 595 $instance['number'] = (int) $new_instance['number']; 596 $instance['show_date'] = (bool) $new_instance['show_date']; 590 597 $this->flush_widget_cache(); 591 598 … … 602 609 603 610 function form( $instance ) { 604 $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; 605 $number = isset($instance['number']) ? absint($instance['number']) : 5; 606 ?> 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> 609 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> 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; 614 ?> 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> 617 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> 612 623 <?php 613 624 }
Note: See TracChangeset
for help on using the changeset viewer.