| 1 |
<?php |
| 2 |
|
| 3 |
namespace King_Addons; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use Elementor\Core\Base\Document; |
| 7 |
use Elementor\Group_Control_Background; |
| 8 |
use Elementor\Group_Control_Border; |
| 9 |
use Elementor\Group_Control_Box_Shadow; |
| 10 |
use Elementor\Plugin; |
| 11 |
use Elementor\Utils; |
| 12 |
|
| 13 |
if (!defined('ABSPATH')) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
class King_Addons_Popup_Module extends Document |
| 18 |
{ |
| 19 |
|
| 20 |
public function get_name(): string |
| 21 |
{ |
| 22 |
return 'king-addons-pb-popups'; |
| 23 |
} |
| 24 |
|
| 25 |
public static function get_type(): string |
| 26 |
{ |
| 27 |
return 'king-addons-pb-popups'; |
| 28 |
} |
| 29 |
|
| 30 |
public static function get_title(): string |
| 31 |
{ |
| 32 |
return esc_html__('Popup Builder by King Addons', 'king-addons'); |
| 33 |
} |
| 34 |
|
| 35 |
public function get_css_wrapper_selector(): string |
| 36 |
{ |
| 37 |
if (Plugin::$instance->editor->is_edit_mode()) { |
| 38 |
return '.king-addons-pb-template-popup'; |
| 39 |
} else { |
| 40 |
return '#king-addons-pb-popup-id-' . $this->get_main_id(); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
public function add_control_popup_trigger() |
| 45 |
{ |
| 46 |
$this->add_control( |
| 47 |
'popup_trigger', |
| 48 |
[ |
| 49 |
'label' => '<b>' . esc_html__('Open Popup Logic', 'king-addons') . '</b>', |
| 50 |
'type' => Controls_Manager::SELECT, |
| 51 |
'default' => 'load', |
| 52 |
'label_block' => false, |
| 53 |
'options' => [ |
| 54 |
'load' => esc_html__('On Page Load', 'king-addons'), |
| 55 |
'pro-sc' => esc_html__('On Page Scroll (PRO)', 'king-addons'), |
| 56 |
'pro-es' => esc_html__('On Scroll to Element (PRO)', 'king-addons'), |
| 57 |
'pro-dt' => esc_html__('After a Specific Date (PRO)', 'king-addons'), |
| 58 |
'pro-ia' => esc_html__('After User Inactivity (PRO)', 'king-addons'), |
| 59 |
'pro-ex' => esc_html__('After User Exit Intent (PRO)', 'king-addons'), |
| 60 |
'pro-cs' => esc_html__('Custom Trigger (Button Click, CSS Selector) (PRO)', 'king-addons'), |
| 61 |
], |
| 62 |
'render_type' => 'template' |
| 63 |
] |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
public function add_control_popup_show_again_delay() |
| 68 |
{ |
| 69 |
$this->add_control( |
| 70 |
'popup_show_again_delay', |
| 71 |
[ |
| 72 |
'label' => esc_html__('Show Again Delay', 'king-addons'), |
| 73 |
'type' => Controls_Manager::SELECT, |
| 74 |
'default' => '0', |
| 75 |
'options' => [ |
| 76 |
'0' => esc_html__('No Delay', 'king-addons'), |
| 77 |
'60000' => esc_html__('1 Minute', 'king-addons'), |
| 78 |
'180000' => esc_html__('3 Minute', 'king-addons'), |
| 79 |
'300000' => esc_html__('5 Minute', 'king-addons'), |
| 80 |
'pro-60' => esc_html__('10 Minute (PRO)', 'king-addons'), |
| 81 |
'pro-180' => esc_html__('30 Minute (PRO)', 'king-addons'), |
| 82 |
'pro-360' => esc_html__('1 Hour (PRO)', 'king-addons'), |
| 83 |
'pro-1080' => esc_html__('3 Hour (PRO)', 'king-addons'), |
| 84 |
'pro-2160' => esc_html__('6 Hour (PRO)', 'king-addons'), |
| 85 |
'pro-4320' => esc_html__('12 Hour (PRO)', 'king-addons'), |
| 86 |
'pro-8640' => esc_html__('1 Day (PRO)', 'king-addons'), |
| 87 |
'pro-25920' => esc_html__('3 Days (PRO)', 'king-addons'), |
| 88 |
'pro-43200' => esc_html__('5 Days (PRO)', 'king-addons'), |
| 89 |
'pro-60480' => esc_html__('7 Days (PRO)', 'king-addons'), |
| 90 |
'pro-864000' => esc_html__('10 Days (PRO)', 'king-addons'), |
| 91 |
'pro-1296000' => esc_html__('15 Days (PRO)', 'king-addons'), |
| 92 |
'pro-1728000' => esc_html__('20 Days (PRO)', 'king-addons'), |
| 93 |
'pro-262800' => esc_html__('1 Month (PRO)', 'king-addons'), |
| 94 |
], |
| 95 |
'description' => esc_html__('This option determines when to show popup again to a visitor after it is closed.', 'king-addons'), |
| 96 |
'separator' => 'before', |
| 97 |
'render_type' => 'template' |
| 98 |
] |
| 99 |
); |
| 100 |
} |
| 101 |
|
| 102 |
public function add_controls_group_popup_settings() |
| 103 |
{ |
| 104 |
} |
| 105 |
|
| 106 |
protected function register_controls() |
| 107 |
{ |
| 108 |
|
| 109 |
$this->start_controls_section( |
| 110 |
'popup_settings', |
| 111 |
[ |
| 112 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Settings', 'king-addons'), |
| 113 |
'tab' => Controls_Manager::TAB_SETTINGS, |
| 114 |
] |
| 115 |
); |
| 116 |
|
| 117 |
$this->add_control_popup_trigger(); |
| 118 |
|
| 119 |
Core::renderUpgradeProNotice($this, Controls_Manager::RAW_HTML, 'popup-builder', 'popup_trigger', [ |
| 120 |
'pro-sc', |
| 121 |
'pro-es', |
| 122 |
'pro-dt', |
| 123 |
'pro-ia', |
| 124 |
'pro-ex', |
| 125 |
'pro-cs' |
| 126 |
]); |
| 127 |
|
| 128 |
$this->add_control( |
| 129 |
'popup_load_delay', |
| 130 |
[ |
| 131 |
'label' => esc_html__('Delay after Page Load (sec)', 'king-addons'), |
| 132 |
'type' => Controls_Manager::NUMBER, |
| 133 |
'default' => 1, |
| 134 |
'min' => 0, |
| 135 |
'condition' => [ |
| 136 |
'popup_trigger' => 'load', |
| 137 |
] |
| 138 |
] |
| 139 |
); |
| 140 |
|
| 141 |
$this->add_control( |
| 142 |
'popup_scroll_progress', |
| 143 |
[ |
| 144 |
'label' => esc_html__('Scroll Progress (in %)', 'king-addons'), |
| 145 |
'type' => Controls_Manager::NUMBER, |
| 146 |
'default' => 10, |
| 147 |
'min' => 1, |
| 148 |
'max' => 100, |
| 149 |
'condition' => [ |
| 150 |
'popup_trigger' => 'scroll', |
| 151 |
] |
| 152 |
] |
| 153 |
); |
| 154 |
|
| 155 |
$this->add_control( |
| 156 |
'popup_element_scroll', |
| 157 |
[ |
| 158 |
'label' => esc_html__('Element Selector', 'king-addons'), |
| 159 |
'description' => 'CSS ID or class name, for example: .test for class and #test for ID, i.e. including dot or hash before the name.', |
| 160 |
'type' => Controls_Manager::TEXT, |
| 161 |
'dynamic' => [ |
| 162 |
'active' => true, |
| 163 |
], |
| 164 |
'default' => '', |
| 165 |
'condition' => [ |
| 166 |
'popup_trigger' => 'element-scroll', |
| 167 |
] |
| 168 |
] |
| 169 |
); |
| 170 |
|
| 171 |
$this->add_control( |
| 172 |
'popup_specific_date', |
| 173 |
[ |
| 174 |
'label' => esc_html__('Select Date', 'king-addons'), |
| 175 |
'label_block' => false, |
| 176 |
'type' => Controls_Manager::DATE_TIME, |
| 177 |
'default' => date('Y-m-d H:i', strtotime('+1 day') + (get_option('gmt_offset') * HOUR_IN_SECONDS)), |
| 178 |
'description' => sprintf(__('Set according to your WordPress timezone: %s.', 'king-addons'), Utils::get_timezone_string()), |
| 179 |
'condition' => [ |
| 180 |
'popup_trigger' => 'date', |
| 181 |
], |
| 182 |
] |
| 183 |
); |
| 184 |
|
| 185 |
$this->add_control( |
| 186 |
'popup_custom_trigger', |
| 187 |
[ |
| 188 |
'label' => esc_html__('Element Selector', 'king-addons'), |
| 189 |
'description' => 'CSS ID or class name, for example: .test for class and #test for ID, i.e. including dot or hash before the name.', |
| 190 |
'type' => Controls_Manager::TEXT, |
| 191 |
'dynamic' => [ |
| 192 |
'active' => true, |
| 193 |
], |
| 194 |
'default' => '', |
| 195 |
'render_type' => 'template', |
| 196 |
'condition' => [ |
| 197 |
'popup_trigger' => 'custom', |
| 198 |
] |
| 199 |
] |
| 200 |
); |
| 201 |
|
| 202 |
$this->add_control( |
| 203 |
'popup_inactivity_time', |
| 204 |
[ |
| 205 |
'label' => esc_html__('Inactivity Time (sec)', 'king-addons'), |
| 206 |
'type' => Controls_Manager::NUMBER, |
| 207 |
'default' => 15, |
| 208 |
'min' => 1, |
| 209 |
'condition' => [ |
| 210 |
'popup_trigger' => 'inactivity', |
| 211 |
] |
| 212 |
] |
| 213 |
); |
| 214 |
|
| 215 |
$this->add_control_popup_show_again_delay(); |
| 216 |
|
| 217 |
Core::renderUpgradeProNotice($this, Controls_Manager::RAW_HTML, 'popup-builder', 'popup_show_again_delay', [ |
| 218 |
'pro-60', |
| 219 |
'pro-180', |
| 220 |
'pro-360', |
| 221 |
'pro-1080', |
| 222 |
'pro-2160', |
| 223 |
'pro-4320', |
| 224 |
'pro-8640', |
| 225 |
'pro-25920', |
| 226 |
'pro-43200', |
| 227 |
'pro-60480', |
| 228 |
'pro-864000', |
| 229 |
'pro-1296000', |
| 230 |
'pro-1728000', |
| 231 |
'pro-262800' |
| 232 |
]); |
| 233 |
|
| 234 |
$this->add_controls_group_popup_settings(); |
| 235 |
|
| 236 |
$this->end_controls_section(); |
| 237 |
|
| 238 |
$this->start_controls_section( |
| 239 |
'popup_layout', |
| 240 |
[ |
| 241 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Layout', 'king-addons'), |
| 242 |
'tab' => Controls_Manager::TAB_SETTINGS, |
| 243 |
] |
| 244 |
); |
| 245 |
|
| 246 |
$this->add_control( |
| 247 |
'popup_display_as', |
| 248 |
[ |
| 249 |
'label' => esc_html__('Display As', 'king-addons'), |
| 250 |
'type' => Controls_Manager::SELECT, |
| 251 |
'default' => 'modal', |
| 252 |
'options' => [ |
| 253 |
'modal' => esc_html__('Modal Popup', 'king-addons'), |
| 254 |
'notification' => esc_html__('Top Bar Banner', 'king-addons'), |
| 255 |
], |
| 256 |
] |
| 257 |
); |
| 258 |
|
| 259 |
$this->add_control( |
| 260 |
'popup_display_as_divider', |
| 261 |
[ |
| 262 |
'type' => Controls_Manager::DIVIDER, |
| 263 |
'style' => 'thick', |
| 264 |
] |
| 265 |
); |
| 266 |
|
| 267 |
$this->add_responsive_control( |
| 268 |
'popup_width', |
| 269 |
[ |
| 270 |
'label' => esc_html__('Width', 'king-addons'), |
| 271 |
'type' => Controls_Manager::SLIDER, |
| 272 |
'size_units' => ['px', '%'], |
| 273 |
'range' => [ |
| 274 |
'px' => [ |
| 275 |
'min' => 0, |
| 276 |
'max' => 1000, |
| 277 |
], |
| 278 |
'%' => [ |
| 279 |
'min' => 0, |
| 280 |
'max' => 100, |
| 281 |
], |
| 282 |
], |
| 283 |
'default' => [ |
| 284 |
'unit' => 'px', |
| 285 |
'size' => 650, |
| 286 |
], |
| 287 |
'selectors' => [ |
| 288 |
'{{WRAPPER}} .king-addons-pb-popup-container' => 'width: {{SIZE}}{{UNIT}};', |
| 289 |
], |
| 290 |
'condition' => [ |
| 291 |
'popup_display_as!' => 'notification', |
| 292 |
] |
| 293 |
] |
| 294 |
); |
| 295 |
|
| 296 |
$this->add_control( |
| 297 |
'popup_height', |
| 298 |
[ |
| 299 |
'label' => esc_html__('Height', 'king-addons'), |
| 300 |
'type' => Controls_Manager::SELECT, |
| 301 |
'default' => 'auto', |
| 302 |
'options' => [ |
| 303 |
'auto' => esc_html__('Auto', 'king-addons'), |
| 304 |
'custom' => esc_html__('Custom', 'king-addons'), |
| 305 |
], |
| 306 |
'selectors_dictionary' => [ |
| 307 |
'auto' => 'height: auto; z-index: 13;', |
| 308 |
], |
| 309 |
'selectors' => [ |
| 310 |
'{{WRAPPER}} .king-addons-pb-popup-container-inner' => '{{VALUE}}', |
| 311 |
], |
| 312 |
] |
| 313 |
); |
| 314 |
|
| 315 |
$this->add_responsive_control( |
| 316 |
'popup_custom_height', |
| 317 |
[ |
| 318 |
'label' => esc_html__('Custom Height', 'king-addons'), |
| 319 |
'type' => Controls_Manager::SLIDER, |
| 320 |
'size_units' => ['px', 'vh'], |
| 321 |
'range' => [ |
| 322 |
'px' => [ |
| 323 |
'min' => 0, |
| 324 |
'max' => 1000, |
| 325 |
], |
| 326 |
'%' => [ |
| 327 |
'min' => 0, |
| 328 |
'max' => 100, |
| 329 |
], |
| 330 |
], |
| 331 |
'default' => [ |
| 332 |
'unit' => 'px', |
| 333 |
'size' => 500, |
| 334 |
], |
| 335 |
'selectors' => [ |
| 336 |
'{{WRAPPER}} .king-addons-pb-popup-container-inner' => 'height: {{SIZE}}{{UNIT}};', |
| 337 |
], |
| 338 |
'condition' => [ |
| 339 |
'popup_height' => 'custom' |
| 340 |
] |
| 341 |
] |
| 342 |
); |
| 343 |
|
| 344 |
$this->add_responsive_control( |
| 345 |
'popup_align_hr', |
| 346 |
[ |
| 347 |
'label' => esc_html__('Horizontal Align', 'king-addons'), |
| 348 |
'type' => Controls_Manager::CHOOSE, |
| 349 |
'label_block' => false, |
| 350 |
'default' => 'center', |
| 351 |
'options' => [ |
| 352 |
'flex-start' => [ |
| 353 |
'title' => esc_html__('Left', 'king-addons'), |
| 354 |
'icon' => 'eicon-h-align-left', |
| 355 |
], |
| 356 |
'center' => [ |
| 357 |
'title' => esc_html__('Center', 'king-addons'), |
| 358 |
'icon' => 'eicon-h-align-center', |
| 359 |
], |
| 360 |
'flex-end' => [ |
| 361 |
'title' => esc_html__('Right', 'king-addons'), |
| 362 |
'icon' => 'eicon-h-align-right', |
| 363 |
] |
| 364 |
], |
| 365 |
'selectors' => [ |
| 366 |
'{{WRAPPER}} .king-addons-pb-template-popup-inner' => 'justify-content: {{VALUE}}', |
| 367 |
], |
| 368 |
'separator' => 'before', |
| 369 |
'condition' => [ |
| 370 |
'popup_display_as!' => 'notification', |
| 371 |
] |
| 372 |
] |
| 373 |
); |
| 374 |
|
| 375 |
$this->add_responsive_control( |
| 376 |
'popup_align_vr', |
| 377 |
[ |
| 378 |
'label' => esc_html__('Vertical Align', 'king-addons'), |
| 379 |
'type' => Controls_Manager::CHOOSE, |
| 380 |
'label_block' => false, |
| 381 |
'default' => 'center', |
| 382 |
'options' => [ |
| 383 |
'flex-start' => [ |
| 384 |
'title' => esc_html__('Top', 'king-addons'), |
| 385 |
'icon' => 'eicon-v-align-top', |
| 386 |
], |
| 387 |
'center' => [ |
| 388 |
'title' => esc_html__('Middle', 'king-addons'), |
| 389 |
'icon' => 'eicon-v-align-middle', |
| 390 |
], |
| 391 |
'flex-end' => [ |
| 392 |
'title' => esc_html__('Bottom', 'king-addons'), |
| 393 |
'icon' => 'eicon-v-align-bottom', |
| 394 |
], |
| 395 |
], |
| 396 |
'selectors' => [ |
| 397 |
'{{WRAPPER}} .king-addons-pb-template-popup-inner' => 'align-items: {{VALUE}}', |
| 398 |
], |
| 399 |
'condition' => [ |
| 400 |
'popup_display_as!' => 'notification', |
| 401 |
] |
| 402 |
] |
| 403 |
); |
| 404 |
|
| 405 |
$this->add_responsive_control( |
| 406 |
'popup_content_align', |
| 407 |
[ |
| 408 |
'label' => esc_html__('Content Align', 'king-addons'), |
| 409 |
'type' => Controls_Manager::CHOOSE, |
| 410 |
'label_block' => false, |
| 411 |
'default' => 'flex-start', |
| 412 |
'options' => [ |
| 413 |
'flex-start' => [ |
| 414 |
'title' => esc_html__('Top', 'king-addons'), |
| 415 |
'icon' => 'eicon-v-align-top', |
| 416 |
], |
| 417 |
'center' => [ |
| 418 |
'title' => esc_html__('Middle', 'king-addons'), |
| 419 |
'icon' => 'eicon-v-align-middle', |
| 420 |
], |
| 421 |
'flex-end' => [ |
| 422 |
'title' => esc_html__('Bottom', 'king-addons'), |
| 423 |
'icon' => 'eicon-v-align-bottom', |
| 424 |
], |
| 425 |
], |
| 426 |
'selectors' => [ |
| 427 |
'{{WRAPPER}} .king-addons-pb-popup-container-inner' => 'align-items: {{VALUE}}', |
| 428 |
], |
| 429 |
'condition' => [ |
| 430 |
'popup_display_as!' => 'notification', |
| 431 |
] |
| 432 |
] |
| 433 |
); |
| 434 |
|
| 435 |
$this->add_control( |
| 436 |
'popup_animation', |
| 437 |
[ |
| 438 |
'label' => esc_html__('Entance Animation', 'king-addons'), |
| 439 |
'type' => Controls_Manager::ANIMATION, |
| 440 |
'default' => 'fadeIn', |
| 441 |
'label_block' => true, |
| 442 |
'frontend_available' => true, |
| 443 |
'separator' => 'before', |
| 444 |
] |
| 445 |
); |
| 446 |
|
| 447 |
$this->add_control( |
| 448 |
'popup_animation_duration', |
| 449 |
[ |
| 450 |
'label' => esc_html__('Animation Duration', 'king-addons'), |
| 451 |
'type' => Controls_Manager::NUMBER, |
| 452 |
'default' => 1, |
| 453 |
'min' => 0, |
| 454 |
'step' => 0.1, |
| 455 |
'selectors' => [ |
| 456 |
'{{WRAPPER}} .king-addons-pb-popup-container' => 'animation-duration: {{SIZE}}s;', |
| 457 |
], |
| 458 |
'condition' => [ |
| 459 |
'popup_animation!' => ['', 'none'], |
| 460 |
] |
| 461 |
] |
| 462 |
); |
| 463 |
|
| 464 |
$this->add_control( |
| 465 |
'popup_zindex', |
| 466 |
[ |
| 467 |
'label' => esc_html__('Z Index', 'king-addons'), |
| 468 |
'type' => Controls_Manager::NUMBER, |
| 469 |
'default' => 9999, |
| 470 |
'min' => 1, |
| 471 |
'selectors' => [ |
| 472 |
'{{WRAPPER}}' => 'z-index: {{VALUE}};', |
| 473 |
], |
| 474 |
'separator' => 'before', |
| 475 |
] |
| 476 |
); |
| 477 |
|
| 478 |
$this->add_control( |
| 479 |
'popup_disable_page_scroll', |
| 480 |
[ |
| 481 |
'label' => esc_html__('Disable Page Scroll', 'king-addons'), |
| 482 |
'type' => Controls_Manager::SWITCHER, |
| 483 |
'default' => true, |
| 484 |
'return_value' => true, |
| 485 |
'separator' => 'before', |
| 486 |
'condition' => [ |
| 487 |
'popup_display_as!' => 'notification', |
| 488 |
] |
| 489 |
] |
| 490 |
); |
| 491 |
|
| 492 |
$this->end_controls_section(); |
| 493 |
|
| 494 |
$this->start_controls_section( |
| 495 |
'popup_overlay', |
| 496 |
[ |
| 497 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Overlay', 'king-addons'), |
| 498 |
'tab' => Controls_Manager::TAB_SETTINGS, |
| 499 |
'condition' => [ |
| 500 |
'popup_display_as!' => 'notification', |
| 501 |
] |
| 502 |
] |
| 503 |
); |
| 504 |
|
| 505 |
$this->add_control( |
| 506 |
'popup_overlay_display', |
| 507 |
[ |
| 508 |
'label' => esc_html__('Show Overlay', 'king-addons'), |
| 509 |
'type' => Controls_Manager::SWITCHER, |
| 510 |
'default' => 'yes', |
| 511 |
'selectors_dictionary' => [ |
| 512 |
'' => 'display: none !important;', |
| 513 |
'yes' => 'display: block;' |
| 514 |
], |
| 515 |
'selectors' => [ |
| 516 |
'{{WRAPPER}} .king-addons-pb-popup-overlay' => '{{VALUE}}', |
| 517 |
], |
| 518 |
] |
| 519 |
); |
| 520 |
|
| 521 |
$this->add_control( |
| 522 |
'popup_overlay_disable_close', |
| 523 |
[ |
| 524 |
'label' => esc_html__('Prevent Closing on Overlay Click', 'king-addons'), |
| 525 |
'type' => Controls_Manager::SWITCHER, |
| 526 |
'condition' => [ |
| 527 |
'popup_overlay_display' => 'yes' |
| 528 |
] |
| 529 |
] |
| 530 |
); |
| 531 |
|
| 532 |
$this->end_controls_section(); |
| 533 |
|
| 534 |
$this->start_controls_section( |
| 535 |
'popup_close_button', |
| 536 |
[ |
| 537 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Close Button', 'king-addons'), |
| 538 |
'tab' => Controls_Manager::TAB_SETTINGS, |
| 539 |
] |
| 540 |
); |
| 541 |
|
| 542 |
$this->add_control( |
| 543 |
'popup_close_button_display', |
| 544 |
[ |
| 545 |
'label' => esc_html__('Show Close Button', 'king-addons'), |
| 546 |
'type' => Controls_Manager::SWITCHER, |
| 547 |
'default' => 'yes', |
| 548 |
'selectors_dictionary' => [ |
| 549 |
'' => 'display: none;', |
| 550 |
'yes' => 'display: block;' |
| 551 |
], |
| 552 |
'selectors' => [ |
| 553 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => '{{VALUE}}', |
| 554 |
], |
| 555 |
] |
| 556 |
); |
| 557 |
|
| 558 |
$this->add_control( |
| 559 |
'popup_close_button_display_delay', |
| 560 |
[ |
| 561 |
'label' => esc_html__('Show Up Delay (sec)', 'king-addons'), |
| 562 |
'type' => Controls_Manager::NUMBER, |
| 563 |
'default' => 0, |
| 564 |
'min' => 0, |
| 565 |
'condition' => [ |
| 566 |
'popup_close_button_display' => 'yes', |
| 567 |
] |
| 568 |
] |
| 569 |
); |
| 570 |
|
| 571 |
$this->add_responsive_control( |
| 572 |
'popup_close_button_position_vr', |
| 573 |
[ |
| 574 |
'label' => esc_html__('Vertical Position', 'king-addons'), |
| 575 |
'type' => Controls_Manager::SLIDER, |
| 576 |
'size_units' => ['px'], |
| 577 |
'range' => [ |
| 578 |
'px' => [ |
| 579 |
'min' => -100, |
| 580 |
'max' => 100, |
| 581 |
], |
| 582 |
], |
| 583 |
'default' => [ |
| 584 |
'unit' => 'px', |
| 585 |
'size' => 10, |
| 586 |
], |
| 587 |
'selectors' => [ |
| 588 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'top: {{SIZE}}{{UNIT}};', |
| 589 |
], |
| 590 |
'condition' => [ |
| 591 |
'popup_close_button_display' => 'yes' |
| 592 |
] |
| 593 |
] |
| 594 |
); |
| 595 |
|
| 596 |
$this->add_responsive_control( |
| 597 |
'popup_close_button_position_hr', |
| 598 |
[ |
| 599 |
'label' => esc_html__('Horizontal Position', 'king-addons'), |
| 600 |
'type' => Controls_Manager::SLIDER, |
| 601 |
'size_units' => ['px'], |
| 602 |
'range' => [ |
| 603 |
'px' => [ |
| 604 |
'min' => -100, |
| 605 |
'max' => 100, |
| 606 |
], |
| 607 |
], |
| 608 |
'default' => [ |
| 609 |
'unit' => 'px', |
| 610 |
'size' => 10, |
| 611 |
], |
| 612 |
'selectors' => [ |
| 613 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'right: {{SIZE}}{{UNIT}};', |
| 614 |
], |
| 615 |
'condition' => [ |
| 616 |
'popup_close_button_display' => 'yes' |
| 617 |
] |
| 618 |
] |
| 619 |
); |
| 620 |
|
| 621 |
$this->end_controls_section(); |
| 622 |
|
| 623 |
if (!king_addons_freemius()->can_use_premium_code__premium_only()) { |
| 624 |
$this->start_controls_section( |
| 625 |
'king_addons_pro_features_section', |
| 626 |
[ |
| 627 |
'label' => KING_ADDONS_ELEMENTOR_ICON_PRO . '<span class="king-addons-pro-features-heading">Pro Features</span>', |
| 628 |
'tab' => Controls_Manager::TAB_SETTINGS, |
| 629 |
] |
| 630 |
); |
| 631 |
|
| 632 |
$this->add_control( |
| 633 |
'king_addons_pro_features_list', |
| 634 |
[ |
| 635 |
'type' => Controls_Manager::RAW_HTML, |
| 636 |
'raw' => '<ul> |
| 637 |
<li>Open Popup: On Page Scroll</li> |
| 638 |
<li>Open Popup: After User Exit Intent</li> |
| 639 |
<li>Open Popup: After User Inactivity</li> |
| 640 |
<li>Open Popup: On Scroll to Element</li> |
| 641 |
<li>Show/Hide Popup on Any Device</li> |
| 642 |
<li>Show Popup for Specific Roles</li> |
| 643 |
<li>Prevent Popup Closing on "ESC" Key</li> |
| 644 |
<li>Open Popup: After a Specific Date</li> |
| 645 |
<li>Show Again Delay: Set a specific time (in hours, days, or weeks). This option determines when the popup will reappear for a visitor after it is closed.</li> |
| 646 |
<li>Stop Showing After a Specific Date</li> |
| 647 |
<li>Automatic Closing Delay</li> |
| 648 |
<li>Show According to URL Keyword - The popup will appear if the URL (referral) contains the chosen keyword.</li> |
| 649 |
<li>Open Popup: Custom Trigger - Button Click, CSS Selector (class or ID)</li> |
| 650 |
</ul>' . |
| 651 |
self::getUpgradeProLink('popup-builder'), |
| 652 |
'content_classes' => 'king-addons-pro-features-list', |
| 653 |
] |
| 654 |
); |
| 655 |
|
| 656 |
$this->end_controls_section(); |
| 657 |
} |
| 658 |
|
| 659 |
parent::register_controls(); |
| 660 |
|
| 661 |
$this->start_controls_section( |
| 662 |
'popup_container_styles', |
| 663 |
[ |
| 664 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Popup', 'king-addons'), |
| 665 |
'tab' => Controls_Manager::TAB_STYLE, |
| 666 |
] |
| 667 |
); |
| 668 |
|
| 669 |
$this->add_group_control( |
| 670 |
Group_Control_Background::get_type(), |
| 671 |
[ |
| 672 |
'name' => 'popup_container_bg', |
| 673 |
'label' => esc_html__('Background', 'king-addons'), |
| 674 |
'types' => ['classic', 'gradient'], |
| 675 |
'fields_options' => [ |
| 676 |
'color' => [ |
| 677 |
'default' => '#ffffff', |
| 678 |
], |
| 679 |
], |
| 680 |
'selector' => '{{WRAPPER}} .king-addons-pb-popup-container-inner' |
| 681 |
] |
| 682 |
); |
| 683 |
|
| 684 |
$this->add_control( |
| 685 |
'popup_scrollbar_color', |
| 686 |
[ |
| 687 |
'label' => esc_html__('ScrollBar Color', 'king-addons'), |
| 688 |
'type' => Controls_Manager::COLOR, |
| 689 |
'default' => '#333333', |
| 690 |
'selectors' => [ |
| 691 |
'{{WRAPPER}} .ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y' => 'background-color: {{VALUE}}', |
| 692 |
'{{WRAPPER}} .ps > .ps__rail-y > .ps__thumb-y' => 'background-color: {{VALUE}}', |
| 693 |
], |
| 694 |
] |
| 695 |
); |
| 696 |
|
| 697 |
$this->add_responsive_control( |
| 698 |
'popup_container_padding', |
| 699 |
[ |
| 700 |
'label' => esc_html__('Padding', 'king-addons'), |
| 701 |
'type' => Controls_Manager::DIMENSIONS, |
| 702 |
'size_units' => ['px', '%'], |
| 703 |
'default' => [ |
| 704 |
'top' => 20, |
| 705 |
'right' => 20, |
| 706 |
'bottom' => 20, |
| 707 |
'left' => 20, |
| 708 |
], |
| 709 |
'selectors' => [ |
| 710 |
'{{WRAPPER}} .king-addons-pb-popup-container-inner' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 711 |
], |
| 712 |
'separator' => 'before' |
| 713 |
] |
| 714 |
); |
| 715 |
|
| 716 |
$this->add_control( |
| 717 |
'popup_container_radius', |
| 718 |
[ |
| 719 |
'label' => esc_html__('Border Radius', 'king-addons'), |
| 720 |
'type' => Controls_Manager::DIMENSIONS, |
| 721 |
'size_units' => ['px', '%'], |
| 722 |
'default' => [ |
| 723 |
'top' => 0, |
| 724 |
'right' => 0, |
| 725 |
'bottom' => 0, |
| 726 |
'left' => 0, |
| 727 |
], |
| 728 |
'selectors' => [ |
| 729 |
'{{WRAPPER}} .king-addons-pb-popup-container-inner' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 730 |
], |
| 731 |
'separator' => 'before', |
| 732 |
] |
| 733 |
); |
| 734 |
|
| 735 |
$this->add_group_control( |
| 736 |
Group_Control_Border::get_type(), |
| 737 |
[ |
| 738 |
'name' => 'popup_container_border', |
| 739 |
'label' => esc_html__('Border', 'king-addons'), |
| 740 |
'placeholder' => '1px', |
| 741 |
'default' => '1px', |
| 742 |
'selector' => '{{WRAPPER}} .king-addons-pb-popup-container-inner', |
| 743 |
'separator' => 'before' |
| 744 |
] |
| 745 |
); |
| 746 |
|
| 747 |
$this->add_group_control( |
| 748 |
Group_Control_Box_Shadow::get_type(), |
| 749 |
[ |
| 750 |
'name' => 'popup_container_shadow', |
| 751 |
'selector' => '{{WRAPPER}} .king-addons-pb-popup-container-inner' |
| 752 |
] |
| 753 |
); |
| 754 |
|
| 755 |
$this->end_controls_section(); |
| 756 |
|
| 757 |
$this->start_controls_section( |
| 758 |
'popup_overlay_styles', |
| 759 |
[ |
| 760 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Overlay', 'king-addons'), |
| 761 |
'tab' => Controls_Manager::TAB_STYLE, |
| 762 |
'condition' => [ |
| 763 |
'popup_overlay_display' => 'yes' |
| 764 |
] |
| 765 |
] |
| 766 |
); |
| 767 |
|
| 768 |
$this->add_group_control( |
| 769 |
Group_Control_Background::get_type(), |
| 770 |
[ |
| 771 |
'name' => 'popup_overlay_bg', |
| 772 |
'label' => esc_html__('Background', 'king-addons'), |
| 773 |
'types' => ['classic', 'gradient'], |
| 774 |
'fields_options' => [ |
| 775 |
'color' => [ |
| 776 |
'default' => '#777777', |
| 777 |
], |
| 778 |
], |
| 779 |
'selector' => '{{WRAPPER}} .king-addons-pb-popup-overlay' |
| 780 |
] |
| 781 |
); |
| 782 |
|
| 783 |
$this->end_controls_section(); |
| 784 |
|
| 785 |
$this->start_controls_section( |
| 786 |
'popup_close_btn_styles', |
| 787 |
[ |
| 788 |
'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Close Button', 'king-addons'), |
| 789 |
'tab' => Controls_Manager::TAB_STYLE, |
| 790 |
'show_label' => false, |
| 791 |
] |
| 792 |
); |
| 793 |
|
| 794 |
$this->start_controls_tabs('tabs_popup_close_btn_style'); |
| 795 |
|
| 796 |
$this->start_controls_tab( |
| 797 |
'tab_popup_close_btn_normal', |
| 798 |
[ |
| 799 |
'label' => esc_html__('Normal', 'king-addons'), |
| 800 |
] |
| 801 |
); |
| 802 |
|
| 803 |
$this->add_control( |
| 804 |
'popup_close_btn_color', |
| 805 |
[ |
| 806 |
'label' => esc_html__('Color', 'king-addons'), |
| 807 |
'type' => Controls_Manager::COLOR, |
| 808 |
'default' => '#333333', |
| 809 |
'selectors' => [ |
| 810 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'color: {{VALUE}}', |
| 811 |
], |
| 812 |
] |
| 813 |
); |
| 814 |
|
| 815 |
$this->add_control( |
| 816 |
'popup_close_btn_bg_color', |
| 817 |
[ |
| 818 |
'label' => esc_html__('Background Color', 'king-addons'), |
| 819 |
'type' => Controls_Manager::COLOR, |
| 820 |
'selectors' => [ |
| 821 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'background-color: {{VALUE}}', |
| 822 |
] |
| 823 |
] |
| 824 |
); |
| 825 |
|
| 826 |
$this->add_control( |
| 827 |
'popup_close_btn_border_color', |
| 828 |
[ |
| 829 |
'label' => esc_html__('Border Color', 'king-addons'), |
| 830 |
'type' => Controls_Manager::COLOR, |
| 831 |
'selectors' => [ |
| 832 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'border-color: {{VALUE}}', |
| 833 |
], |
| 834 |
] |
| 835 |
); |
| 836 |
|
| 837 |
$this->add_group_control( |
| 838 |
Group_Control_Box_Shadow::get_type(), |
| 839 |
[ |
| 840 |
'name' => 'popup_close_btn_box_shadow', |
| 841 |
'selector' => '{{WRAPPER}} .king-addons-pb-popup-close-btn', |
| 842 |
] |
| 843 |
); |
| 844 |
|
| 845 |
$this->end_controls_tab(); |
| 846 |
|
| 847 |
$this->start_controls_tab( |
| 848 |
'tab_popup_close_btn_hover', |
| 849 |
[ |
| 850 |
'label' => esc_html__('Hover', 'king-addons'), |
| 851 |
] |
| 852 |
); |
| 853 |
|
| 854 |
$this->add_control( |
| 855 |
'popup_close_btn_color_hr', |
| 856 |
[ |
| 857 |
'label' => esc_html__('Color', 'king-addons'), |
| 858 |
'type' => Controls_Manager::COLOR, |
| 859 |
'default' => '#54595f', |
| 860 |
'selectors' => [ |
| 861 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn:hover' => 'color: {{VALUE}}', |
| 862 |
], |
| 863 |
] |
| 864 |
); |
| 865 |
|
| 866 |
$this->add_control( |
| 867 |
'popup_close_btn_bg_color_hr', |
| 868 |
[ |
| 869 |
'label' => esc_html__('Background Color', 'king-addons'), |
| 870 |
'type' => Controls_Manager::COLOR, |
| 871 |
'selectors' => [ |
| 872 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn:hover' => 'background-color: {{VALUE}}', |
| 873 |
] |
| 874 |
] |
| 875 |
); |
| 876 |
|
| 877 |
$this->add_control( |
| 878 |
'popup_close_btn_border_color_hr', |
| 879 |
[ |
| 880 |
'label' => esc_html__('Border Color', 'king-addons'), |
| 881 |
'type' => Controls_Manager::COLOR, |
| 882 |
'selectors' => [ |
| 883 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn:hover' => 'border-color: {{VALUE}}', |
| 884 |
] |
| 885 |
] |
| 886 |
); |
| 887 |
|
| 888 |
$this->end_controls_tab(); |
| 889 |
|
| 890 |
$this->end_controls_tabs(); |
| 891 |
|
| 892 |
$this->add_control( |
| 893 |
'popup_close_btn_size', |
| 894 |
[ |
| 895 |
'label' => esc_html__('Size', 'king-addons'), |
| 896 |
'type' => Controls_Manager::SLIDER, |
| 897 |
'size_units' => ['px'], |
| 898 |
'range' => [ |
| 899 |
'px' => [ |
| 900 |
'min' => 10, |
| 901 |
'max' => 100, |
| 902 |
], |
| 903 |
], |
| 904 |
'default' => [ |
| 905 |
'unit' => 'px', |
| 906 |
'size' => 20, |
| 907 |
], |
| 908 |
'selectors' => [ |
| 909 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 910 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};' |
| 911 |
], |
| 912 |
] |
| 913 |
); |
| 914 |
|
| 915 |
$this->add_control( |
| 916 |
'popup_close_btn_box_size', |
| 917 |
[ |
| 918 |
'label' => esc_html__('Box Size', 'king-addons'), |
| 919 |
'type' => Controls_Manager::SLIDER, |
| 920 |
'size_units' => ['px'], |
| 921 |
'range' => [ |
| 922 |
'px' => [ |
| 923 |
'min' => 10, |
| 924 |
'max' => 100, |
| 925 |
], |
| 926 |
], |
| 927 |
'default' => [ |
| 928 |
'unit' => 'px', |
| 929 |
'size' => 35, |
| 930 |
], |
| 931 |
'selectors' => [ |
| 932 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};', |
| 933 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn i' => 'line-height: {{SIZE}}{{UNIT}};', |
| 934 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn svg' => 'line-height: {{SIZE}}{{UNIT}};' |
| 935 |
], |
| 936 |
] |
| 937 |
); |
| 938 |
|
| 939 |
$this->add_control( |
| 940 |
'popup_close_btn_border_type', |
| 941 |
[ |
| 942 |
'label' => esc_html__('Border Type', 'king-addons'), |
| 943 |
'type' => Controls_Manager::SELECT, |
| 944 |
'options' => [ |
| 945 |
'none' => esc_html__('None', 'king-addons'), |
| 946 |
'solid' => esc_html__('Solid', 'king-addons'), |
| 947 |
'double' => esc_html__('Double', 'king-addons'), |
| 948 |
'dotted' => esc_html__('Dotted', 'king-addons'), |
| 949 |
'dashed' => esc_html__('Dashed', 'king-addons'), |
| 950 |
'groove' => esc_html__('Groove', 'king-addons'), |
| 951 |
], |
| 952 |
'default' => 'none', |
| 953 |
'selectors' => [ |
| 954 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'border-style: {{VALUE}};', |
| 955 |
], |
| 956 |
'separator' => 'before', |
| 957 |
] |
| 958 |
); |
| 959 |
|
| 960 |
$this->add_control( |
| 961 |
'popup_close_btn_border_width', |
| 962 |
[ |
| 963 |
'label' => esc_html__('Border Width', 'king-addons'), |
| 964 |
'type' => Controls_Manager::DIMENSIONS, |
| 965 |
'size_units' => ['px'], |
| 966 |
'default' => [ |
| 967 |
'top' => 1, |
| 968 |
'right' => 1, |
| 969 |
'bottom' => 1, |
| 970 |
'left' => 1, |
| 971 |
], |
| 972 |
'selectors' => [ |
| 973 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 974 |
], |
| 975 |
'condition' => [ |
| 976 |
'popup_close_btn_border_type!' => 'none', |
| 977 |
], |
| 978 |
] |
| 979 |
); |
| 980 |
|
| 981 |
$this->add_control( |
| 982 |
'popup_close_btn_radius', |
| 983 |
[ |
| 984 |
'label' => esc_html__('Border Radius', 'king-addons'), |
| 985 |
'type' => Controls_Manager::DIMENSIONS, |
| 986 |
'size_units' => ['px', '%'], |
| 987 |
'default' => [ |
| 988 |
'top' => 2, |
| 989 |
'right' => 2, |
| 990 |
'bottom' => 2, |
| 991 |
'left' => 2, |
| 992 |
], |
| 993 |
'selectors' => [ |
| 994 |
'{{WRAPPER}} .king-addons-pb-popup-close-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 995 |
], |
| 996 |
'separator' => 'before', |
| 997 |
] |
| 998 |
); |
| 999 |
|
| 1000 |
$this->end_controls_section(); |
| 1001 |
|
| 1002 |
} |
| 1003 |
|
| 1004 |
public static function getUpgradeProLink($widget_name): string |
| 1005 |
{ |
| 1006 |
return '<a class="king-addons-pro-features-cta-btn" href="https://kingaddons.com/pricing/?utm_source=kng-module-' . $widget_name . '-upgrade-pro&utm_medium=plugin&utm_campaign=kng" target="_blank">' . esc_html__('Learn More About Pro', 'king-addons') . '</a>'; |
| 1007 |
} |
| 1008 |
|
| 1009 |
} |