-
Notifications
You must be signed in to change notification settings - Fork 823
Jetpack Shortcodes: Prevent hooking onto pre_kses
in front-end
#44373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Jetpack Shortcodes: Prevent hooking onto pre_kses
in front-end
#44373
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 20 files. Only the first 5 are listed here.
1 file is newly checked for coverage.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
…es/shortcodes/conditionally-hook-on-pre-kses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't specifically test the code, but it reads well.
I left some comments on 188368-ghe-Automattic/wpcom to denote how to prepare WP.com for this (and after that, I believe the tests on this PR would pass).
Marking request changes since it needs the wp.com work done before merging, so will give a final approval after wp.com is prepared and those tests pass.
Additionally, please add tests for the new function to ensure that it is true in a frontend condition and that the filter is not added in a frontend condition. At least, add tests for the new function and get coverage good for the new file. Bonus for increasing the coverage in an existing file. |
projects/plugins/jetpack/tests/php/modules/shortcodes/Jetpack_Shortcodes_Flickr_Test.php
Show resolved
Hide resolved
projects/plugins/jetpack/tests/php/modules/shortcodes/Jetpack_Shortcodes_Flickr_Test.php
Show resolved
Hide resolved
projects/plugins/jetpack/tests/php/modules/shortcodes/Jetpack_Shortcodes_Soundcloud_Test.php
Show resolved
Hide resolved
…es/shortcodes/conditionally-hook-on-pre-kses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, some legit wp.com test failures (at least needing more investigation). Un-approving :)
Fixes HOG-132
pre_kses
runs everywhere. However, shortcodes have code that "preserves" content (mostly embeds) by transforming it into a shortcode string. This code is necessary only when the post content is updated/added. It's not necessary in the front-end.This PR adds a check to conditionally allow hooking onto
pre_kses
. To avoid calling theis_frontend
ofRequest
many times, I created a helper function with a static variable. I thought it's preferable to callingis_frontend
every time a shortcode hooks ontopre_kses
.It also updates the
is_frontend
method to allow not sending the Vary header. I didn't want to cause side-effects from just checking if we're in the front-end multiple times throughout Jetpack.Proposed changes:
pre_kses
for front-end requests;Request::is_frontend
method to allow not sending the Vary header;Other information:
Jetpack product discussion
HOG-132
Does this pull request change what data or activity we track or use?
no
Testing instructions:
archiveorg-book.php
for example: