top-posts.php 19 KB

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