| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPFunnels\Widgets\Elementor; |
| 4 |
|
| 5 |
use Elementor\Widget_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Group_Control_Border; |
| 8 |
use Elementor\Group_Control_Typography; |
| 9 |
use Elementor\Group_Control_Box_Shadow; |
| 10 |
use Elementor\Group_Control_Text_Shadow; |
| 11 |
use Elementor\Icons_Manager; |
| 12 |
use WPFunnels\Wpfnl_functions; |
| 13 |
if (!defined('ABSPATH')) { |
| 14 |
exit; |
| 15 |
} // Exit if accessed directly |
| 16 |
|
| 17 |
/** |
| 18 |
* Funnel sell accept button |
| 19 |
* |
| 20 |
* @since 1.0.0 |
| 21 |
*/ |
| 22 |
class Offer_Button extends Widget_Base |
| 23 |
{ |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* Register the widget controls. |
| 28 |
* |
| 29 |
* Adds different input fields to allow the user to change and Wpvrize the widget settings. |
| 30 |
* |
| 31 |
* @since 1.0.0 |
| 32 |
* |
| 33 |
* @access protected |
| 34 |
*/ |
| 35 |
protected function init_controls() { |
| 36 |
if ( version_compare(ELEMENTOR_VERSION, '3.1.0', '>=') ) { |
| 37 |
$this->register_controls(); |
| 38 |
} else { |
| 39 |
$this->_register_controls(); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
/** |
| 46 |
* Retrieve the widget name. |
| 47 |
* |
| 48 |
* @return string Widget name. |
| 49 |
* @since 1.0.0 |
| 50 |
* |
| 51 |
* @access public |
| 52 |
* |
| 53 |
*/ |
| 54 |
public function get_name() |
| 55 |
{ |
| 56 |
return 'wpfnl-offer'; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Retrieve the widget title. |
| 61 |
* |
| 62 |
* @return string Widget title. |
| 63 |
* @since 1.0.0 |
| 64 |
* |
| 65 |
* @access public |
| 66 |
* |
| 67 |
*/ |
| 68 |
public function get_title() |
| 69 |
{ |
| 70 |
return __('Offer Button', 'wpfnl'); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Retrieve the widget icon. |
| 75 |
* |
| 76 |
* @return string Widget icon. |
| 77 |
* @since 1.0.0 |
| 78 |
* |
| 79 |
* @access public |
| 80 |
* |
| 81 |
*/ |
| 82 |
public function get_icon() |
| 83 |
{ |
| 84 |
return 'icon-wpfnl sell-accept'; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Retrieve the list of categories the widget belongs to. |
| 89 |
* |
| 90 |
* Used to determine where to display the widget in the editor. |
| 91 |
* |
| 92 |
* Note that currently Elementor supports only one category. |
| 93 |
* When multiple categories passed, Elementor uses the first one. |
| 94 |
* |
| 95 |
* @return array Widget categories. |
| 96 |
* @since 1.0.0 |
| 97 |
* |
| 98 |
* @access public |
| 99 |
* |
| 100 |
*/ |
| 101 |
public function get_categories() |
| 102 |
{ |
| 103 |
return ['wp-funnel']; |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Retrieve the list of scripts the widget depended on. |
| 108 |
* |
| 109 |
* Used to set scripts dependencies required to run the widget. |
| 110 |
* |
| 111 |
* @return array Widget scripts dependencies. |
| 112 |
* @since 1.0.0 |
| 113 |
* |
| 114 |
* @access public |
| 115 |
* |
| 116 |
*/ |
| 117 |
public function get_script_depends() |
| 118 |
{ |
| 119 |
return ['upsell-downsell-widget']; |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Get button sizes. |
| 124 |
* |
| 125 |
* Retrieve an array of button sizes for the button widget. |
| 126 |
* |
| 127 |
* @return array An array containing button sizes. |
| 128 |
* @since 1.0.0 |
| 129 |
* @access public |
| 130 |
* @static |
| 131 |
* |
| 132 |
*/ |
| 133 |
public static function get_button_sizes() |
| 134 |
{ |
| 135 |
return [ |
| 136 |
'xs' => __('Extra Small', 'wpfnl-pro'), |
| 137 |
'sm' => __('Small', 'wpfnl-pro'), |
| 138 |
'md' => __('Medium', 'wpfnl-pro'), |
| 139 |
'lg' => __('Large', 'wpfnl-pro'), |
| 140 |
'xl' => __('Extra Large', 'wpfnl-pro'), |
| 141 |
]; |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* Register the widget controls. |
| 146 |
* @since 1.0.0 |
| 147 |
* |
| 148 |
* @access protected |
| 149 |
*/ |
| 150 |
protected function _register_controls() |
| 151 |
{ |
| 152 |
//----content funtion---- |
| 153 |
|
| 154 |
$this->register_dynamic_data_template_content(); |
| 155 |
$this->register_offer_button_content(); |
| 156 |
$this->register_offer_button_display_conditions(); |
| 157 |
|
| 158 |
//----style funtion---- |
| 159 |
$this->register_dynamic_data_template_style(); |
| 160 |
$this->register_offer_button_style(); |
| 161 |
|
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
/** |
| 166 |
* Register the widget controls. |
| 167 |
* @since 1.0.0 |
| 168 |
* |
| 169 |
* @access protected |
| 170 |
*/ |
| 171 |
protected function register_controls() |
| 172 |
{ |
| 173 |
//----content funtion---- |
| 174 |
$this->register_offer_button_content(); |
| 175 |
$this->register_offer_button_display_conditions(); |
| 176 |
$this->register_dynamic_data_template_content(); |
| 177 |
|
| 178 |
//----style funtion---- |
| 179 |
$this->register_dynamic_data_template_style(); |
| 180 |
$this->register_offer_button_style(); |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
/** |
| 185 |
* Register Dynamic Data Template content Control. |
| 186 |
* |
| 187 |
* @since x.x.x |
| 188 |
* @access protected |
| 189 |
*/ |
| 190 |
protected function register_dynamic_data_template_content(){ |
| 191 |
|
| 192 |
|
| 193 |
$this->start_controls_section( |
| 194 |
'dynamic_data_template_content', |
| 195 |
array( |
| 196 |
'label' => __('Template Content', 'wpfnl-pro'), |
| 197 |
'condition' => array( |
| 198 |
'show_product_data' => 'yes', |
| 199 |
'offer_type' => 'accept', |
| 200 |
), |
| 201 |
) |
| 202 |
); |
| 203 |
|
| 204 |
$this->add_control( |
| 205 |
'dynamic_data_template_layout', |
| 206 |
[ |
| 207 |
'label' => __('Select Template Style ', 'wpfnl-pro'), |
| 208 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 209 |
'default' => 'style1', |
| 210 |
'options' => [ |
| 211 |
'style1' => __('Left Image Right Content', 'wpfnl-pro'), |
| 212 |
'style2' => __('Left Content Right Image', 'wpfnl-pro'), |
| 213 |
'style3' => __('Top Image Bottom Content', 'wpfnl-pro'), |
| 214 |
], |
| 215 |
|
| 216 |
] |
| 217 |
); |
| 218 |
|
| 219 |
$this->end_controls_section(); |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* Register Dynamic Data Template Style Control. |
| 224 |
* |
| 225 |
* @since x.x.x |
| 226 |
* @access protected |
| 227 |
*/ |
| 228 |
protected function register_dynamic_data_template_style(){ |
| 229 |
|
| 230 |
$this->start_controls_section( |
| 231 |
'dynamic_data_template_style', |
| 232 |
[ |
| 233 |
'label' => __('Template Style', 'wpfnl-pro'), |
| 234 |
'tab' => Controls_Manager::TAB_STYLE, |
| 235 |
'condition' => array( |
| 236 |
'show_product_data' => 'yes', |
| 237 |
'offer_type' => 'accept', |
| 238 |
), |
| 239 |
] |
| 240 |
); |
| 241 |
|
| 242 |
// ----Template Layout Style----- |
| 243 |
$this->add_control( |
| 244 |
'template_layout_style', |
| 245 |
[ |
| 246 |
'label' => __('Layout Style', 'wpfnl-pro'), |
| 247 |
'type' => Controls_Manager::HEADING, |
| 248 |
'label_block' => true, |
| 249 |
] |
| 250 |
); |
| 251 |
|
| 252 |
|
| 253 |
//-----left column for style-1------ |
| 254 |
$this->add_responsive_control( |
| 255 |
'template_left_col_width', |
| 256 |
[ |
| 257 |
'label' => esc_html__( 'Image Column Width', 'wpfnl-pro' ), |
| 258 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 259 |
'size_units' => [ 'px', '%' ], |
| 260 |
'range' => [ |
| 261 |
'px' => [ |
| 262 |
'min' => 0, |
| 263 |
'max' => 1920, |
| 264 |
'step' => 1, |
| 265 |
], |
| 266 |
'%' => [ |
| 267 |
'min' => 0, |
| 268 |
'max' => 100, |
| 269 |
], |
| 270 |
], |
| 271 |
'default' => [ |
| 272 |
'unit' => '%', |
| 273 |
'size' => '', |
| 274 |
], |
| 275 |
'selectors' => [ |
| 276 |
'{{WRAPPER}} .dynamic-offer-template-default .template-left' => 'width: {{SIZE}}{{UNIT}};', |
| 277 |
], |
| 278 |
] |
| 279 |
); |
| 280 |
|
| 281 |
$this->add_responsive_control( |
| 282 |
'template_right_col_width', |
| 283 |
[ |
| 284 |
'label' => esc_html__( 'Content Column Width', 'wpfnl-pro' ), |
| 285 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 286 |
'size_units' => [ 'px', '%' ], |
| 287 |
'range' => [ |
| 288 |
'px' => [ |
| 289 |
'min' => 0, |
| 290 |
'max' => 1920, |
| 291 |
'step' => 1, |
| 292 |
], |
| 293 |
'%' => [ |
| 294 |
'min' => 0, |
| 295 |
'max' => 100, |
| 296 |
], |
| 297 |
], |
| 298 |
'default' => [ |
| 299 |
'unit' => '%', |
| 300 |
'size' => '', |
| 301 |
], |
| 302 |
'selectors' => [ |
| 303 |
'{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'width: {{SIZE}}{{UNIT}};', |
| 304 |
], |
| 305 |
] |
| 306 |
); |
| 307 |
|
| 308 |
$this->add_responsive_control( |
| 309 |
'template_col_gutter_width', |
| 310 |
[ |
| 311 |
'label' => esc_html__( 'Column Gutter Width', 'wpfnl-pro' ), |
| 312 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 313 |
'size_units' => [ 'px', '%' ], |
| 314 |
'range' => [ |
| 315 |
'px' => [ |
| 316 |
'min' => 0, |
| 317 |
'max' => 100, |
| 318 |
'step' => 1, |
| 319 |
], |
| 320 |
'%' => [ |
| 321 |
'min' => 0, |
| 322 |
'max' => 100, |
| 323 |
], |
| 324 |
], |
| 325 |
'default' => [ |
| 326 |
'unit' => 'px', |
| 327 |
'size' => '', |
| 328 |
], |
| 329 |
'selectors' => [ |
| 330 |
'{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'padding-left: {{SIZE}}{{UNIT}};', |
| 331 |
], |
| 332 |
'condition' => array( |
| 333 |
'dynamic_data_template_layout[value]' => 'style1', |
| 334 |
), |
| 335 |
] |
| 336 |
); |
| 337 |
|
| 338 |
//--when template style-2 select then this control will show--- |
| 339 |
$this->add_responsive_control( |
| 340 |
'template_col_right_gutter_width', |
| 341 |
[ |
| 342 |
'label' => esc_html__( 'Column Gutter Width', 'wpfnl-pro' ), |
| 343 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 344 |
'size_units' => [ 'px', '%' ], |
| 345 |
'range' => [ |
| 346 |
'px' => [ |
| 347 |
'min' => 0, |
| 348 |
'max' => 100, |
| 349 |
'step' => 1, |
| 350 |
], |
| 351 |
'%' => [ |
| 352 |
'min' => 0, |
| 353 |
'max' => 100, |
| 354 |
], |
| 355 |
], |
| 356 |
'default' => [ |
| 357 |
'unit' => 'px', |
| 358 |
'size' => '', |
| 359 |
], |
| 360 |
'selectors' => [ |
| 361 |
'{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'padding-right: {{SIZE}}{{UNIT}};', |
| 362 |
], |
| 363 |
'condition' => array( |
| 364 |
'dynamic_data_template_layout[value]' => 'style2', |
| 365 |
), |
| 366 |
] |
| 367 |
); |
| 368 |
|
| 369 |
//--when template style-3 select then this control will show--- |
| 370 |
$this->add_responsive_control( |
| 371 |
'template_col_top_gutter_width', |
| 372 |
[ |
| 373 |
'label' => esc_html__( 'Column Gutter Width', 'wpfnl-pro' ), |
| 374 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 375 |
'size_units' => [ 'px', '%' ], |
| 376 |
'range' => [ |
| 377 |
'px' => [ |
| 378 |
'min' => 0, |
| 379 |
'max' => 100, |
| 380 |
'step' => 1, |
| 381 |
], |
| 382 |
'%' => [ |
| 383 |
'min' => 0, |
| 384 |
'max' => 100, |
| 385 |
], |
| 386 |
], |
| 387 |
'default' => [ |
| 388 |
'unit' => 'px', |
| 389 |
'size' => '', |
| 390 |
], |
| 391 |
'selectors' => [ |
| 392 |
'{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'padding-top: {{SIZE}}{{UNIT}};', |
| 393 |
], |
| 394 |
'condition' => array( |
| 395 |
'dynamic_data_template_layout[value]' => 'style3', |
| 396 |
), |
| 397 |
] |
| 398 |
); |
| 399 |
|
| 400 |
$this->add_responsive_control( |
| 401 |
'template_layout_radius', |
| 402 |
[ |
| 403 |
'label' => __('Radius', 'wpfnl-pro'), |
| 404 |
'type' => Controls_Manager::DIMENSIONS, |
| 405 |
'size_units' => ['px', 'em', '%'], |
| 406 |
'selectors' => [ |
| 407 |
'{{WRAPPER}} .dynamic-offer-template-default' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 408 |
], |
| 409 |
|
| 410 |
] |
| 411 |
); |
| 412 |
|
| 413 |
$this->add_group_control( |
| 414 |
\Elementor\Group_Control_Box_Shadow::get_type(), |
| 415 |
[ |
| 416 |
'name' => 'template_layout_shadow', |
| 417 |
'label' => __( 'Box Shadow', 'wpfnl-pro' ), |
| 418 |
'selector' => '{{WRAPPER}} .dynamic-offer-template-default', |
| 419 |
] |
| 420 |
); |
| 421 |
|
| 422 |
$this->add_responsive_control( |
| 423 |
'template_layout_padding', |
| 424 |
[ |
| 425 |
'label' => __('Padding', 'wpfnl-pro'), |
| 426 |
'type' => Controls_Manager::DIMENSIONS, |
| 427 |
'size_units' => ['px', 'em', '%'], |
| 428 |
'selectors' => [ |
| 429 |
'{{WRAPPER}} .dynamic-offer-template-default' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 430 |
], |
| 431 |
] |
| 432 |
); |
| 433 |
|
| 434 |
$this->add_responsive_control( |
| 435 |
'template_layout_margin', |
| 436 |
[ |
| 437 |
'label' => __('Margin', 'wpfnl-pro'), |
| 438 |
'type' => Controls_Manager::DIMENSIONS, |
| 439 |
'size_units' => ['px', 'em', '%'], |
| 440 |
'selectors' => [ |
| 441 |
'{{WRAPPER}} .dynamic-offer-template-default' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 442 |
], |
| 443 |
'separator' => 'after', |
| 444 |
] |
| 445 |
); |
| 446 |
|
| 447 |
// ----Template Content Style----- |
| 448 |
$this->add_control( |
| 449 |
'template_content_heading', |
| 450 |
[ |
| 451 |
'label' => __('Template Image Style', 'wpfnl-pro'), |
| 452 |
'type' => Controls_Manager::HEADING, |
| 453 |
'label_block' => true, |
| 454 |
] |
| 455 |
); |
| 456 |
|
| 457 |
$this->add_responsive_control( |
| 458 |
'template_image_width', |
| 459 |
[ |
| 460 |
'label' => esc_html__( 'Image Width', 'wpfnl-pro' ), |
| 461 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 462 |
'size_units' => [ 'px', '%' ], |
| 463 |
'range' => [ |
| 464 |
'px' => [ |
| 465 |
'min' => 0, |
| 466 |
'max' => 1920, |
| 467 |
'step' => 1, |
| 468 |
], |
| 469 |
'%' => [ |
| 470 |
'min' => 0, |
| 471 |
'max' => 100, |
| 472 |
], |
| 473 |
], |
| 474 |
'default' => [ |
| 475 |
'unit' => '%', |
| 476 |
'size' => '', |
| 477 |
], |
| 478 |
'selectors' => [ |
| 479 |
'{{WRAPPER}} .dynamic-offer-template-default .product-img img' => 'width: {{SIZE}}{{UNIT}};', |
| 480 |
], |
| 481 |
] |
| 482 |
); |
| 483 |
|
| 484 |
$this->add_responsive_control( |
| 485 |
'template_image_radius', |
| 486 |
[ |
| 487 |
'label' => __('Image Radius', 'wpfnl-pro'), |
| 488 |
'type' => Controls_Manager::DIMENSIONS, |
| 489 |
'size_units' => ['px', 'em', '%'], |
| 490 |
'selectors' => [ |
| 491 |
'{{WRAPPER}} .dynamic-offer-template-default .product-img img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 492 |
], |
| 493 |
'separator' => 'after', |
| 494 |
|
| 495 |
] |
| 496 |
); |
| 497 |
|
| 498 |
$this->add_control( |
| 499 |
'template_heading_style', |
| 500 |
[ |
| 501 |
'label' => __('Heading Style', 'wpfnl-pro'), |
| 502 |
'type' => Controls_Manager::HEADING, |
| 503 |
'label_block' => true, |
| 504 |
] |
| 505 |
); |
| 506 |
$this->add_control( |
| 507 |
'template_heading_color', |
| 508 |
[ |
| 509 |
'label' => __('Color', 'wpfnl-pro'), |
| 510 |
'type' => Controls_Manager::COLOR, |
| 511 |
'default' => '', |
| 512 |
'selectors' => [ |
| 513 |
'{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-title' => 'color: {{VALUE}};', |
| 514 |
], |
| 515 |
] |
| 516 |
); |
| 517 |
$this->add_group_control( |
| 518 |
Group_Control_Typography::get_type(), |
| 519 |
[ |
| 520 |
'name' => 'template_heading_typography', |
| 521 |
'label' => 'Typography', |
| 522 |
'selector' => '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-title', |
| 523 |
] |
| 524 |
); |
| 525 |
$this->add_responsive_control( |
| 526 |
'template_heading_margin', |
| 527 |
[ |
| 528 |
'label' => __('Margin', 'wpfnl-pro'), |
| 529 |
'type' => Controls_Manager::DIMENSIONS, |
| 530 |
'size_units' => ['px', 'em', '%'], |
| 531 |
'selectors' => [ |
| 532 |
'{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 533 |
], |
| 534 |
'separator' => 'after', |
| 535 |
] |
| 536 |
); |
| 537 |
|
| 538 |
|
| 539 |
// ----Template description Style----- |
| 540 |
$this->add_control( |
| 541 |
'template_description_style', |
| 542 |
[ |
| 543 |
'label' => __('Description Style', 'wpfnl-pro'), |
| 544 |
'type' => Controls_Manager::HEADING, |
| 545 |
'label_block' => true, |
| 546 |
] |
| 547 |
); |
| 548 |
|
| 549 |
$this->add_control( |
| 550 |
'template_description_color', |
| 551 |
[ |
| 552 |
'label' => __('Color', 'wpfnl-pro'), |
| 553 |
'type' => Controls_Manager::COLOR, |
| 554 |
'default' => '', |
| 555 |
'selectors' => [ |
| 556 |
'{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-description' => 'color: {{VALUE}};', |
| 557 |
], |
| 558 |
] |
| 559 |
); |
| 560 |
$this->add_group_control( |
| 561 |
Group_Control_Typography::get_type(), |
| 562 |
[ |
| 563 |
'name' => 'template_description_typography', |
| 564 |
'label' => 'Typography', |
| 565 |
'selector' => '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-description', |
| 566 |
] |
| 567 |
); |
| 568 |
$this->add_responsive_control( |
| 569 |
'template_description_margin', |
| 570 |
[ |
| 571 |
'label' => __('Margin', 'wpfnl-pro'), |
| 572 |
'type' => Controls_Manager::DIMENSIONS, |
| 573 |
'size_units' => ['px', 'em', '%'], |
| 574 |
'selectors' => [ |
| 575 |
'{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 576 |
], |
| 577 |
'separator' => 'after', |
| 578 |
] |
| 579 |
); |
| 580 |
|
| 581 |
|
| 582 |
// ----Template price Style----- |
| 583 |
$this->add_control( |
| 584 |
'template_price_style', |
| 585 |
[ |
| 586 |
'label' => __('Price Style', 'wpfnl-pro'), |
| 587 |
'type' => Controls_Manager::HEADING, |
| 588 |
'label_block' => true, |
| 589 |
] |
| 590 |
); |
| 591 |
|
| 592 |
$this->add_control( |
| 593 |
'template_price_color', |
| 594 |
[ |
| 595 |
'label' => __('Regular Price Color', 'wpfnl-pro'), |
| 596 |
'type' => Controls_Manager::COLOR, |
| 597 |
'default' => '', |
| 598 |
'selectors' => [ |
| 599 |
'{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price del bdi, .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price del' => 'color: {{VALUE}};', |
| 600 |
], |
| 601 |
] |
| 602 |
); |
| 603 |
$this->add_control( |
| 604 |
'template_discount_price_color', |
| 605 |
[ |
| 606 |
'label' => __('Discount Price Color', 'wpfnl-pro'), |
| 607 |
'type' => Controls_Manager::COLOR, |
| 608 |
'default' => '', |
| 609 |
'selectors' => [ |
| 610 |
'{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price bdi' => 'color: {{VALUE}};', |
| 611 |
], |
| 612 |
] |
| 613 |
); |
| 614 |
$this->add_group_control( |
| 615 |
Group_Control_Typography::get_type(), |
| 616 |
[ |
| 617 |
'name' => 'template_discount_price_typography', |
| 618 |
'label' => 'Discount Price Typography', |
| 619 |
'selector' => '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price bdi', |
| 620 |
] |
| 621 |
); |
| 622 |
$this->add_group_control( |
| 623 |
Group_Control_Typography::get_type(), |
| 624 |
[ |
| 625 |
'name' => 'template_price_typography', |
| 626 |
'label' => 'Regular Price Typography', |
| 627 |
'selector' => '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price del bdi, |
| 628 |
{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price', |
| 629 |
] |
| 630 |
); |
| 631 |
$this->add_responsive_control( |
| 632 |
'template_price_margin', |
| 633 |
[ |
| 634 |
'label' => __('Margin', 'wpfnl-pro'), |
| 635 |
'type' => Controls_Manager::DIMENSIONS, |
| 636 |
'size_units' => ['px', 'em', '%'], |
| 637 |
'selectors' => [ |
| 638 |
'{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 639 |
], |
| 640 |
'separator' => 'after', |
| 641 |
] |
| 642 |
); |
| 643 |
|
| 644 |
$this->end_controls_section(); |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
/** |
| 649 |
* Register Offer Button Content Control. |
| 650 |
* |
| 651 |
* @since x.x.x |
| 652 |
* @access protected |
| 653 |
*/ |
| 654 |
protected function register_offer_button_content(){ |
| 655 |
$this->start_controls_section( |
| 656 |
'section_button', |
| 657 |
array( |
| 658 |
'label' => __('Upsell/Downsell', 'wpfnl-pro'), |
| 659 |
) |
| 660 |
); |
| 661 |
|
| 662 |
$this->add_control( |
| 663 |
'offer_button_type', |
| 664 |
[ |
| 665 |
'label' => __('Select button type', 'wpfnl-pro'), |
| 666 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 667 |
'default' => 'upsell', |
| 668 |
'options' => [ |
| 669 |
'upsell' => __('Upsell', 'wpfnl-pro'), |
| 670 |
'downsell' => __('Downsell', 'wpfnl-pro'), |
| 671 |
], |
| 672 |
] |
| 673 |
); |
| 674 |
|
| 675 |
$this->add_control( |
| 676 |
'offer_type', |
| 677 |
[ |
| 678 |
'label' => __('Select button action', 'wpfnl-pro'), |
| 679 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 680 |
'default' => 'accept', |
| 681 |
'options' => array( |
| 682 |
'accept' => __('Accept', 'wpfnl-pro'), |
| 683 |
'reject' => __('Reject', 'wpfnl-pro'), |
| 684 |
) |
| 685 |
] |
| 686 |
); |
| 687 |
|
| 688 |
$this->add_control( |
| 689 |
'text', |
| 690 |
[ |
| 691 |
'label' => __('Text', 'wpfnl-pro'), |
| 692 |
'type' => Controls_Manager::TEXT, |
| 693 |
'default' => __('Accept Offer', 'wpfnl-pro'), |
| 694 |
'placeholder' => __('Accept Offer', 'wpfnl-pro'), |
| 695 |
'separator' => 'before', |
| 696 |
] |
| 697 |
); |
| 698 |
|
| 699 |
$this->add_responsive_control( |
| 700 |
'align', |
| 701 |
[ |
| 702 |
'label' => __('Alignment', 'wpfnl-pro'), |
| 703 |
'type' => Controls_Manager::CHOOSE, |
| 704 |
'options' => [ |
| 705 |
'left' => [ |
| 706 |
'title' => __('Left', 'wpfnl-pro'), |
| 707 |
'icon' => 'fa fa-align-left', |
| 708 |
], |
| 709 |
'center' => [ |
| 710 |
'title' => __('Center', 'wpfnl-pro'), |
| 711 |
'icon' => 'fa fa-align-center', |
| 712 |
], |
| 713 |
'right' => [ |
| 714 |
'title' => __('Right', 'wpfnl-pro'), |
| 715 |
'icon' => 'fa fa-align-right', |
| 716 |
], |
| 717 |
'justify' => [ |
| 718 |
'title' => __('Justified', 'wpfnl-pro'), |
| 719 |
'icon' => 'fa fa-align-justify', |
| 720 |
], |
| 721 |
], |
| 722 |
'prefix_class' => 'elementor%s-align-', |
| 723 |
'default' => '', |
| 724 |
] |
| 725 |
); |
| 726 |
|
| 727 |
$this->add_responsive_control( |
| 728 |
'size', |
| 729 |
[ |
| 730 |
'label' => __('Size', 'wpfnl-pro'), |
| 731 |
'type' => Controls_Manager::SELECT, |
| 732 |
'default' => 'sm', |
| 733 |
'options' => self::get_button_sizes(), |
| 734 |
] |
| 735 |
); |
| 736 |
|
| 737 |
$this->add_control( |
| 738 |
'upsell_downsell_button_icon', |
| 739 |
[ |
| 740 |
'label' => __('Icon', 'wpfnl'), |
| 741 |
'type' => Controls_Manager::ICONS, |
| 742 |
'fa4compatibility' => 'icon', |
| 743 |
] |
| 744 |
); |
| 745 |
|
| 746 |
$this->add_control( |
| 747 |
'upsell_downsell_button_icon_align', |
| 748 |
[ |
| 749 |
'label' => __('Icon Position', 'wpfnl-pro'), |
| 750 |
'type' => Controls_Manager::SELECT, |
| 751 |
'default' => 'left', |
| 752 |
'options' => array( |
| 753 |
'left' => __('Before', 'wpfnl-pro'), |
| 754 |
'right' => __('After', 'wpfnl-pro'), |
| 755 |
), |
| 756 |
'condition' => array( |
| 757 |
'upsell_downsell_button_icon[value]!' => '', |
| 758 |
), |
| 759 |
] |
| 760 |
); |
| 761 |
|
| 762 |
$this->add_control( |
| 763 |
'upsell_downsell_button_icon_indent', |
| 764 |
[ |
| 765 |
'label' => __('Icon Spacing', 'wpfnl'), |
| 766 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 767 |
'range' => [ |
| 768 |
'px' => [ |
| 769 |
'max' => 50, |
| 770 |
], |
| 771 |
], |
| 772 |
'condition' => [ |
| 773 |
'upsell_downsell_button_icon[value]!' => '', |
| 774 |
], |
| 775 |
'selectors' => [ |
| 776 |
'{{WRAPPER}} .elementor-button .elementor-align-icon-right' => 'margin-left: {{SIZE}}{{UNIT}};', |
| 777 |
'{{WRAPPER}} .elementor-button .elementor-align-icon-left' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 778 |
], |
| 779 |
] |
| 780 |
); |
| 781 |
|
| 782 |
$this->add_control( |
| 783 |
'view', |
| 784 |
[ |
| 785 |
'label' => __('View', 'wpfnl-pro'), |
| 786 |
'type' => Controls_Manager::HIDDEN, |
| 787 |
'default' => 'traditional', |
| 788 |
] |
| 789 |
); |
| 790 |
|
| 791 |
$get_product_type = Wpfnl_functions::get_offer_product_type( get_the_ID() ); |
| 792 |
|
| 793 |
if( $get_product_type == 'variable' || $get_product_type == 'variable-subscription' ){ |
| 794 |
$this->add_control( |
| 795 |
'variation_tbl_title', |
| 796 |
[ |
| 797 |
'label' => __('Variation Table Title', 'wpfnl-pro'), |
| 798 |
'type' => Controls_Manager::TEXTAREA, |
| 799 |
'separator' => 'before', |
| 800 |
'condition' => [ |
| 801 |
'offer_type' => 'accept', |
| 802 |
], |
| 803 |
] |
| 804 |
); |
| 805 |
} |
| 806 |
|
| 807 |
$this->add_control( |
| 808 |
'show_product_price', |
| 809 |
[ |
| 810 |
'label' => esc_html__( 'Show Product Price', 'wpfnl-pro' ), |
| 811 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 812 |
'label_on' => esc_html__( 'Show', 'wpfnl-pro' ), |
| 813 |
'label_off' => esc_html__( 'Hide', 'wpfnl-pro' ), |
| 814 |
'return_value' => 'yes', |
| 815 |
'default' => 'no', |
| 816 |
'condition' => [ |
| 817 |
'offer_type' => 'accept', |
| 818 |
], |
| 819 |
] |
| 820 |
); |
| 821 |
|
| 822 |
$this->add_control( |
| 823 |
'product_price_alignment', |
| 824 |
[ |
| 825 |
'label' => __('Price Alignment ', 'wpfnl-pro'), |
| 826 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 827 |
'default' => '', |
| 828 |
'options' => [ |
| 829 |
'' => __('On The Left Of Button', 'wpfnl-pro'), |
| 830 |
'price-right' => __('On The Right Of Button', 'wpfnl-pro'), |
| 831 |
'price-top' => __('Above The Button', 'wpfnl-pro'), |
| 832 |
'price-bottom' => __('Below The Button', 'wpfnl-pro'), |
| 833 |
], |
| 834 |
'condition' => [ |
| 835 |
'show_product_price' => 'yes', |
| 836 |
], |
| 837 |
|
| 838 |
] |
| 839 |
); |
| 840 |
|
| 841 |
$funnel_id = get_post_meta( get_the_ID(), '_funnel_id', true ); |
| 842 |
$is_gbf = get_post_meta( $funnel_id, 'is_global_funnel', true ); |
| 843 |
|
| 844 |
if( 'yes' === $is_gbf ){ |
| 845 |
$this->add_control( |
| 846 |
'show_product_data', |
| 847 |
[ |
| 848 |
'label' => esc_html__( 'Show Product Data', 'wpfnl-pro' ), |
| 849 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 850 |
'label_on' => esc_html__( 'Show', 'wpfnl-pro' ), |
| 851 |
'label_off' => esc_html__( 'Hide', 'wpfnl-pro' ), |
| 852 |
'return_value' => 'yes', |
| 853 |
'default' => 'off', |
| 854 |
'condition' => [ |
| 855 |
'offer_type' => 'accept', |
| 856 |
], |
| 857 |
] |
| 858 |
); |
| 859 |
} |
| 860 |
|
| 861 |
// Subtitle Settings |
| 862 |
$this->add_control( |
| 863 |
'enable_subtitle', |
| 864 |
[ |
| 865 |
'label' => __( 'Enable Subtitle', 'wpfnl-pro' ), |
| 866 |
'type' => Controls_Manager::SWITCHER, |
| 867 |
'label_on' => __( 'Yes', 'wpfnl-pro' ), |
| 868 |
'label_off' => __( 'No', 'wpfnl-pro' ), |
| 869 |
'return_value' => 'yes', |
| 870 |
'default' => 'no', |
| 871 |
'separator' => 'before', |
| 872 |
] |
| 873 |
); |
| 874 |
|
| 875 |
$this->add_control( |
| 876 |
'subtitle_text', |
| 877 |
[ |
| 878 |
'label' => __( 'Subtitle Text', 'wpfnl-pro' ), |
| 879 |
'type' => Controls_Manager::TEXT, |
| 880 |
'default' => __( 'Click to continue', 'wpfnl-pro' ), |
| 881 |
'placeholder' => __( 'Enter subtitle text', 'wpfnl-pro' ), |
| 882 |
'condition' => [ |
| 883 |
'enable_subtitle' => 'yes', |
| 884 |
], |
| 885 |
] |
| 886 |
); |
| 887 |
|
| 888 |
$this->end_controls_section(); |
| 889 |
|
| 890 |
} |
| 891 |
|
| 892 |
|
| 893 |
/** |
| 894 |
* Register Offer Button Display Conditions Control. |
| 895 |
* |
| 896 |
* @since x.x.x |
| 897 |
* @access protected |
| 898 |
*/ |
| 899 |
protected function register_offer_button_display_conditions() { |
| 900 |
|
| 901 |
$this->start_controls_section( |
| 902 |
'section_display_conditions', |
| 903 |
[ |
| 904 |
'label' => __( 'Display Conditions', 'wpfnl-pro' ), |
| 905 |
] |
| 906 |
); |
| 907 |
|
| 908 |
$this->add_control( |
| 909 |
'display_condition_type', |
| 910 |
[ |
| 911 |
'label' => __( 'Display Condition', 'wpfnl-pro' ), |
| 912 |
'type' => Controls_Manager::SELECT, |
| 913 |
'default' => 'none', |
| 914 |
'options' => [ |
| 915 |
'none' => __( 'None', 'wpfnl-pro' ), |
| 916 |
'user_state' => __( 'User State', 'wpfnl-pro' ), |
| 917 |
'user_role' => __( 'User Role', 'wpfnl-pro' ), |
| 918 |
'browser' => __( 'Browser', 'wpfnl-pro' ), |
| 919 |
'operating_system' => __( 'Operating System', 'wpfnl-pro' ), |
| 920 |
'day' => __( 'Day', 'wpfnl-pro' ), |
| 921 |
], |
| 922 |
] |
| 923 |
); |
| 924 |
|
| 925 |
// User State |
| 926 |
$this->add_control( |
| 927 |
'hide_from_logged_in', |
| 928 |
[ |
| 929 |
'label' => __( 'Hide From Logged In User', 'wpfnl-pro' ), |
| 930 |
'type' => Controls_Manager::SWITCHER, |
| 931 |
'label_on' => __( 'Yes', 'wpfnl-pro' ), |
| 932 |
'label_off' => __( 'No', 'wpfnl-pro' ), |
| 933 |
'return_value' => 'yes', |
| 934 |
'default' => 'no', |
| 935 |
'condition' => [ 'display_condition_type' => 'user_state' ], |
| 936 |
] |
| 937 |
); |
| 938 |
|
| 939 |
$this->add_control( |
| 940 |
'hide_from_logged_out', |
| 941 |
[ |
| 942 |
'label' => __( 'Hide From Logged Out User', 'wpfnl-pro' ), |
| 943 |
'type' => Controls_Manager::SWITCHER, |
| 944 |
'label_on' => __( 'Yes', 'wpfnl-pro' ), |
| 945 |
'label_off' => __( 'No', 'wpfnl-pro' ), |
| 946 |
'return_value' => 'yes', |
| 947 |
'default' => 'no', |
| 948 |
'condition' => [ 'display_condition_type' => 'user_state' ], |
| 949 |
] |
| 950 |
); |
| 951 |
|
| 952 |
// User Role |
| 953 |
$this->add_control( |
| 954 |
'hide_for_user_role', |
| 955 |
[ |
| 956 |
'label' => __( 'Hide For User Role', 'wpfnl-pro' ), |
| 957 |
'type' => Controls_Manager::SELECT, |
| 958 |
'default' => 'none', |
| 959 |
'options' => $this->get_user_roles_for_offer(), |
| 960 |
'condition' => [ 'display_condition_type' => 'user_role' ], |
| 961 |
] |
| 962 |
); |
| 963 |
|
| 964 |
// Browser |
| 965 |
$this->add_control( |
| 966 |
'hide_on_browser', |
| 967 |
[ |
| 968 |
'label' => __( 'Hide On Browser', 'wpfnl-pro' ), |
| 969 |
'type' => Controls_Manager::SELECT, |
| 970 |
'default' => 'none', |
| 971 |
'options' => [ |
| 972 |
'none' => __( 'None', 'wpfnl-pro' ), |
| 973 |
'mozilla' => __( 'Mozilla Firefox', 'wpfnl-pro' ), |
| 974 |
'chrome' => __( 'Google Chrome', 'wpfnl-pro' ), |
| 975 |
'opera_mini' => __( 'Opera Mini', 'wpfnl-pro' ), |
| 976 |
'safari' => __( 'Safari', 'wpfnl-pro' ), |
| 977 |
'edge' => __( 'Microsoft Edge', 'wpfnl-pro' ), |
| 978 |
], |
| 979 |
'condition' => [ 'display_condition_type' => 'browser' ], |
| 980 |
] |
| 981 |
); |
| 982 |
|
| 983 |
// Operating System |
| 984 |
$this->add_control( |
| 985 |
'hide_on_os', |
| 986 |
[ |
| 987 |
'label' => __( 'Hide On Operating System', 'wpfnl-pro' ), |
| 988 |
'type' => Controls_Manager::SELECT, |
| 989 |
'default' => 'none', |
| 990 |
'options' => [ |
| 991 |
'none' => __( 'None', 'wpfnl-pro' ), |
| 992 |
'ios' => __( 'iOS', 'wpfnl-pro' ), |
| 993 |
'android' => __( 'Android', 'wpfnl-pro' ), |
| 994 |
'windows' => __( 'Windows', 'wpfnl-pro' ), |
| 995 |
'macos' => __( 'MacOS', 'wpfnl-pro' ), |
| 996 |
'linux' => __( 'Linux', 'wpfnl-pro' ), |
| 997 |
'sunos' => __( 'SunOS', 'wpfnl-pro' ), |
| 998 |
'openbsd' => __( 'OpenBSD', 'wpfnl-pro' ), |
| 999 |
], |
| 1000 |
'condition' => [ 'display_condition_type' => 'operating_system' ], |
| 1001 |
] |
| 1002 |
); |
| 1003 |
|
| 1004 |
// Day |
| 1005 |
$this->add_control( |
| 1006 |
'disable_on_days', |
| 1007 |
[ |
| 1008 |
'label' => __( 'Select Days You Want To Disable', 'wpfnl-pro' ), |
| 1009 |
'type' => Controls_Manager::SELECT2, |
| 1010 |
'multiple' => true, |
| 1011 |
'options' => [ |
| 1012 |
'monday' => __( 'Monday', 'wpfnl-pro' ), |
| 1013 |
'tuesday' => __( 'Tuesday', 'wpfnl-pro' ), |
| 1014 |
'wednesday' => __( 'Wednesday', 'wpfnl-pro' ), |
| 1015 |
'thursday' => __( 'Thursday', 'wpfnl-pro' ), |
| 1016 |
'friday' => __( 'Friday', 'wpfnl-pro' ), |
| 1017 |
'saturday' => __( 'Saturday', 'wpfnl-pro' ), |
| 1018 |
'sunday' => __( 'Sunday', 'wpfnl-pro' ), |
| 1019 |
], |
| 1020 |
'condition' => [ 'display_condition_type' => 'day' ], |
| 1021 |
] |
| 1022 |
); |
| 1023 |
|
| 1024 |
$this->end_controls_section(); |
| 1025 |
} |
| 1026 |
|
| 1027 |
/** |
| 1028 |
* Get WordPress user roles for display condition. |
| 1029 |
* |
| 1030 |
* @return array |
| 1031 |
*/ |
| 1032 |
protected function get_user_roles_for_offer() { |
| 1033 |
$roles = [ 'none' => __( 'None', 'wpfnl-pro' ) ]; |
| 1034 |
|
| 1035 |
if ( ! function_exists( 'get_editable_roles' ) ) { |
| 1036 |
require_once ABSPATH . 'wp-admin/includes/user.php'; |
| 1037 |
} |
| 1038 |
|
| 1039 |
foreach ( get_editable_roles() as $role_key => $role_info ) { |
| 1040 |
$roles[ $role_key ] = $role_info['name']; |
| 1041 |
} |
| 1042 |
|
| 1043 |
return $roles; |
| 1044 |
} |
| 1045 |
|
| 1046 |
/** |
| 1047 |
* Register Offer Button Style Control. |
| 1048 |
* |
| 1049 |
* @since x.x.x |
| 1050 |
* @access protected |
| 1051 |
*/ |
| 1052 |
protected function register_offer_button_style(){ |
| 1053 |
|
| 1054 |
$this->start_controls_section( |
| 1055 |
'button_section_style', |
| 1056 |
[ |
| 1057 |
'label' => __('Button', 'wpfnl-pro'), |
| 1058 |
'tab' => Controls_Manager::TAB_STYLE, |
| 1059 |
] |
| 1060 |
); |
| 1061 |
|
| 1062 |
$this->add_group_control( |
| 1063 |
Group_Control_Typography::get_type(), |
| 1064 |
[ |
| 1065 |
'name' => 'upsell_downsell_button_typography', |
| 1066 |
'label' => 'Typography', |
| 1067 |
'selector' => '{{WRAPPER}} a.elementor-button', |
| 1068 |
] |
| 1069 |
); |
| 1070 |
|
| 1071 |
$this->add_group_control( |
| 1072 |
Group_Control_Text_Shadow::get_type(), |
| 1073 |
[ |
| 1074 |
'name' => 'upsell_downsell_button_text_shadow', |
| 1075 |
'selector' => '{{WRAPPER}} a.elementor-button', |
| 1076 |
] |
| 1077 |
); |
| 1078 |
|
| 1079 |
$this->start_controls_tabs('tabs_button_style'); |
| 1080 |
|
| 1081 |
$this->start_controls_tab( |
| 1082 |
'tab_button_normal', |
| 1083 |
[ |
| 1084 |
'label' => __('Normal', 'wpfnl-pro'), |
| 1085 |
] |
| 1086 |
); |
| 1087 |
|
| 1088 |
$this->add_control( |
| 1089 |
'button_text_color', |
| 1090 |
[ |
| 1091 |
'label' => __('Text Color', 'wpfnl-pro'), |
| 1092 |
'type' => Controls_Manager::COLOR, |
| 1093 |
'default' => '', |
| 1094 |
'selectors' => [ |
| 1095 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'color: {{VALUE}};', |
| 1096 |
], |
| 1097 |
] |
| 1098 |
); |
| 1099 |
|
| 1100 |
$this->add_control( |
| 1101 |
'background_color', |
| 1102 |
[ |
| 1103 |
'label' => __('Background Color', 'wpfnl-pro'), |
| 1104 |
'type' => Controls_Manager::COLOR, |
| 1105 |
'default' => '#61CE70', |
| 1106 |
'selectors' => [ |
| 1107 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'background-color: {{VALUE}};', |
| 1108 |
], |
| 1109 |
] |
| 1110 |
); |
| 1111 |
|
| 1112 |
$this->end_controls_tab(); |
| 1113 |
|
| 1114 |
$this->start_controls_tab( |
| 1115 |
'tab_button_hover', |
| 1116 |
[ |
| 1117 |
'label' => __('Hover', 'wpfnl-pro'), |
| 1118 |
] |
| 1119 |
); |
| 1120 |
|
| 1121 |
$this->add_control( |
| 1122 |
'hover_color', |
| 1123 |
[ |
| 1124 |
'label' => __('Text Color', 'wpfnl-pro'), |
| 1125 |
'type' => Controls_Manager::COLOR, |
| 1126 |
'selectors' => [ |
| 1127 |
'{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'color: {{VALUE}};', |
| 1128 |
], |
| 1129 |
] |
| 1130 |
); |
| 1131 |
|
| 1132 |
$this->add_control( |
| 1133 |
'button_background_hover_color', |
| 1134 |
[ |
| 1135 |
'label' => __('Background Color', 'wpfnl-pro'), |
| 1136 |
'type' => Controls_Manager::COLOR, |
| 1137 |
'selectors' => [ |
| 1138 |
'{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'background-color: {{VALUE}};', |
| 1139 |
], |
| 1140 |
] |
| 1141 |
); |
| 1142 |
|
| 1143 |
$this->add_control( |
| 1144 |
'button_hover_border_color', |
| 1145 |
[ |
| 1146 |
'label' => __('Border Color', 'wpfnl-pro'), |
| 1147 |
'type' => Controls_Manager::COLOR, |
| 1148 |
'condition' => [ |
| 1149 |
'border_border!' => '', |
| 1150 |
], |
| 1151 |
'selectors' => [ |
| 1152 |
'{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};', |
| 1153 |
], |
| 1154 |
] |
| 1155 |
); |
| 1156 |
|
| 1157 |
$this->end_controls_tab(); |
| 1158 |
|
| 1159 |
$this->end_controls_tabs(); |
| 1160 |
|
| 1161 |
$this->add_group_control( |
| 1162 |
Group_Control_Border::get_type(), |
| 1163 |
[ |
| 1164 |
'name' => 'border', |
| 1165 |
'label' => __('Border', 'wpfnl-pro'), |
| 1166 |
'placeholder' => '1px', |
| 1167 |
'default' => '1px', |
| 1168 |
'selector' => '{{WRAPPER}} .elementor-button', |
| 1169 |
'separator' => 'before', |
| 1170 |
] |
| 1171 |
); |
| 1172 |
|
| 1173 |
$this->add_control( |
| 1174 |
'border_radius', |
| 1175 |
[ |
| 1176 |
'label' => __('Border Radius', 'wpfnl-pro'), |
| 1177 |
'type' => Controls_Manager::DIMENSIONS, |
| 1178 |
'size_units' => ['px', '%'], |
| 1179 |
'selectors' => [ |
| 1180 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 1181 |
], |
| 1182 |
] |
| 1183 |
); |
| 1184 |
|
| 1185 |
$this->add_group_control( |
| 1186 |
Group_Control_Box_Shadow::get_type(), |
| 1187 |
[ |
| 1188 |
'name' => 'button_box_shadow', |
| 1189 |
'selector' => '{{WRAPPER}} .elementor-button', |
| 1190 |
] |
| 1191 |
); |
| 1192 |
|
| 1193 |
$this->add_responsive_control( |
| 1194 |
'upsell_downsell_padding', |
| 1195 |
[ |
| 1196 |
'label' => __('Padding', 'wpfnl-pro'), |
| 1197 |
'type' => Controls_Manager::DIMENSIONS, |
| 1198 |
'size_units' => ['px', 'em', '%'], |
| 1199 |
'selectors' => [ |
| 1200 |
'{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 1201 |
], |
| 1202 |
'separator' => 'before', |
| 1203 |
] |
| 1204 |
); |
| 1205 |
|
| 1206 |
$this->end_controls_section(); |
| 1207 |
|
| 1208 |
// Subtitle Style Section |
| 1209 |
$this->start_controls_section( |
| 1210 |
'section_subtitle_style', |
| 1211 |
[ |
| 1212 |
'label' => __( 'Subtitle', 'wpfnl-pro' ), |
| 1213 |
'tab' => Controls_Manager::TAB_STYLE, |
| 1214 |
'condition' => [ |
| 1215 |
'enable_subtitle' => 'yes', |
| 1216 |
], |
| 1217 |
] |
| 1218 |
); |
| 1219 |
|
| 1220 |
$this->add_group_control( |
| 1221 |
Group_Control_Typography::get_type(), |
| 1222 |
[ |
| 1223 |
'name' => 'subtitle_typography', |
| 1224 |
'label' => __( 'Typography', 'wpfnl-pro' ), |
| 1225 |
'selector' => '{{WRAPPER}} .wpfnl-button-subtitle', |
| 1226 |
] |
| 1227 |
); |
| 1228 |
|
| 1229 |
$this->add_responsive_control( |
| 1230 |
'subtitle_spacing', |
| 1231 |
[ |
| 1232 |
'label' => __( 'Spacing', 'wpfnl-pro' ), |
| 1233 |
'type' => Controls_Manager::SLIDER, |
| 1234 |
'range' => [ |
| 1235 |
'px' => [ 'min' => 0, 'max' => 50 ], |
| 1236 |
], |
| 1237 |
'selectors' => [ |
| 1238 |
'{{WRAPPER}} .wpfnl-button-subtitle' => 'margin-top: {{SIZE}}{{UNIT}};', |
| 1239 |
], |
| 1240 |
] |
| 1241 |
); |
| 1242 |
|
| 1243 |
$this->end_controls_section(); |
| 1244 |
|
| 1245 |
} |
| 1246 |
|
| 1247 |
|
| 1248 |
public function get_prev_next_link_options() |
| 1249 |
{ |
| 1250 |
$associate_funnel_id = get_post_meta(get_the_ID(), '_funnel_id', true); |
| 1251 |
$steps_array = [ |
| 1252 |
'upsell' => 'Upsell', |
| 1253 |
'downsell' => 'Downsell', |
| 1254 |
'thankyou' => 'Thankyou' |
| 1255 |
]; |
| 1256 |
$option_group = []; |
| 1257 |
foreach ($steps_array as $key => $value) { |
| 1258 |
$args = [ |
| 1259 |
'posts_per_page' => -1, |
| 1260 |
'orderby' => 'date', |
| 1261 |
'order' => 'DESC', |
| 1262 |
'post_type' => WPFNL_STEPS_POST_TYPE, |
| 1263 |
'post_status' => 'publish', |
| 1264 |
'post__not_in' => [$this->get_id()], |
| 1265 |
'meta_query' => [ |
| 1266 |
'relation' => 'AND', |
| 1267 |
[ |
| 1268 |
'key' => '_step_type', |
| 1269 |
'value' => $key, |
| 1270 |
'compare' => '=', |
| 1271 |
], |
| 1272 |
[ |
| 1273 |
'key' => '_funnel_id', |
| 1274 |
'value' => $associate_funnel_id, |
| 1275 |
'compare' => '=', |
| 1276 |
], |
| 1277 |
], |
| 1278 |
]; |
| 1279 |
$query = new \WP_Query($args); |
| 1280 |
$steps = $query->posts; |
| 1281 |
if ($steps) { |
| 1282 |
foreach ($steps as $s) { |
| 1283 |
$option_group[$key][] = [ |
| 1284 |
'id' => $s->ID, |
| 1285 |
'title' => $s->post_title, |
| 1286 |
]; |
| 1287 |
} |
| 1288 |
} |
| 1289 |
} |
| 1290 |
return $option_group; |
| 1291 |
} |
| 1292 |
|
| 1293 |
/** |
| 1294 |
* Get all WC products |
| 1295 |
* @since 1.0.0 |
| 1296 |
* |
| 1297 |
* @access protected |
| 1298 |
*/ |
| 1299 |
protected function get_products_array() |
| 1300 |
{ |
| 1301 |
$products = array(); |
| 1302 |
if (in_array('woocommerce/woocommerce.php', WPFNL_ACTIVE_PLUGINS)) { |
| 1303 |
$ids = wc_get_products(array('return' => 'ids', 'limit' => -1)); |
| 1304 |
if( !empty($ids) ){ |
| 1305 |
foreach ($ids as $id) { |
| 1306 |
$title = get_the_title($id); |
| 1307 |
$products[$id] = $title; |
| 1308 |
} |
| 1309 |
} |
| 1310 |
} |
| 1311 |
return $products; |
| 1312 |
} |
| 1313 |
|
| 1314 |
/** |
| 1315 |
* Get all funnel steps |
| 1316 |
* @since 1.0.0 |
| 1317 |
* |
| 1318 |
* @access protected |
| 1319 |
*/ |
| 1320 |
protected function get_steps_array($type = 'upsell') |
| 1321 |
{ |
| 1322 |
$options = $this->get_prev_next_link_options(); |
| 1323 |
$response = array(); |
| 1324 |
if (isset($options[$type])) { |
| 1325 |
$prime_data = $options[$type]; |
| 1326 |
foreach ($prime_data as $data) { |
| 1327 |
$response[$data['id']] = $data['title']; |
| 1328 |
} |
| 1329 |
} |
| 1330 |
|
| 1331 |
return $response; |
| 1332 |
} |
| 1333 |
|
| 1334 |
/** |
| 1335 |
* Render the widget output on the frontend. |
| 1336 |
* |
| 1337 |
* Written in PHP and used to generate the final HTML. |
| 1338 |
* |
| 1339 |
* @since 1.0.0 |
| 1340 |
* |
| 1341 |
* @access protected |
| 1342 |
*/ |
| 1343 |
protected function render() |
| 1344 |
{ |
| 1345 |
|
| 1346 |
$settings = $this->get_settings(); |
| 1347 |
$this->add_render_attribute('wrapper', 'class', 'elementor-button-wrapper'); |
| 1348 |
|
| 1349 |
$this->add_render_attribute('button', 'class', 'elementor-button'); |
| 1350 |
$this->add_render_attribute( |
| 1351 |
'button', |
| 1352 |
array( |
| 1353 |
'id' => ['wpfunnels_'.$settings['offer_button_type'].'_'.$settings['offer_type']], |
| 1354 |
'class' => [ 'wpfunnels-elementor-widget', 'wpfunnels_offer_button' ], |
| 1355 |
) |
| 1356 |
); |
| 1357 |
|
| 1358 |
if (!empty($settings['size'])) { |
| 1359 |
$this->add_render_attribute('button', 'class', 'elementor-size-' . $settings['size']); |
| 1360 |
} |
| 1361 |
|
| 1362 |
// Add subtitle class if enabled |
| 1363 |
$enable_subtitle = isset( $settings['enable_subtitle'] ) ? $settings['enable_subtitle'] : 'no'; |
| 1364 |
$subtitle_text = isset( $settings['subtitle_text'] ) ? $settings['subtitle_text'] : ''; |
| 1365 |
if ( 'yes' === $enable_subtitle && ! empty( $subtitle_text ) && 'accept' === $settings['offer_type'] ) { |
| 1366 |
$this->add_render_attribute('button', 'class', 'wpfnl-has-subtitle'); |
| 1367 |
} |
| 1368 |
|
| 1369 |
if ( isset($settings['hover_animation']) && $settings['hover_animation']) { |
| 1370 |
$this->add_render_attribute('button', 'class', 'elementor-animation-' . $settings['hover_animation']); |
| 1371 |
} |
| 1372 |
$response = Wpfnl_functions::get_product_data_for_widget( get_the_ID() ); |
| 1373 |
$offer_product = isset($response['offer_product']) && $response['offer_product'] ? $response['offer_product'] : ''; |
| 1374 |
$get_product_type = isset($response['get_product_type']) && $response['get_product_type'] ? $response['get_product_type'] : ''; |
| 1375 |
$is_gbf = isset($response['is_gbf']) && $response['is_gbf'] ? $response['is_gbf'] : ''; |
| 1376 |
$builder = 'elementor'; |
| 1377 |
|
| 1378 |
// ---- Display Conditions ---- |
| 1379 |
$display_condition = isset( $settings['display_condition_type'] ) ? $settings['display_condition_type'] : 'none'; |
| 1380 |
|
| 1381 |
if ( $display_condition === 'user_state' ) { |
| 1382 |
$hide_logged_in = isset( $settings['hide_from_logged_in'] ) ? $settings['hide_from_logged_in'] : 'no'; |
| 1383 |
$hide_logged_out = isset( $settings['hide_from_logged_out'] ) ? $settings['hide_from_logged_out'] : 'no'; |
| 1384 |
|
| 1385 |
if ( $hide_logged_in === 'yes' && is_user_logged_in() ) { |
| 1386 |
return; |
| 1387 |
} |
| 1388 |
if ( $hide_logged_out === 'yes' && ! is_user_logged_in() ) { |
| 1389 |
return; |
| 1390 |
} |
| 1391 |
|
| 1392 |
} elseif ( $display_condition === 'user_role' ) { |
| 1393 |
$hide_for_user_role = isset( $settings['hide_for_user_role'] ) ? $settings['hide_for_user_role'] : 'none'; |
| 1394 |
|
| 1395 |
if ( $hide_for_user_role !== 'none' && is_user_logged_in() ) { |
| 1396 |
$user = wp_get_current_user(); |
| 1397 |
if ( in_array( $hide_for_user_role, $user->roles ) ) { |
| 1398 |
return; |
| 1399 |
} |
| 1400 |
} |
| 1401 |
|
| 1402 |
} elseif ( $display_condition === 'day' ) { |
| 1403 |
$disable_on_days = isset( $settings['disable_on_days'] ) ? $settings['disable_on_days'] : array(); |
| 1404 |
|
| 1405 |
if ( ! empty( $disable_on_days ) && is_array( $disable_on_days ) ) { |
| 1406 |
$current_day = strtolower( date( 'l' ) ); |
| 1407 |
if ( in_array( $current_day, $disable_on_days ) ) { |
| 1408 |
return; |
| 1409 |
} |
| 1410 |
} |
| 1411 |
|
| 1412 |
} elseif ( $display_condition === 'browser' ) { |
| 1413 |
$hide_on_browser = isset( $settings['hide_on_browser'] ) ? $settings['hide_on_browser'] : 'none'; |
| 1414 |
|
| 1415 |
if ( $hide_on_browser !== 'none' ) { |
| 1416 |
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; |
| 1417 |
$current_browser = ''; |
| 1418 |
|
| 1419 |
if ( strpos( $user_agent, 'edg' ) !== false ) { |
| 1420 |
$current_browser = 'edge'; |
| 1421 |
} elseif ( strpos( $user_agent, 'opr' ) !== false || strpos( $user_agent, 'opera' ) !== false ) { |
| 1422 |
$current_browser = 'opera_mini'; |
| 1423 |
} elseif ( strpos( $user_agent, 'chrome' ) !== false ) { |
| 1424 |
$current_browser = 'chrome'; |
| 1425 |
} elseif ( strpos( $user_agent, 'safari' ) !== false ) { |
| 1426 |
$current_browser = 'safari'; |
| 1427 |
} elseif ( strpos( $user_agent, 'firefox' ) !== false ) { |
| 1428 |
$current_browser = 'mozilla'; |
| 1429 |
} |
| 1430 |
|
| 1431 |
if ( $current_browser === $hide_on_browser ) { |
| 1432 |
return; |
| 1433 |
} |
| 1434 |
} |
| 1435 |
|
| 1436 |
} elseif ( $display_condition === 'operating_system' ) { |
| 1437 |
$hide_on_os = isset( $settings['hide_on_os'] ) ? $settings['hide_on_os'] : 'none'; |
| 1438 |
|
| 1439 |
if ( $hide_on_os !== 'none' ) { |
| 1440 |
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; |
| 1441 |
$current_os = ''; |
| 1442 |
|
| 1443 |
if ( strpos( $user_agent, 'windows' ) !== false || strpos( $user_agent, 'win32' ) !== false || strpos( $user_agent, 'win64' ) !== false ) { |
| 1444 |
$current_os = 'windows'; |
| 1445 |
} elseif ( strpos( $user_agent, 'macintosh' ) !== false || strpos( $user_agent, 'mac os x' ) !== false ) { |
| 1446 |
$current_os = 'macos'; |
| 1447 |
} elseif ( strpos( $user_agent, 'linux' ) !== false && strpos( $user_agent, 'android' ) === false ) { |
| 1448 |
$current_os = 'linux'; |
| 1449 |
} elseif ( strpos( $user_agent, 'android' ) !== false ) { |
| 1450 |
$current_os = 'android'; |
| 1451 |
} elseif ( strpos( $user_agent, 'iphone' ) !== false || strpos( $user_agent, 'ipad' ) !== false || strpos( $user_agent, 'ipod' ) !== false ) { |
| 1452 |
$current_os = 'ios'; |
| 1453 |
} elseif ( strpos( $user_agent, 'sunos' ) !== false ) { |
| 1454 |
$current_os = 'sunos'; |
| 1455 |
} elseif ( strpos( $user_agent, 'openbsd' ) !== false ) { |
| 1456 |
$current_os = 'openbsd'; |
| 1457 |
} |
| 1458 |
|
| 1459 |
if ( $current_os === $hide_on_os ) { |
| 1460 |
return; |
| 1461 |
} |
| 1462 |
} |
| 1463 |
} |
| 1464 |
// ---- End Display Conditions ---- |
| 1465 |
|
| 1466 |
if( 'yes' == $is_gbf && $settings['show_product_data'] == 'yes' && $settings['offer_type'] == 'accept' ){ |
| 1467 |
require WPFNL_DIR . 'public/modules/dynamic-offer-templates/styles/offer-' . $settings['dynamic_data_template_layout'] . '.php'; |
| 1468 |
}else{ |
| 1469 |
require WPFNL_DIR . 'public/modules/dynamic-offer-templates/elementor/offer-button.php'; |
| 1470 |
} |
| 1471 |
|
| 1472 |
} |
| 1473 |
|
| 1474 |
/** |
| 1475 |
* Render button text. |
| 1476 |
* |
| 1477 |
* Render button widget text. |
| 1478 |
* |
| 1479 |
* @since 1.5.0 |
| 1480 |
* @access protected |
| 1481 |
*/ |
| 1482 |
protected function render_text() |
| 1483 |
{ |
| 1484 |
$settings = $this->get_settings(); |
| 1485 |
|
| 1486 |
$migrated = isset($settings['__fa4_migrated']['upsell_downsell_button_icon']); |
| 1487 |
$is_new = empty($settings['icon']) && Icons_Manager::is_migration_allowed(); |
| 1488 |
|
| 1489 |
if (!$is_new && empty($settings['upsell_downsell_button_icon_align'])) { |
| 1490 |
$settings['upsell_downsell_button_icon_align'] = $this->get_settings('upsell_downsell_button_icon_align'); |
| 1491 |
} |
| 1492 |
|
| 1493 |
$this->add_render_attribute([ |
| 1494 |
'content-wrapper' => [ |
| 1495 |
'class' => 'elementor-button-content-wrapper', |
| 1496 |
], |
| 1497 |
'icon-align' => [ |
| 1498 |
'class' => [ |
| 1499 |
'elementor-button-icon', |
| 1500 |
'elementor-align-icon-' . $settings['upsell_downsell_button_icon_align'], |
| 1501 |
], |
| 1502 |
], |
| 1503 |
'text' => [ |
| 1504 |
'class' => 'elementor-button-text', |
| 1505 |
], |
| 1506 |
]); |
| 1507 |
|
| 1508 |
$this->add_render_attribute('content-wrapper', 'class', 'elementor-button-content-wrapper'); |
| 1509 |
$this->add_render_attribute('text', 'class', 'elementor-button-text'); |
| 1510 |
$this->add_inline_editing_attributes('text', 'none'); |
| 1511 |
?> |
| 1512 |
<span <?php echo $this->get_render_attribute_string('content-wrapper'); ?> style="<?php echo $settings['upsell_downsell_button_icon_align'] === 'right' ? 'flex-direction: row-reverse' : '' ?>"> |
| 1513 |
<?php if (!empty($settings['icon']) || !empty($settings['upsell_downsell_button_icon']['value'])) : ?> |
| 1514 |
<span <?php echo $this->get_render_attribute_string('icon-align'); ?>> |
| 1515 |
<?php if ($is_new || $migrated) : |
| 1516 |
Icons_Manager::render_icon($settings['upsell_downsell_button_icon'], ['aria-hidden' => 'true']); |
| 1517 |
else : ?> |
| 1518 |
<i class="<?php echo esc_attr($settings['icon']); ?>" aria-hidden="true"></i> |
| 1519 |
<?php endif; ?> |
| 1520 |
</span> |
| 1521 |
<?php endif; ?> |
| 1522 |
<span <?php echo $this->get_render_attribute_string('text'); ?>><?php echo $settings['text']; ?></span> |
| 1523 |
</span> |
| 1524 |
<?php |
| 1525 |
} |
| 1526 |
} |