PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 11.7.2
Jetpack – WP Security, Backup, Speed, & Growth v11.7.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / likes.php
likes.php
621 lines 21.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Module Name: Likes
4 * Module Description: Give visitors an easy way to show they appreciate your content.
5 * First Introduced: 2.2
6 * Sort Order: 23
7 * Requires Connection: Yes
8 * Auto Activate: No
9 * Module Tags: Social
10 * Feature: Engagement
11 * Additional Search Queries: like, likes, wordpress.com
12 *
13 * @package automattic/jetpack
14 */
15 /**
16 * NOTE: While the front-end behavior currently varies, try to keep the data
17 * model here the same as on wpcom to facilitate Simple→Atomic moves and
18 * possible future work to recombine the front-ends.
19 */
20
21 use Automattic\Jetpack\Assets;
22
23 Assets::add_resource_hint(
24 array(
25 '//widgets.wp.com',
26 '//s0.wp.com',
27 '//0.gravatar.com',
28 '//1.gravatar.com',
29 '//2.gravatar.com',
30 ),
31 'dns-prefetch'
32 );
33
34 require_once __DIR__ . '/likes/jetpack-likes-master-iframe.php';
35 require_once __DIR__ . '/likes/jetpack-likes-settings.php';
36
37 /**
38 * Jetpack Like Class
39 */
40 class Jetpack_Likes {
41
42 /**
43 * Jetpack_Likes_Settings object
44 *
45 * @var Jetpack_Likes_Settings
46 */
47 public $settings;
48
49 /**
50 * Initialize class
51 */
52 public static function init() {
53 static $instance = null;
54
55 if ( ! $instance ) {
56 $instance = new Jetpack_Likes();
57 }
58
59 return $instance;
60 }
61
62 /**
63 * Constructs Likes class
64 */
65 public function __construct() {
66 $this->settings = new Jetpack_Likes_Settings();
67
68 // We need to run on wp hook rather than init because we check is_amp_endpoint()
69 // when bootstrapping hooks.
70 add_action( 'wp', array( $this, 'action_init' ), 99 );
71
72 add_action( 'admin_init', array( $this, 'admin_init' ) );
73
74 add_action( 'jetpack_activate_module_likes', array( $this, 'set_social_notifications_like' ) );
75 add_action( 'jetpack_deactivate_module_likes', array( $this, 'delete_social_notifications_like' ) );
76
77 Jetpack::enable_module_configurable( __FILE__ );
78 add_filter( 'jetpack_module_configuration_url_likes', array( $this, 'jetpack_likes_configuration_url' ) );
79 add_action( 'admin_print_scripts-settings_page_sharing', array( $this, 'load_jp_css' ) );
80 add_filter( 'sharing_show_buttons_on_row_start', array( $this, 'configuration_target_area' ) );
81
82 $active = Jetpack::get_active_modules();
83
84 if ( ! in_array( 'sharedaddy', $active, true ) && ! in_array( 'publicize', $active, true ) ) {
85 // we don't have a sharing page yet.
86 add_action( 'admin_menu', array( $this->settings, 'sharing_menu' ) );
87 }
88
89 if ( in_array( 'publicize', $active, true ) && ! in_array( 'sharedaddy', $active, true ) ) {
90 // we have a sharing page but not the global options area.
91 add_action( 'pre_admin_screen_sharing', array( $this->settings, 'sharing_block' ), 20 );
92 add_action( 'pre_admin_screen_sharing', array( $this->settings, 'updated_message' ), -10 );
93 }
94
95 if ( ! in_array( 'sharedaddy', $active, true ) ) {
96 add_action( 'admin_init', array( $this->settings, 'process_update_requests_if_sharedaddy_not_loaded' ) );
97 add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_showbuttonon_init' ), 19 );
98 add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_showbuttonon_callback' ), 19 );
99 add_action( 'admin_init', array( $this->settings, 'add_meta_box' ) );
100 } else {
101 add_filter( 'sharing_meta_box_title', array( $this->settings, 'add_likes_to_sharing_meta_box_title' ) );
102 add_action( 'start_sharing_meta_box_content', array( $this->settings, 'meta_box_content' ) );
103 }
104
105 add_action( 'admin_init', array( $this, 'admin_discussion_likes_settings_init' ) ); // Likes notifications.
106
107 add_action( 'admin_bar_menu', array( $this, 'admin_bar_likes' ), 60 );
108
109 add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_register_scripts' ) );
110
111 add_action( 'save_post', array( $this->settings, 'meta_box_save' ) );
112 add_action( 'edit_attachment', array( $this->settings, 'meta_box_save' ) );
113 add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_init' ), 20 );
114 add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_callback' ), 20 );
115 }
116
117 /**
118 * Set the social_notifications_like option to `on` when the Likes module is activated.
119 *
120 * @since 3.7.0
121 */
122 public function set_social_notifications_like() {
123 update_option( 'social_notifications_like', 'on' );
124 }
125
126 /**
127 * Delete the social_notifications_like option that was set to `on` on module activation.
128 *
129 * @since 3.7.0
130 */
131 public function delete_social_notifications_like() {
132 delete_option( 'social_notifications_like' );
133 }
134
135 /**
136 * Overrides default configuration url
137 *
138 * @uses admin_url
139 * @return string module settings URL
140 */
141 public function jetpack_likes_configuration_url() {
142 return admin_url( 'options-general.php?page=sharing#likes' );
143 }
144
145 /**
146 * Loads Jetpack's CSS on the sharing page so we can use .jetpack-targetable
147 */
148 public function load_jp_css() {
149 /**
150 * Do we really need `admin_styles`? With the new admin UI, it's breaking some bits.
151 * Jetpack::init()->admin_styles();
152 */
153 }
154
155 /**
156 * Load scripts and styles for front end.
157 */
158 public function load_styles_register_scripts() {
159 wp_enqueue_style( 'jetpack_likes', plugins_url( 'likes/style.css', __FILE__ ), array(), JETPACK__VERSION );
160 wp_register_script(
161 'jetpack_likes_queuehandler',
162 Assets::get_file_url_for_environment(
163 '_inc/build/likes/queuehandler.min.js',
164 'modules/likes/queuehandler.js'
165 ),
166 array(),
167 JETPACK__VERSION,
168 true
169 );
170 }
171
172 /**
173 * Adds in the jetpack-targetable class so when we visit sharing#likes our like settings get highlighted by a yellow box
174 *
175 * @param string $html row heading for the sharedaddy "which page" setting.
176 * @return string $html with the jetpack-targetable class and likes id. tbody gets closed after the like settings
177 */
178 public function configuration_target_area( $html = '' ) {
179 $html = "<tbody id='likes' class='jetpack-targetable'>" . $html;
180 return $html;
181 }
182
183 /**
184 * Options to be added to the discussion page (see also admin_settings_init, etc below for Sharing settings page)
185 */
186 public function admin_discussion_likes_settings_init() {
187 // Add a temporary section, until we can move the setting out of there and with the rest of the email notification settings.
188 add_settings_section( 'likes-notifications', __( 'Likes Notifications', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_section' ), 'discussion' );
189 add_settings_field( 'social-notifications', __( 'Email me whenever', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_field' ), 'discussion', 'likes-notifications' );
190 // Register the setting.
191 register_setting( 'discussion', 'social_notifications_like', array( $this, 'admin_discussion_likes_settings_validate' ) );
192 }
193
194 /** Add email notification options to WordPress discussion settings */
195 public function admin_discussion_likes_settings_section() {
196 // Atypical usage here. We emit jquery to move likes notification checkbox to be with the rest of the email notification settings.
197 ?>
198 <script type="text/javascript">
199 jQuery( function( $ ) {
200 var table = $( '#social_notifications_like' ).parents( 'table:first' ),
201 header = table.prevAll( 'h2:first' ),
202 newParent = $( '#moderation_notify' ).parent( 'label' ).parent();
203
204 if ( !table.length || !header.length || !newParent.length ) {
205 return;
206 }
207
208 newParent.append( '<br/>' ).append( table.end().parent( 'label' ).siblings().andSelf() );
209 header.remove();
210 table.remove();
211 } );
212 </script>
213 <?php
214 }
215
216 /** Check if email notifications for likes is on or off.
217 *
218 * @param string $option - which option we're checking (social_notifications_like).
219 */
220 public function admin_likes_get_option( $option ) {
221 $option_setting = get_option( $option, 'on' );
222
223 return (int) ( 'on' === $option_setting );
224 }
225
226 /** Display email notification for likes setting in WordPress' discussion settings. */
227 public function admin_discussion_likes_settings_field() {
228 $like = $this->admin_likes_get_option( 'social_notifications_like' );
229 ?>
230 <label><input type="checkbox" id="social_notifications_like" name="social_notifications_like" value="1" <?php checked( $like ); ?> /> <?php esc_html_e( 'Someone likes one of my posts', 'jetpack' ); ?></label>
231 <?php
232 }
233
234 /**
235 * Validate email notification settings.
236 *
237 * @param string $input - determines if checbox is on or off.
238 */
239 public function admin_discussion_likes_settings_validate( $input ) {
240 // If it's not set (was unchecked during form submission) or was set to off (during option update), return 'off'.
241 if ( ! $input || 'off' === $input ) {
242 return 'off';
243 }
244 // Otherwise return 'on'.
245 return 'on';
246 }
247
248 /** Initialize admin settings */
249 public function admin_init() {
250 add_filter( 'manage_posts_columns', array( $this, 'add_like_count_column' ) );
251 add_filter( 'manage_pages_columns', array( $this, 'add_like_count_column' ) );
252 add_action( 'manage_posts_custom_column', array( $this, 'likes_edit_column' ), 10, 2 );
253 add_action( 'manage_pages_custom_column', array( $this, 'likes_edit_column' ), 10, 2 );
254 add_action( 'admin_print_styles-edit.php', array( $this, 'load_admin_css' ) );
255 add_action( 'admin_print_scripts-edit.php', array( $this, 'enqueue_admin_scripts' ) );
256 }
257
258 /** Initialize action */
259 public function action_init() {
260 /*
261 * Only check if the module is enabled here because
262 * we are not currently in The Loop and do not yet have access to check
263 * the switch_like_status post meta flag for the post to be loaded.
264 */
265 if ( is_admin() || ! $this->settings->is_likes_module_enabled() ) {
266 return;
267 }
268
269 if ( ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) ||
270 ( defined( 'APP_REQUEST' ) && APP_REQUEST ) ||
271 ( defined( 'REST_API_REQUEST' ) && REST_API_REQUEST ) ||
272 ( defined( 'COOKIE_AUTH_REQUEST' ) && COOKIE_AUTH_REQUEST ) ||
273 ( defined( 'JABBER_SERVER' ) && JABBER_SERVER ) ) {
274 return;
275 }
276
277 if (
278 class_exists( 'Jetpack_AMP_Support' )
279 && Jetpack_AMP_Support::is_amp_request()
280 ) {
281 return;
282 }
283
284 add_filter( 'the_content', array( $this, 'post_likes' ), 30, 1 );
285 add_filter( 'the_excerpt', array( $this, 'post_likes' ), 30, 1 );
286 }
287
288 /**
289 * Load the CSS needed for the wp-admin area.
290 */
291 public function load_admin_css() {
292 ?>
293 <style type="text/css">
294 .vers img { display: none; }
295 .metabox-prefs .vers img { display: inline; }
296 .fixed .column-likes { width: 5.5em; padding: 8px 0; text-align: left; }
297 .fixed .column-stats { width: 5em; }
298 .fixed .column-likes .post-com-count {
299 -webkit-box-sizing: border-box;
300 -moz-box-sizing: border-box;
301 box-sizing: border-box;
302 display: inline-block;
303 padding: 0 8px;
304 height: 2em;
305 margin-top: 5px;
306 -webkit-border-radius: 5px;
307 border-radius: 5px;
308 background-color: #787c82;
309 color: #FFF;
310 font-size: 11px;
311 line-height: 21px;
312 }
313 .fixed .column-likes .post-com-count::after { border: none !important; }
314 .fixed .column-likes .post-com-count:hover { background-color: #2271b1; }
315 .fixed .column-likes .vers:before {
316 font: normal 20px/1 dashicons;
317 content: '\f155';
318 speak: none;
319 -webkit-font-smoothing: antialiased;
320 -moz-osx-font-smoothing: grayscale;
321 }
322 @media screen and (max-width: 782px) {
323 .fixed .column-likes {
324 display: none;
325 }
326 }
327 </style>
328 <?php
329 }
330
331 /**
332 * Load the JS required for loading the like counts.
333 */
334 public function enqueue_admin_scripts() {
335 if ( empty( $_GET['post_type'] ) || 'post' === $_GET['post_type'] || 'page' === $_GET['post_type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
336 wp_enqueue_script(
337 'likes-post-count',
338 Assets::get_file_url_for_environment(
339 '_inc/build/likes/post-count.min.js',
340 'modules/likes/post-count.js'
341 ),
342 array( 'jquery' ),
343 JETPACK__VERSION,
344 $in_footer = false
345 );
346 wp_enqueue_script(
347 'likes-post-count-jetpack',
348 Assets::get_file_url_for_environment(
349 '_inc/build/likes/post-count-jetpack.min.js',
350 'modules/likes/post-count-jetpack.js'
351 ),
352 array( 'likes-post-count' ),
353 JETPACK__VERSION,
354 $in_footer = false
355 );
356 }
357 }
358
359 /**
360 * Add "Likes" column data to the post edit table in wp-admin.
361 *
362 * @param string $column_name - name of the column.
363 * @param int $post_id - the post id.
364 */
365 public function likes_edit_column( $column_name, $post_id ) {
366 if ( 'likes' === $column_name ) {
367
368 $blog_id = Jetpack_Options::get_option( 'id' );
369
370 $permalink = get_permalink( get_the_ID() );
371 ?>
372 <a title="" data-post-id="<?php echo (int) $post_id; ?>" class="post-com-count post-like-count" id="post-like-count-<?php echo (int) $post_id; ?>" data-blog-id="<?php echo (int) $blog_id; ?>" href="<?php echo esc_url( $permalink ); ?>#like-<?php echo (int) $post_id; ?>">
373 <span class="comment-count">0</span>
374 </a>
375 <?php
376 }
377 }
378
379 /**
380 * Add a "Likes" column header to the post edit table in wp-admin.
381 *
382 * @param array $columns - array of columns in wp-admin.
383 */
384 public function add_like_count_column( $columns ) {
385 $date = $columns['date'];
386 unset( $columns['date'] );
387
388 $columns['likes'] = '<span class="vers"><img title="' . esc_attr__( 'Likes', 'jetpack' ) . '" alt="' . esc_attr__( 'Likes', 'jetpack' ) . '" src="//s0.wordpress.com/i/like-grey-icon.png" /><span class="screen-reader-text">' . __( 'Likes', 'jetpack' ) . '</span></span>';
389 $columns['date'] = $date;
390
391 return $columns;
392 }
393
394 /**
395 * Append like button to content.
396 *
397 * @param string $content - content of the page.
398 */
399 public function post_likes( $content ) {
400 global $wp_current_filter;
401 $post_id = get_the_ID();
402
403 if ( ! is_numeric( $post_id ) || ! $this->settings->is_likes_visible() ) {
404 return $content;
405 }
406
407 // Ensure we don't display like button on post excerpts that are hooked inside the post content
408 if ( in_array( 'the_excerpt', (array) $wp_current_filter, true ) &&
409 in_array( 'the_content', (array) $wp_current_filter, true ) ) {
410 return $content;
411 }
412
413 $blog_id = Jetpack_Options::get_option( 'id' );
414 $url = home_url();
415 $url_parts = wp_parse_url( $url );
416 $domain = $url_parts['host'];
417
418 // Make sure to include the scripts before the iframe otherwise weird things happen.
419 add_action( 'wp_footer', 'jetpack_likes_master_iframe', 21 );
420
421 /**
422 * If the same post appears more then once on a page the page goes crazy
423 * we need a slightly more unique id / name for the widget wrapper.
424 */
425 $uniqid = uniqid();
426
427 $src = sprintf( 'https://widgets.wp.com/likes/#blog_id=%1$d&amp;post_id=%2$d&amp;origin=%3$s&amp;obj_id=%1$d-%2$d-%4$s', $blog_id, $post_id, $domain, $uniqid );
428 $name = sprintf( 'like-post-frame-%1$d-%2$d-%3$s', $blog_id, $post_id, $uniqid );
429 $wrapper = sprintf( 'like-post-wrapper-%1$d-%2$d-%3$s', $blog_id, $post_id, $uniqid );
430 $headline = sprintf(
431 /** This filter is already documented in modules/sharedaddy/sharing-service.php */
432 apply_filters( 'jetpack_sharing_headline_html', '<h3 class="sd-title">%s</h3>', esc_html__( 'Like this:', 'jetpack' ), 'likes' ),
433 esc_html__( 'Like this:', 'jetpack' )
434 );
435
436 $title = esc_html__( 'Like or Reblog', 'jetpack' );
437
438 $html = "<div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='$wrapper' data-src='$src' data-name='$name' data-title='$title'>";
439 $html .= $headline;
440 $html .= "<div class='likes-widget-placeholder post-likes-widget-placeholder' style='height: 55px;'><span class='button'><span>" . esc_html__( 'Like', 'jetpack' ) . '</span></span> <span class="loading">' . esc_html__( 'Loading...', 'jetpack' ) . '</span></div>';
441 $html .= "<span class='sd-text-color'></span><a class='sd-link-color'></a>";
442 $html .= '</div>';
443
444 // Let's make sure that the script is enqueued.
445 wp_enqueue_script( 'jetpack_likes_queuehandler' );
446
447 return $content . $html;
448 }
449
450 /** Checks if admin bar is visible.*/
451 public function is_admin_bar_button_visible() {
452 global $wp_admin_bar;
453
454 if ( ! is_object( $wp_admin_bar ) ) {
455 return false;
456 }
457
458 if ( ( ! is_singular( 'post' ) && ! is_attachment() && ! is_page() ) ) {
459 return false;
460 }
461
462 if ( ! $this->settings->is_likes_visible() ) {
463 return false;
464 }
465
466 if ( ! $this->settings->is_post_likeable() ) {
467 return false;
468 }
469
470 /**
471 * Filters whether the Like button is enabled in the admin bar.
472 *
473 * @module likes
474 *
475 * @since 2.2.0
476 *
477 * @param bool true Should the Like button be visible in the Admin bar. Default to true.
478 */
479 return (bool) apply_filters( 'jetpack_admin_bar_likes_enabled', true );
480 }
481
482 /** Adds like section in admin bar. */
483 public function admin_bar_likes() {
484 global $wp_admin_bar;
485
486 $post_id = get_the_ID();
487
488 if ( ! is_numeric( $post_id ) || ! $this->is_admin_bar_button_visible() ) {
489 return;
490 }
491
492 $protocol = 'http';
493 if ( is_ssl() ) {
494 $protocol = 'https';
495 }
496 $blog_id = Jetpack_Options::get_option( 'id' );
497 $url = home_url();
498 $url_parts = wp_parse_url( $url );
499 $domain = $url_parts['host'];
500
501 // Make sure to include the scripts before the iframe otherwise weird things happen.
502 add_action( 'wp_footer', 'jetpack_likes_master_iframe', 21 );
503
504 $src = sprintf( 'https://widgets.wp.com/likes/#blog_id=%2$d&amp;post_id=%3$d&amp;origin=%1$s://%4$s', $protocol, $blog_id, $post_id, $domain );
505
506 $html = "<iframe class='admin-bar-likes-widget jetpack-likes-widget' scrolling='no' frameBorder='0' name='admin-bar-likes-widget' src='$src'></iframe>";
507
508 $node = array(
509 'id' => 'admin-bar-likes-widget',
510 'meta' => array(
511 'html' => $html,
512 ),
513 );
514
515 $wp_admin_bar->add_node( $node );
516 }
517 }
518
519 /**
520 * Callback to get the value for the jetpack_likes_enabled field.
521 *
522 * Warning: this behavior is somewhat complicated!
523 * When the switch_like_status post_meta is unset, we follow the global setting in Sharing.
524 * When it is set to 0, we disable likes on the post, regardless of the global setting.
525 * When it is set to 1, we enable likes on the post, regardless of the global setting.
526 *
527 * @param array $post - post data we're checking.
528 */
529 function jetpack_post_likes_get_value( array $post ) {
530 $post_likes_switched = get_post_meta( $post['id'], 'switch_like_status', true );
531
532 /** This filter is documented in modules/jetpack-likes-settings.php */
533 $sitewide_likes_enabled = (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) );
534
535 // An empty string: post meta was not set, so go with the global setting.
536 if ( '' === $post_likes_switched ) {
537 return $sitewide_likes_enabled;
538 } elseif ( '0' === $post_likes_switched ) { // User overrode the global setting to disable likes.
539 return false;
540 } elseif ( '1' === $post_likes_switched ) { // User overrode the global setting to enable likes.
541 return true;
542 }
543 // No default fallback, let's stay explicit.
544 }
545
546 /**
547 * Callback to set switch_like_status post_meta when jetpack_likes_enabled is updated.
548 *
549 * Warning: this behavior is somewhat complicated!
550 * When the switch_like_status post_meta is unset, we follow the global setting in Sharing.
551 * When it is set to 0, we disable likes on the post, regardless of the global setting.
552 * When it is set to 1, we enable likes on the post, regardless of the global setting.
553 *
554 * @param bool $enable_post_likes - checks if post likes are enabled.
555 * @param object $post_object - object containing post data.
556 */
557 function jetpack_post_likes_update_value( $enable_post_likes, $post_object ) {
558 /** This filter is documented in modules/jetpack-likes-settings.php */
559 $sitewide_likes_enabled = (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) );
560
561 $should_switch_status = $enable_post_likes !== $sitewide_likes_enabled;
562
563 if ( $should_switch_status ) {
564 // Set the meta to 0 if the user wants to disable likes, 1 if user wants to enable.
565 $switch_like_status = ( $enable_post_likes ? 1 : 0 );
566 return update_post_meta( $post_object->ID, 'switch_like_status', $switch_like_status );
567 } else {
568 // Unset the meta otherwise.
569 return delete_post_meta( $post_object->ID, 'switch_like_status' );
570 }
571 }
572
573 /**
574 * Add Likes post_meta to the REST API Post response.
575 *
576 * @action rest_api_init
577 * @uses register_rest_field
578 * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
579 */
580 function jetpack_post_likes_register_rest_field() {
581 $post_types = get_post_types( array( 'public' => true ) );
582 foreach ( $post_types as $post_type ) {
583 register_rest_field(
584 $post_type,
585 'jetpack_likes_enabled',
586 array(
587 'get_callback' => 'jetpack_post_likes_get_value',
588 'update_callback' => 'jetpack_post_likes_update_value',
589 'schema' => array(
590 'description' => __( 'Are Likes enabled?', 'jetpack' ),
591 'type' => 'boolean',
592 ),
593 )
594 );
595
596 /**
597 * Ensures all public internal post-types support `likes`
598 * This feature support flag is used by the REST API and Gutenberg.
599 */
600 add_post_type_support( $post_type, 'jetpack-post-likes' );
601 }
602 }
603
604 // Add Likes post_meta to the REST API Post response.
605 add_action( 'rest_api_init', 'jetpack_post_likes_register_rest_field' );
606
607 // Some CPTs (e.g. Jetpack portfolios and testimonials) get registered with
608 // restapi_theme_init because they depend on theme support, so let's also hook to that.
609 add_action( 'restapi_theme_init', 'jetpack_post_likes_register_rest_field', 20 );
610
611 /**
612 * Set the Likes and Sharing Gutenberg extension availability.
613 */
614 function jetpack_post_likes_set_extension_availability() {
615 Jetpack_Gutenberg::set_extension_available( 'likes' );
616 }
617
618 add_action( 'jetpack_register_gutenberg_extensions', 'jetpack_post_likes_set_extension_availability' );
619
620 Jetpack_Likes::init();
621