' . esc_html__('Choose how the search engine is displayed on the frontend.', 'allergen-exclusion-filter') . '

'; } public function saef_render_texts_section_info() { echo '

' . esc_html__('Customize all the texts shown in the search engine. Leave empty to use the default text.', 'allergen-exclusion-filter') . '

'; } public function saef_render_appearance_section_info() { echo '

' . esc_html__('Customize the visual appearance of the search block.', 'allergen-exclusion-filter') . '

'; } public function saef_render_section_info() { echo '

' . esc_html__('Configure how the allergen search engine behaves on the frontend.', 'allergen-exclusion-filter') . '

'; } public function saef_sanitize_options($input) { $output = array(); $mode = isset($input['display_mode']) ? sanitize_key($input['display_mode']) : 'simple'; $output['display_mode'] = in_array($mode, array('simple', 'block'), true) ? $mode : 'simple'; $title = isset($input['block_title']) ? sanitize_text_field($input['block_title']) : ''; $output['block_title'] = mb_substr($title, 0, 200); $desc = isset($input['block_description']) ? sanitize_text_field($input['block_description']) : ''; $output['block_description'] = mb_substr($desc, 0, 300); $placeholder = isset($input['placeholder']) ? sanitize_text_field($input['placeholder']) : ''; $output['placeholder'] = mb_substr($placeholder, 0, 200); $btn = isset($input['button_text']) ? sanitize_text_field($input['button_text']) : ''; $output['button_text'] = mb_substr($btn, 0, 80); $msg = isset($input['initial_message']) ? sanitize_text_field($input['initial_message']) : ''; $output['initial_message'] = mb_substr($msg, 0, 200); $color = isset($input['background_color']) ? sanitize_hex_color($input['background_color']) : ''; $output['background_color'] = $color; $button_color = isset($input['button_color']) ? sanitize_hex_color($input['button_color']) : ''; $output['button_color'] = $button_color; // (ES) Ancho de la barra: entero entre 30 y 100. // (EN) Search bar width: integer between 30 and 100. $width = isset($input['search_bar_width']) ? absint($input['search_bar_width']) : 100; $output['search_bar_width'] = max(30, min(100, $width)); // (ES) Ancho de la barra en modo compact: entero entre 150 y 600 píxeles, default 300. // (EN) Compact mode bar width: integer between 150 and 600 pixels, default 300. $compact_width = isset($input['compact_bar_width']) ? absint($input['compact_bar_width']) : 300; $output['compact_bar_width'] = max(150, min(600, $compact_width)); $ppp = isset($input['posts_per_page']) ? absint($input['posts_per_page']) : 12; $output['posts_per_page'] = max(1, min(100, $ppp)); return $output; } // =============================== // RENDERIZADO DE CADA CAMPO // =============================== public function saef_render_display_mode_field() { $current = self::saef_get_option('display_mode', 'simple'); ?>
'; } public function saef_render_block_description_field() { $value = self::saef_get_option('block_description', ''); echo ''; } public function saef_render_placeholder_field() { $value = self::saef_get_option('placeholder', ''); echo ''; } public function saef_render_button_text_field() { $value = self::saef_get_option('button_text', ''); echo ''; } public function saef_render_initial_message_field() { $value = self::saef_get_option('initial_message', ''); echo ''; echo '

' . esc_html__('Only shown in "Block" mode. The "Simple bar" mode keeps the results area empty until the user searches.', 'allergen-exclusion-filter') . '

'; } public function saef_render_background_color_field() { $value = self::saef_get_option('background_color', ''); echo ''; echo '

' . esc_html__('Choose a custom background color for the search block. Only applies in "Block" mode.', 'allergen-exclusion-filter') . '

'; } public function saef_render_button_color_field() { $value = self::saef_get_option('button_color', ''); echo ''; echo '

' . esc_html__('Choose a custom color for the search button. Applies to both simple and block mode.', 'allergen-exclusion-filter') . '

'; } public function saef_render_search_bar_width_field() { $value = (int) self::saef_get_option('search_bar_width', 100); ?>
%

px

'; echo '

' . esc_html__('Number of products shown in the instant search preview (before the full list link).', 'allergen-exclusion-filter') . '

'; } public static function saef_get_option($key, $default = '') { $options = get_option('saef_options', array()); return isset($options[$key]) ? $options[$key] : $default; } }