PluginProbe
WP Directory Kit / 1.4.8
WP Directory Kit v1.4.8
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / classes / wdk-button.php

wdk-button.php in WP Directory Kit 1.4.8, at elementor-elements/classes/wdk-button.php

417 lines 12.4 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 class WdkButton extends WdkElementorBase {
26
27 public $field_id = NULL;
28 public $fields_list = array();
29
30 public function __construct($data = array(), $args = null) {
31
32 \Elementor\Controls_Manager::add_tab(
33 'tab_conf',
34 esc_html__('Settings', 'wpdirectorykit')
35 );
36
37 \Elementor\Controls_Manager::add_tab(
38 'tab_layout',
39 esc_html__('Layout', 'wpdirectorykit')
40 );
41
42 \Elementor\Controls_Manager::add_tab(
43 'tab_content',
44 esc_html__('Main', 'wpdirectorykit')
45 );
46
47
48 if ($this->is_edit_mode_load()) {
49 $this->enqueue_styles_scripts();
50 }
51
52 parent::__construct($data, $args);
53
54 }
55
56
57 /**
58 * Retrieve the widget name.
59 *
60 * @since 1.1.0
61 *
62 * @access public
63 *
64 * @return string Widget name.
65 */
66 public function get_name() {
67 return 'wdk-button';
68 }
69
70 /**
71 * Retrieve the widget title.
72 *
73 * @since 1.1.0
74 *
75 * @access public
76 *
77 * @return string Widget title.
78 */
79 public function get_title() {
80 return esc_html__('Wdk Button', 'wpdirectorykit');
81 }
82
83 /**
84 * Retrieve the widget icon.
85 *
86 * @since 1.1.0
87 *
88 * @access public
89 *
90 * @return string Widget icon.
91 */
92 public function get_icon() {
93 return 'eicon-download-button';
94 }
95
96 /**
97 * Register the widget controls.
98 *
99 * Adds different input fields to allow the user to change and customize the widget settings.
100 *
101 * @since 1.1.0
102 *
103 * @access protected
104 */
105 protected function register_controls() {
106 $this->generate_controls_conf();
107 $this->generate_controls_layout();
108 $this->generate_controls_styles();
109 $this->generate_controls_content();
110
111 $this->insert_pro_message('1');
112 parent::register_controls();
113 }
114
115 /**
116 * Render the widget output on the frontend.
117 *
118 * Written in PHP and used to generate the final HTML.
119 *
120 * @since 1.1.0
121 *
122 * @access protected
123 */
124 protected function render() {
125 parent::render();
126
127 $this->data['id_element'] = $this->get_id();
128 $this->data['settings'] = $this->get_settings();
129
130 $enable = false;
131 if(wmvc_show_data('event_is_login_all', $this->data['settings'])) {
132 if(is_user_logged_in()){
133 $enable = true;
134 }
135 }
136
137 if(wmvc_show_data('event_is_not_login', $this->data['settings'])) {
138 if(!is_user_logged_in()){
139 $enable = true;
140 }
141 }
142
143 if(wmvc_show_data('event_is_login_custom_user_type', $this->data['settings'])) {
144 if(is_user_logged_in()){
145 foreach ($this->data['settings']['event_is_login_custom_user_type_list'] as $user_type) {
146 if(wmvc_user_in_role($user_type['role'])) {
147 $enable = true;
148 }
149 }
150 }
151 }
152
153 $this->data['is_edit_mode']= false;
154 if(Plugin::$instance->editor->is_edit_mode()){
155 $this->data['is_edit_mode']= true;
156 } else {
157 if(!$enable) {
158 return false;
159 }
160 }
161
162 echo $this->view('wdk-button', $this->data);
163 }
164
165
166 private function generate_controls_conf() {
167 $this->start_controls_section(
168 'tab_conf_main_section',
169 [
170 'label' => esc_html__('Main', 'wpdirectorykit'),
171 'tab' => '1',
172 ]
173 );
174
175 $this->add_control(
176 'link_text',
177 [
178 'label' => __('Text Link', 'wpdirectorykit'),
179 'type' => \Elementor\Controls_Manager::TEXT,
180 'default' => __('Text button', 'wpdirectorykit'),
181 'separator' => 'before',
182 ]
183 );
184
185 $this->add_control(
186 'link_url',
187 [
188 'label' => __('Link Url', 'wpdirectorykit'),
189 'type' => \Elementor\Controls_Manager::TEXT,
190 'default' => '#',
191 ]
192 );
193
194 $this->add_control(
195 'link_id',
196 [
197 'label' => __('Special attr id for link', 'wpdirectorykit'),
198 'type' => \Elementor\Controls_Manager::TEXT,
199 'default' => '',
200 ]
201 );
202
203 $this->add_control(
204 'link_icon',
205 [
206 'label' => esc_html__('Icon', 'wpdirectorykit'),
207 'type' => Controls_Manager::ICONS,
208 'label_block' => true,
209 'default' => [
210 'value' => 'fa fa-home',
211 'library' => 'solid',
212 ],
213 ]
214 );
215
216 $this->add_control(
217 'link_icon_position',
218 [
219 'label' => esc_html__('icon Position', 'wpdirectorykit'),
220 'type' => Controls_Manager::SELECT,
221 'options' => [
222 'left' => esc_html__('Left', 'wpdirectorykit'),
223 'right' => esc_html__('Right', 'wpdirectorykit'),
224 ],
225 'default' => 'left',
226 ]
227 );
228
229 $this->add_control(
230 'link_in_new_tab',
231 [
232 'label' => __( 'Open Link in New tab', 'wpdirectorykit' ),
233 'type' => \Elementor\Controls_Manager::SWITCHER,
234 'label_on' => __( 'On', 'wpdirectorykit' ),
235 'label_off' => __( 'Off', 'wpdirectorykit' ),
236 'return_value' => 'true',
237 'default' => '',
238 ]
239 );
240
241 $this->end_controls_section();
242
243 $this->start_controls_section(
244 'tab_conf_main_section_event',
245 [
246 'label' => esc_html__('Events When Visible Button', 'wpdirectorykit'),
247 'tab' => '1',
248 ]
249 );
250
251 $this->add_control(
252 'event_is_not_login',
253 [
254 'label' => __( 'Visible if Not Login', 'wpdirectorykit' ),
255 'type' => \Elementor\Controls_Manager::SWITCHER,
256 'label_on' => __( 'On', 'wpdirectorykit' ),
257 'label_off' => __( 'Off', 'wpdirectorykit' ),
258 'return_value' => 'true',
259 'default' => 'true',
260 ]
261 );
262
263 $this->add_control(
264 'event_is_login_all',
265 [
266 'label' => __( 'Visible if Login All Users', 'wpdirectorykit' ),
267 'type' => \Elementor\Controls_Manager::SWITCHER,
268 'description' => __( 'Disable for set by user type', 'wpdirectorykit' ),
269 'label_on' => __( 'On', 'wpdirectorykit' ),
270 'label_off' => __( 'Off', 'wpdirectorykit' ),
271 'return_value' => 'true',
272 'default' => 'true',
273
274 ]
275 );
276
277 $this->add_control(
278 'event_is_login_custom_user_type',
279 [
280 'label' => __( 'Visible if Login By Custom user type', 'wpdirectorykit' ),
281 'type' => \Elementor\Controls_Manager::SWITCHER,
282 'label_on' => __( 'On', 'wpdirectorykit' ),
283 'label_off' => __( 'Off', 'wpdirectorykit' ),
284 'return_value' => 'true',
285 'default' => '',
286 'conditions' => [
287 'terms' => [
288 [
289 'name' => 'event_is_login_all',
290 'operator' => '==',
291 'value' => '',
292 ]
293 ],
294 ],
295 ]
296 );
297
298 global $wp_roles;
299 if ( ! isset( $wp_roles ) ) {
300 $wp_roles = new \WP_Roles();
301 }
302
303 if(true){
304 $repeater = new Repeater();
305 $repeater->start_controls_tabs( 'user_roles' );
306 $repeater->add_control(
307 'role',
308 [
309 'label' => esc_html__('icon Position', 'wpdirectorykit'),
310 'type' => Controls_Manager::SELECT,
311 'options' => $wp_roles->role_names,
312 ]
313 );
314
315 $repeater->end_controls_tabs();
316
317
318 $this->add_control(
319 'event_is_login_custom_user_type_list',
320 [
321 'type' => Controls_Manager::REPEATER,
322 'fields' => $repeater->get_controls(),
323 'default' => [
324 ],
325 'title_field' => '{{{ role }}}',
326 'conditions' => [
327 'terms' => [
328 [
329 'name' => 'event_is_login_custom_user_type',
330 'operator' => '==',
331 'value' => 'true',
332 ],
333 [
334 'name' => 'event_is_login_all',
335 'operator' => '==',
336 'value' => '',
337 ]
338 ],
339 ],
340 ]
341 );
342
343 }
344
345 $this->end_controls_section();
346 }
347
348 private function generate_controls_layout() {
349
350 }
351
352 private function generate_controls_styles() {
353 $items = [
354 [
355 'key'=>'btn',
356 'label'=> esc_html__('Button', 'wpdirectorykit'),
357 'options'=>'full',
358 ]
359 ];
360
361 foreach ($items as $item) {
362 $this->start_controls_section(
363 $item['key'].'_section',
364 [
365 'label' => $item['label'],
366 'tab' => 'tab_layout'
367 ]
368 );
369
370 $selectors = array(
371 'normal' => '{{WRAPPER}} .wdk-element .wdk-element-button',
372 'hover'=>'{{WRAPPER}} .wdk-element .wdk-element-button%1$s, .wdk-listings-results .hover_link:hover {{WRAPPER}} .wdk-element .wdk-element-button'
373 );
374 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
375
376 $this->end_controls_section();
377 /* END special for some elements */
378 }
379
380 $items = [
381 [
382 'key'=>'icon',
383 'label'=> esc_html__('Icon', 'wpdirectorykit'),
384 'options'=>'full',
385 ]
386 ];
387
388 foreach ($items as $item) {
389 $this->start_controls_section(
390 $item['key'].'_section',
391 [
392 'label' => $item['label'],
393 'tab' => 'tab_layout'
394 ]
395 );
396
397 $selectors = array(
398 'normal' => '{{WRAPPER}} .wdk-element .wdk-element-button i,{{WRAPPER}} .wdk-element .wdk-element-button svg',
399 'hover'=>'{{WRAPPER}} .wdk-element .wdk-element-button%1$s i,{{WRAPPER}} .wdk-element .wdk-element-button%1$s svg, .wdk-listings-results .hover_link:hover {{WRAPPER}} .wdk-element .wdk-element-button i'
400 );
401 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
402
403 $this->end_controls_section();
404 /* END special for some elements */
405 }
406 }
407
408
409 private function generate_controls_content() {
410
411 }
412
413 public function enqueue_styles_scripts() {
414 wp_enqueue_style('wdk-element-button');
415 }
416 }
417