Skip to content
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: Widget preview broken on WPCOM when visiblity settings are enabled for legacy widgets #22460

Open
yoavf opened this issue Jan 24, 2022 · 10 comments · Fixed by #22457
Assignees
Labels
Customer Report Issues or PRs that were reported via Happiness. Previously known as "Happiness Request". [Feature] Widget Visibility [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Bug When a feature is broken and / or not performing as intended

Comments

@yoavf
Copy link
Contributor

yoavf commented Jan 24, 2022

Impacted plugin

Jetpack

Steps to Reproduce

Environment: On a WP.com simple site with a widget-area enabled theme (i.e "Twenty Fourteen")

  1. Go to Appearance->Widgets
  2. In one of the widget areas, add a "Legacy Widget" block
  3. Edit the widget visiblity settings - add any condition

A clear and concise description of what you expected to happen.

The widget preview should be visible, even when visiblity rules are set (like it happens on a non-wpcom site)

What actually happened

The widget preview is empty when visiblity settings are set

Other information

Screen.Capture.on.2022-01-24.at.10-06-16.mp4

Operating System

No response

OS Version

No response

Browser

Chrome/Chromium, Firefox

Browser Version(s)

No response

@yoavf yoavf added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Widget Visibility labels Jan 24, 2022
@yoavf
Copy link
Contributor Author

yoavf commented Jan 24, 2022

Tracked it down to the specific WPCOM condition in \Jetpack_Widget_Conditions::filter_widget which doesn't seem to work - and probably has been that way for a couple of months at least.

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Jan 24, 2022
@jeherve
Copy link
Member

jeherve commented Jan 24, 2022

cc @mreishus who worked on #20731.

Edit: I just noticed you created #22457 to fix this issue already. Thank you!

@yoavf
Copy link
Contributor Author

yoavf commented Jan 25, 2022

#22457 was for another bug :-)

@gwensmithx
Copy link

I have just run into this issue with the Music Player widget. I can replicate on my simple site. On Chrome. Theme is Twenty Seventeen.

Screen.Capture.on.2022-05-24.at.17-27-23.mp4

@samiff
Copy link
Contributor

samiff commented May 25, 2022

@mreishus or @yoavf Would you be able to help with this one? I see the WordPress.com specific check was added in #20731

The relevant section seems to be:

// WordPress.com specific check - here, referer ends in /rest-proxy/ and doesn't tell us what's requesting.
$current_url = ! empty( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$nonce = ! empty( $_REQUEST['_gutenberg_nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_gutenberg_nonce'] ) ) : '';
$context = ! empty( $_REQUEST['context'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['context'] ) ) : '';
if ( wp_verify_nonce( $nonce, 'gutenberg_request' ) &&
1 === preg_match( '~^/wp/v2/sites/\d+/(sidebars|widgets)~', $current_url ) && 'edit' === $context ) {
return $instance;
}

But I don't think the context is always set as edit for this to work right. I quickly tried something naive like:

if ( wp_verify_nonce( $nonce, 'gutenberg_request' ) &&
	1 === preg_match( '~^/wp/v2/sites/\d+~', $current_url ) ) {
	return $instance;
}

Which seems to work on both the widgets.php and customize.php pages, and the visibility rules still play out. Though I'm not all familiar with the requests performed here, so any thoughts would be appreciated. It's a pretty confusing experience to not be able to see the legacy blocks to edit.

@jp-imagines
Copy link

Came across this in 36060586-hc (and thought it was just a recurrence of Automattic/wp-calypso#56468).

@matticbot matticbot added the Customer Report Issues or PRs that were reported via Happiness. Previously known as "Happiness Request". label Jul 14, 2022
@jp-imagines
Copy link

Another instance in 37809953-hc. I was able to see the widget previews load on my end through SU, but the user couldn't see any of their widgets (all of which had conditional visibility).

@ckmccoy2
Copy link

ckmccoy2 commented Jan 2, 2023

32848742-hc

@villanovachile
Copy link
Contributor

Another report 6351339-zen

@github-actions
Copy link
Contributor

Support References

This comment is automatically generated. Please do not edit it.

  • 6351339-zen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customer Report Issues or PRs that were reported via Happiness. Previously known as "Happiness Request". [Feature] Widget Visibility [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants