PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.1
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / widgets / elementor / elements / next-step-widget.php

next-step-widget.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.1, at includes/core/widgets/elementor/elements/next-step-widget.php

1,199 lines 29.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Next step widget
4 *
5 * @package WPFunnels\Widgets\Elementor
6 */
7 namespace WPFunnels\Widgets\Elementor;
8
9 use Elementor\Widget_Base;
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\Group_Control_Text_Shadow;
15 use Elementor\Icons_Manager;
16 use WPFunnels\Data_Store\Wpfnl_Steps_Store_Data;
17 use WPFunnels\Wpfnl_functions;
18 use Elementor\Controls_Stack;
19 if (!defined('ABSPATH')) {
20 exit; // Exit if accessed directly
21 }
22
23 /**
24 * Funnel sell Reject button
25 *
26 * @since 1.0.0
27 */
28 class Step_Pointer extends Widget_Base
29 {
30
31
32 /**
33 * Register the widget controls.
34 *
35 * Adds different input fields to allow the user to change and Wpvrize the widget settings.
36 *
37 * @since 1.0.0
38 *
39 * @access protected
40 */
41 protected function init_controls() {
42 if ( version_compare(ELEMENTOR_VERSION, '3.1.0', '>=') ) {
43 $this->register_controls();
44 } else {
45 $this->_register_controls();
46 }
47 }
48
49
50
51 /**
52 * Retrieve the widget name.
53 *
54 * @return string Widget name.
55 * @since 1.0.0
56 *
57 * @access public
58 */
59 public function get_name()
60 {
61 return 'wpfnl-next-step';
62 }
63
64 /**
65 * Retrieve the widget title.
66 *
67 * @return string Widget title.
68 * @since 1.0.0
69 *
70 * @access public
71 */
72 public function get_title()
73 {
74 return __('Next Step Button', 'wpfnl');
75 }
76
77 /**
78 * Retrieve the widget icon.
79 *
80 * @return string Widget icon.
81 * @since 1.0.0
82 *
83 * @access public
84 */
85 public function get_icon()
86 {
87 return 'icon-wpfnl next-step';
88 }
89
90 /**
91 * Retrieve the list of categories the widget belongs to.
92 *
93 * Used to determine where to display the widget in the editor.
94 *
95 * Note that currently Elementor supports only one category.
96 * When multiple categories passed, Elementor uses the first one.
97 *
98 * @return array Widget categories.
99 * @since 1.0.0
100 *
101 * @access public
102 */
103 public function get_categories()
104 {
105 return ['wp-funnel'];
106 }
107
108
109 /**
110 * Retrieve the list of scripts the widget depended on.
111 *
112 * Used to set scripts dependencies required to run the widget.
113 *
114 * @return array Widget scripts dependencies.
115 * @since 1.0.0
116 *
117 * @access public
118 */
119 public function get_script_depends()
120 {
121 return ['next-step-widget'];
122 }
123
124 /**
125 * Get button sizes.
126 *
127 * Retrieve an array of button sizes for the button widget.
128 *
129 * @return array An array containing button sizes.
130 * @since 1.0.0
131 * @access public
132 * @static
133 */
134 public static function get_button_sizes()
135 {
136 return [
137 'xs' => __('Extra Small', 'wpfnl'),
138 'sm' => __('Small', 'wpfnl'),
139 'md' => __('Medium', 'wpfnl'),
140 'lg' => __('Large', 'wpfnl'),
141 'xl' => __('Extra Large', 'wpfnl'),
142 ];
143 }
144
145 /**
146 * Get funnel types.
147 *
148 * Retrieve an array of funnel types.
149 *
150 * @return array An array containing funnel types.
151 * @since 1.0.0
152 * @access public
153 * @static
154 */
155 public function get_funnel_types()
156 {
157 $response = array(
158 ' ' => __('Select Type', 'wpfnl'),
159 );
160 $response['checkout'] = __('Next Step', 'wpfnl');
161 $response['url-path'] = __('Go To URL Path', 'wpfnl');
162 $response['another-funnel'] = __('Another Funnel', 'wpfnl');
163
164 return $response;
165 }
166
167 /**
168 * Get user roles.
169 *
170 * Retrieve an array of WordPress user roles.
171 *
172 * @return array An array containing user roles.
173 * @since 1.0.0
174 * @access public
175 */
176 public function get_user_roles()
177 {
178 $roles = array(
179 'none' => __('None', 'wpfnl'),
180 );
181
182 if (!function_exists('get_editable_roles')) {
183 require_once ABSPATH . 'wp-admin/includes/user.php';
184 }
185
186 $wp_roles = get_editable_roles();
187
188 foreach ($wp_roles as $role_key => $role_info) {
189 $roles[$role_key] = $role_info['name'];
190 }
191
192 return $roles;
193 }
194
195 /**
196 * Get all WC products
197 *
198 * @since 1.0.0
199 *
200 * @access protected
201 */
202 protected function get_products_array()
203 {
204 $products = array();
205 if (in_array('woocommerce/woocommerce.php', WPFNL_ACTIVE_PLUGINS)) {
206 $ids = wc_get_products(array('return' => 'ids', 'limit' => -1));
207 if( !empty($ids) ){
208 foreach ($ids as $id) {
209 $title = get_the_title($id);
210 $products[$id] = $title ? $title : '';
211 }
212 }
213 }
214 return $products;
215 }
216
217 /**
218 * Get all wp pages
219 *
220 * @since 1.0.0
221 *
222 * @access protected
223 */
224 protected function get_available_pages()
225 {
226 $data = array();
227 global $wpdb;
228 if (in_array('fluentform/fluentform.php', WPFNL_ACTIVE_PLUGINS)) {
229 $sql = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}fluentform_forms");
230 $results = $wpdb->get_results($sql);
231 foreach ($results as $value) {
232 $sql = $wpdb->prepare("SELECT title FROM {$wpdb->prefix}fluentform_forms WHERE id=$value->id");
233 $title = $wpdb->get_results($sql);
234 $data[$value->id] = $title[0]->title;
235 }
236 }
237 return $data;
238 }
239
240 protected function get_available_steps()
241 {
242 $step_id = get_the_ID();
243 $funnel_id = get_post_meta($step_id, '_funnel_id', true);
244 if (!$funnel_id) {
245 return null;
246 }
247 $data = array();
248 $steps = get_post_meta($funnel_id, '_steps_order', true);
249 if($steps) {
250 foreach ($steps as $step_key => $step_value) {
251 $data[$step_value['id']] = $step_value['name'];
252 }
253 }
254
255 return $data;
256 }
257
258 public function get_prev_next_link_options()
259 {
260 $associate_funnel_id = get_post_meta(get_the_ID(), '_funnel_id', true);
261 $steps_array = [
262 'landing' => 'Landing',
263 'checkout' => 'Checkout',
264 'custom' => 'Custom',
265 'upsell' => 'Upsell',
266 'downsell' => 'Downsell',
267 'thankyou' => 'Thankyou'
268 ];
269 $option_group = [];
270 foreach ($steps_array as $key => $value) {
271 $args = [
272 'posts_per_page' => -1,
273 'orderby' => 'date',
274 'order' => 'DESC',
275 'post_type' => WPFNL_STEPS_POST_TYPE,
276 'post_status' => 'publish',
277 'post__not_in' => [$this->get_id()],
278 'meta_query' => [
279 'relation' => 'AND',
280 [
281 'key' => '_step_type',
282 'value' => $key,
283 'compare' => '=',
284 ],
285 [
286 'key' => '_funnel_id',
287 'value' => $associate_funnel_id,
288 'compare' => '=',
289 ],
290 ],
291 ];
292 $query = new \WP_Query($args);
293 $steps = $query->posts;
294 if ($steps) {
295 foreach ($steps as $s) {
296 $option_group[$key][] = [
297 'id' => $s->ID,
298 'title' => $s->post_title,
299 ];
300 }
301 }
302 }
303 return $option_group;
304 }
305
306 /**
307 * Get all funnel steps
308 *
309 * @since 1.0.0
310 *
311 * @access protected
312 */
313 protected function get_steps_array($type = 'upsell')
314 {
315 $options = $this->get_prev_next_link_options();
316 $response = array();
317 if (isset($options[$type])) {
318 $prime_data = $options[$type];
319 foreach ($prime_data as $data) {
320 $response[$data['id']] = $data['title'];
321 }
322 }
323
324 return $response;
325 }
326
327 /**
328 * Register the widget controls.
329 *
330 * @since 1.0.0
331 *
332 * @access protected
333 */
334 protected function register_controls()
335 {
336
337 $this->next_step_button_controls();
338 }
339
340 /**
341 * Register the widget controls.
342 *
343 * @since 1.0.0
344 *
345 * @access protected
346 */
347 protected function _register_controls()
348 {
349 $this->next_step_button_controls();
350
351 }
352
353 /**
354 * Next step button controls.
355 *
356 * @since 1.0.0
357 *
358 * @access protected
359 */
360 protected function next_step_button_controls(){
361 $this->start_controls_section(
362 'section_button_controller',
363 [
364 'label' => __('Next Step Button', 'wpfnl'),
365 ]
366 );
367
368 $general_data = get_option('_wpfunnels_general_settings');
369 $funnel_types = $general_data['funnel_type'];
370
371
372 $this->add_control(
373 'button_type_selector',
374 [
375 'label' => __('Select Button Type', 'wpfnl'),
376 'type' => \Elementor\Controls_Manager::SELECT,
377 'default' => 'checkout',
378 'options' => $this->get_funnel_types(),
379 ]
380 );
381
382 $this->add_control(
383 'lead_type_selector',
384 [
385 'label' => __('Lead Type', 'wpfnl'),
386 'type' => \Elementor\Controls_Manager::SELECT,
387 'default' => '',
388 'options' => [
389 'page' => __('Page', 'wpfnl'),
390 'popup' => __('Popup', 'wpfnl'),
391 ],
392 'condition' => [
393 'button_type_selector' => 'lead',
394 ]
395 ]
396 );
397
398 $this->add_control(
399 'fluent_form_next_step',
400 [
401 'label' => __('Select Next Step', 'wpfnl'),
402 'type' => \Elementor\Controls_Manager::SELECT,
403 'options' => $this->get_available_steps(),
404 'condition' => [
405 'button_type_selector' => 'lead',
406 ]
407 ]
408 );
409
410 $this->add_control(
411 'url_path_field',
412 [
413 'label' => __('URL Path', 'wpfnl'),
414 'type' => \Elementor\Controls_Manager::URL,
415 'default' => [],
416 'condition' => [
417 'button_type_selector' => 'url-path',
418 ]
419 ]
420 );
421
422 $this->add_control(
423 'another_funnel_field',
424 [
425 'label' => __('Choose funnel', 'wpfnl'),
426 'type' => \Elementor\Controls_Manager::SELECT,
427 'default' => '',
428 'options' => Wpfnl_functions::get_funnel_list(),
429 'condition' => [
430 'button_type_selector' => 'another-funnel',
431 ]
432 ]
433 );
434
435 $this->end_controls_section();
436
437 $this->start_controls_section(
438 'section_button',
439 [
440 'label' => __('Next Step Button Content', 'wpfnl'),
441 // 'condition' => [
442 // 'button_type_selector' => 'checkout',
443 // ]
444 ]
445 );
446
447 $this->add_control(
448 'text',
449 [
450 'label' => __('Text', 'wpfnl'),
451 'type' => Controls_Manager::TEXT,
452 'default' => __('Go Next', 'wpfnl'),
453 'placeholder' => __('Go Next', 'wpfnl'),
454 ]
455 );
456
457 $this->add_responsive_control(
458 'align',
459 [
460 'label' => __('Alignment', 'wpfnl'),
461 'type' => Controls_Manager::CHOOSE,
462 'options' => [
463 'left' => [
464 'title' => __('Left', 'wpfnl'),
465 'icon' => 'fa fa-align-left',
466 ],
467 'center' => [
468 'title' => __('Center', 'wpfnl'),
469 'icon' => 'fa fa-align-center',
470 ],
471 'right' => [
472 'title' => __('Right', 'wpfnl'),
473 'icon' => 'fa fa-align-right',
474 ],
475 'justify' => [
476 'title' => __('Justified', 'wpfnl'),
477 'icon' => 'fa fa-align-justify',
478 ],
479 ],
480 'prefix_class' => 'elementor%s-align-',
481 'default' => '',
482 ]
483 );
484
485 $this->add_control(
486 'size',
487 [
488 'label' => __('Size', 'wpfnl'),
489 'type' => Controls_Manager::SELECT,
490 'default' => 'sm',
491 'options' => self::get_button_sizes(),
492 ]
493 );
494
495
496 $this->add_control(
497 'next_step_button_icon',
498 [
499 'label' => __('Icon', 'wpfnl'),
500 'type' => Controls_Manager::ICONS,
501 'fa4compatibility' => 'icon',
502 ]
503 );
504
505 $this->add_control(
506 'next_step_button_icon_align',
507 [
508 'label' => __('Icon Position', 'wpfnl'),
509 'type' => Controls_Manager::SELECT,
510 'default' => 'left',
511 'options' => [
512 'left' => __('Before Text', 'wpfnl'),
513 'right' => __('After Text', 'wpfnl'),
514 ],
515 'condition' => [
516 'next_step_button_icon[value]!' => '',
517 ],
518 ]
519 );
520
521 $this->add_control(
522 'next_step_button_icon_indent',
523 [
524 'label' => __('Icon Spacing', 'wpfnl'),
525 'type' => \Elementor\Controls_Manager::SLIDER,
526 'range' => [
527 'px' => [
528 'max' => 50,
529 ],
530 ],
531 'condition' => [
532 'next_step_button_icon!' => '',
533 ],
534 'selectors' => [
535 '{{WRAPPER}} .elementor-button .elementor-align-icon-right' => 'margin-left: {{SIZE}}{{UNIT}};',
536 '{{WRAPPER}} .elementor-button .elementor-align-icon-left' => 'margin-right: {{SIZE}}{{UNIT}};',
537 ],
538 ]
539 );
540
541
542 $this->add_control(
543 'view',
544 [
545 'label' => __('View', 'wpfnl'),
546 'type' => Controls_Manager::HIDDEN,
547 'default' => 'traditional',
548 ]
549 );
550
551 // Subtitle Settings
552 $this->add_control(
553 'enable_subtitle',
554 [
555 'label' => __('Enable Subtitle', 'wpfnl'),
556 'type' => Controls_Manager::SWITCHER,
557 'label_on' => __('Yes', 'wpfnl'),
558 'label_off' => __('No', 'wpfnl'),
559 'return_value' => 'yes',
560 'default' => 'no',
561 'separator' => 'before',
562 ]
563 );
564
565 $this->add_control(
566 'subtitle_text',
567 [
568 'label' => __('Subtitle Text', 'wpfnl'),
569 'type' => Controls_Manager::TEXT,
570 'default' => __('Click to continue', 'wpfnl'),
571 'placeholder' => __('Enter subtitle text', 'wpfnl'),
572 'condition' => [
573 'enable_subtitle' => 'yes',
574 ],
575 ]
576 );
577
578 $this->end_controls_section();
579
580 // Display Conditions Section
581 $this->start_controls_section(
582 'section_display_conditions',
583 [
584 'label' => __('Display Conditions', 'wpfnl'),
585 ]
586 );
587
588 $this->add_control(
589 'display_condition_type',
590 [
591 'label' => __('Display Condition', 'wpfnl'),
592 'type' => Controls_Manager::SELECT,
593 'default' => 'none',
594 'options' => [
595 'none' => __('None', 'wpfnl'),
596 'user_state' => __('User State', 'wpfnl'),
597 'user_role' => __('User Role', 'wpfnl'),
598 'browser' => __('Browser', 'wpfnl'),
599 'operating_system' => __('Operating System', 'wpfnl'),
600 'day' => __('Day', 'wpfnl'),
601 ],
602 ]
603 );
604
605 // User State Conditions
606 $this->add_control(
607 'hide_from_logged_in',
608 [
609 'label' => __('Hide From Logged In User', 'wpfnl'),
610 'type' => Controls_Manager::SWITCHER,
611 'label_on' => __('Yes', 'wpfnl'),
612 'label_off' => __('No', 'wpfnl'),
613 'return_value' => 'yes',
614 'default' => 'no',
615 'condition' => [
616 'display_condition_type' => 'user_state',
617 ],
618 ]
619 );
620
621 $this->add_control(
622 'hide_from_logged_out',
623 [
624 'label' => __('Hide From Logged Out User', 'wpfnl'),
625 'type' => Controls_Manager::SWITCHER,
626 'label_on' => __('Yes', 'wpfnl'),
627 'label_off' => __('No', 'wpfnl'),
628 'return_value' => 'yes',
629 'default' => 'no',
630 'condition' => [
631 'display_condition_type' => 'user_state',
632 ],
633 ]
634 );
635
636 // User Role Condition
637 $this->add_control(
638 'hide_for_user_role',
639 [
640 'label' => __('Hide For User Role', 'wpfnl'),
641 'type' => Controls_Manager::SELECT,
642 'default' => 'none',
643 'options' => $this->get_user_roles(),
644 'condition' => [
645 'display_condition_type' => 'user_role',
646 ],
647 ]
648 );
649
650 // Browser Condition
651 $this->add_control(
652 'hide_on_browser',
653 [
654 'label' => __('Hide On Browser', 'wpfnl'),
655 'type' => Controls_Manager::SELECT,
656 'default' => 'none',
657 'options' => [
658 'none' => __('None', 'wpfnl'),
659 'mozilla' => __('Mozilla Firefox', 'wpfnl'),
660 'chrome' => __('Google Chrome', 'wpfnl'),
661 'opera_mini' => __('Opera Mini', 'wpfnl'),
662 'safari' => __('Safari', 'wpfnl'),
663 'edge' => __('Microsoft Edge', 'wpfnl'),
664 ],
665 'condition' => [
666 'display_condition_type' => 'browser',
667 ],
668 ]
669 );
670
671 // Operating System Condition
672 $this->add_control(
673 'hide_on_os',
674 [
675 'label' => __('Hide On Operating System', 'wpfnl'),
676 'type' => Controls_Manager::SELECT,
677 'default' => 'none',
678 'options' => [
679 'none' => __('None', 'wpfnl'),
680 'ios' => __('iOS', 'wpfnl'),
681 'android' => __('Android', 'wpfnl'),
682 'windows' => __('Windows', 'wpfnl'),
683 'macos' => __('MacOS', 'wpfnl'),
684 'linux' => __('Linux', 'wpfnl'),
685 'sunos' => __('SunOS', 'wpfnl'),
686 'openbsd' => __('OpenBSD', 'wpfnl'),
687 ],
688 'condition' => [
689 'display_condition_type' => 'operating_system',
690 ],
691 ]
692 );
693
694 // Day Condition
695 $this->add_control(
696 'disable_on_days',
697 [
698 'label' => __('Select Days You Want To Disable', 'wpfnl'),
699 'type' => Controls_Manager::SELECT2,
700 'multiple' => true,
701 'options' => [
702 'monday' => __('Monday', 'wpfnl'),
703 'tuesday' => __('Tuesday', 'wpfnl'),
704 'wednesday' => __('Wednesday', 'wpfnl'),
705 'thursday' => __('Thursday', 'wpfnl'),
706 'friday' => __('Friday', 'wpfnl'),
707 'saturday' => __('Saturday', 'wpfnl'),
708 'sunday' => __('Sunday', 'wpfnl'),
709 ],
710 'condition' => [
711 'display_condition_type' => 'day',
712 ],
713 ]
714 );
715
716 $this->end_controls_section();
717
718 $this->start_controls_section(
719 'section_style',
720 [
721 'label' => __('Button', 'wpfnl'),
722 'tab' => Controls_Manager::TAB_STYLE,
723 ]
724 );
725
726 $this->add_group_control(
727 Group_Control_Typography::get_type(),
728 [
729 'name' => 'next_step_button_typography',
730 'label' => 'Typography',
731 'selector' => '{{WRAPPER}} a.elementor-button',
732 ]
733 );
734
735 $this->add_group_control(
736 Group_Control_Text_Shadow::get_type(),
737 [
738 'name' => 'next_step_button_text_shadow',
739 'selector' => '{{WRAPPER}} a.elementor-button',
740 ]
741 );
742
743 $this->start_controls_tabs('tabs_button_style');
744
745 $this->start_controls_tab(
746 'tab_button_normal',
747 [
748 'label' => __('Normal', 'wpfnl'),
749 ]
750 );
751
752 $this->add_control(
753 'button_text_color',
754 [
755 'label' => __('Text Color', 'wpfnl'),
756 'type' => Controls_Manager::COLOR,
757 'default' => '',
758 'selectors' => [
759 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'color: {{VALUE}};',
760 ],
761 ]
762 );
763
764 $this->add_control(
765 'background_color',
766 [
767 'label' => __('Background Color', 'wpfnl'),
768 'type' => Controls_Manager::COLOR,
769 'selectors' => [
770 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'background-color: {{VALUE}};',
771 ],
772 'default' => '#61CE70',
773 ]
774 );
775
776 $this->end_controls_tab();
777
778 $this->start_controls_tab(
779 'tab_button_hover',
780 [
781 'label' => __('Hover', 'wpfnl'),
782 ]
783 );
784
785 $this->add_control(
786 'hover_color',
787 [
788 'label' => __('Text Color', 'wpfnl'),
789 'type' => Controls_Manager::COLOR,
790 'selectors' => [
791 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'color: {{VALUE}};',
792 ],
793 ]
794 );
795
796 $this->add_control(
797 'button_background_hover_color',
798 [
799 'label' => __('Background Color', 'wpfnl'),
800 'type' => Controls_Manager::COLOR,
801 'selectors' => [
802 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'background-color: {{VALUE}};',
803 ],
804 ]
805 );
806
807 $this->add_control(
808 'button_hover_border_color',
809 [
810 'label' => __('Border Color', 'wpfnl'),
811 'type' => Controls_Manager::COLOR,
812 'condition' => [
813 'border_border!' => '',
814 ],
815 'selectors' => [
816 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};',
817 ],
818 ]
819 );
820
821 $this->add_control(
822 'hover_animation',
823 [
824 'label' => __('Animation', 'wpfnl'),
825 'type' => Controls_Manager::HOVER_ANIMATION,
826 ]
827 );
828
829 $this->end_controls_tab();
830
831 $this->end_controls_tabs();
832
833 $this->add_group_control(
834 Group_Control_Border::get_type(),
835 [
836 'name' => 'border',
837 'label' => __('Border', 'wpfnl'),
838 'placeholder' => '1px',
839 'default' => '1px',
840 'selector' => '{{WRAPPER}} .elementor-button',
841 'separator' => 'before',
842 ]
843 );
844
845 $this->add_responsive_control(
846 'border_radius',
847 [
848 'label' => __('Border Radius', 'wpfnl'),
849 'type' => Controls_Manager::DIMENSIONS,
850 'size_units' => ['px', '%'],
851 'selectors' => [
852 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
853 ],
854 ]
855 );
856
857
858 $this->add_group_control(
859 Group_Control_Box_Shadow::get_type(),
860 [
861 'name' => 'button_box_shadow',
862 'selector' => '{{WRAPPER}} .elementor-button',
863 ]
864 );
865
866 $this->add_responsive_control(
867 'text_padding',
868 [
869 'label' => __('Padding', 'wpfnl'),
870 'type' => Controls_Manager::DIMENSIONS,
871 'size_units' => ['px', 'em', '%'],
872 'selectors' => [
873 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
874 ],
875 'separator' => 'before',
876 ]
877 );
878
879
880 $this->end_controls_section();
881
882 // Subtitle Style Section
883 $this->start_controls_section(
884 'section_subtitle_style',
885 [
886 'label' => __('Subtitle', 'wpfnl'),
887 'tab' => Controls_Manager::TAB_STYLE,
888 'condition' => [
889 'enable_subtitle' => 'yes',
890 ],
891 ]
892 );
893
894 $this->add_group_control(
895 Group_Control_Typography::get_type(),
896 [
897 'name' => 'subtitle_typography',
898 'label' => __('Typography', 'wpfnl'),
899 'selector' => '{{WRAPPER}} .wpfnl-button-subtitle',
900 ]
901 );
902
903 $this->add_responsive_control(
904 'subtitle_spacing',
905 [
906 'label' => __('Spacing', 'wpfnl'),
907 'type' => Controls_Manager::SLIDER,
908 'range' => [
909 'px' => [
910 'min' => 0,
911 'max' => 50,
912 ],
913 ],
914 'selectors' => [
915 '{{WRAPPER}} .wpfnl-button-subtitle' => 'margin-top: {{SIZE}}{{UNIT}};',
916 ],
917 ]
918 );
919
920 $this->end_controls_section();
921 }
922
923
924 /**
925 * Render the widget output on the frontend.
926 *
927 * Written in PHP and used to generate the final HTML.
928 *
929 * @since 1.0.0
930 *
931 * @access protected
932 */
933 protected function render()
934 {
935 $settings = $this->get_settings();
936 $this->add_render_attribute('wrapper', 'class', 'elementor-button-wrapper');
937 $this->add_render_attribute('button', 'class', 'elementor-button');
938 $products = '';
939
940
941 // Get subtitle settings
942 $enable_subtitle = isset($settings['enable_subtitle']) ? $settings['enable_subtitle'] : 'no';
943 $subtitle_text = isset($settings['subtitle_text']) ? $settings['subtitle_text'] : '';
944
945 if (!empty($settings['size'])) {
946 $this->add_render_attribute('button', 'class', 'elementor-size-' . $settings['size']);
947 }
948
949 if (isset($enable_subtitle) && $enable_subtitle === 'yes' && !empty($enable_subtitle)) {
950 $this->add_render_attribute('button', 'class', 'wpfnl-has-subtitle');
951 }
952
953 if (isset($settings['hover_animation']) && $settings['hover_animation']) {
954 $this->add_render_attribute('button', 'class', 'elementor-animation-' . $settings['hover_animation']);
955 }
956
957 if (isset($settings['button_type_selector']) && $settings['button_type_selector'] !== 'lead') {
958
959 // $products = implode(",", $settings['checkout_product_selector']);
960 $products_array = get_post_meta(get_the_ID(), 'checkout_product_selector', true);
961 if ($products_array) {
962 $products = implode(",", $products_array);
963 }
964
965 if( 'url-path' === $settings['button_type_selector'] ){
966 $url = isset($settings['url_path_field']['url']) ? $settings['url_path_field']['url'] : '';
967 }elseif( 'another-funnel' === $settings['button_type_selector'] ){
968 $url = $settings['another_funnel_field'];
969 }else{
970 $url = '';
971 }
972
973
974 // Prepare data attributes for client-side display conditions
975 $hide_on_browser = isset($settings['hide_on_browser']) ? esc_attr($settings['hide_on_browser']) : 'none';
976 $hide_on_os = isset($settings['hide_on_os']) ? esc_attr($settings['hide_on_os']) : 'none';
977
978 // Get display condition settings
979 $display_condition = isset($settings['display_condition_type']) ? $settings['display_condition_type'] : 'none';
980
981 // Check display conditions and return early if button should be hidden
982 if ($display_condition === 'user_state') {
983 $hide_logged_in = isset($settings['hide_from_logged_in']) ? $settings['hide_from_logged_in'] : 'no';
984 $hide_logged_out = isset($settings['hide_from_logged_out']) ? $settings['hide_from_logged_out'] : 'no';
985
986 // Hide from logged in users
987 if ($hide_logged_in === 'yes' && is_user_logged_in()) {
988 return;
989 }
990
991 // Hide from logged out users
992 if ($hide_logged_out === 'yes' && !is_user_logged_in()) {
993 return;
994 }
995
996 } elseif ($display_condition === 'user_role') {
997 $hide_for_user_role = isset($settings['hide_for_user_role']) ? $settings['hide_for_user_role'] : 'none';
998
999 if ($hide_for_user_role !== 'none' && is_user_logged_in()) {
1000 $user = wp_get_current_user();
1001 if (in_array($hide_for_user_role, $user->roles)) {
1002 return;
1003 }
1004 }
1005
1006 } elseif ($display_condition === 'day') {
1007 $disable_on_days = isset($settings['disable_on_days']) ? $settings['disable_on_days'] : array();
1008
1009 if (!empty($disable_on_days) && is_array($disable_on_days)) {
1010 $current_day = strtolower(date('l')); // e.g., 'monday'
1011 if (in_array($current_day, $disable_on_days)) {
1012 return;
1013 }
1014 }
1015
1016 } elseif ($display_condition === 'browser') {
1017 $hide_on_browser = isset($settings['hide_on_browser']) ? $settings['hide_on_browser'] : 'none';
1018
1019 if ($hide_on_browser !== 'none') {
1020 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
1021 $current_browser = '';
1022
1023 // Detect browser from user agent
1024 if (strpos($user_agent, 'edg') !== false) {
1025 $current_browser = 'edge';
1026 } elseif (strpos($user_agent, 'opr') !== false || strpos($user_agent, 'opera') !== false) {
1027 $current_browser = 'opera_mini';
1028 } elseif (strpos($user_agent, 'chrome') !== false) {
1029 $current_browser = 'chrome';
1030 } elseif (strpos($user_agent, 'safari') !== false) {
1031 $current_browser = 'safari';
1032 } elseif (strpos($user_agent, 'firefox') !== false) {
1033 $current_browser = 'mozilla';
1034 }
1035
1036 // Hide button if current browser matches
1037 if ($current_browser === $hide_on_browser) {
1038 return;
1039 }
1040 }
1041 } elseif ($display_condition === 'operating_system') {
1042 $hide_on_os = isset($settings['hide_on_os']) ? $settings['hide_on_os'] : 'none';
1043
1044 if ($hide_on_os !== 'none') {
1045 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
1046 $current_os = '';
1047
1048 // Detect operating system from user agent
1049 if (strpos($user_agent, 'windows') !== false || strpos($user_agent, 'win32') !== false || strpos($user_agent, 'win64') !== false) {
1050 $current_os = 'windows';
1051 } elseif (strpos($user_agent, 'macintosh') !== false || strpos($user_agent, 'mac os x') !== false) {
1052 $current_os = 'macos';
1053 } elseif (strpos($user_agent, 'linux') !== false && strpos($user_agent, 'android') === false) {
1054 $current_os = 'linux';
1055 } elseif (strpos($user_agent, 'android') !== false) {
1056 $current_os = 'android';
1057 } elseif (strpos($user_agent, 'iphone') !== false || strpos($user_agent, 'ipad') !== false || strpos($user_agent, 'ipod') !== false) {
1058 $current_os = 'ios';
1059 } elseif (strpos($user_agent, 'sunos') !== false) {
1060 $current_os = 'sunos';
1061 } elseif (strpos($user_agent, 'openbsd') !== false) {
1062 $current_os = 'openbsd';
1063 }
1064
1065 // Hide button if current OS matches
1066 if ($current_os === $hide_on_os) {
1067 return;
1068 }
1069 }
1070 }
1071 // -----end display conditioning----
1072
1073 ?>
1074 <div <?php echo $this->get_render_attribute_string('wrapper'); ?>>
1075 <a href="#"
1076 data-button-type="<?php echo $settings['button_type_selector']; ?>"
1077 data-url="<?php echo $url; ?>"
1078 data-id="<?php echo get_the_ID(); ?>"
1079 data-products="<?php echo $products; ?>"
1080 id="wpfunnels_next_step_controller"
1081 style="cursor: pointer;"
1082 <?php echo $this->get_render_attribute_string('button'); ?>
1083 >
1084
1085 <?php if (isset($enable_subtitle) && $enable_subtitle === 'yes' && !empty($subtitle_text)) { ?>
1086 <span class="text-inner-wrapper" style="display: flex; align-items: center; gap: 3px;">
1087 <?php $this->render_text(); ?>
1088 <span class="wpfnl-loader"></span>
1089 </span>
1090
1091 <small class="wpfnl-button-subtitle">
1092 <?php echo esc_html($subtitle_text); ?>
1093 </small>
1094 <?php } else { ?>
1095 <?php $this->render_text(); ?>
1096 <span class="wpfnl-loader"></span>
1097 <?php } ?>
1098 </a>
1099 </div>
1100 <span class="wpfnl-alert" id="wpfnl-next-button-loader"></span>
1101
1102 <?php
1103 } elseif (isset($settings['button_type_selector']) && $settings['button_type_selector'] == 'lead') {
1104 if (!in_array('fluentform/fluentform.php', WPFNL_ACTIVE_PLUGINS)) {
1105 echo '<p style="color: red;">Please activate Fluent Forms</p>';
1106 }
1107 $form = $settings['lead_type_page_selector'];
1108 if (isset($settings['lead_type_selector']) && $settings['lead_type_selector'] == 'page') {
1109 echo do_shortcode('[fluentform id="' . $form . '"]');
1110 } elseif (isset($settings['lead_type_selector']) && $settings['lead_type_selector'] == 'popup') {
1111 echo do_shortcode('[fluentform_modal form_id="' . $form . '" ]');
1112 //echo '<a href="#" id="modal-id">show modal</a>';
1113 }
1114 }
1115
1116 }
1117
1118
1119 /**
1120 * Render button text.
1121 *
1122 * Render button widget text.
1123 *
1124 * @since 1.5.0
1125 * @access protected
1126 */
1127 protected function render_text()
1128 {
1129 $settings = $this->get_settings();
1130 $migrated = isset($settings['__fa4_migrated']['next_step_button_icon']);
1131 $is_new = empty($settings['icon']) && Icons_Manager::is_migration_allowed();
1132
1133 if (!$is_new && empty($settings['next_step_button_icon_align'])) {
1134
1135 $settings['next_step_button_icon_align'] = $this->get_settings('next_step_button_icon_align');
1136 }
1137
1138 $this->add_render_attribute([
1139 'content-wrapper' => [
1140 'class' => 'elementor-button-content-wrapper',
1141 ],
1142 'icon-align' => [
1143 'class' => [
1144 'elementor-button-icon',
1145 'elementor-align-icon-' . $settings['next_step_button_icon_align'],
1146 ],
1147 ],
1148 'text' => [
1149 'class' => 'elementor-button-text',
1150 ],
1151 ]);
1152
1153 $this->add_render_attribute('content-wrapper', 'class', 'elementor-button-content-wrapper');
1154 $this->add_render_attribute('text', 'class', 'elementor-button-text');
1155
1156 $this->add_inline_editing_attributes('text', 'none');
1157 ?>
1158 <span <?php echo $this->get_render_attribute_string('content-wrapper'); ?> style="<?php echo $settings['next_step_button_icon_align'] === 'right' ? 'flex-direction: row-reverse' : '' ?>">
1159
1160 <?php if (!empty($settings['icon']) || !empty($settings['next_step_button_icon']['value'])) : ?>
1161 <span <?php echo $this->get_render_attribute_string('icon-align'); ?>>
1162 <?php if ($is_new || $migrated) :
1163 Icons_Manager::render_icon($settings['next_step_button_icon'], ['aria-hidden' => 'true']);
1164 else : ?>
1165 <i class="<?php echo esc_attr($settings['icon']); ?>" aria-hidden="true"></i>
1166 <?php endif; ?>
1167 </span>
1168 <?php endif; ?>
1169
1170 <span <?php echo $this->get_render_attribute_string('text'); ?>>
1171 <?php echo $settings['text']; ?>
1172 </span>
1173 </span>
1174 <?php
1175 }
1176
1177
1178 /**
1179 * Fnd next step url
1180 *
1181 * @since 1.5.0
1182 * @access protected
1183 */
1184 public function get_next_step_url()
1185 {
1186 $id = get_the_ID();
1187 $funnel_id = get_post_meta($id, '_funnel_id', true);
1188 $steps_order = get_post_meta($funnel_id, '_steps_order', true);
1189 $step_object = new Wpfnl_Steps_Store_Data();
1190 $next_step_id = $step_object->get_next_step($steps_order, $funnel_id);
1191 if ($next_step_id) {
1192 $next_step_url = get_post_permalink($next_step_id);
1193 } else {
1194 $next_step_url = '#';
1195 }
1196 return $next_step_url;
1197 }
1198 }
1199