Ticket #40203: 40203.1.patch
| File 40203.1.patch, 3.6 KB (added by , 7 years ago) |
|---|
-
src/wp-includes/widgets/class-wp-widget-recent-posts.php
56 56 } 57 57 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 58 58 59 $show_thumbnail = isset( $instance['show_thumbnail'] ) ? $instance['show_thumbnail'] : false; 60 59 61 /** 60 62 * Filters the arguments for the Recent Posts widget. 61 63 * … … 97 99 $title = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' ); 98 100 ?> 99 101 <li> 102 <?php 103 if ( $show_thumbnail && has_post_thumbnail( $recent_post->ID ) ) : 104 echo wp_get_attachment_image( get_post_thumbnail_id( $recent_post->ID ) ); 105 endif; 106 ?> 100 107 <a href="<?php the_permalink( $recent_post->ID ); ?>"><?php echo $title; ?></a> 101 108 <?php if ( $show_date ) : ?> 102 109 <span class="post-date"><?php echo get_the_date( '', $recent_post->ID ); ?></span> … … 119 126 * @return array Updated settings to save. 120 127 */ 121 128 public function update( $new_instance, $old_instance ) { 122 $instance = $old_instance; 123 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 124 $instance['number'] = (int) $new_instance['number']; 125 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 129 $instance = $old_instance; 130 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 131 $instance['number'] = (int) $new_instance['number']; 132 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 133 $instance['show_thumbnail'] = isset( $new_instance['show_thumbnail'] ) ? (bool) $new_instance['show_thumbnail'] : false; 126 134 return $instance; 127 135 } 128 136 … … 134 142 * @param array $instance Current settings. 135 143 */ 136 144 public function form( $instance ) { 137 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; 138 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; 139 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; 145 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; 146 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; 147 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; 148 $show_thumbnail = isset( $instance['show_thumbnail'] ) ? (bool) $instance['show_thumbnail'] : false; 140 149 ?> 141 150 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 142 151 <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> … … 146 155 147 156 <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' ); ?>" /> 148 157 <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p> 158 159 <p><input class="checkbox" type="checkbox"<?php checked( $show_thumbnail ); ?> id="<?php echo $this->get_field_id( 'show_thumbnail' ); ?>" name="<?php echo $this->get_field_name( 'show_thumbnail' ); ?>" /> 160 <label for="<?php echo $this->get_field_id( 'show_thumbnail' ); ?>"><?php _e( 'Display post thumbnail?' ); ?></label></p> 149 161 <?php 150 162 } 151 163 }