| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | /** |
| 3 | 3 | * Module Name: Likes |
| 4 | - * Module Description: Give visitors an easy way to show they appreciate your content. | |
| 4 | + * Module Description: Let readers like your posts to show appreciation and encourage interaction. | |
| 5 | 5 | * First Introduced: 2.2 |
| 6 | 6 | * Sort Order: 23 |
| 7 | 7 | * Requires Connection: Yes |
| 8 | 8 | * Auto Activate: No |
| @@ -20,18 +20,40 @@ | ||
| 20 | 20 | |
| 21 | 21 | // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. |
| 22 | 22 | |
| 23 | 23 | use Automattic\Jetpack\Assets; |
| 24 | +use Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch; | |
| 25 | +use Automattic\Jetpack\Status\Host; | |
| 24 | 26 | |
| 25 | -Assets::add_resource_hint( | |
| 26 | - array( | |
| 27 | - '//widgets.wp.com', | |
| 28 | - '//s0.wp.com', | |
| 29 | - '//0.gravatar.com', | |
| 30 | - '//1.gravatar.com', | |
| 31 | - '//2.gravatar.com', | |
| 32 | - ), | |
| 33 | - 'dns-prefetch' | |
| 27 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 28 | + exit( 0 ); | |
| 29 | +} | |
| 30 | + | |
| 31 | +add_filter( | |
| 32 | + 'wp_resource_hints', | |
| 33 | + function ( $hints, $relation_type ) { | |
| 34 | + if ( 'dns-prefetch' !== $relation_type ) { | |
| 35 | + return $hints; | |
| 36 | + } | |
| 37 | + | |
| 38 | + // Only hint on pages where Likes can render. | |
| 39 | + if ( ! is_singular() && ! is_home() && ! is_front_page() && ! is_archive() && ! is_search() ) { | |
| 40 | + return $hints; | |
| 41 | + } | |
| 42 | + | |
| 43 | + return array_merge( | |
| 44 | + $hints, | |
| 45 | + array( | |
| 46 | + '//widgets.wp.com', | |
| 47 | + '//s0.wp.com', | |
| 48 | + '//0.gravatar.com', | |
| 49 | + '//1.gravatar.com', | |
| 50 | + '//2.gravatar.com', | |
| 51 | + ) | |
| 52 | + ); | |
| 53 | + }, | |
| 54 | + 10, | |
| 55 | + 2 | |
| 34 | 56 | ); |
| 35 | 57 | |
| 36 | 58 | require_once __DIR__ . '/likes/jetpack-likes-master-iframe.php'; |
| 37 | 59 | require_once __DIR__ . '/likes/jetpack-likes-settings.php'; |
| @@ -39,9 +61,8 @@ | ||
| 39 | 61 | /** |
| 40 | 62 | * Jetpack Like Class |
| 41 | 63 | */ |
| 42 | 64 | class Jetpack_Likes { |
| 43 | - | |
| 44 | 65 | /** |
| 45 | 66 | * Jetpack_Likes_Settings object |
| 46 | 67 | * |
| 47 | 68 | * @var Jetpack_Likes_Settings |
| @@ -75,25 +96,18 @@ | ||
| 75 | 96 | |
| 76 | 97 | add_action( 'jetpack_activate_module_likes', array( $this, 'set_social_notifications_like' ) ); |
| 77 | 98 | add_action( 'jetpack_deactivate_module_likes', array( $this, 'delete_social_notifications_like' ) ); |
| 78 | 99 | |
| 79 | - Jetpack::enable_module_configurable( __FILE__ ); | |
| 100 | + // The `enable_module_configurable` method doesn't exist in the WP.com loader implementation. | |
| 101 | + if ( ! ( new Host() )->is_wpcom_simple() ) { | |
| 102 | + Jetpack::enable_module_configurable( __FILE__ ); | |
| 103 | + } | |
| 104 | + | |
| 80 | 105 | add_filter( 'jetpack_module_configuration_url_likes', array( $this, 'jetpack_likes_configuration_url' ) ); |
| 81 | - add_action( 'admin_print_scripts-settings_page_sharing', array( $this, 'load_jp_css' ) ); | |
| 82 | - add_filter( 'sharing_show_buttons_on_row_start', array( $this, 'configuration_target_area' ) ); | |
| 83 | 106 | |
| 84 | - $active = Jetpack::get_active_modules(); | |
| 107 | + $sharedaddy_active = Jetpack::is_module_active( 'sharedaddy' ); | |
| 85 | 108 | |
| 86 | - if ( in_array( 'publicize', $active, true ) && ! in_array( 'sharedaddy', $active, true ) ) { | |
| 87 | - // we have a sharing page but not the global options area. | |
| 88 | - add_action( 'pre_admin_screen_sharing', array( $this->settings, 'sharing_block' ), 20 ); | |
| 89 | - add_action( 'pre_admin_screen_sharing', array( $this->settings, 'updated_message' ), -10 ); | |
| 90 | - } | |
| 91 | - | |
| 92 | - if ( ! in_array( 'sharedaddy', $active, true ) ) { | |
| 93 | - add_action( 'admin_init', array( $this->settings, 'process_update_requests_if_sharedaddy_not_loaded' ) ); | |
| 94 | - add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_showbuttonon_init' ), 19 ); | |
| 95 | - add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_showbuttonon_callback' ), 19 ); | |
| 109 | + if ( ! $sharedaddy_active ) { | |
| 96 | 110 | add_action( 'admin_init', array( $this->settings, 'add_meta_box' ) ); |
| 97 | 111 | } else { |
| 98 | 112 | add_filter( 'sharing_meta_box_title', array( $this->settings, 'add_likes_to_sharing_meta_box_title' ) ); |
| 99 | 113 | add_action( 'start_sharing_meta_box_content', array( $this->settings, 'meta_box_content' ) ); |
| @@ -104,10 +118,8 @@ | ||
| 104 | 118 | add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_register_scripts' ) ); |
| 105 | 119 | |
| 106 | 120 | add_action( 'save_post', array( $this->settings, 'meta_box_save' ) ); |
| 107 | 121 | add_action( 'edit_attachment', array( $this->settings, 'meta_box_save' ) ); |
| 108 | - add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_init' ), 20 ); | |
| 109 | - add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_callback' ), 20 ); | |
| 110 | 122 | } |
| 111 | 123 | |
| 112 | 124 | /** |
| 113 | 125 | * Set the social_notifications_like option to `on` when the Likes module is activated. |
| @@ -138,21 +150,51 @@ | ||
| 138 | 150 | } |
| 139 | 151 | |
| 140 | 152 | /** |
| 141 | 153 | * Loads Jetpack's CSS on the sharing page so we can use .jetpack-targetable |
| 154 | + * | |
| 155 | + * @deprecated 16.3 Settings > Sharing is a plain WordPress settings screen now. | |
| 156 | + * | |
| 157 | + * @return void | |
| 142 | 158 | */ |
| 143 | 159 | public function load_jp_css() { |
| 144 | - /** | |
| 145 | - * Do we really need `admin_styles`? With the new admin UI, it's breaking some bits. | |
| 146 | - * Jetpack::init()->admin_styles(); | |
| 147 | - */ | |
| 160 | + _deprecated_function( __METHOD__, 'jetpack-16.3' ); | |
| 148 | 161 | } |
| 149 | 162 | |
| 150 | 163 | /** |
| 164 | + * Adds in the jetpack-targetable class so when we visit sharing#likes our like settings get highlighted by a yellow box | |
| 165 | + * | |
| 166 | + * @deprecated 16.3 The Likes settings have a section of their own on Settings > Sharing. | |
| 167 | + * | |
| 168 | + * @param string $html row heading for the sharedaddy "which page" setting. | |
| 169 | + * @return string The unchanged $html. | |
| 170 | + */ | |
| 171 | + public function configuration_target_area( $html = '' ) { | |
| 172 | + _deprecated_function( __METHOD__, 'jetpack-16.3' ); | |
| 173 | + return $html; | |
| 174 | + } | |
| 175 | + | |
| 176 | + /** | |
| 151 | 177 | * Load scripts and styles for front end. |
| 152 | 178 | */ |
| 153 | 179 | public function load_styles_register_scripts() { |
| 154 | - wp_enqueue_style( 'jetpack_likes', plugins_url( 'likes/style.css', __FILE__ ), array(), JETPACK__VERSION ); | |
| 180 | + // Likes are only rendered on pages that display post content. | |
| 181 | + if ( ! is_singular() && ! is_home() && ! is_front_page() && ! is_archive() && ! is_search() ) { | |
| 182 | + return; | |
| 183 | + } | |
| 184 | + | |
| 185 | + $style_url = Assets::get_file_url_for_environment( | |
| 186 | + '_inc/build/likes/style.min.css', | |
| 187 | + 'modules/likes/style.css' | |
| 188 | + ); | |
| 189 | + wp_enqueue_style( 'jetpack_likes', $style_url, array(), JETPACK__VERSION ); | |
| 190 | + $style_path = plugin_dir_path( JETPACK__PLUGIN_FILE ) . ( | |
| 191 | + /** This filter is documented in projects/plugins/jetpack/load-jetpack.php */ | |
| 192 | + apply_filters( 'jetpack_should_use_minified_assets', true ) | |
| 193 | + ? '_inc/build/likes/style.min.css' | |
| 194 | + : 'modules/likes/style.css' | |
| 195 | + ); | |
| 196 | + wp_style_add_data( 'jetpack_likes', 'path', $style_path ); | |
| 155 | 197 | wp_register_script( |
| 156 | 198 | 'jetpack_likes_queuehandler', |
| 157 | 199 | Assets::get_file_url_for_environment( |
| 158 | 200 | '_inc/build/likes/queuehandler.min.js', |
| @@ -164,21 +206,10 @@ | ||
| 164 | 206 | ); |
| 165 | 207 | } |
| 166 | 208 | |
| 167 | 209 | /** |
| 168 | - * Adds in the jetpack-targetable class so when we visit sharing#likes our like settings get highlighted by a yellow box | |
| 169 | - * | |
| 170 | - * @param string $html row heading for the sharedaddy "which page" setting. | |
| 171 | - * @return string $html with the jetpack-targetable class and likes id. tbody gets closed after the like settings | |
| 210 | + * Options to be added to the discussion page. The Sharing settings live in Sharing_Likes\Settings\Likes_Section. | |
| 172 | 211 | */ |
| 173 | - public function configuration_target_area( $html = '' ) { | |
| 174 | - $html = "<tbody id='likes' class='jetpack-targetable'>" . $html; | |
| 175 | - return $html; | |
| 176 | - } | |
| 177 | - | |
| 178 | - /** | |
| 179 | - * Options to be added to the discussion page (see also admin_settings_init, etc below for Sharing settings page) | |
| 180 | - */ | |
| 181 | 212 | public function admin_discussion_likes_settings_init() { |
| 182 | 213 | // Add a temporary section, until we can move the setting out of there and with the rest of the email notification settings. |
| 183 | 214 | add_settings_section( 'likes-notifications', __( 'Likes Notifications', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_section' ), 'discussion' ); |
| 184 | 215 | add_settings_field( 'social-notifications', __( 'Email me whenever', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_field' ), 'discussion', 'likes-notifications' ); |
| @@ -287,16 +318,18 @@ | ||
| 287 | 318 | ?> |
| 288 | 319 | <style type="text/css"> |
| 289 | 320 | .vers img { display: none; } |
| 290 | 321 | .metabox-prefs .vers img { display: inline; } |
| 291 | - .fixed .column-likes { width: 5.5em; padding: 8px 0; text-align: left; } | |
| 292 | - .fixed .column-stats { width: 5em; } | |
| 322 | + .fixed .column-likes { width: 2.5em; padding: 4px 0; text-align: left; } | |
| 323 | + .fixed .column-stats { width: 5em; white-space: nowrap; } | |
| 293 | 324 | .fixed .column-likes .post-com-count { |
| 294 | 325 | -webkit-box-sizing: border-box; |
| 295 | 326 | -moz-box-sizing: border-box; |
| 296 | 327 | box-sizing: border-box; |
| 297 | 328 | display: inline-block; |
| 298 | - padding: 0 8px; | |
| 329 | + padding: 0 4px; | |
| 330 | + min-width: 2em; | |
| 331 | + text-align: center; | |
| 299 | 332 | height: 2em; |
| 300 | 333 | margin-top: 5px; |
| 301 | 334 | -webkit-border-radius: 5px; |
| 302 | 335 | border-radius: 5px; |
| @@ -306,9 +339,9 @@ | ||
| 306 | 339 | line-height: 21px; |
| 307 | 340 | } |
| 308 | 341 | .fixed .column-likes .post-com-count::after { border: none !important; } |
| 309 | 342 | .fixed .column-likes .post-com-count:hover { background-color: #2271b1; } |
| 310 | - .fixed .column-likes .vers:before { | |
| 343 | + .fixed .column-likes .vers::before { | |
| 311 | 344 | font: normal 20px/1 dashicons; |
| 312 | 345 | content: '\f155'; |
| 313 | 346 | speak: none; |
| 314 | 347 | -webkit-font-smoothing: antialiased; |
| @@ -335,9 +368,9 @@ | ||
| 335 | 368 | 'modules/likes/post-count.js' |
| 336 | 369 | ), |
| 337 | 370 | array( 'jquery' ), |
| 338 | 371 | JETPACK__VERSION, |
| 339 | - $in_footer = false | |
| 372 | + false | |
| 340 | 373 | ); |
| 341 | 374 | wp_enqueue_script( |
| 342 | 375 | 'likes-post-count-jetpack', |
| 343 | 376 | Assets::get_file_url_for_environment( |
| @@ -345,9 +378,9 @@ | ||
| 345 | 378 | 'modules/likes/post-count-jetpack.js' |
| 346 | 379 | ), |
| 347 | 380 | array( 'jquery', 'likes-post-count' ), |
| 348 | 381 | JETPACK__VERSION, |
| 349 | - $in_footer = false | |
| 382 | + false | |
| 350 | 383 | ); |
| 351 | 384 | } |
| 352 | 385 | } |
| 353 | 386 | |
| @@ -417,28 +450,19 @@ | ||
| 417 | 450 | $url = home_url(); |
| 418 | 451 | $url_parts = wp_parse_url( $url ); |
| 419 | 452 | $domain = $url_parts['host']; |
| 420 | 453 | |
| 421 | - // Make sure to include the scripts before the iframe otherwise weird things happen. | |
| 422 | - add_action( 'wp_footer', 'jetpack_likes_master_iframe', 21 ); | |
| 454 | + // Make sure to include the `queuehandler` scripts before the iframe otherwise the script won't find the iframe. | |
| 455 | + if ( ! has_action( 'wp_footer', 'jetpack_likes_master_iframe' ) ) { | |
| 456 | + add_action( 'wp_footer', 'jetpack_likes_master_iframe', 21 ); | |
| 457 | + } | |
| 423 | 458 | |
| 424 | 459 | /** |
| 425 | 460 | * If the same post appears more then once on a page the page goes crazy |
| 426 | 461 | * we need a slightly more unique id / name for the widget wrapper. |
| 427 | 462 | */ |
| 428 | - $uniqid = uniqid(); | |
| 429 | - /** | |
| 430 | - * Enable an alternate Likes layout. | |
| 431 | - * | |
| 432 | - * @since 12.9 | |
| 433 | - * | |
| 434 | - * @module likes | |
| 435 | - * | |
| 436 | - * @param bool $new_layout Enable the new Likes layout. False by default. | |
| 437 | - */ | |
| 438 | - $new_layout = apply_filters( 'likes_new_layout', true ) ? '&n=1' : ''; | |
| 439 | - | |
| 440 | - $src = sprintf( 'https://widgets.wp.com/likes/?ver=%1$s#blog_id=%2$d&post_id=%3$d&origin=%4$s&obj_id=%2$d-%3$d-%5$s%6$s', rawurlencode( JETPACK__VERSION ), $blog_id, $post_id, $domain, $uniqid, $new_layout ); | |
| 463 | + $uniqid = uniqid(); | |
| 464 | + $src = sprintf( 'https://widgets.wp.com/likes/?ver=%1$s#blog_id=%2$d&post_id=%3$d&origin=%4$s&obj_id=%2$d-%3$d-%5$s', rawurlencode( JETPACK__VERSION ), $blog_id, $post_id, $domain, $uniqid ); | |
| 441 | 465 | $name = sprintf( 'like-post-frame-%1$d-%2$d-%3$s', $blog_id, $post_id, $uniqid ); |
| 442 | 466 | $wrapper = sprintf( 'like-post-wrapper-%1$d-%2$d-%3$s', $blog_id, $post_id, $uniqid ); |
| 443 | 467 | $headline = sprintf( |
| 444 | 468 | /** This filter is already documented in modules/sharedaddy/sharing-service.php */ |
| @@ -447,11 +471,15 @@ | ||
| 447 | 471 | ); |
| 448 | 472 | |
| 449 | 473 | $title = esc_html__( 'Like or Reblog', 'jetpack' ); |
| 450 | 474 | |
| 475 | + /** This filter is documented in modules/likes/jetpack-likes-master-iframe.php */ | |
| 476 | + $src = apply_filters( 'jetpack_likes_iframe_src', $src ); | |
| 477 | + | |
| 451 | 478 | $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'>"; |
| 452 | 479 | $html .= $headline; |
| 453 | - $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>'; | |
| 480 | + require_once JETPACK__PLUGIN_DIR . '_inc/lib/class-jetpack-spinner.php'; | |
| 481 | + $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">' . Jetpack_Spinner::render( 18 ) . '<span class="screen-reader-text">' . esc_html__( 'Loading…', 'jetpack' ) . '</span></span></div>'; | |
| 454 | 482 | $html .= "<span class='sd-text-color'></span><a class='sd-link-color'></a>"; |
| 455 | 483 | $html .= '</div>'; |
| 456 | 484 | |
| 457 | 485 | // Let's make sure that the script is enqueued. |
| @@ -463,100 +491,43 @@ | ||
| 463 | 491 | |
| 464 | 492 | /** |
| 465 | 493 | * Callback to get the value for the jetpack_likes_enabled field. |
| 466 | 494 | * |
| 467 | - * Warning: this behavior is somewhat complicated! | |
| 468 | - * When the switch_like_status post_meta is unset, we follow the global setting in Sharing. | |
| 469 | - * When it is set to 0, we disable likes on the post, regardless of the global setting. | |
| 470 | - * When it is set to 1, we enable likes on the post, regardless of the global setting. | |
| 495 | + * @deprecated 16.3 Use Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::get_value() instead. | |
| 471 | 496 | * |
| 472 | 497 | * @param array $post - post data we're checking. |
| 473 | 498 | * |
| 474 | - * @return bool | |
| 499 | + * @return bool|null | |
| 475 | 500 | */ |
| 476 | 501 | function jetpack_post_likes_get_value( array $post ) { |
| 477 | - if ( ! isset( $post['id'] ) ) { | |
| 478 | - return false; | |
| 479 | - } | |
| 480 | - | |
| 481 | - $post_likes_switched = get_post_meta( $post['id'], 'switch_like_status', true ); | |
| 482 | - | |
| 483 | - /** This filter is documented in modules/jetpack-likes-settings.php */ | |
| 484 | - $sitewide_likes_enabled = (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) ); | |
| 485 | - | |
| 486 | - // An empty string: post meta was not set, so go with the global setting. | |
| 487 | - if ( '' === $post_likes_switched ) { | |
| 488 | - return $sitewide_likes_enabled; | |
| 489 | - } elseif ( '0' === $post_likes_switched ) { // User overrode the global setting to disable likes. | |
| 490 | - return false; | |
| 491 | - } elseif ( '1' === $post_likes_switched ) { // User overrode the global setting to enable likes. | |
| 492 | - return true; | |
| 493 | - } | |
| 494 | - // No default fallback, let's stay explicit. | |
| 502 | + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::get_value' ); | |
| 503 | + return Post_Likes_Switch::get_value( $post ); | |
| 495 | 504 | } |
| 496 | 505 | |
| 497 | 506 | /** |
| 498 | 507 | * Callback to set switch_like_status post_meta when jetpack_likes_enabled is updated. |
| 499 | 508 | * |
| 500 | - * Warning: this behavior is somewhat complicated! | |
| 501 | - * When the switch_like_status post_meta is unset, we follow the global setting in Sharing. | |
| 502 | - * When it is set to 0, we disable likes on the post, regardless of the global setting. | |
| 503 | - * When it is set to 1, we enable likes on the post, regardless of the global setting. | |
| 509 | + * @deprecated 16.3 Use Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::update_value() instead. | |
| 504 | 510 | * |
| 505 | 511 | * @param bool $enable_post_likes - checks if post likes are enabled. |
| 506 | 512 | * @param object $post_object - object containing post data. |
| 513 | + * | |
| 514 | + * @return int|bool | |
| 507 | 515 | */ |
| 508 | 516 | function jetpack_post_likes_update_value( $enable_post_likes, $post_object ) { |
| 509 | - /** This filter is documented in modules/jetpack-likes-settings.php */ | |
| 510 | - $sitewide_likes_enabled = (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) ); | |
| 511 | - | |
| 512 | - $should_switch_status = $enable_post_likes !== $sitewide_likes_enabled; | |
| 513 | - | |
| 514 | - if ( $should_switch_status ) { | |
| 515 | - // Set the meta to 0 if the user wants to disable likes, 1 if user wants to enable. | |
| 516 | - $switch_like_status = ( $enable_post_likes ? 1 : 0 ); | |
| 517 | - return update_post_meta( $post_object->ID, 'switch_like_status', $switch_like_status ); | |
| 518 | - } else { | |
| 519 | - // Unset the meta otherwise. | |
| 520 | - return delete_post_meta( $post_object->ID, 'switch_like_status' ); | |
| 521 | - } | |
| 517 | + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::update_value' ); | |
| 518 | + return Post_Likes_Switch::update_value( $enable_post_likes, $post_object ); | |
| 522 | 519 | } |
| 523 | 520 | |
| 524 | 521 | /** |
| 525 | 522 | * Add Likes post_meta to the REST API Post response. |
| 526 | 523 | * |
| 527 | - * @action rest_api_init | |
| 528 | - * @uses register_rest_field | |
| 529 | - * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ | |
| 524 | + * @deprecated 16.3 Use Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::register_rest_field() instead. | |
| 530 | 525 | */ |
| 531 | 526 | function jetpack_post_likes_register_rest_field() { |
| 532 | - $post_types = get_post_types( array( 'public' => true ) ); | |
| 533 | - foreach ( $post_types as $post_type ) { | |
| 534 | - register_rest_field( | |
| 535 | - $post_type, | |
| 536 | - 'jetpack_likes_enabled', | |
| 537 | - array( | |
| 538 | - 'get_callback' => 'jetpack_post_likes_get_value', | |
| 539 | - 'update_callback' => 'jetpack_post_likes_update_value', | |
| 540 | - 'schema' => array( | |
| 541 | - 'description' => __( 'Are Likes enabled?', 'jetpack' ), | |
| 542 | - 'type' => 'boolean', | |
| 543 | - ), | |
| 544 | - ) | |
| 545 | - ); | |
| 546 | - | |
| 547 | - /** | |
| 548 | - * Ensures all public internal post-types support `likes` | |
| 549 | - * This feature support flag is used by the REST API and Gutenberg. | |
| 550 | - */ | |
| 551 | - add_post_type_support( $post_type, 'jetpack-post-likes' ); | |
| 552 | - } | |
| 527 | + _deprecated_function( __FUNCTION__, 'jetpack-16.3', 'Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::register_rest_field' ); | |
| 528 | + Post_Likes_Switch::register_rest_field(); | |
| 553 | 529 | } |
| 554 | 530 | |
| 555 | -// Add Likes post_meta to the REST API Post response. | |
| 556 | -add_action( 'rest_api_init', 'jetpack_post_likes_register_rest_field' ); | |
| 557 | - | |
| 558 | -// Some CPTs (e.g. Jetpack portfolios and testimonials) get registered with | |
| 559 | -// restapi_theme_init because they depend on theme support, so let's also hook to that. | |
| 560 | -add_action( 'restapi_theme_init', 'jetpack_post_likes_register_rest_field', 20 ); | |
| 531 | +Post_Likes_Switch::init(); | |
| 561 | 532 | |
| 562 | 533 | Jetpack_Likes::init(); |