start_controls_section( 'section_search_settings', [ 'label' => __( 'Search Settings', 'admore-widgets-suite' ), ] ); $this->add_control( 'placeholder', [ 'label' => __( 'Placeholder Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Search…', 'admore-widgets-suite' ), ] ); $this->add_control( 'post_types', [ 'label' => __( 'Post Types', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT2, 'multiple' => true, 'options' => self::get_post_type_options(), 'default' => [ 'post', 'page' ], ] ); $this->add_control( 'max_results', [ 'label' => __( 'Max Results', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 20, 'default' => 6, ] ); $this->add_control( 'min_chars', [ 'label' => __( 'Min Characters to Search', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 5, 'default' => 2, ] ); $this->add_control( 'show_thumbnail', [ 'label' => __( 'Show Thumbnail', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'admore-widgets-suite' ), 'label_off' => __( 'No', 'admore-widgets-suite' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_type_label', [ 'label' => __( 'Show Post Type Label', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'admore-widgets-suite' ), 'label_off' => __( 'No', 'admore-widgets-suite' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_excerpt', [ 'label' => __( 'Show Excerpt', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'admore-widgets-suite' ), 'label_off' => __( 'No', 'admore-widgets-suite' ), 'return_value' => 'yes', 'default' => 'no', ] ); $this->add_control( 'no_results_text', [ 'label' => __( 'No Results Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'No results found.', 'admore-widgets-suite' ), ] ); $this->add_control( 'show_search_button', [ 'label' => __( 'Show Search Button', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'separator' => 'before', 'description' => __( 'Add a clickable search button next to the input.', 'admore-widgets-suite' ), ] ); $this->add_control( 'search_button_text', [ 'label' => __( 'Button Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Search', 'admore-widgets-suite' ), 'condition' => [ 'show_search_button' => 'yes' ], ] ); $this->add_control( 'enable_clear_button', [ 'label' => __( 'Enable Clear Button', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', 'description' => __( 'Show X button to clear search input.', 'admore-widgets-suite' ), ] ); $this->add_control( 'keyboard_shortcut', [ 'label' => __( 'Keyboard Shortcut (Ctrl+K)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', 'description' => __( 'Press Ctrl+K (Cmd+K on Mac) to focus search.', 'admore-widgets-suite' ), ] ); $this->add_control( 'show_category_filter', [ 'label' => __( 'Category Filter Dropdown', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'separator' => 'before', 'description' => __( 'Show a category dropdown next to the search field.', 'admore-widgets-suite' ), ] ); $this->add_control( 'category_taxonomy', [ 'label' => __( 'Taxonomy', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'category', 'options' => self::get_taxonomy_options(), 'condition' => [ 'show_category_filter' => 'yes' ], ] ); $this->add_control( 'category_all_label', [ 'label' => __( '"All" Label', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'All Categories', 'admore-widgets-suite' ), 'condition' => [ 'show_category_filter' => 'yes' ], ] ); $this->add_control( 'show_view_all', [ 'label' => __( 'Show "View All Results" Link', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', 'separator' => 'before', 'description' => __( 'Add a link at bottom to view full search results page.', 'admore-widgets-suite' ), ] ); $this->add_control( 'view_all_text', [ 'label' => __( '"View All" Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'View all results →', 'admore-widgets-suite' ), 'condition' => [ 'show_view_all' => 'yes' ], ] ); $this->end_controls_section(); /* ── Input Style ── */ $this->start_controls_section( 'section_input_style', [ 'label' => __( 'Input Style', 'admore-widgets-suite' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'input_width', [ 'label' => __( 'Width', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 200, 'max' => 1200 ], '%' => [ 'min' => 20, 'max' => 100 ] ], 'default' => [ 'unit' => '%', 'size' => 100 ], 'selectors' => [ '{{WRAPPER}} .eppro-search-wrap' => 'width: {{SIZE}}{{UNIT}};' ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'input_typography', 'selector' => '{{WRAPPER}} .eppro-search-field', ] ); $this->add_control( 'input_text_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-search-field' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'input_bg_color', [ 'label' => __( 'Background Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .eppro-search-field' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'input_placeholder_color', [ 'label' => __( 'Placeholder Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-search-field::placeholder' => 'color: {{VALUE}};', '{{WRAPPER}} .eppro-search-field::-webkit-input-placeholder' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'input_border', 'selector' => '{{WRAPPER}} .eppro-search-field', ] ); $this->add_control( 'input_border_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .eppro-search-field' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'input_padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .eppro-search-field' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'icon_color', [ 'label' => __( 'Icon Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-search-icon' => 'color: {{VALUE}};' ], 'separator' => 'before', ] ); $this->add_control( 'focus_heading', [ 'label' => __( 'Focus State', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'focus_border_color', [ 'label' => __( 'Border Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => EPPRO_Elementor_Helper::brand_color(), 'selectors' => [ '{{WRAPPER}} .eppro-search-field:focus' => 'border-color: {{VALUE}};' ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'focus_box_shadow', 'label' => __( 'Focus Shadow', 'admore-widgets-suite' ), 'selector' => '{{WRAPPER}} .eppro-search-field:focus', ] ); $this->add_control( 'focus_bg_color', [ 'label' => __( 'Background on Focus', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-search-field:focus' => 'background-color: {{VALUE}};' ], ] ); $this->end_controls_section(); /* ── Results Style ── */ $this->start_controls_section( 'section_results_style', [ 'label' => __( 'Results Dropdown', 'admore-widgets-suite' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'results_bg', [ 'label' => __( 'Background', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .eppro-search-results' => 'background-color: {{VALUE}};' ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'results_shadow', 'selector' => '{{WRAPPER}} .eppro-search-results', ] ); $this->add_control( 'result_title_color', [ 'label' => __( 'Title Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-result-title' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'result_hover_bg', [ 'label' => __( 'Item Hover Background', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#f8fafc', 'selectors' => [ '{{WRAPPER}} .eppro-result-item:hover' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'highlight_color', [ 'label' => __( 'Highlight Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#fef08a', 'selectors' => [ '{{WRAPPER}} .eppro-result-highlight' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'excerpt_color', [ 'label' => __( 'Excerpt Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#64748b', 'selectors' => [ '{{WRAPPER}} .eppro-result-excerpt' => 'color: {{VALUE}};' ], ] ); $this->end_controls_section(); /* ── Search Button Style ── */ $this->start_controls_section( 'section_btn_style', [ 'label' => __( 'Search Button', 'admore-widgets-suite' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'condition' => [ 'show_search_button' => 'yes' ], ] ); $this->add_control( 'search_btn_bg', [ 'label' => __( 'Background', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => EPPRO_Elementor_Helper::brand_color(), 'selectors' => [ '{{WRAPPER}} .eppro-search-btn' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'search_btn_color', [ 'label' => __( 'Text / Icon Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .eppro-search-btn, {{WRAPPER}} .eppro-search-btn svg' => 'color: {{VALUE}}; stroke: {{VALUE}};' ], ] ); $this->add_control( 'search_btn_hover_bg', [ 'label' => __( 'Hover Background', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => EPPRO_Elementor_Helper::brand_color( 'dark' ), 'selectors' => [ '{{WRAPPER}} .eppro-search-btn:hover' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'search_btn_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'default' => [ 'size' => 6 ], 'selectors' => [ '{{WRAPPER}} .eppro-search-btn' => 'border-radius: {{SIZE}}{{UNIT}};' ], ] ); $this->add_responsive_control( 'search_btn_padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .eppro-search-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->end_controls_section(); // Entrance animation — inherited from base $this->eppro_register_entrance_animation_controls(); } // ------------------------------------------------------------------------- // Render // ------------------------------------------------------------------------- protected function render(): void { $s = $this->get_settings_for_display(); $post_types = (array) ( $s['post_types'] ?? [ 'post', 'page' ] ); $max_results = absint( $s['max_results'] ?? 6 ); $min_chars = absint( $s['min_chars'] ?? 2 ); $placeholder = esc_attr( $s['placeholder'] ?? __( 'Search…', 'admore-widgets-suite' ) ); $nonce = wp_create_nonce( 'eppro_live_search' ); $show_cat_filter = 'yes' === ( $s['show_category_filter'] ?? '' ); $cat_taxonomy = sanitize_key( $s['category_taxonomy'] ?? 'category' ); $cat_all_label = esc_attr( $s['category_all_label'] ?? __( 'All Categories', 'admore-widgets-suite' ) ); $enable_clear = 'yes' === ( $s['enable_clear_button'] ?? 'yes' ); $show_search_btn = 'yes' === ( $s['show_search_button'] ?? '' ); $enable_shortcut = 'yes' === ( $s['keyboard_shortcut'] ?? 'yes' ); $show_view_all = 'yes' === ( $s['show_view_all'] ?? 'yes' ); $view_all_text = $s['view_all_text'] ?? __( 'View all results →', 'admore-widgets-suite' ); $search_btn_text = $s['search_button_text'] ?? __( 'Search', 'admore-widgets-suite' ); ?>