Skip to content

Commit

Permalink
fix: styles not applying on blocks added to widgets
Browse files Browse the repository at this point in the history
This fixes the issue with CSS not being applied instantly to blocks
added to Widgets in Customizer or Widgets area.

Previously, it was working if you make another change and Publish your
changes from the Customizer but the current block status wasn't being
taken into consideration.

We remove the previously implemented `wp_registered_widgets` check as we
are already using `$widgets_used` to check for inactive widgets.

Fixes https://github.com/Codeinwp/otter-internals/issues/121`
  • Loading branch information
HardeepAsrani committed Jul 30, 2024
1 parent 22ef688 commit 5dd5442
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions inc/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -1054,20 +1054,13 @@ public static function get_active_widgets_content() {
return $content;
}

global $wp_registered_widgets;
$valid_widgets = array();
$widget_data = get_option( 'widget_block', array() );

// Loop through all widgets, and add any that are active.
foreach ( $wp_registered_widgets as $widget_name => $widget ) {
if ( ! in_array( $widget['id'], self::$widget_used, true ) ) {
continue;
}

$key = $widget['params'][0]['number'];

if ( isset( $widget_data[ $key ] ) ) {
$valid_widgets[] = (object) $widget_data[ $key ];
foreach ( self::$widget_used as $widget_id ) {
$widget_id = str_replace( 'block-', '', $widget_id );
if ( isset( $widget_data[ $widget_id ] ) ) {
$valid_widgets[] = (object) $widget_data[ $widget_id ];
}
}

Expand Down

0 comments on commit 5dd5442

Please sign in to comment.