Ensure ampify_threaded_comments
runs when in Strict sandboxing
#6769
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6443 (comment).
As discovered by @milindmore22, when a site is in the Strict level for Sandboxing, the ampification of threaded comments was failing to happen. This meant that the comment form lacked the expected
on="submit-success:commentform.clear,AMP.setState({ampCommentThreading: {"replyTo":"","commentParent":"0"}})"
attribute, andamp-bind
was not being used for comment replies.The issue is that in Strict mode, the script sanitizer will remove all scripts, including the
comment-reply
one:amp-wp/includes/sanitizers/class-amp-script-sanitizer.php
Line 60 in 4558144
amp-wp/includes/sanitizers/class-amp-script-sanitizer.php
Lines 348 to 358 in 4558144
However, the comments sanitizer was using the presence of this script to determine whether to ampify commenting:
amp-wp/includes/sanitizers/class-amp-comments-sanitizer.php
Lines 78 to 80 in 4558144
So we just need to replace the
false
with a'always' === $this->args['ampify_comment_threading']
condition so that even when the script is not on the page, the ampification will be done.Checklist