Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Widget Visibility: restore visibility controls for legacy widgets in the block-based widget editor.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ public static function init() {
}

if ( $add_data_assets_to_page ) {
add_action( 'sidebar_admin_setup', array( __CLASS__, 'widget_admin_setup' ) );
// In the classic widget editor, sidebar_admin_setup fires and is the correct hook.
// In the Gutenberg block widget editor, sidebar_admin_setup may not fire, so we
// also register on enqueue_block_editor_assets to ensure assets are always loaded.
if ( $using_classic_experience ) {
add_action( 'sidebar_admin_setup', array( __CLASS__, 'widget_admin_setup' ) );
} else {
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'widget_admin_setup' ) );
}
}

if ( $add_block_controls ) {
Expand Down Expand Up @@ -203,7 +210,10 @@ public static function add_block_attributes_filter() {
* Prepare the interface for editing widgets - loading css, javascript & data
*/
public static function widget_admin_setup() {
wp_enqueue_style( 'widget-conditions', plugins_url( 'widget-conditions/widget-conditions.css', __FILE__ ), array( 'widgets' ), JETPACK__VERSION );
// The 'widgets' style handle is only registered in the classic widget editor.
// In the Gutenberg block widget editor it is absent, so omit it as a dependency.
$style_deps = wp_use_widgets_block_editor() ? array() : array( 'widgets' );
wp_enqueue_style( 'widget-conditions', plugins_url( 'widget-conditions/widget-conditions.css', __FILE__ ), $style_deps, JETPACK__VERSION );
wp_style_add_data( 'widget-conditions', 'rtl', 'replace' );
wp_enqueue_script(
'widget-conditions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jQuery( function ( $ ) {

widgets_shell.on( 'click.widgetconditions', 'a.display-options', function ( e ) {
var $displayOptionsButton = $( this ),
$widget = $displayOptionsButton.closest( 'div.widget' );
$widget = $displayOptionsButton.closest( 'div.widget, .wp-block-legacy-widget__edit-form' );

e.preventDefault();

Expand All @@ -137,7 +137,10 @@ jQuery( function ( $ ) {
e.preventDefault();

if ( $condition.is( ':first-child' ) && $condition.is( ':last-child' ) ) {
$( this ).closest( 'div.widget' ).find( 'a.display-options' ).click();
$( this )
.closest( 'div.widget, .wp-block-legacy-widget__edit-form' )
.find( 'a.display-options' )
.click();
$condition.find( 'select.conditions-rule-major' ).val( '' ).change();
} else {
$condition.find( 'select.conditions-rule-major' ).change();
Expand Down
Loading