PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.65
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.65
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 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Facet_Meta / Facet_Meta.php

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

147 lines 4.5 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 use King_Addons\Woo_Builder\Context as Woo_Context;
13
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 /**
19 * Renders meta/ACF filter controls for faceted filters.
20 */
21 class Facet_Meta extends Widget_Base
22 {
23 public function get_name(): string
24 {
25 return 'facet_meta';
26 }
27
28 public function get_title(): string
29 {
30 return esc_html__('Facet Meta/ACF', 'king-addons');
31 }
32
33 public function get_icon(): string
34 {
35 return 'eicon-filter';
36 }
37
38 public function get_categories(): array
39 {
40 return ['king-addons'];
41 }
42
43 public function get_script_depends(): array
44 {
45 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-meta-script'];
46 }
47
48 public function get_style_depends(): array
49 {
50 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-meta-style'];
51 }
52
53 public function get_custom_help_url()
54 {
55 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
56 }
57
58 protected function register_controls(): void
59 {
60 $this->start_controls_section(
61 'section_content',
62 [
63 'label' => esc_html__('Content', 'king-addons'),
64 'tab' => Controls_Manager::TAB_CONTENT,
65 ]
66 );
67
68 $this->add_control(
69 'query_id',
70 [
71 'label' => esc_html__('Query ID', 'king-addons'),
72 'type' => Controls_Manager::TEXT,
73 'description' => esc_html__('Must match the grid Query ID.', 'king-addons'),
74 ]
75 );
76
77 $this->add_control(
78 'meta_key',
79 [
80 'label' => esc_html__('Meta/ACF key', 'king-addons'),
81 'type' => Controls_Manager::TEXT,
82 'placeholder' => 'custom_field',
83 ]
84 );
85
86 $this->add_control(
87 'control_type',
88 [
89 'label' => esc_html__('Control type', 'king-addons'),
90 'type' => Controls_Manager::SELECT,
91 'options' => [
92 'text' => esc_html__('Text', 'king-addons'),
93 'select' => esc_html__('Select', 'king-addons'),
94 'range' => esc_html__('Range', 'king-addons'),
95 ],
96 'default' => 'text',
97 ]
98 );
99
100 $this->add_control(
101 'placeholder',
102 [
103 'label' => esc_html__('Placeholder', 'king-addons'),
104 'type' => Controls_Manager::TEXT,
105 ]
106 );
107
108 $this->end_controls_section();
109 }
110
111 protected function render(): void
112 {
113 $settings = $this->get_settings_for_display();
114 $query_id = $settings['query_id'] ?? '';
115 $meta_key = $settings['meta_key'] ?? '';
116 if (empty($query_id) || empty($meta_key)) {
117 if (class_exists(Woo_Context::class) && Woo_Context::is_editor()) {
118 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
119 }
120 return;
121 }
122
123 $type = $settings['control_type'] ?? 'text';
124 $placeholder = $settings['placeholder'] ?? '';
125 $data = ' data-ka-filters-query-id="' . esc_attr($query_id) . '" data-ka-filter-type="meta" data-ka-meta-key="' . esc_attr($meta_key) . '"';
126
127 echo '<div class="ka-facet-meta" ' . $data . '>';
128 if ('text' === $type) {
129 echo '<input type="text" class="ka-facet-meta__input" placeholder="' . esc_attr($placeholder) . '" />';
130 } elseif ('select' === $type) {
131 $ph = $placeholder ?: __('Any', 'king-addons');
132 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>';
133 } elseif ('range' === $type) {
134 echo '<div class="ka-facet-meta__range">';
135 echo '<input type="number" class="ka-facet-meta__range-min" placeholder="' . esc_attr__('Min', 'king-addons') . '" />';
136 echo '<input type="number" class="ka-facet-meta__range-max" placeholder="' . esc_attr__('Max', 'king-addons') . '" />';
137 echo '</div>';
138 }
139 echo '</div>';
140 }
141 }
142
143
144
145
146
147