Ticket #35524: 355241.patch
File 355241.patch, 4.7 KB (added by , 9 years ago) |
---|
-
wp-includes/widgets/class-wp-widget-recent-posts.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
39 39 * @param array $instance Settings for the current Recent Posts widget instance. 40 40 */ 41 41 public function widget( $args, $instance ) { 42 if ( ! isset( $args['widget_id'] ) ) { 43 $args['widget_id'] = $this->id; 44 } 42 if ( has_action( 'widget_recent_post' ) ) { 45 43 46 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); 47 48 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 49 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 50 51 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 52 if ( ! $number ) 53 $number = 5; 54 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 55 56 /** 57 * Filter the arguments for the Recent Posts widget. 58 * 59 * @since 3.4.0 60 * 61 * @see WP_Query::get_posts() 62 * 63 * @param array $args An array of arguments used to retrieve the recent posts. 64 */ 65 $r = new WP_Query( apply_filters( 'widget_posts_args', array( 66 'posts_per_page' => $number, 67 'no_found_rows' => true, 68 'post_status' => 'publish', 69 'ignore_sticky_posts' => true 70 ) ) ); 44 /** 45 * Custom content for widget recent post 46 * 47 * @since 4.5.0 48 * 49 * @param array $args Display arguments for the current widget. 50 * @param array $instance Array of settings for the current widget. 51 */ 71 52 72 if ($r->have_posts()) : 73 ?> 74 <?php echo $args['before_widget']; ?> 75 <?php if ( $title ) { 76 echo $args['before_title'] . $title . $args['after_title']; 77 } ?> 78 <ul> 79 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 80 <li> 81 <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a> 82 <?php if ( $show_date ) : ?> 83 <span class="post-date"><?php echo get_the_date(); ?></span> 84 <?php endif; ?> 85 </li> 86 <?php endwhile; ?> 87 </ul> 88 <?php echo $args['after_widget']; ?> 89 <?php 90 // Reset the global $the_post as this query will have stomped on it 91 wp_reset_postdata(); 92 93 endif; 53 do_action( 'widget_recent_post', $args, $instance ); 54 } else { 55 include ABSPATH . WPINC . '/widget-templates/recent-posts.php'; 56 } 94 57 } 95 58 96 59 /** -
wp-includes/widget-templates/recent-posts.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1 <?php 2 3 if ( ! isset( $args['widget_id'] ) ) { 4 $args['widget_id'] = $this->id; 5 } 6 7 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); 8 9 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 10 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 11 12 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 13 if ( ! $number ) 14 $number = 5; 15 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 16 17 /** 18 * Filter the arguments for the Recent Posts widget. 19 * 20 * @since 3.4.0 21 * 22 * @see WP_Query::get_posts() 23 * 24 * @param array $args An array of arguments used to retrieve the recent posts. 25 */ 26 $r = new WP_Query( apply_filters( 'widget_posts_args', array( 27 'posts_per_page' => $number, 28 'no_found_rows' => true, 29 'post_status' => 'publish', 30 'ignore_sticky_posts' => true 31 ) ) ); 32 33 if ($r->have_posts()) : 34 ?> 35 <?php echo $args['before_widget']; ?> 36 <?php if ( $title ) { 37 echo $args['before_title'] . $title . $args['after_title']; 38 } ?> 39 <ul> 40 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 41 <li> 42 <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a> 43 <?php if ( $show_date ) : ?> 44 <span class="post-date"><?php echo get_the_date(); ?></span> 45 <?php endif; ?> 46 </li> 47 <?php endwhile; ?> 48 </ul> 49 <?php echo $args['after_widget']; ?> 50 <?php 51 // Reset the global $the_post as this query will have stomped on it 52 wp_reset_postdata(); 53 54 endif; 55 No newline at end of file