Ticket #34892: 34892.patch
File 34892.patch, 2.6 KB (added by , 9 years ago) |
---|
-
src/wp-includes/widgets/class-wp-widget-recent-posts.php
52 52 if ( ! $number ) 53 53 $number = 5; 54 54 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 55 $format = ( ! empty( $instance['format'] ) ) ? $instance['format'] : null; 55 56 56 57 /** 57 58 * Filter the arguments for the Recent Posts widget. … … 80 81 <li> 81 82 <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a> 82 83 <?php if ( $show_date ) : ?> 83 <span class="post-date"><?php echo get_the_date(); ?></span>84 <span class="post-date"><?php echo ( $format===null ? get_the_date() : get_the_date($format) ); ?></span> 84 85 <?php endif; ?> 85 86 </li> 86 87 <?php endwhile; ?> … … 109 110 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 110 111 $instance['number'] = (int) $new_instance['number']; 111 112 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 113 $instance['format'] = sanitize_text_field( trim($new_instance['format']) ); 112 114 return $instance; 113 115 } 114 116 … … 124 126 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; 125 127 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; 126 128 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; 129 $format = isset( $instance['format'] ) ? esc_attr( $instance['format'] ) : ''; 127 130 ?> 128 131 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 129 132 <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> … … 133 136 134 137 <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' ); ?>" /> 135 138 <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p> 139 140 <p><label for="<?php echo $this->get_field_id( 'format' ); ?>"><?php _e( 'PHP date format:' ); ?></label> 141 <input class="widefat" id="<?php echo $this->get_field_id( 'format' ); ?>" name="<?php echo $this->get_field_name( 'format' ); ?>" placeholder="<?php _e('Leave blank for default'); ?>" type="text" value="<?php echo $format; ?>" /></p> 136 142 <?php 137 143 } 138 144 }