0, 'columns' => '', 'posts' => '', 'pagination' => '', ), $atts, 'filterx' ); $search_id = absint( $atts['id'] ); if ( ! $search_id ) { return '

' . esc_html__( 'Webcasata FilterX: No search ID specified.', 'webcasata-filterx' ) . '

'; } $post = get_post( $search_id ); if ( ! $post || 'filterx_item' !== $post->post_type ) { return '

' . esc_html__( 'Webcasata FilterX: Search item not found.', 'webcasata-filterx' ) . '

'; } // Load settings and allow shortcode attribute overrides $settings = FilterX_Post_Type::get_settings( $search_id ); if ( ! empty( $atts['columns'] ) ) { $settings['columns'] = min( 6, max( 1, absint( $atts['columns'] ) ) ); } if ( ! empty( $atts['posts'] ) ) { $settings['posts_per_page'] = min( 100, max( 1, absint( $atts['posts'] ) ) ); } if ( ! empty( $atts['pagination'] ) ) { $settings['pagination_type'] = sanitize_key( $atts['pagination'] ); } // Get taxonomy objects for filter dropdowns $taxonomies = self::get_taxonomy_objects( $settings['taxonomies'] ); // Delegate all rendering to the template system return FilterX_Template_Loader::get_template_html( 'widget/wrapper.php', array( 'search_id' => $search_id, 'settings' => $settings, 'taxonomies' => $taxonomies, 'widget_id' => 'filterx-widget-' . $search_id, 'nonce' => wp_create_nonce( 'filterx_nonce' ), ) ); } /* ------------------------------------------------------------------ */ /* Helper: taxonomy objects */ /* ------------------------------------------------------------------ */ private static function get_taxonomy_objects( $taxonomy_names ) { $objects = array(); foreach ( $taxonomy_names as $name ) { $obj = get_taxonomy( sanitize_key( $name ) ); if ( $obj ) { $objects[] = $obj; } } return $objects; } }