PluginProbe
WP Directory Kit / 1.1.6
WP Directory Kit v1.1.6
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.1.6, at elementor-elements/classes/wdk-button.php

404 lines 11.8 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' => __('Secial 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 $this->end_controls_section();
229
230 $this->start_controls_section(
231 'tab_conf_main_section_event',
232 [
233 'label' => esc_html__('Events When Visible Button', 'wpdirectorykit'),
234 'tab' => '1',
235 ]
236 );
237
238 $this->add_control(
239 'event_is_not_login',
240 [
241 'label' => __( 'Visible if Not Login', 'wpdirectorykit' ),
242 'type' => \Elementor\Controls_Manager::SWITCHER,
243 'label_on' => __( 'On', 'wpdirectorykit' ),
244 'label_off' => __( 'Off', 'wpdirectorykit' ),
245 'return_value' => 'true',
246 'default' => 'true',
247 ]
248 );
249
250 $this->add_control(
251 'event_is_login_all',
252 [
253 'label' => __( 'Visible if Login All Users', 'wpdirectorykit' ),
254 'type' => \Elementor\Controls_Manager::SWITCHER,
255 'description' => __( 'Disable for set by user type', 'wpdirectorykit' ),
256 'label_on' => __( 'On', 'wpdirectorykit' ),
257 'label_off' => __( 'Off', 'wpdirectorykit' ),
258 'return_value' => 'true',
259 'default' => 'true',
260
261 ]
262 );
263
264 $this->add_control(
265 'event_is_login_custom_user_type',
266 [
267 'label' => __( 'Visible if Login By Custom user type', 'wpdirectorykit' ),
268 'type' => \Elementor\Controls_Manager::SWITCHER,
269 'label_on' => __( 'On', 'wpdirectorykit' ),
270 'label_off' => __( 'Off', 'wpdirectorykit' ),
271 'return_value' => 'true',
272 'default' => '',
273 'conditions' => [
274 'terms' => [
275 [
276 'name' => 'event_is_login_all',
277 'operator' => '==',
278 'value' => '',
279 ]
280 ],
281 ],
282 ]
283 );
284
285 global $wp_roles;
286 if ( ! isset( $wp_roles ) ) {
287 $wp_roles = new \WP_Roles();
288 }
289
290 if(true){
291 $repeater = new Repeater();
292 $repeater->start_controls_tabs( 'user_roles' );
293 $repeater->add_control(
294 'role',
295 [
296 'label' => esc_html__('icon Position', 'wpdirectorykit'),
297 'type' => Controls_Manager::SELECT,
298 'options' => $wp_roles->role_names,
299 ]
300 );
301
302 $repeater->end_controls_tabs();
303
304
305 $this->add_control(
306 'event_is_login_custom_user_type_list',
307 [
308 'type' => Controls_Manager::REPEATER,
309 'fields' => $repeater->get_controls(),
310 'default' => [
311 ],
312 'title_field' => '{{{ role }}}',
313 'conditions' => [
314 'terms' => [
315 [
316 'name' => 'event_is_login_custom_user_type',
317 'operator' => '==',
318 'value' => 'true',
319 ],
320 [
321 'name' => 'event_is_login_all',
322 'operator' => '==',
323 'value' => '',
324 ]
325 ],
326 ],
327 ]
328 );
329
330 }
331
332 $this->end_controls_section();
333 }
334
335 private function generate_controls_layout() {
336
337 }
338
339 private function generate_controls_styles() {
340 $items = [
341 [
342 'key'=>'btn',
343 'label'=> esc_html__('Button', 'wpdirectorykit'),
344 'options'=>'full',
345 ]
346 ];
347
348 foreach ($items as $item) {
349 $this->start_controls_section(
350 $item['key'].'_section',
351 [
352 'label' => $item['label'],
353 'tab' => 'tab_layout'
354 ]
355 );
356
357 $selectors = array(
358 'normal' => '{{WRAPPER}} .wdk-element .wdk-element-button',
359 'hover'=>'{{WRAPPER}} .wdk-element .wdk-element-button%1$s'
360 );
361 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
362
363 $this->end_controls_section();
364 /* END special for some elements */
365 }
366
367 $items = [
368 [
369 'key'=>'icon',
370 'label'=> esc_html__('Icon', 'wpdirectorykit'),
371 'options'=>'full',
372 ]
373 ];
374
375 foreach ($items as $item) {
376 $this->start_controls_section(
377 $item['key'].'_section',
378 [
379 'label' => $item['label'],
380 'tab' => 'tab_layout'
381 ]
382 );
383
384 $selectors = array(
385 'normal' => '{{WRAPPER}} .wdk-element .wdk-element-button i,{{WRAPPER}} .wdk-element .wdk-element-button svg',
386 'hover'=>'{{WRAPPER}} .wdk-element .wdk-element-button%1$s i,{{WRAPPER}} .wdk-element .wdk-element-button%1$s svg'
387 );
388 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
389
390 $this->end_controls_section();
391 /* END special for some elements */
392 }
393 }
394
395
396 private function generate_controls_content() {
397
398 }
399
400 public function enqueue_styles_scripts() {
401 wp_enqueue_style('wdk-element-button');
402 }
403 }
404