| @@ -13,8 +13,9 @@ | ||
| 13 | 13 | use ContentControl\Base\Controller; |
| 14 | 14 | |
| 15 | 15 | use WP_Customize_Manager; |
| 16 | 16 | |
| 17 | +use function ContentControl\is_rest; | |
| 17 | 18 | use function ContentControl\protection_is_disabled; |
| 18 | 19 | use function ContentControl\user_meets_requirements; |
| 19 | 20 | use function ContentControl\Widgets\get_options as get_widget_options; |
| 20 | 21 | |
| @@ -26,20 +27,20 @@ | ||
| 26 | 27 | /** |
| 27 | 28 | * Initialize Widgets Frontend. |
| 28 | 29 | */ |
| 29 | 30 | public function init() { |
| 30 | - add_action( 'sidebars_widgets', [ $this, 'exclude_widgets' ] ); | |
| 31 | + add_filter( 'sidebars_widgets', [ $this, 'exclude_widgets' ] ); | |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | /** |
| 34 | 35 | * Checks for and excludes widgets based on their chosen options. |
| 35 | 36 | * |
| 36 | - * @param array $widget_areas An array of widget areas and their widgets. | |
| 37 | + * @param array<string,array<string>> $widget_areas An array of widget areas and their widgets. | |
| 37 | 38 | * |
| 38 | - * @return array The modified $widget_area array. | |
| 39 | + * @return array<string,array<string>> The modified $widget_area array. | |
| 39 | 40 | */ |
| 40 | 41 | public function exclude_widgets( $widget_areas ) { |
| 41 | - if ( protection_is_disabled() || $this->is_customize_preview() ) { | |
| 42 | + if ( is_rest() || protection_is_disabled() || $this->is_customize_preview() ) { | |
| 42 | 43 | return $widget_areas; |
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | foreach ( $widget_areas as $widget_area => $widgets ) { |