diff --git src/wp-includes/widgets.php src/wp-includes/widgets.php
index 6c559c3..e041ad3 100644
|
|
|
function wp_widgets_init() { |
| 1457 | 1457 | |
| 1458 | 1458 | register_widget('WP_Widget_Categories'); |
| 1459 | 1459 | |
| 1460 | | register_widget('WP_Widget_Recent_Posts'); |
| | 1460 | foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $post_type_obj ) { |
| | 1461 | $recent_posts_widget = new WP_Widget_Recent_Posts( $post_type_obj->name ); |
| | 1462 | register_widget( $recent_posts_widget ); |
| | 1463 | } |
| 1461 | 1464 | |
| 1462 | 1465 | register_widget('WP_Widget_Recent_Comments'); |
| 1463 | 1466 | |
diff --git src/wp-includes/widgets/class-wp-widget-recent-posts.php src/wp-includes/widgets/class-wp-widget-recent-posts.php
index 8f92bf3..46a151f 100644
|
|
|
|
| 17 | 17 | class WP_Widget_Recent_Posts extends WP_Widget { |
| 18 | 18 | |
| 19 | 19 | /** |
| | 20 | * Post type for this widget. |
| | 21 | * |
| | 22 | * @var string |
| | 23 | */ |
| | 24 | public $post_type = 'post'; |
| | 25 | |
| | 26 | /** |
| 20 | 27 | * Sets up a new Recent Posts widget instance. |
| 21 | 28 | * |
| 22 | 29 | * @since 2.8.0 |
| 23 | 30 | * @access public |
| | 31 | * |
| | 32 | * @param string $post_type Post type. |
| 24 | 33 | */ |
| 25 | | public function __construct() { |
| 26 | | $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site’s most recent Posts.") ); |
| 27 | | parent::__construct('recent-posts', __('Recent Posts'), $widget_ops); |
| | 34 | public function __construct( $post_type = 'post' ) { |
| | 35 | $this->post_type = $post_type; |
| | 36 | $post_type_obj = get_post_type( $post_type ); |
| | 37 | $widget_ops = array( |
| | 38 | 'classname' => 'widget_recent_entries', |
| | 39 | 'description' => sprintf( __( 'Your site’s most recent %s.', $post_type_obj->labels->name ) ), |
| | 40 | ); |
| | 41 | $id_base = sprintf( 'recent-%s', $post_type === 'post' ? 'posts' : "$post_type-posts" ); |
| | 42 | parent::__construct( |
| | 43 | $id_base, |
| | 44 | sprintf( __( 'Recent %s', $post_type_obj->labels->name ) ), |
| | 45 | $widget_ops |
| | 46 | ); |
| 28 | 47 | $this->alt_option_name = 'widget_recent_entries'; |
| 29 | 48 | } |
| 30 | 49 | |
| … |
… |
class WP_Widget_Recent_Posts extends WP_Widget { |
| 66 | 85 | 'posts_per_page' => $number, |
| 67 | 86 | 'no_found_rows' => true, |
| 68 | 87 | 'post_status' => 'publish', |
| 69 | | 'ignore_sticky_posts' => true |
| | 88 | 'ignore_sticky_posts' => true, |
| | 89 | 'post_type' => $this->post_type, |
| 70 | 90 | ) ) ); |
| 71 | 91 | |
| 72 | 92 | if ($r->have_posts()) : |