-
Notifications
You must be signed in to change notification settings - Fork 798
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
Widget Visibility: Restrict to top level blocks #21222
Widget Visibility: Restrict to top level blocks #21222
Conversation
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 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
I'm testing this locally, and I'm able to see the widget visibility settings when in Screen.Recording.2021-09-29.at.10.45.38.AM.mov |
The good news is the widgets behave as expected on my local test site. 👍 |
Good catch; fixed. |
Before patching, was able to recreate the Then I applied this PR and the fatal was no longer occurring. Was also able to see the |
…ility-block-editor-top-level
@mreishus I've created a WordPress.com diff, D67826-code, to bring us back in sync on WordPress.com. It tests well for me. I'll let you handle the commit? Thank you! |
Co-authored-by: Jeremy Herve <[email protected]>
Cherry-picked to |
r232714-wpcom Looking good on wpcom so far, keeping an eye on support channels today. |
Fixes #20057
Changes proposed in this Pull Request (TLDR):
render_block()
call fromfilter_widget()
. Users are only allowed to set visibility rules on the top level block of each widget.Changes proposed in this Pull Request:
filter_widget()
runningrender_block()
. Before Widget Visibility was implemented,filter_widget()
only returned its argument unchanged or returned false. With Widget Visibility, sometimes it would change the content of the block passed to it by re-rendering the block, and return that.filter_widget()
runningrender_block()
is risky because so many plugins modify rendering behavior. For example, we saw an infinite loop bug whererender_block()
would need to seek out sidebar settings, which would end up getting a list of widgets and callingfilter_widget()
, which would callrender_block()
, which calledfilter_widget()
.. etc.Jetpack_Widget_Conditions
class, but there was at least one render related bug I couldn't fix (wp-calypso#56546).render_block()
call fromfilter_widget()
.filter_widget()
works the same as before: It only ever returns false or returns its argument unchanged.Jetpack product discussion
Does this pull request change what data or activity we track or use?
No
Testing instructions:
jetpack docker up
jetpack docker install
, and possibly edit one of the env files such that your password isn't easily guessable if you decide to use a tunneling solution in the future.jetpack watch plugins/jetpack
jetpack build plugins/jetpack
first.You should see the following in the sidebar, which lets you set up rules:
When visiting the frontend of the site, those widgets should follow those rules.
Testing instructions (wpcom)
We need to make a custom patch, since #20057 is merged in JP but reverted on wpcom.
Testing instructions (Unit Tests)
jetpack docker phpunit -- --filter=Widget_Conditions
jetpack docker sh
, thencd /tmp/wordpress-develop/tests/phpunit/data
, thensvn up -r44722
, thencd ../includes/
, then againsvn up -r44722
. This was done a few weeks ago and I am no longer certain this is working with new docker images.