PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.44
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.44
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / widgets / Facet_Meta / Facet_Meta.php

Facet_Meta.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.44, at includes/widgets/Facet_Meta/Facet_Meta.php

139 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Facet Meta/ACF filter widget (placeholder).
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Widget_Base;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 /**
18 * Renders meta/ACF filter controls for faceted filters.
19 */
20 class Facet_Meta extends Widget_Base
21 {
22 public function get_name(): string
23 {
24 return 'facet_meta';
25 }
26
27 public function get_title(): string
28 {
29 return esc_html__('Facet Meta/ACF', 'king-addons');
30 }
31
32 public function get_icon(): string
33 {
34 return 'eicon-filter';
35 }
36
37 public function get_categories(): array
38 {
39 return ['king-addons'];
40 }
41
42 public function get_script_depends(): array
43 {
44 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-meta-script'];
45 }
46
47 public function get_style_depends(): array
48 {
49 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-meta-style'];
50 }
51
52 protected function register_controls(): void
53 {
54 $this->start_controls_section(
55 'section_content',
56 [
57 'label' => esc_html__('Content', 'king-addons'),
58 'tab' => Controls_Manager::TAB_CONTENT,
59 ]
60 );
61
62 $this->add_control(
63 'query_id',
64 [
65 'label' => esc_html__('Query ID', 'king-addons'),
66 'type' => Controls_Manager::TEXT,
67 'description' => esc_html__('Must match the grid Query ID.', 'king-addons'),
68 ]
69 );
70
71 $this->add_control(
72 'meta_key',
73 [
74 'label' => esc_html__('Meta/ACF key', 'king-addons'),
75 'type' => Controls_Manager::TEXT,
76 'placeholder' => 'custom_field',
77 ]
78 );
79
80 $this->add_control(
81 'control_type',
82 [
83 'label' => esc_html__('Control type', 'king-addons'),
84 'type' => Controls_Manager::SELECT,
85 'options' => [
86 'text' => esc_html__('Text', 'king-addons'),
87 'select' => esc_html__('Select', 'king-addons'),
88 'range' => esc_html__('Range', 'king-addons'),
89 ],
90 'default' => 'text',
91 ]
92 );
93
94 $this->add_control(
95 'placeholder',
96 [
97 'label' => esc_html__('Placeholder', 'king-addons'),
98 'type' => Controls_Manager::TEXT,
99 ]
100 );
101
102 $this->end_controls_section();
103 }
104
105 protected function render(): void
106 {
107 $settings = $this->get_settings_for_display();
108 $query_id = $settings['query_id'] ?? '';
109 $meta_key = $settings['meta_key'] ?? '';
110 if (empty($query_id) || empty($meta_key)) {
111 echo '<div class="king-addons-woo-builder-notice">' . esc_html__('Set Query ID and Meta key.', 'king-addons') . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
112 return;
113 }
114
115 $type = $settings['control_type'] ?? 'text';
116 $placeholder = $settings['placeholder'] ?? '';
117 $data = ' data-ka-filters-query-id="' . esc_attr($query_id) . '" data-ka-filter-type="meta" data-ka-meta-key="' . esc_attr($meta_key) . '"';
118
119 echo '<div class="ka-facet-meta" ' . $data . '>';
120 if ('text' === $type) {
121 echo '<input type="text" class="ka-facet-meta__input" placeholder="' . esc_attr($placeholder) . '" />';
122 } elseif ('select' === $type) {
123 $ph = $placeholder ?: __('Any', 'king-addons');
124 echo '<select class="ka-facet-meta__select" data-placeholder="' . esc_attr($ph) . '" data-ka-meta-key="' . esc_attr($meta_key) . '" data-ka-filters-query-id="' . esc_attr($query_id) . '"><option value="">' . esc_html($ph) . '</option></select>';
125 } elseif ('range' === $type) {
126 echo '<div class="ka-facet-meta__range">';
127 echo '<input type="number" class="ka-facet-meta__range-min" placeholder="' . esc_attr__('Min', 'king-addons') . '" />';
128 echo '<input type="number" class="ka-facet-meta__range-max" placeholder="' . esc_attr__('Max', 'king-addons') . '" />';
129 echo '</div>';
130 }
131 echo '</div>';
132 }
133 }
134
135
136
137
138
139