PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.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 All 507 releases
← All changes | extensions/plugins/likes/likes.php +17 -1 13.3.3 → 16.3-beta View file →
@@ -7,12 +7,17 @@
7 7
8 8 namespace Automattic\Jetpack\Extensions\Likes;
9 9
10 10 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
11 +use Automattic\Jetpack\Modules;
11 12 use Automattic\Jetpack\Status;
12 13 use Automattic\Jetpack\Status\Host;
13 14 use Jetpack_Gutenberg;
14 15
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit( 0 );
18 +}
19 +
15 20 /**
16 21 * Register Likes plugin.
17 22 *
18 23 * @return void
@@ -17,8 +22,19 @@
17 22 *
18 23 * @return void
19 24 */
20 25 function register_plugins() {
26 + $modules = new Modules();
27 +
28 + // The panel's per-post switch applies to Like buttons and Comment Likes alike.
29 + $shows_switch = $modules->is_active( 'likes' ) || $modules->is_active( 'comment-likes' );
30 +
31 + // Without it, the panel can only nudge to activate Likes. Skip that for users who can't,
32 + // and on block themes, where the Like block in a template replaces the legacy module.
33 + if ( ! $shows_switch && ( ! current_user_can( 'jetpack_activate_modules' ) || wp_is_block_theme() ) ) {
34 + return;
35 + }
36 +
21 37 // Register Likes.
22 38 if (
23 39 ( new Host() )->is_wpcom_simple()
24 40 || ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() )
@@ -34,9 +50,9 @@
34 50 */
35 51 add_action(
36 52 'rest_api_init',
37 53 function () {
38 - if ( ! \Jetpack::is_module_active( 'likes' ) ) {
54 + if ( ! ( new Modules() )->is_active( 'likes' ) ) {
39 55 $post_types = get_post_types( array( 'public' => true ) );
40 56 foreach ( $post_types as $post_type ) {
41 57 add_post_type_support( $post_type, 'jetpack-post-likes' );
42 58 }