PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.78
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.78
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 / Cookie_Preferences_Button / Cookie_Preferences_Button.php

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

273 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cookie Preferences Button widget (Free).
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Border;
12 use Elementor\Group_Control_Box_Shadow;
13 use Elementor\Group_Control_Typography;
14 use Elementor\Widget_Base;
15
16 if (!defined('ABSPATH')) {
17 exit;
18 }
19
20 /**
21 * Renders a manage-consent button that opens the cookie settings modal.
22 */
23 class Cookie_Preferences_Button extends Widget_Base
24 {
25 /**
26 * Get widget slug.
27 *
28 * @return string
29 */
30 public function get_name(): string
31 {
32 return 'king-addons-cookie-preferences-button';
33 }
34
35 /**
36 * Get widget title.
37 *
38 * @return string
39 */
40 public function get_title(): string
41 {
42 return esc_html__('Cookie Preferences Button', 'king-addons');
43 }
44
45 /**
46 * Get widget icon.
47 *
48 * @return string
49 */
50 public function get_icon(): string
51 {
52 return 'king-addons-icon king-addons-button';
53 }
54
55 /**
56 * Get widget categories.
57 *
58 * @return array<int, string>
59 */
60 public function get_categories(): array
61 {
62 return ['king-addons'];
63 }
64
65 /**
66 * Get widget keywords.
67 *
68 * @return array<int, string>
69 */
70 public function get_keywords(): array
71 {
72 return ['cookie', 'consent', 'gdpr', 'ccpa', 'privacy'];
73 }
74
75 /**
76 * Enqueue style dependencies.
77 *
78 * @return array<int, string>
79 */
80 public function get_style_depends(): array
81 {
82 return [
83 KING_ADDONS_ASSETS_UNIQUE_KEY . '-cookie-preferences-button-style',
84 ];
85 }
86
87 /**
88 * Enqueue script dependencies.
89 *
90 * @return array<int, string>
91 */
92 public function get_script_depends(): array
93 {
94 return [
95 KING_ADDONS_ASSETS_UNIQUE_KEY . '-cookie-preferences-button-script',
96 ];
97 }
98
99 public function get_custom_help_url()
100 {
101 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
102 }
103
104 /**
105 * Register widget controls.
106 *
107 * @return void
108 */
109 public function register_controls(): void
110 {
111 $this->start_controls_section(
112 'kng_content_section',
113 [
114 'label' => esc_html__('Content', 'king-addons'),
115 'tab' => Controls_Manager::TAB_CONTENT,
116 ]
117 );
118
119 $this->add_control(
120 'kng_label',
121 [
122 'label' => esc_html__('Button Label', 'king-addons'),
123 'type' => Controls_Manager::TEXT,
124 'default' => esc_html__('Cookie settings', 'king-addons'),
125 ]
126 );
127
128 $this->add_responsive_control(
129 'kng_align',
130 [
131 'label' => esc_html__('Alignment', 'king-addons'),
132 'type' => Controls_Manager::CHOOSE,
133 'options' => [
134 'flex-start' => [
135 'title' => esc_html__('Left', 'king-addons'),
136 'icon' => 'eicon-text-align-left',
137 ],
138 'center' => [
139 'title' => esc_html__('Center', 'king-addons'),
140 'icon' => 'eicon-text-align-center',
141 ],
142 'flex-end' => [
143 'title' => esc_html__('Right', 'king-addons'),
144 'icon' => 'eicon-text-align-right',
145 ],
146 ],
147 'selectors' => [
148 '{{WRAPPER}} .king-addons-cookie-button' => 'justify-content: {{VALUE}};',
149 ],
150 ]
151 );
152
153 $this->end_controls_section();
154
155 $this->start_controls_section(
156 'kng_style_section',
157 [
158 'label' => esc_html__('Button', 'king-addons'),
159 'tab' => Controls_Manager::TAB_STYLE,
160 ]
161 );
162
163 $this->add_group_control(
164 Group_Control_Typography::get_type(),
165 [
166 'name' => 'kng_typography',
167 'selector' => '{{WRAPPER}} .king-addons-cookie-button__trigger',
168 ]
169 );
170
171 $this->add_control(
172 'kng_text_color',
173 [
174 'label' => esc_html__('Text Color', 'king-addons'),
175 'type' => Controls_Manager::COLOR,
176 'selectors' => [
177 '{{WRAPPER}} .king-addons-cookie-button__trigger' => 'color: {{VALUE}};',
178 ],
179 ]
180 );
181
182 $this->add_control(
183 'kng_background',
184 [
185 'label' => esc_html__('Background', 'king-addons'),
186 'type' => Controls_Manager::COLOR,
187 'selectors' => [
188 '{{WRAPPER}} .king-addons-cookie-button__trigger' => 'background-color: {{VALUE}};',
189 ],
190 ]
191 );
192
193 $this->add_control(
194 'kng_border_color',
195 [
196 'label' => esc_html__('Border Color', 'king-addons'),
197 'type' => Controls_Manager::COLOR,
198 'selectors' => [
199 '{{WRAPPER}} .king-addons-cookie-button__trigger' => 'border-color: {{VALUE}};',
200 ],
201 ]
202 );
203
204 $this->add_group_control(
205 Group_Control_Border::get_type(),
206 [
207 'name' => 'kng_border',
208 'selector' => '{{WRAPPER}} .king-addons-cookie-button__trigger',
209 ]
210 );
211
212 $this->add_group_control(
213 Group_Control_Box_Shadow::get_type(),
214 [
215 'name' => 'kng_box_shadow',
216 'selector' => '{{WRAPPER}} .king-addons-cookie-button__trigger',
217 ]
218 );
219
220 $this->add_control(
221 'kng_border_radius',
222 [
223 'label' => esc_html__('Border Radius', 'king-addons'),
224 'type' => Controls_Manager::SLIDER,
225 'range' => [
226 'px' => [
227 'min' => 0,
228 'max' => 50,
229 ],
230 ],
231 'selectors' => [
232 '{{WRAPPER}} .king-addons-cookie-button__trigger' => 'border-radius: {{SIZE}}{{UNIT}};',
233 ],
234 ]
235 );
236
237 $this->add_responsive_control(
238 'kng_padding',
239 [
240 'label' => esc_html__('Padding', 'king-addons'),
241 'type' => Controls_Manager::DIMENSIONS,
242 'size_units' => ['px', 'em', '%'],
243 'selectors' => [
244 '{{WRAPPER}} .king-addons-cookie-button__trigger' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
245 ],
246 ]
247 );
248
249 $this->end_controls_section();
250 }
251
252 /**
253 * Render widget output.
254 *
255 * @return void
256 */
257 public function render(): void
258 {
259 $settings = $this->get_settings_for_display();
260 $label = !empty($settings['kng_label']) ? $settings['kng_label'] : esc_html__('Cookie settings', 'king-addons');
261 ?>
262 <div class="king-addons-cookie-button">
263 <button type="button" class="king-addons-cookie-button__trigger" data-ka-cookie-manage="true">
264 <?php echo esc_html($label); ?>
265 </button>
266 </div>
267 <?php
268 }
269 }
270
271
272
273