-
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: add controls to widget block editor #20057
Comments
Loading the resources in the right screen seems to be possible (I believe something like below should help), but we'll need some extra work to update the JS to target the right elements. diff --git a/projects/plugins/jetpack/modules/widget-visibility/widget-conditions.php b/projects/plugins/jetpack/modules/widget-visibility/widget-conditions.php
index 2574690f73..6db2e95047 100644
--- a/projects/plugins/jetpack/modules/widget-visibility/widget-conditions.php
+++ b/projects/plugins/jetpack/modules/widget-visibility/widget-conditions.php
@@ -10,11 +10,13 @@ class Jetpack_Widget_Conditions {
static $passed_template_redirect = false;
public static function init() {
- if ( is_admin() ) {
+ global $pagenow;
+
+ if ( is_customize_preview() || 'widgets.php' === $pagenow || 'themes.php' === $pagenow ) {
add_action( 'sidebar_admin_setup', array( __CLASS__, 'widget_admin_setup' ) );
add_filter( 'widget_update_callback', array( __CLASS__, 'widget_update' ), 10, 3 );
add_action( 'in_widget_form', array( __CLASS__, 'widget_conditions_admin' ), 10, 3 );
- } elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
+ } elseif ( ! in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ), true ) ) {
add_filter( 'widget_display_callback', array( __CLASS__, 'filter_widget' ) );
add_filter( 'sidebars_widgets', array( __CLASS__, 'sidebars_widgets' ) );
add_action( 'template_redirect', array( __CLASS__, 'template_redirect' ) );
@@ -22,11 +24,6 @@ class Jetpack_Widget_Conditions {
}
public static function widget_admin_setup() {
- // Return early if we are not in the block editor.
- if ( wp_should_load_block_editor_scripts_and_styles() ) {
- return;
- }
-
wp_enqueue_style( 'widget-conditions', plugins_url( 'widget-conditions/widget-conditions.css', __FILE__ ) );
wp_style_add_data( 'widget-conditions', 'rtl', 'replace' );
wp_enqueue_script(
|
Reserved for onboarding. |
I would suggest limiting the scope of this issue to Legacy Widgets so that it's fully ready and tested when WordPress 5.8 is released and opening (?) a new issue regarding support to blocks which will need a more "Gutenberg" oriented approach rather than using jQuery to inject HTML. |
cc: @simison |
That's fair. We can also keep this issue open and add a new item to the task list here. |
Fine by me. 👍 We could even roll with that limited scope and sit back and observe feedback and adjust only later, if ever. Important to consider if it's clear why there's such a difference in UI between different blocks. Please also do inform .com happiness + docs people at pbAok1-2cr-p2 — @jeherve can prolly loop in Jetpack HEs/docs? |
@a8ck3n Could you add this to your list for the 9.1.1 release? In short, Widget Visibility will only work for legacy widgets (i.e. widgets as we know them today) for all folks using the new Widget management screen that will be introduced in WP 5.8. That screen also allows you to add blocks to widget areas, but those will not include any widget visibility controls yet. Thank you! |
Re-opened because widget visibility settings still need to be addressed for block widgets themselves, especially as more people convert legacy widgets to block, breaking their visibility settings. |
Another case in 4212591-zen |
Another report here: https://wordpress.com/forums/topic/widget-visibility-on-block-editor/ |
Another report here 29532833-hc. User with a Simple Site with no visibility option (even with Legacy Widgets) |
The fix for legacy widgets in the new interface got deployed for simple sites (D65412-code, D65394-code). Blocks in the new widgets interface still need a fix. |
Another user who needs visibility settings: 4222374-zen |
|
@mtias No worries, thanks for caring. :-) Another half of these reports were sorted with the fix, and the rest will be sorted by work from Flow patrol. Looks like we need design help though, so I've reached out to arrange some eyes for this. (p1629285502046400-slack-dotcom-design) |
4221429-zen asking for visibility for block widgets |
Looking for reviews on #20731 |
Another request for visibility on block widgets: 4238114-zd-woothemes |
31354335-hc |
Another request: 28417583-hc |
Request for followup in https://wordpress.com/forums/topic/changing-widget-visibility-in-sidebar/ when visibility is restored |
@mreishus hi! What's the status/timeframe on this? |
Another forum post regarding this here: https://wordpress.com/forums/topic/visibility-in-blocks-in-the-widget-area/ |
4313215-zd-woothemes |
Another request came in via 31060326-hc / 4320892-zd |
This is scheduled for the next Jetpack release (10.2 on 2021-10-05) and is available on certain WordPress.com plans today. p7DVsv-cIY-p2 |
Related issue: WordPress/gutenberg#31181
Jetpack's Widget Visibility module adds visibility controls to the widgets available in Appearance > Customize > Widgets and Appearance > Widgets
Those controls are added here:
jetpack/projects/plugins/jetpack/modules/widget-visibility/widget-conditions.php
Line 12 in 41fe374
With the upcoming version of WordPress, the widget UI changes to allow you to insert legacy widgets as well as blocks, in two areas:
themes.php?page=gutenberg-widgets
instead ofwidgets.php
.We'll need to do a few things to ensure that Widget Visibility is compatible with those changes:
Primary issue: #19654
Related discussion: pbAok1-2dI-p2
The text was updated successfully, but these errors were encountered: