register_jet_control_group( 'section_stars_style', [ 'title' => esc_html__( 'Stars', 'jet-smart-filters' ), 'tab' => 'style', ] ); } public function register_filter_style_controls() { $css_scheme = apply_filters( 'jet-smart-filters/widgets/rating/css-scheme', array( 'filter-rating-stars' => '.jet-rating-stars', 'filter-rating-icon' => '.jet-rating-star__icon', 'filter' => '.jet-filter', 'filter-control' => '.jet-rating__control', 'filters-label' => '.jet-filter-label', 'apply-filters' => '.apply-filters', 'apply-filters-button' => '.apply-filters__button', ) ); $this->start_jet_control_group( 'section_stars_style' ); $this->register_jet_control( 'stars_size', [ 'tab' => 'style', 'label' => esc_html__( 'Size', 'jet-smart-filters' ), 'type' => 'number', 'units' => true, 'css' => [ [ 'property' => 'font-size', 'selector' => $css_scheme['filter-rating-icon'], ], ], ] ); $this->register_jet_control( 'stars_gutter', [ 'tab' => 'style', 'label' => esc_html__( 'Gutter', 'jet-smart-filters' ), 'type' => 'number', 'units' => true, 'css' => [ [ 'property' => 'margin-left', 'selector' => $css_scheme['filter-rating-icon'], ], ], ] ); $this->register_jet_control( 'stars_color', [ 'tab' => 'style', 'label' => esc_html__( 'Color', 'jet-smart-filters' ), 'type' => 'color', 'css' => [ [ 'property' => '--rating-color', ], ], ] ); $this->register_jet_control( 'stars_selected_color', [ 'tab' => 'style', 'label' => esc_html__( 'Selected color', 'jet-smart-filters' ), 'type' => 'color', 'css' => [ [ 'property' => '--rating-selected-color', ], ], ] ); $this->register_jet_control( 'stars_color_second', [ 'tab' => 'style', 'label' => esc_html__( 'Selected hover color', 'jet-smart-filters' ), 'type' => 'color', 'css' => [ [ 'property' => '--rating-hover-color', ], ], ] ); $this->register_jet_control( 'stars_margin', [ 'tab' => 'style', 'label' => esc_html__( 'Margin', 'jet-smart-filters' ), 'type' => 'dimensions', 'css' => [ [ 'property' => 'margin', 'selector' => $css_scheme['filter-rating-stars'], ], ], ] ); $this->register_jet_control( 'stars_alignment', [ 'tab' => 'style', 'label' => esc_html__( 'Alignment', 'jet-smart-filters' ), 'type' => 'text-align', 'exclude' => [ 'justify', ], 'css' => [ [ 'property' => 'text-align', 'selector' => $css_scheme['filter-control'], ], ], ] ); $this->end_jet_control_group(); } // Render element HTML public function render() { jet_smart_filters()->set_filters_used(); $base_class = $this->name; $settings = $this->parse_jet_render_attributes( $this->get_jet_settings() ); $filter_id = ! empty( $settings['filter_id'] ) ? $settings['filter_id'] : ''; // STEP: Select filter is empty: Show placeholder text if ( empty( $filter_id ) ) { return $this->render_element_placeholder( [ 'title' => esc_html__( 'Please select filter to show.', 'jet-smart-filters' ) ] ); } $filter_id = apply_filters( 'jet-smart-filters/render_filter_template/filter_id', $filter_id ); echo "
render_attributes( '_root' )}>"; printf( '
', $base_class ); $provider = ! empty( $settings['content_provider'] ) ? $settings['content_provider'] : ''; $query_id = ! empty( $settings['query_id'] ) ? $settings['query_id'] : 'default'; $show_label = ! empty( $settings['show_label'] ) ? filter_var( $settings['show_label'], FILTER_VALIDATE_BOOLEAN ) : false; $additional_providers = jet_smart_filters()->utils->get_additional_providers( $settings ); $rating_icon = ''; if ( ! empty( $settings['rating_icon'] ) ) { $rating_icon = Element::render_icon( $settings['rating_icon'] ); } jet_smart_filters()->admin_bar_register_item( $filter_id ); $apply_type = ! empty( $settings['apply_type'] ) ? $settings['apply_type'] : 'ajax'; $apply_on = ! empty( $settings['apply_on'] ) ? $settings['apply_on'] : 'value'; if ( 'submit' === $apply_on && in_array( $apply_type, [ 'ajax', 'mixed' ] ) ) { $apply_type = $apply_type . '-reload'; } if ( empty( $settings['apply_button_text'] ) ) { $settings['apply_button_text'] = ''; } $filter_template_args = [ 'filter_id' => $filter_id, 'content_provider' => $provider, 'additional_providers' => $additional_providers, 'query_id' => $query_id, 'apply_type' => $apply_type, 'button_text' => $settings['apply_button_text'], 'rating_icon' => $rating_icon, '__widget_id' => $this->id ]; include jet_smart_filters()->get_template( 'common/filter-label.php' ); jet_smart_filters()->filter_types->render_filter_template( $this->jet_element_render, $filter_template_args ); echo '
'; include jet_smart_filters()->get_template( 'common/apply-filters.php' ); echo "
"; } }