PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.4
Jetpack – WP Security, Backup, Speed, & Growth v6.4
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 14.4.2 All 500 releases
← All changes | modules/comments/comments.php +217 -596 13.2.46.4 View file →
@@ -1,19 +1,13 @@
1 -<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 -/**
3 - * Module: Comments
4 - *
5 - * @package automattic/jetpack
6 - */
1 +<?php
7 2
8 -require __DIR__ . '/base.php';
9 -use Automattic\Jetpack\Connection\Tokens;
10 -use Automattic\Jetpack\Status\Host;
3 +require dirname( __FILE__ ) . '/base.php';
11 4
12 5 /**
13 6 * Main Comments class
14 7 *
15 - * @package automattic/jetpack
8 + * @package JetpackComments
9 + * @version 1.4
16 10 * @since 1.4
17 11 */
18 12 class Jetpack_Comments extends Highlander_Comments_Base {
19 13
@@ -19,24 +13,21 @@
19 13
20 14 /** Variables *************************************************************/
21 15
22 16 /**
23 - * Possible comment form sources - empty array as default
24 - *
17 + * Possible comment form sources
25 18 * @var array
26 19 */
27 20 public $id_sources = array();
28 21
29 22 /**
30 - * Remote comment URL - empty string as default
31 - *
23 + * URL
32 24 * @var string
33 25 */
34 26 public $signed_url = '';
35 27
36 28 /**
37 - * The default comment form color scheme - default is light
38 - *
29 + * The default comment form color scheme
39 30 * @var string
40 31 * @see ::set_default_color_theme_based_on_theme_settings()
41 32 */
42 33 public $default_color_scheme = 'light';
@@ -42,16 +33,13 @@
42 33 public $default_color_scheme = 'light';
43 34
44 35 /** Methods ***************************************************************/
45 36
46 - /**
47 - * Initialize class
48 - */
49 37 public static function init() {
50 38 static $instance = false;
51 39
52 40 if ( ! $instance ) {
53 - $instance = new Jetpack_Comments();
41 + $instance = new Jetpack_Comments;
54 42 }
55 43
56 44 return $instance;
57 45 }
@@ -58,14 +46,14 @@
58 46
59 47 /**
60 48 * Main constructor for Comments
61 49 *
62 - * @since 1.4
50 + * @since JetpackComments (1.4)
63 51 */
64 52 public function __construct() {
65 53 parent::__construct();
66 54
67 - // Comments is loaded.
55 + // Comments is loaded
68 56
69 57 /**
70 58 * Fires after the Jetpack_Comments object has been instantiated
71 59 *
@@ -73,16 +61,13 @@
73 61 *
74 62 * @since 1.4.0
75 63 *
76 64 * @param array $jetpack_comments_loaded First element in array of type Jetpack_Comments
77 - */
65 + **/
78 66 do_action_ref_array( 'jetpack_comments_loaded', array( $this ) );
79 67 add_action( 'after_setup_theme', array( $this, 'set_default_color_theme_based_on_theme_settings' ), 100 );
80 68 }
81 69
82 - /**
83 - * Set the default comments color theme based on theme settings
84 - */
85 70 public function set_default_color_theme_based_on_theme_settings() {
86 71 if ( function_exists( 'twentyeleven_get_theme_options' ) ) {
87 72 $theme_options = twentyeleven_get_theme_options();
88 73 $theme_color_scheme = isset( $theme_options['color_scheme'] ) ? $theme_options['color_scheme'] : 'transparent';
@@ -88,10 +73,10 @@
88 73 $theme_color_scheme = isset( $theme_options['color_scheme'] ) ? $theme_options['color_scheme'] : 'transparent';
89 74 } else {
90 75 $theme_color_scheme = get_theme_mod( 'color_scheme', 'transparent' );
91 76 }
92 - // Default for $theme_color_scheme is 'transparent' just so it doesn't match 'light' or 'dark'.
93 - // The default for Jetpack's color scheme is still defined above as 'light'.
77 + // Default for $theme_color_scheme is 'transparent' just so it doesn't match 'light' or 'dark'
78 + // The default for Jetpack's color scheme is still defined above as 'light'
94 79
95 80 if ( false !== stripos( $theme_color_scheme, 'light' ) ) {
96 81 $this->default_color_scheme = 'light';
97 82 } elseif ( false !== stripos( $theme_color_scheme, 'dark' ) ) {
@@ -102,51 +87,46 @@
102 87 /** Private Methods *******************************************************/
103 88
104 89 /**
105 90 * Set any global variables or class variables
106 - *
107 - * This is primarily defining the comment form sources.
108 - *
109 - * @since 1.4
91 + * @since JetpackComments (1.4)
110 92 */
111 93 protected function setup_globals() {
112 94 parent::setup_globals();
113 95
114 - // Sources.
96 + // Sources
115 97 $this->id_sources = array(
116 98 'guest',
117 99 'jetpack',
118 100 'wordpress',
119 - 'facebook',
101 + 'twitter',
102 + 'facebook'
120 103 );
121 104 }
122 105
123 106 /**
124 107 * Setup actions for methods in this class
125 - *
126 - * @since 1.4
108 + * @since JetpackComments (1.4)
127 109 */
128 110 protected function setup_actions() {
129 111 parent::setup_actions();
130 112
131 - // Selfishly remove everything from the existing comment form.
113 + // Selfishly remove everything from the existing comment form
132 114 remove_all_actions( 'comment_form_before' );
133 115
134 - // Selfishly add only our actions back to the comment form.
135 - add_action( 'comment_form_before', array( $this, 'manage_post_cookie' ) );
116 + // Selfishly add only our actions back to the comment form
136 117 add_action( 'comment_form_before', array( $this, 'comment_form_before' ) );
137 - add_action( 'comment_form_after', array( $this, 'comment_form_after' ), 1 ); // Set very early since we remove everything outputed before our action.
118 + add_action( 'comment_form_after', array( $this, 'comment_form_after' ), 1 ); // Set very early since we remove everything outputed before our action.
138 119
139 - // Before a comment is posted.
120 + // Before a comment is posted
140 121 add_action( 'pre_comment_on_post', array( $this, 'pre_comment_on_post' ), 1 );
141 122
142 - // After a comment is posted.
123 + // After a comment is posted
143 124 add_action( 'comment_post', array( $this, 'add_comment_meta' ) );
144 125 }
145 126
146 127 /**
147 128 * Setup filters for methods in this class
148 - *
149 129 * @since 1.6.2
150 130 */
151 131 protected function setup_filters() {
152 132 parent::setup_filters();
@@ -151,167 +131,50 @@
151 131 protected function setup_filters() {
152 132 parent::setup_filters();
153 133
154 134 add_filter( 'comment_post_redirect', array( $this, 'capture_comment_post_redirect_to_reload_parent_frame' ), 100 );
155 - add_filter( 'comment_duplicate_trigger', array( $this, 'capture_comment_duplicate_trigger' ), 100 );
156 135 add_filter( 'get_avatar', array( $this, 'get_avatar' ), 10, 4 );
157 - // Fix comment reply link when `comment_registration` is required.
158 - add_filter( 'comment_reply_link', array( $this, 'comment_reply_link' ), 10, 4 );
159 136 }
160 137
161 138 /**
162 - * In order for comments to work properly for password-protected posts we need to set `wp-postpass` cookie to SameSite none.
163 - */
164 - public function manage_post_cookie() {
165 - $postpass_cookie_key = 'wp-postpass_' . COOKIEHASH;
166 -
167 - if ( empty( $_COOKIE[ $postpass_cookie_key ] ) ) {
168 - return;
169 - }
170 -
171 - $postpass_cookie_value = sanitize_text_field( wp_unslash( $_COOKIE[ $postpass_cookie_key ] ) );
172 -
173 - if ( empty( $_COOKIE['verbum-wp-postpass'] ) || ( $_COOKIE['verbum-wp-postpass'] !== $postpass_cookie_value ) ) {
174 - $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
175 -
176 - jetpack_shim_setcookie(
177 - $postpass_cookie_key,
178 - $postpass_cookie_value,
179 - array(
180 - 'expires' => $expire,
181 - 'samesite' => 'None',
182 - 'path' => '/',
183 - 'domain' => COOKIE_DOMAIN,
184 - 'secure' => is_ssl(),
185 - )
186 - );
187 -
188 - jetpack_shim_setcookie(
189 - 'verbum-wp-postpass',
190 - $postpass_cookie_value,
191 - array(
192 - 'expires' => $expire,
193 - 'samesite' => 'None',
194 - 'path' => '/',
195 - 'domain' => COOKIE_DOMAIN,
196 - 'secure' => is_ssl(),
197 - )
198 - );
199 - }
200 - }
201 -
202 - /**
203 - * Get the comment avatar from Gravatar or Twitter/Facebook.
139 + * Get the comment avatar from Gravatar, Twitter, or Facebook
204 140 *
205 - * Leaving the Twitter reference for legacy comments even though support is no longer offered.
141 + * @since JetpackComments (1.4)
206 142 *
207 - * @since 1.4
143 + * @param string $avatar Current avatar URL
144 + * @param string $comment Comment for the avatar
145 + * @param int $size Size of the avatar
146 + * @param string $default Not used
208 147 *
209 - * @param string $avatar Current avatar URL.
210 - * @param string $comment Comment for the avatar.
211 - * @param int $size Size of the avatar.
212 - *
213 148 * @return string New avatar
214 149 */
215 - public function get_avatar( $avatar, $comment, $size ) {
150 + public function get_avatar( $avatar, $comment, $size, $default ) {
216 151 if ( ! isset( $comment->comment_post_ID ) || ! isset( $comment->comment_ID ) ) {
217 - // it's not a comment - bail.
152 + // it's not a comment - bail
218 153 return $avatar;
219 154 }
220 155
221 - // Detect whether it's a Facebook avatar.
156 + // Detect whether it's a Facebook or Twitter avatar
222 157 $foreign_avatar = get_comment_meta( $comment->comment_ID, 'hc_avatar', true );
223 - $foreign_avatar_hostname = wp_parse_url( $foreign_avatar, PHP_URL_HOST );
158 + $foreign_avatar_hostname = parse_url( $foreign_avatar, PHP_URL_HOST );
224 159 if ( ! $foreign_avatar_hostname ||
225 160 ! preg_match( '/\.?(graph\.facebook\.com|twimg\.com)$/', $foreign_avatar_hostname ) ) {
226 161 return $avatar;
227 162 }
228 163
229 - // Return the Facebook or Twitter avatar.
164 + // Return the FB or Twitter avatar
230 165 return preg_replace( '#src=([\'"])[^\'"]+\\1#', 'src=\\1' . esc_url( set_url_scheme( $this->photon_avatar( $foreign_avatar, $size ), 'https' ) ) . '\\1', $avatar );
231 166 }
232 167
233 - /**
234 - * Set comment reply link.
235 - * This is to fix the reply link when comment registration is required.
236 - *
237 - * @param string $reply_link The HTML markup for the comment reply link.
238 - * @param array $args An array of arguments overriding the defaults.
239 - * @param WP_Comment $comment The object of the comment being replied.
240 - * @param WP_Post $post The WP_Post object.
241 - *
242 - * @return string New reply link.
243 - */
244 - public function comment_reply_link( $reply_link, $args, $comment, $post ) {
245 - // This is only necessary if comment_registration is required to post comments
246 - if ( ! get_option( 'comment_registration' ) ) {
247 - return $reply_link;
248 - }
249 -
250 - $respond_id = esc_attr( $args['respond_id'] );
251 - $add_below = esc_attr( $args['add_below'] );
252 - /* This is to accommodate some themes that add an SVG to the Reply link like twenty-seventeen. */
253 - $reply_text = wp_kses(
254 - $args['reply_text'],
255 - array(
256 - 'svg' => array(
257 - 'class' => true,
258 - 'aria-hidden' => true,
259 - 'aria-labelledby' => true,
260 - 'role' => true,
261 - 'xmlns' => true,
262 - 'width' => true,
263 - 'height' => true,
264 - 'viewbox' => true,
265 - ),
266 - 'use' => array(
267 - 'href' => true,
268 - 'xlink:href' => true,
269 - ),
270 - )
271 - );
272 - $before_link = wp_kses( $args['before'], wp_kses_allowed_html( 'post' ) );
273 - $after_link = wp_kses( $args['after'], wp_kses_allowed_html( 'post' ) );
274 -
275 - $reply_url = esc_url( add_query_arg( 'replytocom', $comment->comment_ID . '#' . $respond_id ) );
276 -
277 - return <<<HTML
278 - $before_link
279 - <a class="comment-reply-link" href="$reply_url" onclick="return addComment.moveForm( '$add_below-$comment->comment_ID', '$comment->comment_ID', '$respond_id', '$post->ID' )">$reply_text</a>
280 - $after_link
281 -HTML;
282 - }
283 -
284 - /**
285 - * Get the site's blog token.
286 - * This can be used to bypass Comments entirely if Jetpack is not properly connected.
287 - *
288 - * @since 11.2
289 - *
290 - * @return bool|object False if not properly connected. Object with the blog token if connected.
291 - */
292 - private function get_blog_token() {
293 - $blog_token = ( new Tokens() )->get_access_token();
294 - // If we have no token, bail.
295 - if ( ! $blog_token || is_wp_error( $blog_token ) ) {
296 - return false;
297 - }
298 -
299 - return $blog_token;
300 - }
301 -
302 168 /** Output Methods ********************************************************/
303 169
304 170 /**
305 171 * Start capturing the core comment_form() output
306 - *
307 - * Comment form output will only be captured if comments are enabled - we return otherwise.
308 - *
309 - * @since 1.4
172 + * @since JetpackComments (1.4)
310 173 */
311 174 public function comment_form_before() {
312 175 /**
313 - * Filters the setting that determines if Jetpack comments should be enabled for
176 + * Filters the setting that determines if Jetpagk comments should be enabled for
314 177 * the current post type.
315 178 *
316 179 * @module comments
317 180 *
@@ -322,14 +185,9 @@
322 185 if ( ! apply_filters( 'jetpack_comment_form_enabled_for_' . get_post_type(), true ) ) {
323 186 return;
324 187 }
325 188
326 - // If the Jetpack connection is not healthy, bail.
327 - if ( ! $this->get_blog_token() ) {
328 - return;
329 - }
330 -
331 - // Add some JS to the footer.
189 + // Add some JS to the footer
332 190 add_action( 'wp_footer', array( $this, 'watch_comment_parent' ), 100 );
333 191
334 192 ob_start();
335 193 }
@@ -337,9 +195,9 @@
337 195 /**
338 196 * Noop the default comment form output, get some options, and output our
339 197 * tricked out totally radical comment form.
340 198 *
341 - * @since 1.4
199 + * @since JetpackComments (1.4)
342 200 */
343 201 public function comment_form_after() {
344 202 /** This filter is documented in modules/comments/comments.php */
345 203 if ( ! apply_filters( 'jetpack_comment_form_enabled_for_' . get_post_type(), true ) ) {
@@ -345,18 +203,28 @@
345 203 if ( ! apply_filters( 'jetpack_comment_form_enabled_for_' . get_post_type(), true ) ) {
346 204 return;
347 205 }
348 206
349 - $blog_token = $this->get_blog_token();
350 - // If the Jetpack connection is not healthy, bail.
351 - if ( ! $blog_token ) {
207 + // Throw it all out and drop in our replacement
208 + ob_end_clean();
209 +
210 + // If users are required to be logged in, and they're not, then we don't need to do anything else
211 + if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
212 + /**
213 + * Changes the log in to comment prompt.
214 + *
215 + * @module comments
216 + *
217 + * @since 1.4.0
218 + *
219 + * @param string $var Default is "You must log in to post a comment."
220 + */
221 + echo '<p class="must-log-in">' . sprintf( apply_filters( 'jetpack_must_log_in_to_comment', __( 'You must <a href="%s">log in</a> to post a comment.', 'jetpack' ) ), wp_login_url( get_permalink() . '#respond' ) ) . '</p>';
222 +
352 223 return;
353 224 }
354 225
355 - // Throw it all out and drop in our replacement.
356 - ob_end_clean();
357 -
358 - if ( in_array( 'subscriptions', Jetpack::get_active_modules(), true ) ) {
226 + if ( in_array( 'subscriptions', Jetpack::get_active_modules() ) ) {
359 227 $stb_enabled = get_option( 'stb_enabled', 1 );
360 228 $stb_enabled = empty( $stb_enabled ) ? 0 : 1;
361 229
362 230 $stc_enabled = get_option( 'stc_enabled', 1 );
@@ -366,18 +234,17 @@
366 234 $stc_enabled = 0;
367 235 }
368 236
369 237 $params = array(
370 - 'blogid' => Jetpack_Options::get_option( 'id' ),
371 - 'postid' => get_the_ID(),
372 - 'comment_registration' => ( get_option( 'comment_registration' ) ? '1' : '0' ), // Need to explicitly send a '1' or a '0' for these.
373 - 'require_name_email' => ( get_option( 'require_name_email' ) ? '1' : '0' ),
374 - 'stc_enabled' => $stc_enabled,
375 - 'stb_enabled' => $stb_enabled,
376 - 'show_avatars' => ( get_option( 'show_avatars' ) ? '1' : '0' ),
377 - 'avatar_default' => get_option( 'avatar_default' ),
378 - 'greeting' => get_option( 'highlander_comment_form_prompt', __( 'Leave a Reply', 'jetpack' ) ),
379 - 'jetpack_comments_nonce' => wp_create_nonce( 'jetpack_comments_nonce-' . get_the_ID() ),
238 + 'blogid' => Jetpack_Options::get_option( 'id' ),
239 + 'postid' => get_the_ID(),
240 + 'comment_registration' => ( get_option( 'comment_registration' ) ? '1' : '0' ), // Need to explicitly send a '1' or a '0' for these
241 + 'require_name_email' => ( get_option( 'require_name_email' ) ? '1' : '0' ),
242 + 'stc_enabled' => $stc_enabled,
243 + 'stb_enabled' => $stb_enabled,
244 + 'show_avatars' => ( get_option( 'show_avatars' ) ? '1' : '0' ),
245 + 'avatar_default' => get_option( 'avatar_default' ),
246 + 'greeting' => get_option( 'highlander_comment_form_prompt', __( 'Leave a Reply', 'jetpack' ) ),
380 247 /**
381 248 * Changes the comment form prompt.
382 249 *
383 250 * @module comments
@@ -385,19 +252,15 @@
385 252 * @since 2.3.0
386 253 *
387 254 * @param string $var Default is "Leave a Reply to %s."
388 255 */
389 - 'greeting_reply' => apply_filters(
390 - 'jetpack_comment_form_prompt_reply',
391 - /* translators: %s is the displayed username of the post (or comment) author */
392 - __( 'Leave a Reply to %s', 'jetpack' )
393 - ),
394 - 'color_scheme' => get_option( 'jetpack_comment_form_color_scheme', $this->default_color_scheme ),
395 - 'lang' => get_locale(),
396 - 'jetpack_version' => JETPACK__VERSION,
256 + 'greeting_reply' => apply_filters( 'jetpack_comment_form_prompt_reply', __( 'Leave a Reply to %s', 'jetpack' ) ),
257 + 'color_scheme' => get_option( 'jetpack_comment_form_color_scheme', $this->default_color_scheme ),
258 + 'lang' => get_locale(),
259 + 'jetpack_version' => JETPACK__VERSION,
397 260 );
398 261
399 - // Extra parameters for logged in user.
262 + // Extra parameters for logged in user
400 263 if ( is_user_logged_in() ) {
401 264 $current_user = wp_get_current_user();
402 265 $params['hc_post_as'] = 'jetpack';
403 266 $params['hc_userid'] = $current_user->ID;
@@ -407,49 +270,28 @@
407 270 if ( current_user_can( 'unfiltered_html' ) ) {
408 271 $params['_wp_unfiltered_html_comment'] = wp_create_nonce( 'unfiltered-html-comment_' . get_the_ID() );
409 272 }
410 273 } else {
411 - $commenter = wp_get_current_commenter();
274 + $commenter = wp_get_current_commenter();
412 275 $params['show_cookie_consent'] = (int) has_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
413 - $params['has_cookie_consent'] = (int) ! empty( $commenter['comment_author_email'] );
414 - // Jetpack_Memberships for logged out users only checks for the wp-jp-premium-content-session cookie
415 - $params['is_current_user_subscribed'] = class_exists( '\Jetpack_Memberships' ) ? (int) Jetpack_Memberships::is_current_user_subscribed() : 0;
276 + $params['has_cookie_consent'] = (int) ! empty( $commenter['comment_author_email'] );
416 277 }
417 278
418 - list( $token_key ) = explode( '.', $blog_token->secret, 2 );
419 - // Prophylactic check: anything else should never happen.
420 - if ( $token_key && $token_key !== $blog_token->secret ) {
421 - // Is the token a Special Token (@see class.tokens.php)?
422 - if ( preg_match( '/^;.\d+;\d+;$/', $token_key, $matches ) ) {
423 - // The token key for a Special Token is public.
424 - $params['token_key'] = $token_key;
425 - } else {
426 - /*
427 - * The token key for a Normal Token is public but
428 - * looks like sensitive data. Since there can only be
429 - * one Normal Token per site, avoid concern by
430 - * sending the magic "use the Normal Token" token key.
431 - */
432 - $params['token_key'] = Tokens::MAGIC_NORMAL_TOKEN_KEY;
433 - }
434 - }
435 -
436 - $signature = self::sign_remote_comment_parameters( $params, $blog_token->secret );
279 + $signature = Jetpack_Comments::sign_remote_comment_parameters( $params, Jetpack_Options::get_option( 'blog_token' ) );
437 280 if ( is_wp_error( $signature ) ) {
438 281 $signature = 'error';
439 282 }
440 283
441 - $params['sig'] = $signature;
442 - $url_origin = 'https://jetpack.wordpress.com';
443 - $url = "{$url_origin}/jetpack-comment/?" . http_build_query( $params );
444 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sniff misses the esc_url_raw.
445 - $url = "{$url}#parent=" . rawurlencode( esc_url_raw( set_url_scheme( 'http://' . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) ) ) );
284 + $params['sig'] = $signature;
285 + $url_origin = set_url_scheme( 'http://jetpack.wordpress.com' );
286 + $url = "{$url_origin}/jetpack-comment/?" . http_build_query( $params );
287 + $url = "{$url}#parent=" . urlencode( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
446 288 $this->signed_url = $url;
447 - $height = $params['comment_registration'] || is_user_logged_in() ? '315' : '430'; // Iframe can be shorter if we're not allowing guest commenting.
448 - $transparent = ( 'transparent' === $params['color_scheme'] ) ? 'true' : 'false';
289 + $height = $params['comment_registration'] || is_user_logged_in() ? '315' : '430'; // Iframe can be shorter if we're not allowing guest commenting
290 + $transparent = ( $params['color_scheme'] == 'transparent' ) ? 'true' : 'false';
449 291
450 - if ( isset( $_GET['replytocom'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
451 - $url .= '&replytocom=' . (int) $_GET['replytocom']; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
292 + if ( isset( $_GET['replytocom'] ) ) {
293 + $url .= '&replytocom=' . (int) $_GET['replytocom'];
452 294 }
453 295
454 296 /**
455 297 * Filter whether the comment title can be displayed.
@@ -461,72 +303,26 @@
461 303 * @param bool $show Can the comment be displayed? Default to true.
462 304 */
463 305 $show_greeting = apply_filters( 'jetpack_comment_form_display_greeting', true );
464 306
465 - /**
466 - * Filter the comment title tag.
467 - *
468 - * @module comments
469 - * @since 12.4
470 - *
471 - * @param string $comment_reply_title_tag The comment title tag. Default to h3.
472 - */
473 - $comment_reply_title_tag = apply_filters( 'jetpack_comment_reply_title_tag', 'h3' );
474 -
475 - // The actual iframe (loads comment form from Jetpack server).
476 -
477 - $is_amp = class_exists( Jetpack_AMP_Support::class ) && Jetpack_AMP_Support::is_amp_request();
307 + // The actual iframe (loads comment form from Jetpack server)
478 308 ?>
479 309
480 310 <div id="respond" class="comment-respond">
481 - <?php
482 - if ( true === $show_greeting ) :
483 - printf(
484 - '<%1$s id="reply-title" class="comment-reply-title">',
485 - esc_html( $comment_reply_title_tag )
486 - );
487 -
488 - comment_form_title(
489 - esc_html( $params['greeting'] ),
490 - esc_html( $params['greeting_reply'] )
491 - );
492 - echo '<small>';
493 - cancel_comment_reply_link( esc_html__( 'Cancel reply', 'jetpack' ) );
494 - echo '</small>';
495 -
496 - printf(
497 - '</%1$s>',
498 - esc_html( $comment_reply_title_tag )
499 - );
500 - endif;
501 - ?>
311 + <?php if ( true === $show_greeting ) : ?>
312 + <h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( esc_html( $params['greeting'] ), esc_html( $params['greeting_reply'] ) ); ?>
313 + <small><?php cancel_comment_reply_link( esc_html__( 'Cancel reply', 'jetpack' ) ); ?></small>
314 + </h3>
315 + <?php endif; ?>
502 316 <form id="commentform" class="comment-form">
503 - <iframe
504 - title="<?php esc_attr_e( 'Comment Form', 'jetpack' ); ?>"
505 - src="<?php echo esc_url( $url ); ?>"
506 - <?php if ( $is_amp ) : ?>
507 - resizable
508 - layout="fixed-height"
509 - height="<?php echo esc_attr( $height ); ?>"
510 - <?php else : ?>
511 - name="jetpack_remote_comment"
512 - style="width:100%; height: <?php echo esc_attr( $height ); ?>px; border:0;"
513 - <?php endif; ?>
514 - class="jetpack_remote_comment"
515 - id="jetpack_remote_comment"
516 - sandbox="allow-same-origin allow-top-navigation allow-scripts allow-forms allow-popups"
517 - >
518 - <?php if ( $is_amp ) : ?>
519 - <button overflow><?php esc_html_e( 'Show more', 'jetpack' ); ?></button>
520 - <?php endif; ?>
521 - </iframe>
522 - <?php if ( ! $is_amp ) : ?>
317 + <iframe title="<?php esc_attr_e( 'Comment Form' , 'jetpack' ); ?>" src="<?php echo esc_url( $url ); ?>" style="width:100%; height: <?php echo $height; ?>px; border:0;" name="jetpack_remote_comment" class="jetpack_remote_comment" id="jetpack_remote_comment" sandbox="allow-scripts allow-top-navigation-by-user-activation allow-forms"></iframe>
318 + <?php if ( ! Jetpack_AMP_Support::is_amp_request() ) : ?>
523 319 <!--[if !IE]><!-->
524 320 <script>
525 321 document.addEventListener('DOMContentLoaded', function () {
526 322 var commentForms = document.getElementsByClassName('jetpack_remote_comment');
527 323 for (var i = 0; i < commentForms.length; i++) {
528 - commentForms[i].allowTransparency = <?php echo esc_html( $transparent ); ?>;
324 + commentForms[i].allowTransparency = <?php echo $transparent; ?>;
529 325 commentForms[i].scrolling = 'no';
530 326 }
531 327 });
532 328 </script>
@@ -534,9 +330,9 @@
534 330 <?php endif; ?>
535 331 </form>
536 332 </div>
537 333
538 - <?php // Below is required for comment reply JS to work. ?>
334 + <?php // Below is required for comment reply JS to work ?>
539 335
540 336 <input type="hidden" name="comment_parent" id="comment_parent" value="" />
541 337
542 338 <?php
@@ -544,66 +340,108 @@
544 340
545 341 /**
546 342 * Add some JS to wp_footer to watch for hierarchical reply parent change
547 343 *
548 - * If AMP is enabled, we don't make any changes.
549 - *
550 - * @since 1.4
344 + * @since JetpackComments (1.4)
551 345 */
552 346 public function watch_comment_parent() {
553 - if ( class_exists( Jetpack_AMP_Support::class ) && Jetpack_AMP_Support::is_amp_request() ) {
554 - // @todo Implement AMP support.
555 - return;
556 - }
347 + $url_origin = set_url_scheme( 'http://jetpack.wordpress.com' );
557 348 ?>
349 +
350 + <!--[if IE]>
558 351 <script type="text/javascript">
352 + if ( 0 === window.location.hash.indexOf( '#comment-' ) ) {
353 + // window.location.reload() doesn't respect the Hash in IE
354 + window.location.hash = window.location.hash;
355 + }
356 + </script>
357 + <![endif]-->
358 + <script type="text/javascript">
559 359 (function () {
560 - const iframe = document.getElementById( 'jetpack_remote_comment' );
360 + var comm_par_el = document.getElementById( 'comment_parent' ),
361 + comm_par = ( comm_par_el && comm_par_el.value ) ? comm_par_el.value : '',
362 + frame = document.getElementById( 'jetpack_remote_comment' ),
363 + tellFrameNewParent;
364 +
365 + tellFrameNewParent = function () {
366 + if ( comm_par ) {
367 + frame.src = "<?php echo esc_url_raw( $this->signed_url ); ?>" + '&replytocom=' + parseInt( comm_par, 10 ).toString();
368 + } else {
369 + frame.src = "<?php echo esc_url_raw( $this->signed_url ); ?>";
370 + }
371 + };
372 +
561 373 <?php if ( get_option( 'thread_comments' ) && get_option( 'thread_comments_depth' ) ) : ?>
562 - const watchReply = function() {
563 - // Check addComment._Jetpack_moveForm to make sure we don't monkey-patch twice.
564 - if ( 'undefined' !== typeof addComment && ! addComment._Jetpack_moveForm ) {
565 - // Cache the Core function.
566 - addComment._Jetpack_moveForm = addComment.moveForm;
567 - const commentParent = document.getElementById( 'comment_parent' );
568 - const cancel = document.getElementById( 'cancel-comment-reply-link' );
569 374
570 - function tellFrameNewParent ( commentParentValue ) {
571 - const url = new URL( iframe.src );
572 - if ( commentParentValue ) {
573 - url.searchParams.set( 'replytocom', commentParentValue )
574 - } else {
575 - url.searchParams.delete( 'replytocom' );
576 - }
577 - if( iframe.src !== url.href ) {
578 - iframe.src = url.href;
579 - }
580 - };
375 + if ( 'undefined' !== typeof addComment ) {
376 + addComment._Jetpack_moveForm = addComment.moveForm;
581 377
582 - cancel.addEventListener( 'click', function () {
583 - tellFrameNewParent( false );
584 - } );
378 + addComment.moveForm = function ( commId, parentId, respondId, postId ) {
379 + var returnValue = addComment._Jetpack_moveForm( commId, parentId, respondId, postId ),
380 + cancelClick, cancel;
585 381
586 - addComment.moveForm = function ( _, parentId ) {
587 - tellFrameNewParent( parentId );
588 - return addComment._Jetpack_moveForm.apply( null, arguments );
589 - };
590 - }
382 + if ( false === returnValue ) {
383 + cancel = document.getElementById( 'cancel-comment-reply-link' );
384 + cancelClick = cancel.onclick;
385 + cancel.onclick = function () {
386 + var cancelReturn = cancelClick.call( this );
387 + if ( false !== cancelReturn ) {
388 + return cancelReturn;
389 + }
390 +
391 + if ( ! comm_par ) {
392 + return cancelReturn;
393 + }
394 +
395 + comm_par = 0;
396 +
397 + tellFrameNewParent();
398 +
399 + return cancelReturn;
400 + };
401 + }
402 +
403 + if ( comm_par == parentId ) {
404 + return returnValue;
405 + }
406 +
407 + comm_par = parentId;
408 +
409 + tellFrameNewParent();
410 +
411 + return returnValue;
412 + };
591 413 }
592 - document.addEventListener( 'DOMContentLoaded', watchReply );
593 - // In WP 6.4+, the script is loaded asynchronously, so we need to wait for it to load before we monkey-patch the functions it introduces.
594 - document.querySelector('#comment-reply-js')?.addEventListener( 'load', watchReply );
595 414
596 415 <?php endif; ?>
597 416
598 - window.addEventListener( 'message', function ( event ) {
599 - if ( event.origin !== 'https://jetpack.wordpress.com' ) {
600 - return;
417 + // Do the post message bit after the dom has loaded.
418 + document.addEventListener( 'DOMContentLoaded', function () {
419 + var iframe_url = <?php echo json_encode( esc_url_raw( $url_origin ) ); ?>;
420 + if ( window.postMessage ) {
421 + if ( document.addEventListener ) {
422 + window.addEventListener( 'message', function ( event ) {
423 + var origin = event.origin.replace( /^http:\/\//i, 'https://' );
424 + if ( iframe_url.replace( /^http:\/\//i, 'https://' ) !== origin ) {
425 + return;
426 + }
427 + jQuery( frame ).height( event.data );
428 + });
429 + } else if ( document.attachEvent ) {
430 + window.attachEvent( 'message', function ( event ) {
431 + var origin = event.origin.replace( /^http:\/\//i, 'https://' );
432 + if ( iframe_url.replace( /^http:\/\//i, 'https://' ) !== origin ) {
433 + return;
434 + }
435 + jQuery( frame ).height( event.data );
436 + });
437 + }
601 438 }
602 - iframe.style.height = event.data + 'px';
603 - });
439 + })
440 +
604 441 })();
605 442 </script>
443 +
606 444 <?php
607 445 }
608 446
609 447 /**
@@ -608,51 +446,42 @@
608 446
609 447 /**
610 448 * Verify the hash included in remote comments.
611 449 *
612 - * If the Jetpack token is missing we return nothing,
613 - * and if the token is unknown or invalid, or comments not allowed, an error is returned.
450 + * @since JetpackComments (1.4)
614 451 *
615 - * @since 1.4
452 + * @param type $comment Not used
616 453 */
617 - public function pre_comment_on_post() {
454 + public function pre_comment_on_post( $comment ) {
618 455 $post_array = stripslashes_deep( $_POST );
619 456
620 - // Bail if missing the Jetpack token.
621 - if ( ! isset( $post_array['sig'] ) || ! isset( $post_array['token_key'] ) ) {
457 + // Bail if missing the Jetpack token
458 + if ( ! isset( $post_array['sig'] ) ) {
622 459 unset( $_POST['hc_post_as'] );
623 460
624 461 return;
625 462 }
626 463
627 - if ( empty( $post_array['jetpack_comments_nonce'] ) || ! wp_verify_nonce( $post_array['jetpack_comments_nonce'], "jetpack_comments_nonce-{$post_array['comment_post_ID']}" ) ) {
628 - wp_die( esc_html__( 'Nonce verification failed.', 'jetpack' ), 400 );
464 + if ( false !== strpos( $post_array['hc_avatar'], '.gravatar.com' ) ) {
465 + $post_array['hc_avatar'] = htmlentities( $post_array['hc_avatar'] );
629 466 }
630 467
631 - if ( str_contains( $post_array['hc_avatar'], '.gravatar.com' ) ) {
632 - $post_array['hc_avatar'] = htmlentities( $post_array['hc_avatar'], ENT_COMPAT );
633 - }
634 -
635 - $blog_token = ( new Tokens() )->get_access_token( false, $post_array['token_key'] );
636 - if ( ! $blog_token || is_wp_error( $blog_token ) ) {
637 - wp_die( esc_html__( 'Unknown security token.', 'jetpack' ), 400 );
638 - }
639 - $check = self::sign_remote_comment_parameters( $post_array, $blog_token->secret );
468 + $check = Jetpack_Comments::sign_remote_comment_parameters( $post_array, Jetpack_Options::get_option( 'blog_token' ) );
640 469 if ( is_wp_error( $check ) ) {
641 - wp_die( esc_html( $check ) );
470 + wp_die( $check );
642 471 }
643 472
644 - // Bail if token is expired or not valid.
645 - if ( ! hash_equals( $check, $post_array['sig'] ) ) {
646 - wp_die( esc_html__( 'Invalid security token.', 'jetpack' ), 400 );
473 + // Bail if token is expired or not valid
474 + if ( $check !== $post_array['sig'] ) {
475 + wp_die( __( 'Invalid security token.', 'jetpack' ) );
647 476 }
648 477
649 478 /** This filter is documented in modules/comments/comments.php */
650 479 if ( ! apply_filters( 'jetpack_comment_form_enabled_for_' . get_post_type( $post_array['comment_post_ID'] ), true ) ) {
651 480 // In case the comment POST is legit, but the comments are
652 - // now disabled, we don't allow the comment.
481 + // now disabled, we don't allow the comment
653 482
654 - wp_die( esc_html__( 'Comments are not allowed.', 'jetpack' ), 403 );
483 + wp_die( __( 'Comments are not allowed.', 'jetpack' ) );
655 484 }
656 485 }
657 486
658 487 /** Capabilities **********************************************************/
@@ -660,223 +489,58 @@
660 489 /**
661 490 * Add some additional comment meta after comment is saved about what
662 491 * service the comment is from, the avatar, user_id, etc...
663 492 *
664 - * @since 1.4
493 + * @since JetpackComments (1.4)
665 494 *
666 - * @param int $comment_id The comment ID.
495 + * @param type $comment_id
667 496 */
668 497 public function add_comment_meta( $comment_id ) {
669 498 $comment_meta = array();
670 499
671 - // phpcs:disable WordPress.Security.NonceVerification.Missing
672 500 switch ( $this->is_highlander_comment_post() ) {
673 - case 'facebook':
501 + case 'facebook' :
674 502 $comment_meta['hc_post_as'] = 'facebook';
675 - $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
676 - $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
503 + $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
504 + $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
677 505 break;
678 506
679 - // phpcs:ignore WordPress.WP.CapitalPDangit
680 - case 'wordpress':
681 - // phpcs:ignore WordPress.WP.CapitalPDangit
507 + case 'twitter' :
508 + $comment_meta['hc_post_as'] = 'twitter';
509 + $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
510 + $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
511 + break;
512 +
513 + case 'wordpress' :
682 514 $comment_meta['hc_post_as'] = 'wordpress';
683 - $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
684 - $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
685 - $comment_meta['hc_wpcom_id_sig'] = isset( $_POST['hc_wpcom_id_sig'] ) ? filter_var( wp_unslash( $_POST['hc_wpcom_id_sig'] ) ) : null; // since 1.9.
515 + $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
516 + $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
517 + $comment_meta['hc_wpcom_id_sig'] = stripslashes( $_POST['hc_wpcom_id_sig'] ); //since 1.9
686 518 break;
687 519
688 - case 'jetpack':
520 + case 'jetpack' :
689 521 $comment_meta['hc_post_as'] = 'jetpack';
690 - $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
691 - $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
522 + $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
523 + $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
692 524 break;
693 525
694 526 }
695 - // phpcs:enable WordPress.Security.NonceVerification.Missing
696 527
697 - // Bail if no extra comment meta.
528 + // Bail if no extra comment meta
698 529 if ( empty( $comment_meta ) ) {
699 530 return;
700 531 }
701 532
702 - // Loop through extra meta and add values.
533 + // Loop through extra meta and add values
703 534 foreach ( $comment_meta as $key => $value ) {
704 535 add_comment_meta( $comment_id, $key, $value, true );
705 536 }
706 537 }
707 538
708 - /**
709 - * Should show the subscription modal
710 - *
711 - * @return boolean
712 - */
713 - public function should_show_subscription_modal() {
714 -
715 - // Not allow it to run on self-hosted or simple sites
716 - if ( ! ( new Host() )->is_wpcom_platform() || ( new Host() )->is_wpcom_simple() ) {
717 - return false;
718 - }
719 -
720 - // phpcs:disable WordPress.Security.NonceVerification.Missing
721 - $is_current_user_subscribed = (bool) isset( $_POST['is_current_user_subscribed'] ) ? filter_var( wp_unslash( $_POST['is_current_user_subscribed'] ) ) : null;
722 -
723 - // Atomic sites with jetpack_verbum_subscription_modal option enabled
724 - $modal_enabled = ( new Host() )->is_woa_site() && get_option( 'jetpack_verbum_subscription_modal', true );
725 -
726 - return $modal_enabled && ! $is_current_user_subscribed;
727 - }
728 -
729 - /**
730 - * Get the data to send as an event to the parent window on subscription modal
731 - *
732 - * @param string $url url to redirect to.
733 - *
734 - * @return array
735 - */
736 - public function get_subscription_modal_data_to_parent( $url ) {
737 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
738 - $current_user_email = isset( $_POST['email'] ) ? filter_var( wp_unslash( $_POST['email'] ) ) : null;
739 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
740 - $post_id = isset( $_POST['comment_post_ID'] ) ? filter_var( wp_unslash( $_POST['comment_post_ID'] ) ) : null;
741 - return array(
742 - 'url' => $url,
743 - 'email' => $current_user_email,
744 - 'blog_id' => esc_attr( \Jetpack_Options::get_option( 'id' ) ),
745 - 'post_id' => esc_attr( $post_id ),
746 - 'lang' => esc_attr( get_locale() ),
747 - 'is_logged_in' => isset( $_POST['hc_userid'] ),
748 - );
749 - }
750 -
751 - /**
752 - * Track the hidden event for the subscription modal
753 - */
754 - public function subscription_modal_status_track_event() {
755 - $tracking_event = 'hidden_disabled';
756 - // Not allow it to run on self-hosted or simple sites
757 - if ( ! ( new Host() )->is_wpcom_platform() || ( new Host() )->is_wpcom_simple() ) {
758 - $tracking_event = 'hidden_self_hosted';
759 - }
760 -
761 - // phpcs:disable WordPress.Security.NonceVerification.Missing
762 - $is_current_user_subscribed = (bool) isset( $_POST['is_current_user_subscribed'] ) ? filter_var( wp_unslash( $_POST['is_current_user_subscribed'] ) ) : null;
763 -
764 - if ( $is_current_user_subscribed ) {
765 - $tracking_event = 'hidden_already_subscribed';
766 - }
767 -
768 - $jetpack = Jetpack::init();
769 - // $jetpack->stat automatically prepends the stat group with 'jetpack-'
770 - $jetpack->stat( 'subscribe-modal-comm', $tracking_event );
771 - $jetpack->do_stats( 'server_side' );
772 - }
773 -
774 - /**
775 - * Catch the duplicated comment error and show a custom error page
776 - *
777 - * @return void
778 - */
779 - public function capture_comment_duplicate_trigger() {
780 - if ( ! isset( $_GET['for'] ) || 'jetpack' !== $_GET['for'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
781 - exit;
782 - }
783 -
784 - ?>
785 - <!DOCTYPE html>
786 - <html <?php language_attributes(); ?>>
787 - <!--<![endif]-->
788 - <head>
789 - <meta charset="<?php bloginfo( 'charset' ); ?>" />
790 - <title>
791 - <?php
792 - wp_kses_post(
793 - printf(
794 - /* translators: %s is replaced by an ellipsis */
795 - __( 'Submitting Comment%s', 'jetpack' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
796 - '&hellip;'
797 - )
798 - );
799 - ?>
800 - </title>
801 - <style type="text/css">
802 - body {
803 - display: table;
804 - width: 100%;
805 - height: 60%;
806 - position: absolute;
807 - top: 0;
808 - left: 0;
809 - overflow: hidden;
810 - color: #333;
811 - padding-top: 3%;
812 - }
813 - div {
814 - text-align: left;
815 - margin: 0;
816 - padding: 0;
817 - display: table-cell;
818 - vertical-align: top;
819 - font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
820 - font-weight: normal;
821 - }
822 -
823 - h3 {
824 - margin: 0;
825 - padding-bottom: 3%;
826 - font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
827 - font-weight: normal;
828 - }
829 - a {
830 - text-decoration: underline;
831 - color: #333 !important;
832 - }
833 - </style>
834 - </head>
835 - <body>
836 - <div>
837 - <h3>
838 - <?php
839 - esc_html_e( 'Duplicate comment detected; it looks as though you’ve already said that!', 'jetpack' );
840 - ?>
841 - </h3>
842 - <a href="javascript:backToComments()"><?php esc_html_e( '&laquo; Back', 'jetpack' ); ?></a>
843 - </div>
844 - <script type="text/javascript">
845 - function backToComments() {
846 - const test = regexp => {
847 - return regexp.test(navigator.userAgent);
848 - };
849 - if (test(/chrome|chromium|crios|safari|edg/i)) {
850 - history.go(-2);
851 - return;
852 - }
853 - history.back();
854 - }
855 - </script>
856 -
857 - </body>
858 - </html>
859 - <?php
860 - exit;
861 - }
862 -
863 - /**
864 - * POST the submitted comment to the iframe
865 - *
866 - * @param string $url The comment URL origin.
867 - */
868 - public function capture_comment_post_redirect_to_reload_parent_frame( $url ) {
869 - if ( ! isset( $_GET['for'] ) || 'jetpack' !== $_GET['for'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
539 + function capture_comment_post_redirect_to_reload_parent_frame( $url ) {
540 + if ( ! isset( $_GET['for'] ) || 'jetpack' != $_GET['for'] ) {
870 541 return $url;
871 542 }
872 -
873 - $should_show_subscription_modal = $this->should_show_subscription_modal();
874 -
875 - // Track event when not showing the subscription modal
876 - if ( ! $should_show_subscription_modal ) {
877 - $this->subscription_modal_status_track_event();
878 - }
879 543 ?>
880 544 <!DOCTYPE html>
881 545 <html <?php language_attributes(); ?>>
882 546 <!--<![endif]-->
@@ -881,19 +545,9 @@
881 545 <html <?php language_attributes(); ?>>
882 546 <!--<![endif]-->
883 547 <head>
884 548 <meta charset="<?php bloginfo( 'charset' ); ?>" />
885 - <title>
886 - <?php
887 - wp_kses_post(
888 - printf(
889 - /* translators: %s is replaced by an ellipsis */
890 - __( 'Submitting Comment%s', 'jetpack' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
891 - '&hellip;'
892 - )
893 - );
894 - ?>
895 - </title>
549 + <title><?php printf( __( 'Submitting Comment%s', 'jetpack' ), '&hellip;' ); ?></title>
896 550 <style type="text/css">
897 551 body {
898 552 display: table;
899 553 width: 100%;
@@ -902,17 +556,16 @@
902 556 top: 0;
903 557 left: 0;
904 558 overflow: hidden;
905 559 color: #333;
906 - padding-top: 3%;
907 560 }
908 561
909 - h3 {
562 + h1 {
910 563 text-align: center;
911 564 margin: 0;
912 565 padding: 0;
913 566 display: table-cell;
914 - vertical-align: top;
567 + vertical-align: middle;
915 568 font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
916 569 font-weight: normal;
917 570 }
918 571
@@ -919,9 +572,9 @@
919 572 .hidden {
920 573 opacity: 0;
921 574 }
922 575
923 - h3 span {
576 + h1 span {
924 577 -moz-transition-property: opacity;
925 578 -moz-transition-duration: 1s;
926 579 -moz-transition-timing-function: ease-in-out;
927 580
@@ -943,26 +596,15 @@
943 596 }
944 597 </style>
945 598 </head>
946 599 <body>
947 - <?php if ( ! $should_show_subscription_modal ) { ?>
948 - <h3>
949 - <?php
950 - wp_kses_post(
951 - printf(
952 - /* translators: %s is replaced by HTML markup to include an ellipsis */
953 - __( 'Submitting Comment%s', 'jetpack' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
954 - '<span id="ellipsis" class="hidden">&hellip;</span>'
955 - )
956 - );
957 - ?>
958 - </h3>
600 + <h1><?php printf( __( 'Submitting Comment%s', 'jetpack' ), '<span id="ellipsis" class="hidden">&hellip;</span>' ); ?></h1>
959 601 <script type="text/javascript">
960 602 try {
961 - window.parent.location = <?php echo wp_json_encode( $url ); ?>;
603 + window.parent.location = <?php echo json_encode( $url ); ?>;
962 604 window.parent.location.reload(true);
963 605 } catch (e) {
964 - window.location = <?php echo wp_json_encode( $url ); ?>;
606 + window.location = <?php echo json_encode( $url ); ?>;
965 607 window.location.reload(true);
966 608 }
967 609 ellipsis = document.getElementById('ellipsis');
968 610
@@ -971,29 +613,8 @@
971 613 }
972 614
973 615 setInterval(toggleEllipsis, 1200);
974 616 </script>
975 - <?php } else { ?>
976 - <h3>
977 - <?php
978 - wp_kses_post(
979 - print __( 'Comment sent', 'jetpack' ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
980 - );
981 - ?>
982 - </h3>
983 - <script type="text/javascript">
984 - if ( window.parent && window.parent !== window ) {
985 -
986 - window.parent.postMessage(
987 - {
988 - type: 'subscriptionModalShow',
989 - data: <?php echo wp_json_encode( $this->get_subscription_modal_data_to_parent( $url ) ); ?>,
990 - },
991 - window.location.origin
992 - );
993 - }
994 - </script>
995 - <?php } ?>
996 617 </body>
997 618 </html>
998 619 <?php
999 620 exit;