start_controls_section( 'section_content', [ 'label' => esc_html__('Content', 'king-addons'), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'query_id', [ 'label' => esc_html__('Query ID', 'king-addons'), 'type' => Controls_Manager::TEXT, 'description' => esc_html__('Must match the grid Query ID.', 'king-addons'), ] ); $this->add_control( 'meta_key', [ 'label' => esc_html__('Meta/ACF key', 'king-addons'), 'type' => Controls_Manager::TEXT, 'placeholder' => 'custom_field', ] ); $this->add_control( 'control_type', [ 'label' => esc_html__('Control type', 'king-addons'), 'type' => Controls_Manager::SELECT, 'options' => [ 'text' => esc_html__('Text', 'king-addons'), 'select' => esc_html__('Select', 'king-addons'), 'range' => esc_html__('Range', 'king-addons'), ], 'default' => 'text', ] ); $this->add_control( 'placeholder', [ 'label' => esc_html__('Placeholder', 'king-addons'), 'type' => Controls_Manager::TEXT, ] ); $this->end_controls_section(); } protected function render(): void { $settings = $this->get_settings_for_display(); $query_id = $settings['query_id'] ?? ''; $meta_key = $settings['meta_key'] ?? ''; if (empty($query_id) || empty($meta_key)) { if (class_exists(Woo_Context::class) && Woo_Context::is_editor()) { echo '
' . esc_html__('Set Query ID and Meta key.', 'king-addons') . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } return; } $type = $settings['control_type'] ?? 'text'; $placeholder = $settings['placeholder'] ?? ''; $data = ' data-ka-filters-query-id="' . esc_attr($query_id) . '" data-ka-filter-type="meta" data-ka-meta-key="' . esc_attr($meta_key) . '"'; echo '
'; if ('text' === $type) { echo ''; } elseif ('select' === $type) { $ph = $placeholder ?: __('Any', 'king-addons'); echo ''; } elseif ('range' === $type) { echo '
'; echo ''; echo ''; echo '
'; } echo '
'; } }