diff options
Diffstat (limited to 'plugins/jetpack/modules/comments/comments.php')
-rw-r--r-- | plugins/jetpack/modules/comments/comments.php | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php index dfc8f070..368f1633 100644 --- a/plugins/jetpack/modules/comments/comments.php +++ b/plugins/jetpack/modules/comments/comments.php @@ -1,12 +1,12 @@ -<?php +<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName require dirname( __FILE__ ) . '/base.php'; -use Automattic\Jetpack\Connection\Manager as Connection_Manager; +use Automattic\Jetpack\Connection\Tokens; /** * Main Comments class * - * @package JetpackComments + * @package automattic/jetpack * @version 1.4 * @since 1.4 */ @@ -174,7 +174,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { */ public function comment_form_before() { /** - * Filters the setting that determines if Jetpagk comments should be enabled for + * Filters the setting that determines if Jetpack comments should be enabled for * the current post type. * * @module comments @@ -277,11 +277,11 @@ class Jetpack_Comments extends Highlander_Comments_Base { $params['has_cookie_consent'] = (int) ! empty( $commenter['comment_author_email'] ); } - $blog_token = Jetpack_Data::get_access_token(); + $blog_token = ( new Tokens() )->get_access_token(); list( $token_key ) = explode( '.', $blog_token->secret, 2 ); // Prophylactic check: anything else should never happen. if ( $token_key && $token_key !== $blog_token->secret ) { - // Is the token a Special Token (@see class.jetpack-data.php)? + // Is the token a Special Token (@see class.tokens.php)? if ( preg_match( '/^;.\d+;\d+;$/', $token_key, $matches ) ) { // The token key for a Special Token is public. $params['token_key'] = $token_key; @@ -292,7 +292,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { * one Normal Token per site, avoid concern by * sending the magic "use the Normal Token" token key. */ - $params['token_key'] = Connection_Manager::MAGIC_NORMAL_TOKEN_KEY; + $params['token_key'] = Tokens::MAGIC_NORMAL_TOKEN_KEY; } } @@ -325,6 +325,8 @@ class Jetpack_Comments extends Highlander_Comments_Base { $show_greeting = apply_filters( 'jetpack_comment_form_display_greeting', true ); // The actual iframe (loads comment form from Jetpack server) + + $is_amp = Jetpack_AMP_Support::is_amp_request(); ?> <div id="respond" class="comment-respond"> @@ -334,8 +336,26 @@ class Jetpack_Comments extends Highlander_Comments_Base { </h3> <?php endif; ?> <form id="commentform" class="comment-form"> - <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-same-origin allow-top-navigation allow-scripts allow-forms allow-popups"></iframe> - <?php if ( ! Jetpack_AMP_Support::is_amp_request() ) : ?> + <iframe + title="<?php esc_attr_e( 'Comment Form', 'jetpack' ); ?>" + src="<?php echo esc_url( $url ); ?>" + <?php if ( $is_amp ) : ?> + resizable + layout="fixed-height" + height="<?php echo esc_attr( $height ); ?>" + <?php else : ?> + name="jetpack_remote_comment" + style="width:100%; height: <?php echo esc_attr( $height ); ?>px; border:0;" + <?php endif; ?> + class="jetpack_remote_comment" + id="jetpack_remote_comment" + sandbox="allow-same-origin allow-top-navigation allow-scripts allow-forms allow-popups" + > + <?php if ( $is_amp ) : ?> + <button overflow><?php esc_html_e( 'Show more', 'jetpack' ); ?></button> + <?php endif; ?> + </iframe> + <?php if ( ! $is_amp ) : ?> <!--[if !IE]><!--> <script> document.addEventListener('DOMContentLoaded', function () { @@ -364,6 +384,11 @@ class Jetpack_Comments extends Highlander_Comments_Base { * @since JetpackComments (1.4) */ public function watch_comment_parent() { + if ( Jetpack_AMP_Support::is_amp_request() ) { + // @todo Implement AMP support. + return; + } + $url_origin = 'https://jetpack.wordpress.com'; ?> @@ -444,7 +469,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { if ( iframe_url.replace( /^http:\/\//i, 'https://' ) !== origin ) { return; } - jQuery( frame ).height( event.data ); + frame.style.height = event.data + 'px'; }); } else if ( document.attachEvent ) { window.attachEvent( 'message', function ( event ) { @@ -452,7 +477,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { if ( iframe_url.replace( /^http:\/\//i, 'https://' ) !== origin ) { return; } - jQuery( frame ).height( event.data ); + frame.style.height = event.data + 'px'; }); } } @@ -485,7 +510,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { $post_array['hc_avatar'] = htmlentities( $post_array['hc_avatar'] ); } - $blog_token = Jetpack_Data::get_access_token( false, $post_array['token_key'] ); + $blog_token = ( new Tokens() )->get_access_token( false, $post_array['token_key'] ); if ( ! $blog_token ) { wp_die( __( 'Unknown security token.', 'jetpack' ), 400 ); } |