PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.1
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 2.8.17 2.8.18 All 259 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.13.1, at includes/core/widgets/elementor/elements/next-step-widget.php

1,195 lines 29.5 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 $this->add_control(
369 'button_type_selector',
370 [
371 'label' => __('Select Button Type', 'wpfnl'),
372 'type' => \Elementor\Controls_Manager::SELECT,
373 'default' => 'checkout',
374 'options' => $this->get_funnel_types(),
375 ]
376 );
377
378 $this->add_control(
379 'lead_type_selector',
380 [
381 'label' => __('Lead Type', 'wpfnl'),
382 'type' => \Elementor\Controls_Manager::SELECT,
383 'default' => '',
384 'options' => [
385 'page' => __('Page', 'wpfnl'),
386 'popup' => __('Popup', 'wpfnl'),
387 ],
388 'condition' => [
389 'button_type_selector' => 'lead',
390 ]
391 ]
392 );
393
394 $this->add_control(
395 'fluent_form_next_step',
396 [
397 'label' => __('Select Next Step', 'wpfnl'),
398 'type' => \Elementor\Controls_Manager::SELECT,
399 'options' => $this->get_available_steps(),
400 'condition' => [
401 'button_type_selector' => 'lead',
402 ]
403 ]
404 );
405
406 $this->add_control(
407 'url_path_field',
408 [
409 'label' => __('URL Path', 'wpfnl'),
410 'type' => \Elementor\Controls_Manager::URL,
411 'default' => [],
412 'condition' => [
413 'button_type_selector' => 'url-path',
414 ]
415 ]
416 );
417
418 $this->add_control(
419 'another_funnel_field',
420 [
421 'label' => __('Choose funnel', 'wpfnl'),
422 'type' => \Elementor\Controls_Manager::SELECT,
423 'default' => '',
424 'options' => Wpfnl_functions::get_funnel_list(),
425 'condition' => [
426 'button_type_selector' => 'another-funnel',
427 ]
428 ]
429 );
430
431 $this->end_controls_section();
432
433 $this->start_controls_section(
434 'section_button',
435 [
436 'label' => __('Next Step Button Content', 'wpfnl'),
437 // 'condition' => [
438 // 'button_type_selector' => 'checkout',
439 // ]
440 ]
441 );
442
443 $this->add_control(
444 'text',
445 [
446 'label' => __('Text', 'wpfnl'),
447 'type' => Controls_Manager::TEXT,
448 'default' => __('Go Next', 'wpfnl'),
449 'placeholder' => __('Go Next', 'wpfnl'),
450 ]
451 );
452
453 $this->add_responsive_control(
454 'align',
455 [
456 'label' => __('Alignment', 'wpfnl'),
457 'type' => Controls_Manager::CHOOSE,
458 'options' => [
459 'left' => [
460 'title' => __('Left', 'wpfnl'),
461 'icon' => 'fa fa-align-left',
462 ],
463 'center' => [
464 'title' => __('Center', 'wpfnl'),
465 'icon' => 'fa fa-align-center',
466 ],
467 'right' => [
468 'title' => __('Right', 'wpfnl'),
469 'icon' => 'fa fa-align-right',
470 ],
471 'justify' => [
472 'title' => __('Justified', 'wpfnl'),
473 'icon' => 'fa fa-align-justify',
474 ],
475 ],
476 'prefix_class' => 'elementor%s-align-',
477 'default' => '',
478 ]
479 );
480
481 $this->add_control(
482 'size',
483 [
484 'label' => __('Size', 'wpfnl'),
485 'type' => Controls_Manager::SELECT,
486 'default' => 'sm',
487 'options' => self::get_button_sizes(),
488 ]
489 );
490
491
492 $this->add_control(
493 'next_step_button_icon',
494 [
495 'label' => __('Icon', 'wpfnl'),
496 'type' => Controls_Manager::ICONS,
497 'fa4compatibility' => 'icon',
498 ]
499 );
500
501 $this->add_control(
502 'next_step_button_icon_align',
503 [
504 'label' => __('Icon Position', 'wpfnl'),
505 'type' => Controls_Manager::SELECT,
506 'default' => 'left',
507 'options' => [
508 'left' => __('Before Text', 'wpfnl'),
509 'right' => __('After Text', 'wpfnl'),
510 ],
511 'condition' => [
512 'next_step_button_icon[value]!' => '',
513 ],
514 ]
515 );
516
517 $this->add_control(
518 'next_step_button_icon_indent',
519 [
520 'label' => __('Icon Spacing', 'wpfnl'),
521 'type' => \Elementor\Controls_Manager::SLIDER,
522 'range' => [
523 'px' => [
524 'max' => 50,
525 ],
526 ],
527 'condition' => [
528 'next_step_button_icon!' => '',
529 ],
530 'selectors' => [
531 '{{WRAPPER}} .elementor-button .elementor-align-icon-right' => 'margin-left: {{SIZE}}{{UNIT}};',
532 '{{WRAPPER}} .elementor-button .elementor-align-icon-left' => 'margin-right: {{SIZE}}{{UNIT}};',
533 ],
534 ]
535 );
536
537
538 $this->add_control(
539 'view',
540 [
541 'label' => __('View', 'wpfnl'),
542 'type' => Controls_Manager::HIDDEN,
543 'default' => 'traditional',
544 ]
545 );
546
547 // Subtitle Settings
548 $this->add_control(
549 'enable_subtitle',
550 [
551 'label' => __('Enable Subtitle', 'wpfnl'),
552 'type' => Controls_Manager::SWITCHER,
553 'label_on' => __('Yes', 'wpfnl'),
554 'label_off' => __('No', 'wpfnl'),
555 'return_value' => 'yes',
556 'default' => 'no',
557 'separator' => 'before',
558 ]
559 );
560
561 $this->add_control(
562 'subtitle_text',
563 [
564 'label' => __('Subtitle Text', 'wpfnl'),
565 'type' => Controls_Manager::TEXT,
566 'default' => __('Click to continue', 'wpfnl'),
567 'placeholder' => __('Enter subtitle text', 'wpfnl'),
568 'condition' => [
569 'enable_subtitle' => 'yes',
570 ],
571 ]
572 );
573
574 $this->end_controls_section();
575
576 // Display Conditions Section
577 $this->start_controls_section(
578 'section_display_conditions',
579 [
580 'label' => __('Display Conditions', 'wpfnl'),
581 ]
582 );
583
584 $this->add_control(
585 'display_condition_type',
586 [
587 'label' => __('Display Condition', 'wpfnl'),
588 'type' => Controls_Manager::SELECT,
589 'default' => 'none',
590 'options' => [
591 'none' => __('None', 'wpfnl'),
592 'user_state' => __('User State', 'wpfnl'),
593 'user_role' => __('User Role', 'wpfnl'),
594 'browser' => __('Browser', 'wpfnl'),
595 'operating_system' => __('Operating System', 'wpfnl'),
596 'day' => __('Day', 'wpfnl'),
597 ],
598 ]
599 );
600
601 // User State Conditions
602 $this->add_control(
603 'hide_from_logged_in',
604 [
605 'label' => __('Hide From Logged In User', 'wpfnl'),
606 'type' => Controls_Manager::SWITCHER,
607 'label_on' => __('Yes', 'wpfnl'),
608 'label_off' => __('No', 'wpfnl'),
609 'return_value' => 'yes',
610 'default' => 'no',
611 'condition' => [
612 'display_condition_type' => 'user_state',
613 ],
614 ]
615 );
616
617 $this->add_control(
618 'hide_from_logged_out',
619 [
620 'label' => __('Hide From Logged Out User', 'wpfnl'),
621 'type' => Controls_Manager::SWITCHER,
622 'label_on' => __('Yes', 'wpfnl'),
623 'label_off' => __('No', 'wpfnl'),
624 'return_value' => 'yes',
625 'default' => 'no',
626 'condition' => [
627 'display_condition_type' => 'user_state',
628 ],
629 ]
630 );
631
632 // User Role Condition
633 $this->add_control(
634 'hide_for_user_role',
635 [
636 'label' => __('Hide For User Role', 'wpfnl'),
637 'type' => Controls_Manager::SELECT,
638 'default' => 'none',
639 'options' => $this->get_user_roles(),
640 'condition' => [
641 'display_condition_type' => 'user_role',
642 ],
643 ]
644 );
645
646 // Browser Condition
647 $this->add_control(
648 'hide_on_browser',
649 [
650 'label' => __('Hide On Browser', 'wpfnl'),
651 'type' => Controls_Manager::SELECT,
652 'default' => 'none',
653 'options' => [
654 'none' => __('None', 'wpfnl'),
655 'mozilla' => __('Mozilla Firefox', 'wpfnl'),
656 'chrome' => __('Google Chrome', 'wpfnl'),
657 'opera_mini' => __('Opera Mini', 'wpfnl'),
658 'safari' => __('Safari', 'wpfnl'),
659 'edge' => __('Microsoft Edge', 'wpfnl'),
660 ],
661 'condition' => [
662 'display_condition_type' => 'browser',
663 ],
664 ]
665 );
666
667 // Operating System Condition
668 $this->add_control(
669 'hide_on_os',
670 [
671 'label' => __('Hide On Operating System', 'wpfnl'),
672 'type' => Controls_Manager::SELECT,
673 'default' => 'none',
674 'options' => [
675 'none' => __('None', 'wpfnl'),
676 'ios' => __('iOS', 'wpfnl'),
677 'android' => __('Android', 'wpfnl'),
678 'windows' => __('Windows', 'wpfnl'),
679 'macos' => __('MacOS', 'wpfnl'),
680 'linux' => __('Linux', 'wpfnl'),
681 'sunos' => __('SunOS', 'wpfnl'),
682 'openbsd' => __('OpenBSD', 'wpfnl'),
683 ],
684 'condition' => [
685 'display_condition_type' => 'operating_system',
686 ],
687 ]
688 );
689
690 // Day Condition
691 $this->add_control(
692 'disable_on_days',
693 [
694 'label' => __('Select Days You Want To Disable', 'wpfnl'),
695 'type' => Controls_Manager::SELECT2,
696 'multiple' => true,
697 'options' => [
698 'monday' => __('Monday', 'wpfnl'),
699 'tuesday' => __('Tuesday', 'wpfnl'),
700 'wednesday' => __('Wednesday', 'wpfnl'),
701 'thursday' => __('Thursday', 'wpfnl'),
702 'friday' => __('Friday', 'wpfnl'),
703 'saturday' => __('Saturday', 'wpfnl'),
704 'sunday' => __('Sunday', 'wpfnl'),
705 ],
706 'condition' => [
707 'display_condition_type' => 'day',
708 ],
709 ]
710 );
711
712 $this->end_controls_section();
713
714 $this->start_controls_section(
715 'section_style',
716 [
717 'label' => __('Button', 'wpfnl'),
718 'tab' => Controls_Manager::TAB_STYLE,
719 ]
720 );
721
722 $this->add_group_control(
723 Group_Control_Typography::get_type(),
724 [
725 'name' => 'next_step_button_typography',
726 'label' => 'Typography',
727 'selector' => '{{WRAPPER}} a.elementor-button',
728 ]
729 );
730
731 $this->add_group_control(
732 Group_Control_Text_Shadow::get_type(),
733 [
734 'name' => 'next_step_button_text_shadow',
735 'selector' => '{{WRAPPER}} a.elementor-button',
736 ]
737 );
738
739 $this->start_controls_tabs('tabs_button_style');
740
741 $this->start_controls_tab(
742 'tab_button_normal',
743 [
744 'label' => __('Normal', 'wpfnl'),
745 ]
746 );
747
748 $this->add_control(
749 'button_text_color',
750 [
751 'label' => __('Text Color', 'wpfnl'),
752 'type' => Controls_Manager::COLOR,
753 'default' => '',
754 'selectors' => [
755 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'color: {{VALUE}};',
756 ],
757 ]
758 );
759
760 $this->add_control(
761 'background_color',
762 [
763 'label' => __('Background Color', 'wpfnl'),
764 'type' => Controls_Manager::COLOR,
765 'selectors' => [
766 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'background-color: {{VALUE}};',
767 ],
768 'default' => '#61CE70',
769 ]
770 );
771
772 $this->end_controls_tab();
773
774 $this->start_controls_tab(
775 'tab_button_hover',
776 [
777 'label' => __('Hover', 'wpfnl'),
778 ]
779 );
780
781 $this->add_control(
782 'hover_color',
783 [
784 'label' => __('Text Color', 'wpfnl'),
785 'type' => Controls_Manager::COLOR,
786 'selectors' => [
787 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'color: {{VALUE}};',
788 ],
789 ]
790 );
791
792 $this->add_control(
793 'button_background_hover_color',
794 [
795 'label' => __('Background Color', 'wpfnl'),
796 'type' => Controls_Manager::COLOR,
797 'selectors' => [
798 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'background-color: {{VALUE}};',
799 ],
800 ]
801 );
802
803 $this->add_control(
804 'button_hover_border_color',
805 [
806 'label' => __('Border Color', 'wpfnl'),
807 'type' => Controls_Manager::COLOR,
808 'condition' => [
809 'border_border!' => '',
810 ],
811 'selectors' => [
812 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};',
813 ],
814 ]
815 );
816
817 $this->add_control(
818 'hover_animation',
819 [
820 'label' => __('Animation', 'wpfnl'),
821 'type' => Controls_Manager::HOVER_ANIMATION,
822 ]
823 );
824
825 $this->end_controls_tab();
826
827 $this->end_controls_tabs();
828
829 $this->add_group_control(
830 Group_Control_Border::get_type(),
831 [
832 'name' => 'border',
833 'label' => __('Border', 'wpfnl'),
834 'placeholder' => '1px',
835 'default' => '1px',
836 'selector' => '{{WRAPPER}} .elementor-button',
837 'separator' => 'before',
838 ]
839 );
840
841 $this->add_responsive_control(
842 'border_radius',
843 [
844 'label' => __('Border Radius', 'wpfnl'),
845 'type' => Controls_Manager::DIMENSIONS,
846 'size_units' => ['px', '%'],
847 'selectors' => [
848 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
849 ],
850 ]
851 );
852
853
854 $this->add_group_control(
855 Group_Control_Box_Shadow::get_type(),
856 [
857 'name' => 'button_box_shadow',
858 'selector' => '{{WRAPPER}} .elementor-button',
859 ]
860 );
861
862 $this->add_responsive_control(
863 'text_padding',
864 [
865 'label' => __('Padding', 'wpfnl'),
866 'type' => Controls_Manager::DIMENSIONS,
867 'size_units' => ['px', 'em', '%'],
868 'selectors' => [
869 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
870 ],
871 'separator' => 'before',
872 ]
873 );
874
875
876 $this->end_controls_section();
877
878 // Subtitle Style Section
879 $this->start_controls_section(
880 'section_subtitle_style',
881 [
882 'label' => __('Subtitle', 'wpfnl'),
883 'tab' => Controls_Manager::TAB_STYLE,
884 'condition' => [
885 'enable_subtitle' => 'yes',
886 ],
887 ]
888 );
889
890 $this->add_group_control(
891 Group_Control_Typography::get_type(),
892 [
893 'name' => 'subtitle_typography',
894 'label' => __('Typography', 'wpfnl'),
895 'selector' => '{{WRAPPER}} .wpfnl-button-subtitle',
896 ]
897 );
898
899 $this->add_responsive_control(
900 'subtitle_spacing',
901 [
902 'label' => __('Spacing', 'wpfnl'),
903 'type' => Controls_Manager::SLIDER,
904 'range' => [
905 'px' => [
906 'min' => 0,
907 'max' => 50,
908 ],
909 ],
910 'selectors' => [
911 '{{WRAPPER}} .wpfnl-button-subtitle' => 'margin-top: {{SIZE}}{{UNIT}};',
912 ],
913 ]
914 );
915
916 $this->end_controls_section();
917 }
918
919
920 /**
921 * Render the widget output on the frontend.
922 *
923 * Written in PHP and used to generate the final HTML.
924 *
925 * @since 1.0.0
926 *
927 * @access protected
928 */
929 protected function render()
930 {
931 $settings = $this->get_settings();
932 $this->add_render_attribute('wrapper', 'class', 'elementor-button-wrapper');
933 $this->add_render_attribute('button', 'class', 'elementor-button');
934 $products = '';
935
936
937 // Get subtitle settings
938 $enable_subtitle = isset($settings['enable_subtitle']) ? $settings['enable_subtitle'] : 'no';
939 $subtitle_text = isset($settings['subtitle_text']) ? $settings['subtitle_text'] : '';
940
941 if (!empty($settings['size'])) {
942 $this->add_render_attribute('button', 'class', 'elementor-size-' . $settings['size']);
943 }
944
945 if (isset($enable_subtitle) && $enable_subtitle === 'yes' && !empty($enable_subtitle)) {
946 $this->add_render_attribute('button', 'class', 'wpfnl-has-subtitle');
947 }
948
949 if (isset($settings['hover_animation']) && $settings['hover_animation']) {
950 $this->add_render_attribute('button', 'class', 'elementor-animation-' . $settings['hover_animation']);
951 }
952
953 if (isset($settings['button_type_selector']) && $settings['button_type_selector'] !== 'lead') {
954
955 // $products = implode(",", $settings['checkout_product_selector']);
956 $products_array = get_post_meta(get_the_ID(), 'checkout_product_selector', true);
957 if ($products_array) {
958 $products = implode(",", $products_array);
959 }
960
961 if( 'url-path' === $settings['button_type_selector'] ){
962 $url = isset($settings['url_path_field']['url']) ? $settings['url_path_field']['url'] : '';
963 }elseif( 'another-funnel' === $settings['button_type_selector'] ){
964 $url = $settings['another_funnel_field'];
965 }else{
966 $url = '';
967 }
968
969
970 // Prepare data attributes for client-side display conditions
971 $hide_on_browser = isset($settings['hide_on_browser']) ? esc_attr($settings['hide_on_browser']) : 'none';
972 $hide_on_os = isset($settings['hide_on_os']) ? esc_attr($settings['hide_on_os']) : 'none';
973
974 // Get display condition settings
975 $display_condition = isset($settings['display_condition_type']) ? $settings['display_condition_type'] : 'none';
976
977 // Check display conditions and return early if button should be hidden
978 if ($display_condition === 'user_state') {
979 $hide_logged_in = isset($settings['hide_from_logged_in']) ? $settings['hide_from_logged_in'] : 'no';
980 $hide_logged_out = isset($settings['hide_from_logged_out']) ? $settings['hide_from_logged_out'] : 'no';
981
982 // Hide from logged in users
983 if ($hide_logged_in === 'yes' && is_user_logged_in()) {
984 return;
985 }
986
987 // Hide from logged out users
988 if ($hide_logged_out === 'yes' && !is_user_logged_in()) {
989 return;
990 }
991
992 } elseif ($display_condition === 'user_role') {
993 $hide_for_user_role = isset($settings['hide_for_user_role']) ? $settings['hide_for_user_role'] : 'none';
994
995 if ($hide_for_user_role !== 'none' && is_user_logged_in()) {
996 $user = wp_get_current_user();
997 if (in_array($hide_for_user_role, $user->roles)) {
998 return;
999 }
1000 }
1001
1002 } elseif ($display_condition === 'day') {
1003 $disable_on_days = isset($settings['disable_on_days']) ? $settings['disable_on_days'] : array();
1004
1005 if (!empty($disable_on_days) && is_array($disable_on_days)) {
1006 $current_day = strtolower(date('l')); // e.g., 'monday'
1007 if (in_array($current_day, $disable_on_days)) {
1008 return;
1009 }
1010 }
1011
1012 } elseif ($display_condition === 'browser') {
1013 $hide_on_browser = isset($settings['hide_on_browser']) ? $settings['hide_on_browser'] : 'none';
1014
1015 if ($hide_on_browser !== 'none') {
1016 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
1017 $current_browser = '';
1018
1019 // Detect browser from user agent
1020 if (strpos($user_agent, 'edg') !== false) {
1021 $current_browser = 'edge';
1022 } elseif (strpos($user_agent, 'opr') !== false || strpos($user_agent, 'opera') !== false) {
1023 $current_browser = 'opera_mini';
1024 } elseif (strpos($user_agent, 'chrome') !== false) {
1025 $current_browser = 'chrome';
1026 } elseif (strpos($user_agent, 'safari') !== false) {
1027 $current_browser = 'safari';
1028 } elseif (strpos($user_agent, 'firefox') !== false) {
1029 $current_browser = 'mozilla';
1030 }
1031
1032 // Hide button if current browser matches
1033 if ($current_browser === $hide_on_browser) {
1034 return;
1035 }
1036 }
1037 } elseif ($display_condition === 'operating_system') {
1038 $hide_on_os = isset($settings['hide_on_os']) ? $settings['hide_on_os'] : 'none';
1039
1040 if ($hide_on_os !== 'none') {
1041 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
1042 $current_os = '';
1043
1044 // Detect operating system from user agent
1045 if (strpos($user_agent, 'windows') !== false || strpos($user_agent, 'win32') !== false || strpos($user_agent, 'win64') !== false) {
1046 $current_os = 'windows';
1047 } elseif (strpos($user_agent, 'macintosh') !== false || strpos($user_agent, 'mac os x') !== false) {
1048 $current_os = 'macos';
1049 } elseif (strpos($user_agent, 'linux') !== false && strpos($user_agent, 'android') === false) {
1050 $current_os = 'linux';
1051 } elseif (strpos($user_agent, 'android') !== false) {
1052 $current_os = 'android';
1053 } elseif (strpos($user_agent, 'iphone') !== false || strpos($user_agent, 'ipad') !== false || strpos($user_agent, 'ipod') !== false) {
1054 $current_os = 'ios';
1055 } elseif (strpos($user_agent, 'sunos') !== false) {
1056 $current_os = 'sunos';
1057 } elseif (strpos($user_agent, 'openbsd') !== false) {
1058 $current_os = 'openbsd';
1059 }
1060
1061 // Hide button if current OS matches
1062 if ($current_os === $hide_on_os) {
1063 return;
1064 }
1065 }
1066 }
1067 // -----end display conditioning----
1068
1069 ?>
1070 <div <?php echo $this->get_render_attribute_string('wrapper'); ?>>
1071 <a href="#"
1072 data-button-type="<?php echo $settings['button_type_selector']; ?>"
1073 data-url="<?php echo $url; ?>"
1074 data-id="<?php echo get_the_ID(); ?>"
1075 data-products="<?php echo $products; ?>"
1076 id="wpfunnels_next_step_controller"
1077 style="cursor: pointer;"
1078 <?php echo $this->get_render_attribute_string('button'); ?>
1079 >
1080
1081 <?php if (isset($enable_subtitle) && $enable_subtitle === 'yes' && !empty($subtitle_text)) { ?>
1082 <span class="text-inner-wrapper" style="display: flex; align-items: center; gap: 3px;">
1083 <?php $this->render_text(); ?>
1084 <span class="wpfnl-loader"></span>
1085 </span>
1086
1087 <small class="wpfnl-button-subtitle">
1088 <?php echo esc_html($subtitle_text); ?>
1089 </small>
1090 <?php } else { ?>
1091 <?php $this->render_text(); ?>
1092 <span class="wpfnl-loader"></span>
1093 <?php } ?>
1094 </a>
1095 </div>
1096 <span class="wpfnl-alert" id="wpfnl-next-button-loader"></span>
1097
1098 <?php
1099 } elseif (isset($settings['button_type_selector']) && $settings['button_type_selector'] == 'lead') {
1100 if (!in_array('fluentform/fluentform.php', WPFNL_ACTIVE_PLUGINS)) {
1101 echo '<p style="color: red;">Please activate Fluent Forms</p>';
1102 }
1103 $form = $settings['lead_type_page_selector'];
1104 if (isset($settings['lead_type_selector']) && $settings['lead_type_selector'] == 'page') {
1105 echo do_shortcode('[fluentform id="' . $form . '"]');
1106 } elseif (isset($settings['lead_type_selector']) && $settings['lead_type_selector'] == 'popup') {
1107 echo do_shortcode('[fluentform_modal form_id="' . $form . '" ]');
1108 //echo '<a href="#" id="modal-id">show modal</a>';
1109 }
1110 }
1111
1112 }
1113
1114
1115 /**
1116 * Render button text.
1117 *
1118 * Render button widget text.
1119 *
1120 * @since 1.5.0
1121 * @access protected
1122 */
1123 protected function render_text()
1124 {
1125 $settings = $this->get_settings();
1126 $migrated = isset($settings['__fa4_migrated']['next_step_button_icon']);
1127 $is_new = empty($settings['icon']) && Icons_Manager::is_migration_allowed();
1128
1129 if (!$is_new && empty($settings['next_step_button_icon_align'])) {
1130
1131 $settings['next_step_button_icon_align'] = $this->get_settings('next_step_button_icon_align');
1132 }
1133
1134 $this->add_render_attribute([
1135 'content-wrapper' => [
1136 'class' => 'elementor-button-content-wrapper',
1137 ],
1138 'icon-align' => [
1139 'class' => [
1140 'elementor-button-icon',
1141 'elementor-align-icon-' . $settings['next_step_button_icon_align'],
1142 ],
1143 ],
1144 'text' => [
1145 'class' => 'elementor-button-text',
1146 ],
1147 ]);
1148
1149 $this->add_render_attribute('content-wrapper', 'class', 'elementor-button-content-wrapper');
1150 $this->add_render_attribute('text', 'class', 'elementor-button-text');
1151
1152 $this->add_inline_editing_attributes('text', 'none');
1153 ?>
1154 <span <?php echo $this->get_render_attribute_string('content-wrapper'); ?> style="<?php echo $settings['next_step_button_icon_align'] === 'right' ? 'flex-direction: row-reverse' : '' ?>">
1155
1156 <?php if (!empty($settings['icon']) || !empty($settings['next_step_button_icon']['value'])) : ?>
1157 <span <?php echo $this->get_render_attribute_string('icon-align'); ?>>
1158 <?php if ($is_new || $migrated) :
1159 Icons_Manager::render_icon($settings['next_step_button_icon'], ['aria-hidden' => 'true']);
1160 else : ?>
1161 <i class="<?php echo esc_attr($settings['icon']); ?>" aria-hidden="true"></i>
1162 <?php endif; ?>
1163 </span>
1164 <?php endif; ?>
1165
1166 <span <?php echo $this->get_render_attribute_string('text'); ?>>
1167 <?php echo $settings['text']; ?>
1168 </span>
1169 </span>
1170 <?php
1171 }
1172
1173
1174 /**
1175 * Fnd next step url
1176 *
1177 * @since 1.5.0
1178 * @access protected
1179 */
1180 public function get_next_step_url()
1181 {
1182 $id = get_the_ID();
1183 $funnel_id = get_post_meta($id, '_funnel_id', true);
1184 $steps_order = get_post_meta($funnel_id, '_steps_order', true);
1185 $step_object = new Wpfnl_Steps_Store_Data();
1186 $next_step_id = $step_object->get_next_step($steps_order, $funnel_id);
1187 if ($next_step_id) {
1188 $next_step_url = get_post_permalink($next_step_id);
1189 } else {
1190 $next_step_url = '#';
1191 }
1192 return $next_step_url;
1193 }
1194 }
1195