| 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 all WC products |
| 169 |
* |
| 170 |
* @since 1.0.0 |
| 171 |
* |
| 172 |
* @access protected |
| 173 |
*/ |
| 174 |
protected function get_products_array() |
| 175 |
{ |
| 176 |
$products = array(); |
| 177 |
if (in_array('woocommerce/woocommerce.php', WPFNL_ACTIVE_PLUGINS)) { |
| 178 |
$ids = wc_get_products(array('return' => 'ids', 'limit' => -1)); |
| 179 |
if( !empty($ids) ){ |
| 180 |
foreach ($ids as $id) { |
| 181 |
$title = get_the_title($id); |
| 182 |
$products[$id] = $title ? $title : ''; |
| 183 |
} |
| 184 |
} |
| 185 |
} |
| 186 |
return $products; |
| 187 |
} |
| 188 |
|
| 189 |
/** |
| 190 |
* Get all wp pages |
| 191 |
* |
| 192 |
* @since 1.0.0 |
| 193 |
* |
| 194 |
* @access protected |
| 195 |
*/ |
| 196 |
protected function get_available_pages() |
| 197 |
{ |
| 198 |
$data = array(); |
| 199 |
global $wpdb; |
| 200 |
if (in_array('fluentform/fluentform.php', WPFNL_ACTIVE_PLUGINS)) { |
| 201 |
$sql = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}fluentform_forms"); |
| 202 |
$results = $wpdb->get_results($sql); |
| 203 |
foreach ($results as $value) { |
| 204 |
$sql = $wpdb->prepare("SELECT title FROM {$wpdb->prefix}fluentform_forms WHERE id=$value->id"); |
| 205 |
$title = $wpdb->get_results($sql); |
| 206 |
$data[$value->id] = $title[0]->title; |
| 207 |
} |
| 208 |
} |
| 209 |
return $data; |
| 210 |
} |
| 211 |
|
| 212 |
protected function get_available_steps() |
| 213 |
{ |
| 214 |
$step_id = get_the_ID(); |
| 215 |
$funnel_id = get_post_meta($step_id, '_funnel_id', true); |
| 216 |
if (!$funnel_id) { |
| 217 |
return null; |
| 218 |
} |
| 219 |
$data = array(); |
| 220 |
$steps = get_post_meta($funnel_id, '_steps_order', true); |
| 221 |
if($steps) { |
| 222 |
foreach ($steps as $step_key => $step_value) { |
| 223 |
$data[$step_value['id']] = $step_value['name']; |
| 224 |
} |
| 225 |
} |
| 226 |
|
| 227 |
return $data; |
| 228 |
} |
| 229 |
|
| 230 |
public function get_prev_next_link_options() |
| 231 |
{ |
| 232 |
$associate_funnel_id = get_post_meta(get_the_ID(), '_funnel_id', true); |
| 233 |
$steps_array = [ |
| 234 |
'landing' => 'Landing', |
| 235 |
'checkout' => 'Checkout', |
| 236 |
'custom' => 'Custom', |
| 237 |
'upsell' => 'Upsell', |
| 238 |
'downsell' => 'Downsell', |
| 239 |
'thankyou' => 'Thankyou' |
| 240 |
]; |
| 241 |
$option_group = []; |
| 242 |
foreach ($steps_array as $key => $value) { |
| 243 |
$args = [ |
| 244 |
'posts_per_page' => -1, |
| 245 |
'orderby' => 'date', |
| 246 |
'order' => 'DESC', |
| 247 |
'post_type' => WPFNL_STEPS_POST_TYPE, |
| 248 |
'post_status' => 'publish', |
| 249 |
'post__not_in' => [$this->get_id()], |
| 250 |
'meta_query' => [ |
| 251 |
'relation' => 'AND', |
| 252 |
[ |
| 253 |
'key' => '_step_type', |
| 254 |
'value' => $key, |
| 255 |
'compare' => '=', |
| 256 |
], |
| 257 |
[ |
| 258 |
'key' => '_funnel_id', |
| 259 |
'value' => $associate_funnel_id, |
| 260 |
'compare' => '=', |
| 261 |
], |
| 262 |
], |
| 263 |
]; |
| 264 |
$query = new \WP_Query($args); |
| 265 |
$steps = $query->posts; |
| 266 |
if ($steps) { |
| 267 |
foreach ($steps as $s) { |
| 268 |
$option_group[$key][] = [ |
| 269 |
'id' => $s->ID, |
| 270 |
'title' => $s->post_title, |
| 271 |
]; |
| 272 |
} |
| 273 |
} |
| 274 |
} |
| 275 |
return $option_group; |
| 276 |
} |
| 277 |
|
| 278 |
/** |
| 279 |
* Get all funnel steps |
| 280 |
* |
| 281 |
* @since 1.0.0 |
| 282 |
* |
| 283 |
* @access protected |
| 284 |
*/ |
| 285 |
protected function get_steps_array($type = 'upsell') |
| 286 |
{ |
| 287 |
$options = $this->get_prev_next_link_options(); |
| 288 |
$response = array(); |
| 289 |
if (isset($options[$type])) { |
| 290 |
$prime_data = $options[$type]; |
| 291 |
foreach ($prime_data as $data) { |
| 292 |
$response[$data['id']] = $data['title']; |
| 293 |
} |
| 294 |
} |
| 295 |
|
| 296 |
return $response; |
| 297 |
} |
| 298 |
|
| 299 |
/** |
| 300 |
* Register the widget controls. |
| 301 |
* |
| 302 |
* @since 1.0.0 |
| 303 |
* |
| 304 |
* @access protected |
| 305 |
*/ |
| 306 |
protected function register_controls() |
| 307 |
{ |
| 308 |
|
| 309 |
$this->next_step_button_controls(); |
| 310 |
} |
| 311 |
|
| 312 |
/** |
| 313 |
* Register the widget controls. |
| 314 |
* |
| 315 |
* @since 1.0.0 |
| 316 |
* |
| 317 |
* @access protected |
| 318 |
*/ |
| 319 |
protected function _register_controls() |
| 320 |
{ |
| 321 |
$this->next_step_button_controls(); |
| 322 |
|
| 323 |
} |
| 324 |
|
| 325 |
/** |
| 326 |
* Next step button controls. |
| 327 |
* |
| 328 |
* @since 1.0.0 |
| 329 |
* |
| 330 |
* @access protected |
| 331 |
*/ |
| 332 |
protected function next_step_button_controls(){ |
| 333 |
$this->start_controls_section( |
| 334 |
'section_button_controller', |
| 335 |
[ |
| 336 |
'label' => __('Next Step Button', 'wpfnl'), |
| 337 |
] |
| 338 |
); |
| 339 |
|
| 340 |
$general_data = get_option('_wpfunnels_general_settings'); |
| 341 |
$funnel_types = $general_data['funnel_type']; |
| 342 |
|
| 343 |
|
| 344 |
$this->add_control( |
| 345 |
'button_type_selector', |
| 346 |
[ |
| 347 |
'label' => __('Select Button Type', 'wpfnl'), |
| 348 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 349 |
'default' => 'checkout', |
| 350 |
'options' => $this->get_funnel_types(), |
| 351 |
] |
| 352 |
); |
| 353 |
|
| 354 |
$this->add_control( |
| 355 |
'lead_type_selector', |
| 356 |
[ |
| 357 |
'label' => __('Lead Type', 'wpfnl'), |
| 358 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 359 |
'default' => '', |
| 360 |
'options' => [ |
| 361 |
'page' => __('Page', 'wpfnl'), |
| 362 |
'popup' => __('Popup', 'wpfnl'), |
| 363 |
], |
| 364 |
'condition' => [ |
| 365 |
'button_type_selector' => 'lead', |
| 366 |
] |
| 367 |
] |
| 368 |
); |
| 369 |
|
| 370 |
$this->add_control( |
| 371 |
'fluent_form_next_step', |
| 372 |
[ |
| 373 |
'label' => __('Select Next Step', 'wpfnl'), |
| 374 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 375 |
'options' => $this->get_available_steps(), |
| 376 |
'condition' => [ |
| 377 |
'button_type_selector' => 'lead', |
| 378 |
] |
| 379 |
] |
| 380 |
); |
| 381 |
|
| 382 |
$this->add_control( |
| 383 |
'url_path_field', |
| 384 |
[ |
| 385 |
'label' => __('URL Path', 'wpfnl'), |
| 386 |
'type' => \Elementor\Controls_Manager::URL, |
| 387 |
'default' => [], |
| 388 |
'condition' => [ |
| 389 |
'button_type_selector' => 'url-path', |
| 390 |
] |
| 391 |
] |
| 392 |
); |
| 393 |
|
| 394 |
$this->add_control( |
| 395 |
'another_funnel_field', |
| 396 |
[ |
| 397 |
'label' => __('Choose funnel', 'wpfnl'), |
| 398 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 399 |
'default' => '', |
| 400 |
'options' => Wpfnl_functions::get_funnel_list(), |
| 401 |
'condition' => [ |
| 402 |
'button_type_selector' => 'another-funnel', |
| 403 |
] |
| 404 |
] |
| 405 |
); |
| 406 |
|
| 407 |
$this->end_controls_section(); |
| 408 |
|
| 409 |
$this->start_controls_section( |
| 410 |
'section_button', |
| 411 |
[ |
| 412 |
'label' => __('Next Step Button Content', 'wpfnl'), |
| 413 |
// 'condition' => [ |
| 414 |
// 'button_type_selector' => 'checkout', |
| 415 |
// ] |
| 416 |
] |
| 417 |
); |
| 418 |
|
| 419 |
$this->add_control( |
| 420 |
'text', |
| 421 |
[ |
| 422 |
'label' => __('Text', 'wpfnl'), |
| 423 |
'type' => Controls_Manager::TEXT, |
| 424 |
'default' => __('Go Next', 'wpfnl'), |
| 425 |
'placeholder' => __('Go Next', 'wpfnl'), |
| 426 |
] |
| 427 |
); |
| 428 |
|
| 429 |
$this->add_responsive_control( |
| 430 |
'align', |
| 431 |
[ |
| 432 |
'label' => __('Alignment', 'wpfnl'), |
| 433 |
'type' => Controls_Manager::CHOOSE, |
| 434 |
'options' => [ |
| 435 |
'left' => [ |
| 436 |
'title' => __('Left', 'wpfnl'), |
| 437 |
'icon' => 'fa fa-align-left', |
| 438 |
], |
| 439 |
'center' => [ |
| 440 |
'title' => __('Center', 'wpfnl'), |
| 441 |
'icon' => 'fa fa-align-center', |
| 442 |
], |
| 443 |
'right' => [ |
| 444 |
'title' => __('Right', 'wpfnl'), |
| 445 |
'icon' => 'fa fa-align-right', |
| 446 |
], |
| 447 |
'justify' => [ |
| 448 |
'title' => __('Justified', 'wpfnl'), |
| 449 |
'icon' => 'fa fa-align-justify', |
| 450 |
], |
| 451 |
], |
| 452 |
'prefix_class' => 'elementor%s-align-', |
| 453 |
'default' => '', |
| 454 |
] |
| 455 |
); |
| 456 |
|
| 457 |
$this->add_control( |
| 458 |
'size', |
| 459 |
[ |
| 460 |
'label' => __('Size', 'wpfnl'), |
| 461 |
'type' => Controls_Manager::SELECT, |
| 462 |
'default' => 'sm', |
| 463 |
'options' => self::get_button_sizes(), |
| 464 |
] |
| 465 |
); |
| 466 |
|
| 467 |
|
| 468 |
$this->add_control( |
| 469 |
'next_step_button_icon', |
| 470 |
[ |
| 471 |
'label' => __('Icon', 'wpfnl'), |
| 472 |
'type' => Controls_Manager::ICONS, |
| 473 |
'fa4compatibility' => 'icon', |
| 474 |
] |
| 475 |
); |
| 476 |
|
| 477 |
$this->add_control( |
| 478 |
'next_step_button_icon_align', |
| 479 |
[ |
| 480 |
'label' => __('Icon Position', 'wpfnl'), |
| 481 |
'type' => Controls_Manager::SELECT, |
| 482 |
'default' => 'left', |
| 483 |
'options' => [ |
| 484 |
'left' => __('Before Text', 'wpfnl'), |
| 485 |
'right' => __('After Text', 'wpfnl'), |
| 486 |
], |
| 487 |
'condition' => [ |
| 488 |
'next_step_button_icon[value]!' => '', |
| 489 |
], |
| 490 |
] |
| 491 |
); |
| 492 |
|
| 493 |
$this->add_control( |
| 494 |
'next_step_button_icon_indent', |
| 495 |
[ |
| 496 |
'label' => __('Icon Spacing', 'wpfnl'), |
| 497 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 498 |
'range' => [ |
| 499 |
'px' => [ |
| 500 |
'max' => 50, |
| 501 |
], |
| 502 |
], |
| 503 |
'condition' => [ |
| 504 |
'next_step_button_icon!' => '', |
| 505 |
], |
| 506 |
'selectors' => [ |
| 507 |
'{{WRAPPER}} .elementor-button .elementor-align-icon-right' => 'margin-left: {{SIZE}}{{UNIT}};', |
| 508 |
'{{WRAPPER}} .elementor-button .elementor-align-icon-left' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 509 |
], |
| 510 |
] |
| 511 |
); |
| 512 |
|
| 513 |
|
| 514 |
$this->add_control( |
| 515 |
'view', |
| 516 |
[ |
| 517 |
'label' => __('View', 'wpfnl'), |
| 518 |
'type' => Controls_Manager::HIDDEN, |
| 519 |
'default' => 'traditional', |
| 520 |
] |
| 521 |
); |
| 522 |
|
| 523 |
$this->end_controls_section(); |
| 524 |
|
| 525 |
$this->start_controls_section( |
| 526 |
'section_style', |
| 527 |
[ |
| 528 |
'label' => __('Button', 'wpfnl'), |
| 529 |
'tab' => Controls_Manager::TAB_STYLE, |
| 530 |
] |
| 531 |
); |
| 532 |
|
| 533 |
$this->add_group_control( |
| 534 |
Group_Control_Typography::get_type(), |
| 535 |
[ |
| 536 |
'name' => 'next_step_button_typography', |
| 537 |
'label' => 'Typography', |
| 538 |
'selector' => '{{WRAPPER}} a.elementor-button', |
| 539 |
] |
| 540 |
); |
| 541 |
|
| 542 |
$this->add_group_control( |
| 543 |
Group_Control_Text_Shadow::get_type(), |
| 544 |
[ |
| 545 |
'name' => 'next_step_button_text_shadow', |
| 546 |
'selector' => '{{WRAPPER}} a.elementor-button', |
| 547 |
] |
| 548 |
); |
| 549 |
|
| 550 |
$this->start_controls_tabs('tabs_button_style'); |
| 551 |
|
| 552 |
$this->start_controls_tab( |
| 553 |
'tab_button_normal', |
| 554 |
[ |
| 555 |
'label' => __('Normal', 'wpfnl'), |
| 556 |
] |
| 557 |
); |
| 558 |
|
| 559 |
$this->add_control( |
| 560 |
'button_text_color', |
| 561 |
[ |
| 562 |
'label' => __('Text Color', 'wpfnl'), |
| 563 |
'type' => Controls_Manager::COLOR, |
| 564 |
'default' => '', |
| 565 |
'selectors' => [ |
| 566 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'color: {{VALUE}};', |
| 567 |
], |
| 568 |
] |
| 569 |
); |
| 570 |
|
| 571 |
$this->add_control( |
| 572 |
'background_color', |
| 573 |
[ |
| 574 |
'label' => __('Background Color', 'wpfnl'), |
| 575 |
'type' => Controls_Manager::COLOR, |
| 576 |
'selectors' => [ |
| 577 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'background-color: {{VALUE}};', |
| 578 |
], |
| 579 |
'default' => '#61CE70', |
| 580 |
] |
| 581 |
); |
| 582 |
|
| 583 |
$this->end_controls_tab(); |
| 584 |
|
| 585 |
$this->start_controls_tab( |
| 586 |
'tab_button_hover', |
| 587 |
[ |
| 588 |
'label' => __('Hover', 'wpfnl'), |
| 589 |
] |
| 590 |
); |
| 591 |
|
| 592 |
$this->add_control( |
| 593 |
'hover_color', |
| 594 |
[ |
| 595 |
'label' => __('Text Color', 'wpfnl'), |
| 596 |
'type' => Controls_Manager::COLOR, |
| 597 |
'selectors' => [ |
| 598 |
'{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'color: {{VALUE}};', |
| 599 |
], |
| 600 |
] |
| 601 |
); |
| 602 |
|
| 603 |
$this->add_control( |
| 604 |
'button_background_hover_color', |
| 605 |
[ |
| 606 |
'label' => __('Background Color', 'wpfnl'), |
| 607 |
'type' => Controls_Manager::COLOR, |
| 608 |
'selectors' => [ |
| 609 |
'{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'background-color: {{VALUE}};', |
| 610 |
], |
| 611 |
] |
| 612 |
); |
| 613 |
|
| 614 |
$this->add_control( |
| 615 |
'button_hover_border_color', |
| 616 |
[ |
| 617 |
'label' => __('Border Color', 'wpfnl'), |
| 618 |
'type' => Controls_Manager::COLOR, |
| 619 |
'condition' => [ |
| 620 |
'border_border!' => '', |
| 621 |
], |
| 622 |
'selectors' => [ |
| 623 |
'{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};', |
| 624 |
], |
| 625 |
] |
| 626 |
); |
| 627 |
|
| 628 |
$this->add_control( |
| 629 |
'hover_animation', |
| 630 |
[ |
| 631 |
'label' => __('Animation', 'wpfnl'), |
| 632 |
'type' => Controls_Manager::HOVER_ANIMATION, |
| 633 |
] |
| 634 |
); |
| 635 |
|
| 636 |
$this->end_controls_tab(); |
| 637 |
|
| 638 |
$this->end_controls_tabs(); |
| 639 |
|
| 640 |
$this->add_group_control( |
| 641 |
Group_Control_Border::get_type(), |
| 642 |
[ |
| 643 |
'name' => 'border', |
| 644 |
'label' => __('Border', 'wpfnl'), |
| 645 |
'placeholder' => '1px', |
| 646 |
'default' => '1px', |
| 647 |
'selector' => '{{WRAPPER}} .elementor-button', |
| 648 |
'separator' => 'before', |
| 649 |
] |
| 650 |
); |
| 651 |
|
| 652 |
$this->add_responsive_control( |
| 653 |
'border_radius', |
| 654 |
[ |
| 655 |
'label' => __('Border Radius', 'wpfnl'), |
| 656 |
'type' => Controls_Manager::DIMENSIONS, |
| 657 |
'size_units' => ['px', '%'], |
| 658 |
'selectors' => [ |
| 659 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 660 |
], |
| 661 |
] |
| 662 |
); |
| 663 |
|
| 664 |
|
| 665 |
$this->add_group_control( |
| 666 |
Group_Control_Box_Shadow::get_type(), |
| 667 |
[ |
| 668 |
'name' => 'button_box_shadow', |
| 669 |
'selector' => '{{WRAPPER}} .elementor-button', |
| 670 |
] |
| 671 |
); |
| 672 |
|
| 673 |
$this->add_responsive_control( |
| 674 |
'text_padding', |
| 675 |
[ |
| 676 |
'label' => __('Padding', 'wpfnl'), |
| 677 |
'type' => Controls_Manager::DIMENSIONS, |
| 678 |
'size_units' => ['px', 'em', '%'], |
| 679 |
'selectors' => [ |
| 680 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 681 |
], |
| 682 |
'separator' => 'before', |
| 683 |
] |
| 684 |
); |
| 685 |
|
| 686 |
|
| 687 |
$this->end_controls_section(); |
| 688 |
} |
| 689 |
|
| 690 |
|
| 691 |
/** |
| 692 |
* Render the widget output on the frontend. |
| 693 |
* |
| 694 |
* Written in PHP and used to generate the final HTML. |
| 695 |
* |
| 696 |
* @since 1.0.0 |
| 697 |
* |
| 698 |
* @access protected |
| 699 |
*/ |
| 700 |
protected function render() |
| 701 |
{ |
| 702 |
$settings = $this->get_settings(); |
| 703 |
$this->add_render_attribute('wrapper', 'class', 'elementor-button-wrapper'); |
| 704 |
$this->add_render_attribute('button', 'class', 'elementor-button'); |
| 705 |
$products = ''; |
| 706 |
if (!empty($settings['size'])) { |
| 707 |
$this->add_render_attribute('button', 'class', 'elementor-size-' . $settings['size']); |
| 708 |
} |
| 709 |
|
| 710 |
if (isset($settings['hover_animation']) && $settings['hover_animation']) { |
| 711 |
$this->add_render_attribute('button', 'class', 'elementor-animation-' . $settings['hover_animation']); |
| 712 |
} |
| 713 |
if (isset($settings['button_type_selector']) && $settings['button_type_selector'] !== 'lead') { |
| 714 |
|
| 715 |
// $products = implode(",", $settings['checkout_product_selector']); |
| 716 |
$products_array = get_post_meta(get_the_ID(), 'checkout_product_selector', true); |
| 717 |
if ($products_array) { |
| 718 |
$products = implode(",", $products_array); |
| 719 |
} |
| 720 |
|
| 721 |
if( 'url-path' === $settings['button_type_selector'] ){ |
| 722 |
$url = isset($settings['url_path_field']['url']) ? $settings['url_path_field']['url'] : ''; |
| 723 |
}elseif( 'another-funnel' === $settings['button_type_selector'] ){ |
| 724 |
$url = $settings['another_funnel_field']; |
| 725 |
}else{ |
| 726 |
$url = ''; |
| 727 |
} |
| 728 |
|
| 729 |
?> |
| 730 |
<div <?php echo $this->get_render_attribute_string('wrapper'); ?>> |
| 731 |
<a href="#" data-button-type="<?php echo $settings['button_type_selector']; ?>" data-url="<?php echo $url; ?>" data-id="<?php echo get_the_ID(); ?>" data-products="<?php echo $products; ?>" |
| 732 |
id="wpfunnels_next_step_controller" |
| 733 |
style="cursor: pointer;" <?php echo $this->get_render_attribute_string('button'); ?>> |
| 734 |
<?php $this->render_text(); ?> |
| 735 |
<span class="wpfnl-loader"></span> |
| 736 |
</a> |
| 737 |
</div> |
| 738 |
<span class="wpfnl-alert" id="wpfnl-next-button-loader"></span> |
| 739 |
|
| 740 |
<?php |
| 741 |
} elseif (isset($settings['button_type_selector']) && $settings['button_type_selector'] == 'lead') { |
| 742 |
if (!in_array('fluentform/fluentform.php', WPFNL_ACTIVE_PLUGINS)) { |
| 743 |
echo '<p style="color: red;">Please activate Fluent Forms</p>'; |
| 744 |
} |
| 745 |
$form = $settings['lead_type_page_selector']; |
| 746 |
if (isset($settings['lead_type_selector']) && $settings['lead_type_selector'] == 'page') { |
| 747 |
echo do_shortcode('[fluentform id="' . $form . '"]'); |
| 748 |
} elseif (isset($settings['lead_type_selector']) && $settings['lead_type_selector'] == 'popup') { |
| 749 |
echo do_shortcode('[fluentform_modal form_id="' . $form . '" ]'); |
| 750 |
//echo '<a href="#" id="modal-id">show modal</a>'; |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 754 |
} |
| 755 |
|
| 756 |
|
| 757 |
/** |
| 758 |
* Render button text. |
| 759 |
* |
| 760 |
* Render button widget text. |
| 761 |
* |
| 762 |
* @since 1.5.0 |
| 763 |
* @access protected |
| 764 |
*/ |
| 765 |
protected function render_text() |
| 766 |
{ |
| 767 |
$settings = $this->get_settings(); |
| 768 |
$migrated = isset($settings['__fa4_migrated']['next_step_button_icon']); |
| 769 |
$is_new = empty($settings['icon']) && Icons_Manager::is_migration_allowed(); |
| 770 |
|
| 771 |
if (!$is_new && empty($settings['next_step_button_icon_align'])) { |
| 772 |
|
| 773 |
$settings['next_step_button_icon_align'] = $this->get_settings('next_step_button_icon_align'); |
| 774 |
} |
| 775 |
|
| 776 |
$this->add_render_attribute([ |
| 777 |
'content-wrapper' => [ |
| 778 |
'class' => 'elementor-button-content-wrapper', |
| 779 |
], |
| 780 |
'icon-align' => [ |
| 781 |
'class' => [ |
| 782 |
'elementor-button-icon', |
| 783 |
'elementor-align-icon-' . $settings['next_step_button_icon_align'], |
| 784 |
], |
| 785 |
], |
| 786 |
'text' => [ |
| 787 |
'class' => 'elementor-button-text', |
| 788 |
], |
| 789 |
]); |
| 790 |
|
| 791 |
$this->add_render_attribute('content-wrapper', 'class', 'elementor-button-content-wrapper'); |
| 792 |
$this->add_render_attribute('text', 'class', 'elementor-button-text'); |
| 793 |
|
| 794 |
$this->add_inline_editing_attributes('text', 'none'); |
| 795 |
?> |
| 796 |
<span <?php echo $this->get_render_attribute_string('content-wrapper'); ?>> |
| 797 |
|
| 798 |
<?php if (!empty($settings['icon']) || !empty($settings['next_step_button_icon']['value'])) : ?> |
| 799 |
<span <?php echo $this->get_render_attribute_string('icon-align'); ?>> |
| 800 |
<?php if ($is_new || $migrated) : |
| 801 |
Icons_Manager::render_icon($settings['next_step_button_icon'], ['aria-hidden' => 'true']); |
| 802 |
else : ?> |
| 803 |
<i class="<?php echo esc_attr($settings['icon']); ?>" aria-hidden="true"></i> |
| 804 |
<?php endif; ?> |
| 805 |
</span> |
| 806 |
<?php endif; ?> |
| 807 |
|
| 808 |
<span <?php echo $this->get_render_attribute_string('text'); ?>> |
| 809 |
<?php echo $settings['text']; ?> |
| 810 |
</span> |
| 811 |
</span> |
| 812 |
<?php |
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
/** |
| 817 |
* Fnd next step url |
| 818 |
* |
| 819 |
* @since 1.5.0 |
| 820 |
* @access protected |
| 821 |
*/ |
| 822 |
public function get_next_step_url() |
| 823 |
{ |
| 824 |
$id = get_the_ID(); |
| 825 |
$funnel_id = get_post_meta($id, '_funnel_id', true); |
| 826 |
$steps_order = get_post_meta($funnel_id, '_steps_order', true); |
| 827 |
$step_object = new Wpfnl_Steps_Store_Data(); |
| 828 |
$next_step_id = $step_object->get_next_step($steps_order, $funnel_id); |
| 829 |
if ($next_step_id) { |
| 830 |
$next_step_url = get_post_permalink($next_step_id); |
| 831 |
} else { |
| 832 |
$next_step_url = '#'; |
| 833 |
} |
| 834 |
return $next_step_url; |
| 835 |
} |
| 836 |
} |
| 837 |
|