PluginProbe
WP Directory Kit / 1.5.5
WP Directory Kit v1.5.5
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / classes / wdk-language-switcher.php

wdk-language-switcher.php in WP Directory Kit 1.5.5, at elementor-elements/classes/wdk-language-switcher.php

412 lines 12.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25
26 class WdkLanguageSwitcher extends WdkElementorBase {
27
28 public $field_id = NULL;
29 public $fields_list = array();
30
31 public function __construct($data = array(), $args = null) {
32
33 \Elementor\Controls_Manager::add_tab(
34 'tab_conf',
35 esc_html__('Settings', 'wpdirectorykit')
36 );
37
38 \Elementor\Controls_Manager::add_tab(
39 'tab_layout',
40 esc_html__('Layout', 'wpdirectorykit')
41 );
42
43 \Elementor\Controls_Manager::add_tab(
44 'tab_content',
45 esc_html__('Main', 'wpdirectorykit')
46 );
47
48 if (method_exists($this, 'is_edit_mode_load') && $this->is_edit_mode_load()) {
49 $this->enqueue_styles_scripts();
50 }
51
52 parent::__construct($data, $args);
53
54 }
55
56 /**
57 * Retrieve the widget name.
58 *
59 * @since 1.1.0
60 *
61 * @access public
62 *
63 * @return string Widget name.
64 */
65 public function get_name() {
66 return 'wdk-language-switcher';
67 }
68
69 /**
70 * Retrieve the widget title.
71 *
72 * @since 1.1.0
73 *
74 * @access public
75 *
76 * @return string Widget title.
77 */
78 public function get_title() {
79 return esc_html__('Wdk Language Switcher', 'wpdirectorykit');
80 }
81
82 /**
83 * Retrieve the widget icon.
84 *
85 * @since 1.1.0
86 *
87 * @access public
88 *
89 * @return string Widget icon.
90 */
91 public function get_icon() {
92 return 'eicon-export-kit';
93 }
94
95 /**
96 * Register the widget controls.
97 *
98 * Adds different input fields to allow the user to change and customize the widget settings.
99 *
100 * @since 1.1.0
101 *
102 * @access protected
103 */
104 protected function register_controls() {
105 $this->generate_controls_conf();
106 $this->generate_controls_layout();
107 $this->generate_controls_styles();
108 $this->generate_controls_content();
109
110 parent::register_controls();
111 }
112
113 /**
114 * Render the widget output on the frontend.
115 *
116 * Written in PHP and used to generate the final HTML.
117 *
118 * @since 1.1.0
119 *
120 * @access protected
121 */
122 protected function render() {
123 parent::render();
124 $this->data['id_element'] = $this->get_id();
125 $this->data['settings'] = $this->get_settings();
126
127 $this->data['langs'] = wdk_get_languages();
128 $this->data['is_edit_mode']= false;
129 if(Plugin::$instance->editor->is_edit_mode()){
130 $this->data['is_edit_mode']= true;
131 } else {
132 if(empty( $this->data['langs'])) return false;
133 }
134
135 $layout = 'drop';
136
137 if($this->data['settings']['enable_list_layout'] == 'yes')
138 $layout = 'list';
139
140 echo $this->view('wdk-language-switcher-'.$layout, $this->data);
141 }
142
143 private function generate_controls_conf() {
144 $this->start_controls_section(
145 'tab_conf_main_section',
146 [
147 'label' => esc_html__('Main', 'wpdirectorykit'),
148 'tab' => '1',
149 ]
150 );
151
152 $this->add_control (
153 'enable_list_layout',
154 [
155 'label' => __( 'Enable List Layout', 'wpdirectorykit' ),
156 'type' => Controls_Manager::SWITCHER,
157 'label_on' => __( 'Hide', 'wpdirectorykit' ),
158 'label_off' => __( 'Show', 'wpdirectorykit' ),
159 'return_value' => 'yes',
160 'default' => '',
161 ]
162 );
163
164 $this->add_responsive_control (
165 'list_layout_column',
166 [
167 'label' => __( 'Show in one column', 'wpdirectorykit' ),
168 'type' => Controls_Manager::SWITCHER,
169 'label_on' => __( 'Hide', 'wpdirectorykit' ),
170 'label_off' => __( 'Show', 'wpdirectorykit' ),
171 'return_value' => 'flex-direction:column',
172 'default' => '',
173 'conditions' => [
174 'terms' => [
175 [
176 'name' => 'enable_list_layout',
177 'operator' => '==',
178 'value' => 'yes',
179 ]
180 ],
181 ],
182 'selectors' => [
183 '{{WRAPPER}} .wdk-language-switcher-list' => '{{VALUE}};',
184 ],
185 ]
186 );
187
188
189 $this->add_responsive_control(
190 'row_gap',
191 [
192 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
193 'type' => Controls_Manager::SLIDER,
194 'default' => [
195 'size' => 10,
196 ],
197 'range' => [
198 'px' => [
199 'min' => 0,
200 'max' => 60,
201 ],
202 ],
203 'selectors' => [
204 '{{WRAPPER}} .wdk-language-switcher-list' => 'row-gap: {{SIZE}}{{UNIT}};',
205 ],
206 'conditions' => [
207 'terms' => [
208 [
209 'name' => 'enable_list_layout',
210 'operator' => '==',
211 'value' => 'yes',
212 ]
213 ],
214 ],
215 ]
216 );
217
218 $this->add_responsive_control(
219 'сol_gap',
220 [
221 'label' => esc_html__('Column Gap', 'wpdirectorykit'),
222 'type' => Controls_Manager::SLIDER,
223 'default' => [
224 'size' => 10,
225 ],
226 'range' => [
227 'px' => [
228 'min' => 0,
229 'max' => 60,
230 ],
231 ],
232 'selectors' => [
233 '{{WRAPPER}} .wdk-language-switcher-list' => 'column-gap: {{SIZE}}{{UNIT}};',
234 ],
235 'conditions' => [
236 'terms' => [
237 [
238 'name' => 'enable_list_layout',
239 'operator' => '==',
240 'value' => 'yes',
241 ]
242 ],
243 ],
244 ]
245 );
246
247 $this->end_controls_section();
248
249 }
250
251
252 private function generate_controls_layout() {
253 }
254
255 private function generate_controls_styles() {
256 $this->start_controls_section(
257 'icon_section',
258 [
259 'label' => esc_html__('Icon', 'wpdirectorykit'),
260 'tab' => '1',
261 'conditions' => [
262 'terms' => [
263 [
264 'name' => 'enable_list_layout',
265 'operator' => '!=',
266 'value' => 'yes',
267 ]
268 ],
269 ],
270
271 ]
272 );+
273
274 $this->add_control(
275 'select_icon',
276 [
277 'label' => esc_html__('Icon', 'wpdirectorykit'),
278 'type' => Controls_Manager::ICONS,
279 'label_block' => true,
280 'default' => [
281 'value' => 'fa fa-angle-down',
282 'library' => 'solid',
283 ],
284 'conditions' => [
285 'terms' => [
286 [
287 'name' => 'enable_list_layout',
288 'operator' => '!=',
289 'value' => 'yes',
290 ]
291 ],
292 ],
293 ]
294 );
295
296 $selectors = array(
297 'normal' => '{{WRAPPER}} .wdk-language-switcher-drop .wdk-language-switcher-btn-toggle i',
298 'hover'=>'{{WRAPPER}} .wdk-language-switcher-drop .wdk-language-switcher-btn-toggle%1$s i'
299 );
300
301 $this->generate_renders_tabs($selectors, 'icon_dynamic', ['margin','color','font-size','hover_animation']);
302 $this->end_controls_section();
303
304
305 $items = [
306 [
307 'key'=>'button',
308 'label'=> esc_html__('Button Switcher', 'wpdirectorykit'),
309 'selector'=>'.wdk-language-switcher-drop .wdk-language-switcher-btn-toggle',
310 'options'=>'block',
311 ],
312 [
313 'key'=>'dropdown_box',
314 'label'=> esc_html__('DropDown Box', 'wpdirectorykit'),
315 'selector'=>'.wdk-language-switcher-drop .wdk-language-switcher-menu',
316 'options'=>'full',
317 ],
318 [
319 'key'=>'items',
320 'label'=> esc_html__('Items', 'wpdirectorykit'),
321 'selector'=>'.wdk-language-switcher-drop .wdk-language-switcher-menu .item',
322 'options'=>'full',
323 ],
324 ];
325
326 foreach ($items as $item) {
327 $this->start_controls_section(
328 $item['key'].'_section',
329 [
330 'label' => $item['label'],
331 'tab' => '1',
332 'conditions' => [
333 'terms' => [
334 [
335 'name' => 'enable_list_layout',
336 'operator' => '!=',
337 'value' => 'yes',
338 ]
339 ],
340 ],
341 ]
342 );
343
344 if( $item ['key'] == 'items'){
345 $selectors = array(
346 'normal' => '{{WRAPPER}} '.$item['selector'],
347 );
348 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
349 }
350
351 $selectors = array(
352 'normal' => '{{WRAPPER}} '.$item['selector'],
353 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
354 );
355 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
356
357 $this->end_controls_section();
358 /* END special for some elements */
359 }
360
361 $items = [
362 [
363 'key'=>'items_list',
364 'label'=> esc_html__('Items', 'wpdirectorykit'),
365 'selector'=>'.wdk-language-switcher-list .wdk-language-switcher-menu .item',
366 'options'=>'full',
367 ],
368 ];
369
370 foreach ($items as $item) {
371 $this->start_controls_section(
372 $item['key'].'_section',
373 [
374 'label' => $item['label'],
375 'tab' => '1',
376 'conditions' => [
377 'terms' => [
378 [
379 'name' => 'enable_list_layout',
380 'operator' => '==',
381 'value' => 'yes',
382 ]
383 ],
384 ],
385 ]
386 );
387
388 $selectors = array(
389 'normal' => '{{WRAPPER}} '.$item['selector'],
390 );
391 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
392
393 $selectors = array(
394 'normal' => '{{WRAPPER}} '.$item['selector'],
395 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
396 );
397 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
398
399 $this->end_controls_section();
400 /* END special for some elements */
401 }
402 }
403
404 private function generate_controls_content() {
405
406 }
407
408 public function enqueue_styles_scripts() {
409 wp_enqueue_style('wdk-language-switcher');
410 }
411 }
412