PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
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 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/comment-likes.php +26 -5 13.5.216.3-a.1 View file →
@@ -1,8 +1,8 @@
1 1 <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2 /**
3 3 * Module Name: Comment Likes
4 - * Module Description: Increase visitor engagement by adding a Like button to comments.
4 + * Module Description: Enable visitors to like individual comments and boost engagement.
5 5 * Sort Order: 39
6 6 * Recommendation Order: 17
7 7 * First Introduced: 5.1
8 8 * Requires Connection: Yes
@@ -14,8 +14,12 @@
14 14 */
15 15
16 16 use Automattic\Jetpack\Assets;
17 17
18 +if ( ! defined( 'ABSPATH' ) ) {
19 + exit( 0 );
20 +}
21 +
18 22 Assets::add_resource_hint( '//widgets.wp.com', 'dns-prefetch' );
19 23
20 24 require_once __DIR__ . '/likes/jetpack-likes-master-iframe.php';
21 25 require_once __DIR__ . '/likes/jetpack-likes-settings.php';
@@ -65,23 +69,36 @@
65 69 private function __construct() {
66 70 $this->settings = new Jetpack_Likes_Settings();
67 71 $this->blog_id = Jetpack_Options::get_option( 'id' );
68 72 $url_parts = wp_parse_url( home_url() );
69 - $this->domain = $url_parts['host'];
70 73
74 + // Abort if domain can't be determined.
75 + if ( ! $url_parts || ! isset( $url_parts['host'] ) ) {
76 + return;
77 + }
78 + $this->domain = $url_parts['host'];
79 +
71 80 add_action( 'template_redirect', array( $this, 'frontend_init' ) );
72 81 add_action( 'admin_init', array( $this, 'admin_init' ) );
73 82
74 83 if ( ! Jetpack::is_module_active( 'likes' ) ) {
75 - $active = Jetpack::get_active_modules();
84 + $active = Jetpack::get_active_modules();
85 + $sharedaddy_active = in_array( 'sharedaddy', $active, true );
76 86
77 - if ( in_array( 'publicize', $active, true ) && ! in_array( 'sharedaddy', $active, true ) ) {
87 + if ( $this->settings->needs_own_sharing_menu( $sharedaddy_active ) ) {
88 + /*
89 + * Sharedaddy is what registers Settings > Sharing, and it is off, so we
90 + * register that screen ourselves; the Likes settings that gate comment
91 + * likes are displayed on it.
92 + */
93 + add_action( 'admin_menu', array( $this->settings, 'sharing_menu' ) );
94 + } elseif ( in_array( 'publicize', $active, true ) && ! $sharedaddy_active ) {
78 95 // we have a sharing page but not the global options area.
79 96 add_action( 'pre_admin_screen_sharing', array( $this->settings, 'sharing_block' ), 20 );
80 97 add_action( 'pre_admin_screen_sharing', array( $this->settings, 'updated_message' ), -10 );
81 98 }
82 99
83 - if ( ! in_array( 'sharedaddy', $active, true ) ) {
100 + if ( ! $sharedaddy_active ) {
84 101 add_action( 'admin_init', array( $this->settings, 'process_update_requests_if_sharedaddy_not_loaded' ) );
85 102 add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_showbuttonon_init' ), 19 );
86 103 add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_showbuttonon_callback' ), 19 );
87 104 add_action( 'admin_init', array( $this->settings, 'add_meta_box' ) );
@@ -205,8 +222,12 @@
205 222 $comment_id = $comment->comment_ID;
206 223 }
207 224
208 225 if ( empty( $content ) || empty( $comment_id ) ) {
226 + return $content;
227 + }
228 +
229 + if ( empty( $comment->comment_approved ) ) {
209 230 return $content;
210 231 }
211 232
212 233 // In case master iframe hasn't been loaded. This could be the case when Post Likes module is disabled,