From 27aa6d03712fd4b165520816f23488bdf35b7e7a Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Thu, 16 Oct 2025 17:53:25 +0100 Subject: [PATCH] Limit blog filter categories control to portfolio by default Reintroduce a Portfolio-only default for the filter categories checkbox and expose a new siteorigin_widgets_blog_filter_categories_templates hook so extensions can opt-in additional templates. Reuse the filtered template list for both the settings and design state handlers to keep the UI consistent. --- widgets/blog/blog.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/widgets/blog/blog.php b/widgets/blog/blog.php index 2128fdf57..2fc4171db 100644 --- a/widgets/blog/blog.php +++ b/widgets/blog/blog.php @@ -76,6 +76,29 @@ public function register_image_sizes() { public function get_widget_form() { $templates = apply_filters( 'siteorigin_widgets_blog_templates', json_decode( file_get_contents( plugin_dir_path( __FILE__ ) . 'data/templates.json' ), true ) ); + $filter_categories_templates = apply_filters( + 'siteorigin_widgets_blog_filter_categories_templates', + array( 'portfolio' ) + ); + $filter_categories_templates = array_unique( + array_filter( + array_map( + 'sanitize_key', + (array) $filter_categories_templates + ) + ) + ); + + $filter_categories_state_handler = array(); + if ( ! empty( $filter_categories_templates ) ) { + $filter_categories_state_handler[ 'active_template[' . implode( ',', $filter_categories_templates ) . ']' ] = array( 'slideDown' ); + } + $filter_categories_state_handler['_else[active_template]'] = array( 'slideUp' ); + + $filter_categories_design_state_handler = $filter_categories_state_handler; + $filter_categories_design_state_handler['filter_categories[show]'] = array( 'slideDown' ); + $filter_categories_design_state_handler['filter_categories[hide]'] = array( 'slideUp' ); + return $this->dynamic_preset_state_handler( 'active_template', $templates, @@ -212,6 +235,7 @@ public function get_widget_form() { 'filter_categories[hide]: ! val', ), ), + 'state_handler' => $filter_categories_state_handler, ), 'categories' => array( 'type' => 'checkbox', @@ -419,6 +443,7 @@ public function get_widget_form() { 'type' => 'section', 'label' => __( 'Filter Categories', 'so-widgets-bundle' ), 'hide' => true, + 'state_handler' => $filter_categories_design_state_handler, 'fields' => array( 'font' => array( 'type' => 'font',