Jetpack_Top_Posts_Widget

The WordPress Core Jetpack Top Posts Widget class.

Defined (1)

The class is defined in the following location(s).

/modules/widgets/top-posts.php  
  1. class Jetpack_Top_Posts_Widget extends WP_Widget { 
  2. public $alt_option_name = 'widget_stats_topposts'; 
  3. public $default_title = ''; 
  4.  
  5. function __construct() { 
  6. parent::__construct( 
  7. 'top-posts',  
  8. /** This filter is documented in modules/widgets/facebook-likebox.php */ 
  9. apply_filters( 'jetpack_widget_name', __( 'Top Posts & Pages', 'jetpack' ) ),  
  10. array( 
  11. 'description' => __( 'Shows your most viewed posts and pages.', 'jetpack' ),  
  12. 'customize_selective_refresh' => true,  
  13. ); 
  14.  
  15. $this->default_title = __( 'Top Posts & Pages', 'jetpack' ); 
  16.  
  17. if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { 
  18. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); 
  19.  
  20. /** 
  21. * Add explanation about how the statistics are calculated. 
  22. * @module widgets 
  23. * @since 3.9.3 
  24. */ 
  25. add_action( 'jetpack_widget_top_posts_after_fields', array( $this, 'stats_explanation' ) ); 
  26.  
  27. function enqueue_style() { 
  28. wp_register_style( 'jetpack-top-posts-widget', plugins_url( 'top-posts/style.css', __FILE__ ), array(), '20141013' ); 
  29. wp_enqueue_style( 'jetpack-top-posts-widget' ); 
  30.  
  31. function form( $instance ) { 
  32. $instance = wp_parse_args( (array) $instance, $this->defaults() ); 
  33.  
  34. $title = stripslashes( $instance['title'] ); 
  35.  
  36. $count = isset( $instance['count'] ) ? (int) $instance['count'] : 10; 
  37. if ( $count < 1 || 10 < $count ) { 
  38. $count = 10; 
  39.  
  40. $allowed_post_types = array_values( get_post_types( array( 'public' => true ) ) ); 
  41. $types = isset( $instance['types'] ) ? (array) $instance['types'] : array( 'post', 'page' ); 
  42.  
  43. // 'likes' are not available in Jetpack 
  44. $ordering = isset( $instance['ordering'] ) && 'likes' === $instance['ordering'] ? 'likes' : 'views'; 
  45.  
  46. if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) { 
  47. $display = $instance['display']; 
  48. } else { 
  49. $display = 'text'; 
  50.  
  51. ?> 
  52.  
  53. <p> 
  54. <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label> 
  55. <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 
  56. </p> 
  57.  
  58. <p> 
  59. <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php esc_html_e( 'Maximum number of posts to show (no more than 10):', 'jetpack' ); ?></label> 
  60. <input id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" type="number" value="<?php echo (int) $count; ?>" min="1" max="10" /> 
  61. </p> 
  62.  
  63. <?php if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) : ?> 
  64. <p> 
  65. <label><?php esc_html_e( 'Order Top Posts & Pages By:', 'jetpack' ); ?></label> 
  66. <ul> 
  67. <li><label><input id="<?php echo $this->get_field_id( 'ordering' ); ?>-likes" name="<?php echo $this->get_field_name( 'ordering' ); ?>" type="radio" value="likes" <?php checked( 'likes', $ordering ); ?> /> <?php esc_html_e( 'Likes', 'jetpack' ); ?></label></li> 
  68. <li><label><input id="<?php echo $this->get_field_id( 'ordering' ); ?>-views" name="<?php echo $this->get_field_name( 'ordering' ); ?>" type="radio" value="views" <?php checked( 'views', $ordering ); ?> /> <?php esc_html_e( 'Views', 'jetpack' ); ?></label></li> 
  69. </ul> 
  70. </p> 
  71. <?php endif; ?> 
  72.  
  73. <p> 
  74. <label for="<?php echo $this->get_field_id( 'types' ); ?>"><?php esc_html_e( 'Types of pages to display:', 'jetpack' ); ?></label> 
  75. <ul> 
  76. <?php foreach( $allowed_post_types as $type ) { 
  77. // Get the Post Type name to display next to the checkbox 
  78. $post_type_object = get_post_type_object( $type ); 
  79. $label = $post_type_object->labels->name; 
  80.  
  81. $checked = ''; 
  82. if ( in_array( $type, $types ) ) { 
  83. $checked = 'checked="checked" '; 
  84. } ?> 
  85.  
  86. <li><label> 
  87. <input value="<?php echo esc_attr( $type ); ?>" name="<?php echo $this->get_field_name( 'types' ); ?>[]" id="<?php echo $this->get_field_id( 'types' ); ?>-<?php echo $type; ?>" type="checkbox" <?php echo $checked; ?>> 
  88. <?php echo esc_html( $label ); ?> 
  89. </label></li> 
  90.  
  91. <?php } // End foreach ?> 
  92. </ul> 
  93. </p> 
  94.  
  95. <p> 
  96. <label><?php esc_html_e( 'Display as:', 'jetpack' ); ?></label> 
  97. <ul> 
  98. <li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-text" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="text" <?php checked( 'text', $display ); ?> /> <?php esc_html_e( 'Text List', 'jetpack' ); ?></label></li> 
  99. <li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-list" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="list" <?php checked( 'list', $display ); ?> /> <?php esc_html_e( 'Image List', 'jetpack' ); ?></label></li> 
  100. <li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-grid" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="grid" <?php checked( 'grid', $display ); ?> /> <?php esc_html_e( 'Image Grid', 'jetpack' ); ?></label></li> 
  101. </ul> 
  102. </p><?php 
  103.  
  104. /** 
  105. * Fires after the fields are displayed in the Top Posts Widget settings in wp-admin. 
  106. * Allow adding extra content after the fields are displayed. 
  107. * @module widgets 
  108. * @since 3.9.3 
  109. * @param array $args { 
  110. * @param array $instance The widget instance. 
  111. * @param object $this The class object. 
  112. * } 
  113. */ 
  114. do_action( 'jetpack_widget_top_posts_after_fields', array( $instance, $this ) ); 
  115.  
  116. /** 
  117. * Explains how the statics are calculated. 
  118. */ 
  119. function stats_explanation() { 
  120. ?> 
  121.  
  122. <p><?php esc_html_e( 'Top Posts & Pages by views are calculated from 24-48 hours of stats. They take a while to change.', 'jetpack' ); ?></p><?php 
  123.  
  124. function update( $new_instance, $old_instance ) { 
  125. $instance = array(); 
  126. $instance['title'] = wp_kses( $new_instance['title'], array() ); 
  127. if ( $instance['title'] === $this->default_title ) { 
  128. $instance['title'] = false; // Store as false in case of language change 
  129.  
  130. $instance['count'] = (int) $new_instance['count']; 
  131. if ( $instance['count'] < 1 || 10 < $instance['count'] ) { 
  132. $instance['count'] = 10; 
  133.  
  134. // 'likes' are not available in Jetpack 
  135. $instance['ordering'] = isset( $new_instance['ordering'] ) && 'likes' == $new_instance['ordering'] ? 'likes' : 'views'; 
  136.  
  137. $allowed_post_types = array_values( get_post_types( array( 'public' => true ) ) ); 
  138. $instance['types'] = $new_instance['types']; 
  139. foreach( $new_instance['types'] as $key => $type ) { 
  140. if ( ! in_array( $type, $allowed_post_types ) ) { 
  141. unset( $new_instance['types'][ $key ] ); 
  142.  
  143. if ( isset( $new_instance['display'] ) && in_array( $new_instance['display'], array( 'grid', 'list', 'text' ) ) ) { 
  144. $instance['display'] = $new_instance['display']; 
  145. } else { 
  146. $instance['display'] = 'text'; 
  147.  
  148. /** 
  149. * Filters Top Posts Widget settings before they're saved. 
  150. * @module widgets 
  151. * @since 3.9.3 
  152. * @param array $instance The santized widget instance. Only contains data processed by the current widget. 
  153. * @param array $new_instance The new widget instance before sanitization. 
  154. */ 
  155. $instance = apply_filters( 'jetpack_top_posts_saving', $instance, $new_instance ); 
  156.  
  157. return $instance; 
  158.  
  159. function widget( $args, $instance ) { 
  160. /** This action is documented in modules/widgets/gravatar-profile.php */ 
  161. do_action( 'jetpack_stats_extra', 'widget_view', 'top_posts' ); 
  162.  
  163. $instance = wp_parse_args( (array) $instance, $this->defaults() ); 
  164.  
  165. $title = isset( $instance['title' ] ) ? $instance['title'] : false; 
  166. if ( false === $title ) { 
  167. $title = $this->default_title; 
  168. /** This filter is documented in core/src/wp-includes/default-widgets.php */ 
  169. $title = apply_filters( 'widget_title', $title ); 
  170.  
  171. $count = isset( $instance['count'] ) ? (int) $instance['count'] : false; 
  172. if ( $count < 1 || 10 < $count ) { 
  173. $count = 10; 
  174. /** 
  175. * Control the number of displayed posts. 
  176. * @module widgets 
  177. * @since 3.3.0 
  178. * @param string $count Number of Posts displayed in the Top Posts widget. Default is 10. 
  179. */ 
  180. $count = apply_filters( 'jetpack_top_posts_widget_count', $count ); 
  181.  
  182. $types = isset( $instance['types'] ) ? (array) $instance['types'] : array( 'post', 'page' ); 
  183.  
  184. // 'likes' are not available in Jetpack 
  185. $ordering = isset( $instance['ordering'] ) && 'likes' == $instance['ordering'] ? 'likes' : 'views'; 
  186.  
  187. if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) { 
  188. $display = $instance['display']; 
  189. } else { 
  190. $display = 'text'; 
  191.  
  192. if ( 'text' != $display ) { 
  193. $get_image_options = array( 
  194. 'fallback_to_avatars' => true,  
  195. /** This filter is documented in modules/stats.php */ 
  196. 'gravatar_default' => apply_filters( 'jetpack_static_url', set_url_scheme( 'https://en.wordpress.com/i/logo/white-gray-80.png' ) ),  
  197. 'avatar_size' => 40,  
  198. 'width' => null,  
  199. 'height' => null,  
  200. ); 
  201. if ( 'grid' == $display ) { 
  202. $get_image_options['avatar_size'] = 200; 
  203. /** 
  204. * Top Posts Widget Image options. 
  205. * @module widgets 
  206. * @since 1.8.0 
  207. * @param array $get_image_options { 
  208. * Array of Image options. 
  209. * @type bool true Should we default to Gravatars when no image is found? Default is true. 
  210. * @type string $gravatar_default Default Image URL if no Gravatar is found. 
  211. * @type int $avatar_size Default Image size. 
  212. * @type mixed $width Image width, not set by default and $avatar_size is used instead. 
  213. * @type mixed $height Image height, not set by default and $avatar_size is used instead. 
  214. * } 
  215. */ 
  216. $get_image_options = apply_filters( 'jetpack_top_posts_widget_image_options', $get_image_options ); 
  217.  
  218. if ( function_exists( 'wpl_get_blogs_most_liked_posts' ) && 'likes' == $ordering ) { 
  219. $posts = $this->get_by_likes( $count ); 
  220. } else { 
  221. $posts = $this->get_by_views( $count, $args ); 
  222.  
  223. // Filter the returned posts. Remove all posts that do not match the chosen Post Types. 
  224. if ( isset( $types ) ) { 
  225. foreach ( $posts as $k => $post ) { 
  226. if ( ! in_array( $post['post_type'], $types ) ) { 
  227. unset( $posts[$k] ); 
  228.  
  229. if ( ! $posts ) { 
  230. $posts = $this->get_fallback_posts(); 
  231.  
  232. echo $args['before_widget']; 
  233. if ( ! empty( $title ) ) 
  234. echo $args['before_title'] . $title . $args['after_title']; 
  235.  
  236. if ( ! $posts ) { 
  237. if ( current_user_can( 'edit_theme_options' ) ) { 
  238. echo '<p>' . sprintf( 
  239. __( 'There are no posts to display. <a href="%s" target="_blank">Want more traffic?</a>', 'jetpack' ),  
  240. 'https://jetpack.com/support/getting-more-views-and-traffic/' 
  241. ) . '</p>'; 
  242.  
  243. echo $args['after_widget']; 
  244. return; 
  245.  
  246. switch ( $display ) { 
  247. case 'list' : 
  248. case 'grid' : 
  249. // Keep the avatar_size as default dimensions for backward compatibility. 
  250. $width = (int) $get_image_options['avatar_size']; 
  251. $height = (int) $get_image_options['avatar_size']; 
  252.  
  253. // Check if the user has changed the width. 
  254. if ( ! empty( $get_image_options['width'] ) ) { 
  255. $width = (int) $get_image_options['width']; 
  256.  
  257. // Check if the user has changed the height. 
  258. if ( ! empty( $get_image_options['height'] ) ) { 
  259. $height = (int) $get_image_options['height']; 
  260.  
  261. foreach ( $posts as &$post ) { 
  262. $image = Jetpack_PostImages::get_image( 
  263. $post['post_id'],  
  264. array( 
  265. 'fallback_to_avatars' => true,  
  266. 'avatar_size' => (int) $get_image_options['avatar_size'],  
  267. ); 
  268. $post['image'] = $image['src']; 
  269. if ( 'blavatar' != $image['from'] && 'gravatar' != $image['from'] ) { 
  270. $post['image'] = jetpack_photon_url( $post['image'], array( 'resize' => "$width, $height" ) ); 
  271.  
  272. unset( $post ); 
  273.  
  274. if ( 'grid' == $display ) { 
  275. echo "<div class='widgets-grid-layout no-grav'>\n"; 
  276. foreach ( $posts as $post ) : 
  277. ?> 
  278. <div class="widget-grid-view-image"> 
  279. <?php 
  280. /** 
  281. * Fires before each Top Post result, inside <li>. 
  282. * @module widgets 
  283. * @since 3.2.0 
  284. * @param string $post['post_id'] Post ID. 
  285. */ 
  286. do_action( 'jetpack_widget_top_posts_before_post', $post['post_id'] ); 
  287.  
  288. /** 
  289. * Filter the permalink of items in the Top Posts widget. 
  290. * @module widgets 
  291. * @since 4.4.0 
  292. * @param string $post['permalink'] Post permalink. 
  293. * @param array $post Post array. 
  294. */ 
  295. $filtered_permalink = apply_filters( 'jetpack_top_posts_widget_permalink', $post['permalink'], $post ); 
  296.  
  297. ?> 
  298. <a href="<?php echo esc_url( $filtered_permalink ); ?>" title="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" class="bump-view" data-bump-view="tp"> 
  299. <img width="<?php echo absint( $width ); ?>" height="<?php echo absint( $height ); ?>" src="<?php echo esc_url( $post['image'] ); ?>" alt="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" data-pin-nopin="true" /> 
  300. </a> 
  301. <?php 
  302. /** 
  303. * Fires after each Top Post result, inside <li>. 
  304. * @module widgets 
  305. * @since 3.2.0 
  306. * @param string $post['post_id'] Post ID. 
  307. */ 
  308. do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] ); 
  309. ?> 
  310. </div> 
  311. <?php 
  312. endforeach; 
  313. echo "</div>\n"; 
  314. } else { 
  315. echo "<ul class='widgets-list-layout no-grav'>\n"; 
  316. foreach ( $posts as $post ) : 
  317. ?> 
  318. <li> 
  319. <?php 
  320. /** This action is documented in modules/widgets/top-posts.php */ 
  321. do_action( 'jetpack_widget_top_posts_before_post', $post['post_id'] ); 
  322.  
  323. /** This filter is documented in modules/widgets/top-posts.php */ 
  324. $filtered_permalink = apply_filters( 'jetpack_top_posts_widget_permalink', $post['permalink'], $post ); 
  325. ?> 
  326. <a href="<?php echo esc_url( $filtered_permalink ); ?>" title="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" class="bump-view" data-bump-view="tp"> 
  327. <img width="<?php echo absint( $width ); ?>" height="<?php echo absint( $height ); ?>" src="<?php echo esc_url( $post['image'] ); ?>" class='widgets-list-layout-blavatar' alt="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" data-pin-nopin="true" /> 
  328. </a> 
  329. <div class="widgets-list-layout-links"> 
  330. <a href="<?php echo esc_url( $filtered_permalink ); ?>" class="bump-view" data-bump-view="tp"> 
  331. <?php echo esc_html( wp_kses( $post['title'], array() ) ); ?> 
  332. </a> 
  333. </div> 
  334. <?php 
  335. /** This action is documented in modules/widgets/top-posts.php */ 
  336. do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] ); 
  337. ?> 
  338. </li> 
  339. <?php 
  340. endforeach; 
  341. echo "</ul>\n"; 
  342. break; 
  343. default : 
  344. echo '<ul>'; 
  345. foreach ( $posts as $post ) : 
  346. ?> 
  347. <li> 
  348. <?php 
  349. /** This action is documented in modules/widgets/top-posts.php */ 
  350. do_action( 'jetpack_widget_top_posts_before_post', $post['post_id'] ); 
  351.  
  352. /** This filter is documented in modules/widgets/top-posts.php */ 
  353. $filtered_permalink = apply_filters( 'jetpack_top_posts_widget_permalink', $post['permalink'], $post ); 
  354. ?> 
  355. <a href="<?php echo esc_url( $filtered_permalink ); ?>" class="bump-view" data-bump-view="tp"> 
  356. <?php echo esc_html( wp_kses( $post['title'], array() ) ); ?> 
  357. </a> 
  358. <?php 
  359. /** This action is documented in modules/widgets/top-posts.php */ 
  360. do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] ); 
  361. ?> 
  362. </li> 
  363. <?php 
  364. endforeach; 
  365. echo '</ul>'; 
  366.  
  367. echo $args['after_widget']; 
  368.  
  369. public static function defaults() { 
  370. return array( 
  371. 'title' => esc_html__( 'Top Posts & Pages', 'jetpack' ),  
  372. 'count' => absint( 10 ),  
  373. 'types' => array( 'post', 'page' ),  
  374. 'ordering' => 'views',  
  375. 'display' => 'text',  
  376. ); 
  377.  
  378. /** 
  379. * Get most liked posts 
  380. * ONLY TO BE USED IN WPCOM 
  381. */ 
  382. function get_by_likes( $count ) { 
  383. $post_likes = wpl_get_blogs_most_liked_posts(); 
  384. if ( !$post_likes ) { 
  385. return array(); 
  386.  
  387. return $this->get_posts( array_keys( $post_likes ), $count ); 
  388.  
  389. function get_by_views( $count, $args ) { 
  390. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  391. global $wpdb; 
  392.  
  393. $post_views = wp_cache_get( "get_top_posts_$count", 'stats' ); 
  394. if ( false === $post_views ) { 
  395. $post_views = array_shift( stats_get_daily_history( false, get_current_blog_id(), 'postviews', 'post_id', false, 2, '', $count * 2 + 10, true ) ); 
  396. unset( $post_views[0] ); 
  397. wp_cache_add( "get_top_posts_$count", $post_views, 'stats', 1200); 
  398.  
  399. return $this->get_posts( array_keys( $post_views ), $count ); 
  400.  
  401. /** 
  402. * Filter the number of days used to calculate Top Posts for the Top Posts widget. 
  403. * We do not recommend accessing more than 10 days of results at one. 
  404. * When more than 10 days of results are accessed at once, results should be cached via the WordPress transients API. 
  405. * Querying for -1 days will give results for an infinite number of days. 
  406. * @module widgets 
  407. * @since 3.9.3 
  408. * @param int 2 Number of days. Default is 2. 
  409. * @param array $args The widget arguments. 
  410. */ 
  411. $days = (int) apply_filters( 'jetpack_top_posts_days', 2, $args ); 
  412.  
  413. /** Handling situations where the number of days makes no sense - allows for unlimited days where $days = -1 */ 
  414. if ( 0 == $days || false == $days ) { 
  415. $days = 2; 
  416.  
  417. $post_view_posts = stats_get_from_restapi( array(), 'top-posts?max=11&summarize=1&num=' . absint( $days ) ); 
  418.  
  419. if ( ! isset( $post_view_posts->summary ) || empty( $post_view_posts->summary->postviews ) ) { 
  420. return array(); 
  421.  
  422. $post_view_ids = array_filter( wp_list_pluck( $post_view_posts->summary->postviews, 'id' ) ); 
  423.  
  424. if ( ! $post_view_ids ) { 
  425. return array(); 
  426.  
  427. return $this->get_posts( $post_view_ids, $count ); 
  428.  
  429. function get_fallback_posts() { 
  430. if ( current_user_can( 'edit_theme_options' ) ) { 
  431. return array(); 
  432.  
  433. $post_query = new WP_Query; 
  434.  
  435. $posts = $post_query->query( array( 
  436. 'posts_per_page' => 1,  
  437. 'post_status' => 'publish',  
  438. 'post_type' => array( 'post', 'page' ),  
  439. 'no_found_rows' => true,  
  440. ) ); 
  441.  
  442. if ( ! $posts ) { 
  443. return array(); 
  444.  
  445. $post = array_pop( $posts ); 
  446.  
  447. return $this->get_posts( $post->ID, 1 ); 
  448.  
  449. function get_posts( $post_ids, $count ) { 
  450. $counter = 0; 
  451.  
  452. $posts = array(); 
  453. foreach ( (array) $post_ids as $post_id ) { 
  454. $post = get_post( $post_id ); 
  455.  
  456. if ( ! $post ) { 
  457. continue; 
  458.  
  459. /** 
  460. * Attachment pages use the 'inherit' post status by default. 
  461. * To be able to remove attachment pages from private and password protect posts,  
  462. * we need to replace their post status by the parent post' status. 
  463. */ 
  464. if ( 'inherit' == $post->post_status && 'attachment' == $post->post_type ) { 
  465. $post->post_status = get_post_status( $post_id ); 
  466.  
  467. // hide private and password protected posts 
  468. if ( 'publish' != $post->post_status || ! empty( $post->post_password ) ) { 
  469. continue; 
  470.  
  471. // Both get HTML stripped etc on display 
  472. if ( empty( $post->post_title ) ) { 
  473. $title_source = $post->post_content; 
  474. $title = wp_html_excerpt( $title_source, 50 ); 
  475. $title .= '…'; 
  476. } else { 
  477. $title = $post->post_title; 
  478.  
  479. $permalink = get_permalink( $post->ID ); 
  480.  
  481. $post_type = $post->post_type; 
  482.  
  483. $posts[] = compact( 'title', 'permalink', 'post_id', 'post_type' ); 
  484. $counter++; 
  485.  
  486. if ( $counter == $count ) { 
  487. break; // only need to load and show x number of likes 
  488.  
  489. /** 
  490. * Filter the Top Posts and Pages. 
  491. * @module widgets 
  492. * @since 3.0.0 
  493. * @param array $posts Array of the most popular posts. 
  494. * @param array $post_ids Array of Post IDs. 
  495. * @param string $count Number of Top Posts we want to display. 
  496. */ 
  497. return apply_filters( 'jetpack_widget_get_top_posts', $posts, $post_ids, $count );