Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Update Verbum Comments resize logic
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function enqueue_assets() {
$jetpack_username = isset( $__get['hc_username'] ) && is_string( $__get['hc_username'] ) ? $__get['hc_username'] : '';
$jetpack_user_id = isset( $__get['hc_userid'] ) && is_numeric( $__get['hc_userid'] ) ? (int) $__get['hc_userid'] : 0;
$jetpack_signature = isset( $__get['sig'] ) && is_string( $__get['sig'] ) ? $__get['sig'] : '';
$iframe_unique_id = isset( $__get['iframe_unique_id'] ) && is_numeric( $__get['iframe_unique_id'] ) ? (int) $__get['iframe_unique_id'] : 0;
list( $jetpack_avatar ) = wpcom_get_avatar_url( "$email_hash@md5.gravatar.com" );
$comment_registration_enabled = boolval( get_blog_option( $this->blog_id, 'comment_registration' ) );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
Expand Down Expand Up @@ -255,6 +256,7 @@ public function enqueue_assets() {
'verbumBundleUrl' => plugins_url( 'dist/index.js', __FILE__ ),
'isRTL' => is_rtl( $locale ),
'vbeCacheBuster' => $vbe_cache_buster,
'iframeUniqueId' => $iframe_unique_id,
)
),
'before'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Update Verbum Comments resize logic
25 changes: 22 additions & 3 deletions projects/plugins/jetpack/modules/comments/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ public function comment_form_after() {
'color_scheme' => get_option( 'jetpack_comment_form_color_scheme', $this->default_color_scheme ),
'lang' => get_locale(),
'jetpack_version' => JETPACK__VERSION,
'iframe_unique_id' => wp_unique_id(),
);

// Extra parameters for logged in user.
Expand Down Expand Up @@ -594,12 +595,30 @@ function tellFrameNewParent ( commentParentValue ) {
document.querySelector('#comment-reply-js')?.addEventListener( 'load', watchReply );

<?php endif; ?>

const commentIframes = document.getElementsByClassName('jetpack_remote_comment');

window.addEventListener( 'message', function ( event ) {
if ( event.origin !== 'https://jetpack.wordpress.com' ) {
window.addEventListener('message', function(event) {
if (event.origin !== 'https://jetpack.wordpress.com') {
return;
}
iframe.style.height = event.data + 'px';

if (!event?.data?.iframeUniqueId && !event?.data?.height) {
return;
}

const eventDataUniqueId = event.data.iframeUniqueId;

// Change height for the matching comment iframe
for (let i = 0; i < commentIframes.length; i++) {
const iframe = commentIframes[i];
const url = new URL(iframe.src);
const iframeUniqueIdParam = url.searchParams.get('iframe_unique_id');
if (iframeUniqueIdParam == event.data.iframeUniqueId) {
iframe.style.height = event.data.height + 'px';
return;
}
}
});
})();
</script>
Expand Down