dep
5 years ago
premium-banner.php
5 years ago
premium-blog.php
5 years ago
premium-button.php
5 years ago
premium-carousel.php
5 years ago
premium-contactform.php
5 years ago
premium-countdown.php
5 years ago
premium-counter.php
5 years ago
premium-dual-header.php
5 years ago
premium-fancytext.php
5 years ago
premium-grid.php
5 years ago
premium-icon-list.php
5 years ago
premium-image-button.php
5 years ago
premium-image-scroll.php
5 years ago
premium-image-separator.php
5 years ago
premium-lottie.php
5 years ago
premium-maps.php
5 years ago
premium-modalbox.php
5 years ago
premium-person.php
5 years ago
premium-pricing-table.php
5 years ago
premium-progressbar.php
5 years ago
premium-testimonials.php
5 years ago
premium-title.php
5 years ago
premium-videobox.php
5 years ago
premium-vscroll.php
5 years ago
premium-countdown.php
832 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Premium Countdown. |
| 5 | */ |
| 6 | namespace PremiumAddons\Widgets; |
| 7 | |
| 8 | // Elementor Classes. |
| 9 | use Elementor\Modules\DynamicTags\Module as TagsModule; |
| 10 | use Elementor\Widget_Base; |
| 11 | use Elementor\Controls_Manager; |
| 12 | use Elementor\Scheme_Color; |
| 13 | use Elementor\Scheme_Typography; |
| 14 | use Elementor\Group_Control_Border; |
| 15 | use Elementor\Group_Control_Typography; |
| 16 | use Elementor\Group_Control_Box_Shadow; |
| 17 | |
| 18 | // PremiumAddons Classes. |
| 19 | use PremiumAddons\Includes\Helper_Functions; |
| 20 | |
| 21 | if( !defined( 'ABSPATH' ) ) exit; // No access of directly access |
| 22 | |
| 23 | /** |
| 24 | * Class Premium_Countdown |
| 25 | */ |
| 26 | class Premium_Countdown extends Widget_Base { |
| 27 | |
| 28 | public function get_name() { |
| 29 | return 'premium-countdown-timer'; |
| 30 | } |
| 31 | |
| 32 | public function get_title() { |
| 33 | return sprintf( '%1$s %2$s', Helper_Functions::get_prefix(), __('Countdown', 'premium-addons-for-elementor') ); |
| 34 | } |
| 35 | |
| 36 | public function get_icon() { |
| 37 | return 'pa-countdown'; |
| 38 | } |
| 39 | |
| 40 | public function is_reload_preview_required() { |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | public function get_style_depends() { |
| 45 | return [ |
| 46 | 'premium-addons' |
| 47 | ]; |
| 48 | } |
| 49 | |
| 50 | public function get_script_depends() { |
| 51 | return [ |
| 52 | 'count-down-timer-js', |
| 53 | 'premium-addons' |
| 54 | ]; |
| 55 | } |
| 56 | |
| 57 | public function get_categories() { |
| 58 | return [ 'premium-elements' ]; |
| 59 | } |
| 60 | |
| 61 | public function get_custom_help_url() { |
| 62 | return 'https://premiumaddons.com/support/'; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Register Countdown controls. |
| 67 | * |
| 68 | * @since 1.0.0 |
| 69 | * @access protected |
| 70 | */ |
| 71 | protected function _register_controls() { |
| 72 | $this->start_controls_section( |
| 73 | 'premium_countdown_global_settings', |
| 74 | [ |
| 75 | 'label' => __( 'Countdown', 'premium-addons-for-elementor' ) |
| 76 | ] |
| 77 | ); |
| 78 | |
| 79 | $this->add_control( |
| 80 | 'premium_countdown_style', |
| 81 | [ |
| 82 | 'label' => __( 'Style', 'premium-addons-for-elementor' ), |
| 83 | 'type' => Controls_Manager::SELECT, |
| 84 | 'options' => [ |
| 85 | 'd-u-s' => __( 'Inline', 'premium-addons-for-elementor' ), |
| 86 | 'd-u-u' => __( 'Block', 'premium-addons-for-elementor' ), |
| 87 | ], |
| 88 | 'default' => 'd-u-u' |
| 89 | ] |
| 90 | ); |
| 91 | |
| 92 | $this->add_control( |
| 93 | 'premium_countdown_date_time', |
| 94 | [ |
| 95 | 'label' => __( 'Due Date', 'premium-addons-for-elementor' ), |
| 96 | 'type' => Controls_Manager::DATE_TIME, |
| 97 | 'picker_options' => [ |
| 98 | 'format' => 'Ym/d H:m:s' |
| 99 | ], |
| 100 | 'default' => date( "Y/m/d H:m:s", strtotime("+ 1 Day") ), |
| 101 | 'description' => __( 'Date format is (yyyy/mm/dd). Time format is (hh:mm:ss). Example: 2020-01-01 09:30.', 'premium-addons-for-elementor' ) |
| 102 | ] |
| 103 | ); |
| 104 | |
| 105 | $this->add_control( |
| 106 | 'premium_countdown_s_u_time', |
| 107 | [ |
| 108 | 'label' => __( 'Time Zone', 'premium-addons-for-elementor' ), |
| 109 | 'type' => Controls_Manager::SELECT, |
| 110 | 'options' => [ |
| 111 | 'wp-time' => __('WordPress Default', 'premium-addons-for-elementor' ), |
| 112 | 'user-time' => __('User Local Time', 'premium-addons-for-elementor' ) |
| 113 | ], |
| 114 | 'default' => 'wp-time', |
| 115 | 'description' => __('This will set the current time of the option that you will choose.', 'premium-addons-for-elementor') |
| 116 | ] |
| 117 | ); |
| 118 | |
| 119 | $this->add_control( |
| 120 | 'premium_countdown_units', |
| 121 | [ |
| 122 | 'label' => __( 'Time Units', 'premium-addons-for-elementor' ), |
| 123 | 'type' => Controls_Manager::SELECT2, |
| 124 | 'description' => __('Select the time units that you want to display in countdown timer.', 'premium-addons-for-elementor' ), |
| 125 | 'options' => [ |
| 126 | 'Y' => __( 'Years', 'premium-addons-for-elementor' ), |
| 127 | 'O' => __( 'Month', 'premium-addons-for-elementor' ), |
| 128 | 'W' => __( 'Week', 'premium-addons-for-elementor' ), |
| 129 | 'D' => __( 'Day', 'premium-addons-for-elementor' ), |
| 130 | 'H' => __( 'Hours', 'premium-addons-for-elementor' ), |
| 131 | 'M' => __( 'Minutes', 'premium-addons-for-elementor' ), |
| 132 | 'S' => __( 'Second', 'premium-addons-for-elementor' ), |
| 133 | ], |
| 134 | 'default' => [ 'O', 'D', 'H', 'M', 'S' ], |
| 135 | 'multiple' => true, |
| 136 | 'separator' => 'after' |
| 137 | ] |
| 138 | ); |
| 139 | |
| 140 | $this->add_control('premium_countdown_separator', |
| 141 | [ |
| 142 | 'label' => __('Digits Separator', 'premium-addons-for-elementor'), |
| 143 | 'description' => __('Enable or disable digits separator','premium-addons-for-elementor'), |
| 144 | 'type' => Controls_Manager::SWITCHER, |
| 145 | 'condition' => [ |
| 146 | 'premium_countdown_style' => 'd-u-u' |
| 147 | ] |
| 148 | ] |
| 149 | ); |
| 150 | |
| 151 | $this->add_control( |
| 152 | 'premium_countdown_separator_text', |
| 153 | [ |
| 154 | 'label' => __('Separator Text', 'premium-addons-for-elementor'), |
| 155 | 'type' => Controls_Manager::TEXT, |
| 156 | 'condition' => [ |
| 157 | 'premium_countdown_style' => 'd-u-u', |
| 158 | 'premium_countdown_separator' => 'yes' |
| 159 | ], |
| 160 | 'default' => ':' |
| 161 | ] |
| 162 | ); |
| 163 | |
| 164 | $this->add_responsive_control( |
| 165 | 'premium_countdown_align', |
| 166 | [ |
| 167 | 'label' => __( 'Alignment', 'premium-addons-for-elementor' ), |
| 168 | 'type' => Controls_Manager::CHOOSE, |
| 169 | 'options' => [ |
| 170 | 'left' => [ |
| 171 | 'title'=> __( 'Left', 'premium-addons-for-elementor' ), |
| 172 | 'icon' => 'fa fa-align-left', |
| 173 | ], |
| 174 | 'center' => [ |
| 175 | 'title'=> __( 'Center', 'premium-addons-for-elementor' ), |
| 176 | 'icon' => 'fa fa-align-center', |
| 177 | ], |
| 178 | 'right' => [ |
| 179 | 'title'=> __( 'Right', 'premium-addons-for-elementor' ), |
| 180 | 'icon' => 'fa fa-align-right', |
| 181 | ], |
| 182 | ], |
| 183 | 'toggle' => false, |
| 184 | 'default' => 'center', |
| 185 | 'selectors' => [ |
| 186 | '{{WRAPPER}} .premium-countdown' => 'justify-content: {{VALUE}};', |
| 187 | ], |
| 188 | ] |
| 189 | ); |
| 190 | |
| 191 | $this->end_controls_section(); |
| 192 | |
| 193 | $this->start_controls_section( |
| 194 | 'premium_countdown_on_expire_settings', |
| 195 | [ |
| 196 | 'label' => __( 'Expire' , 'premium-addons-for-elementor' ) |
| 197 | ] |
| 198 | ); |
| 199 | |
| 200 | $this->add_control( |
| 201 | 'premium_countdown_expire_text_url', |
| 202 | [ |
| 203 | 'label' => __('Expire Type', 'premium-addons-for-elementor'), |
| 204 | 'label_block' => false, |
| 205 | 'type' => Controls_Manager::SELECT, |
| 206 | 'description' => __('Choose whether if you want to set a message or a redirect link or leave it as digits', 'premium-addons-for-elementor'), |
| 207 | 'options' => [ |
| 208 | 'default' => __('Default', 'premium-addons-for-elementor'), |
| 209 | 'text' => __('Message', 'premium-addons-for-elementor'), |
| 210 | 'url' => __('Redirection Link', 'premium-addons-for-elementor') |
| 211 | ], |
| 212 | 'default' => 'text', |
| 213 | ] |
| 214 | ); |
| 215 | |
| 216 | $this->add_control('default_type_notice', |
| 217 | [ |
| 218 | 'raw' => __('Default option will show the expiration message as <b>Digits [00:00:00]. </b> .', 'premium-addons-for-elementor'), |
| 219 | 'type' => Controls_Manager::RAW_HTML, |
| 220 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 221 | 'condition' => [ |
| 222 | 'premium_countdown_expire_text_url' => 'default', |
| 223 | ] |
| 224 | ] |
| 225 | ); |
| 226 | |
| 227 | |
| 228 | $this->add_control( |
| 229 | 'premium_countdown_expiry_text_', |
| 230 | [ |
| 231 | 'label' => __('On expiry Text', 'premium-addons-for-elementor'), |
| 232 | 'type' => Controls_Manager::WYSIWYG, |
| 233 | 'dynamic' => [ 'active' => true ], |
| 234 | 'default' => __('Countdown Expired!','prmeium_elementor'), |
| 235 | 'condition' => [ |
| 236 | 'premium_countdown_expire_text_url' => 'text' |
| 237 | ] |
| 238 | ] |
| 239 | ); |
| 240 | |
| 241 | $this->add_control( |
| 242 | 'premium_countdown_expiry_redirection_', |
| 243 | [ |
| 244 | 'label' => __('Redirect To', 'premium-addons-for-elementor'), |
| 245 | 'type' => Controls_Manager::TEXT, |
| 246 | 'dynamic' => [ |
| 247 | 'active' => true, |
| 248 | 'categories' => [ |
| 249 | TagsModule::POST_META_CATEGORY, |
| 250 | TagsModule::URL_CATEGORY |
| 251 | ] |
| 252 | ], |
| 253 | 'condition' => [ |
| 254 | 'premium_countdown_expire_text_url' => 'url' |
| 255 | ], |
| 256 | 'default' => get_permalink( 1 ) |
| 257 | ] |
| 258 | ); |
| 259 | |
| 260 | $this->end_controls_section(); |
| 261 | |
| 262 | $this->start_controls_section( |
| 263 | 'premium_countdown_transaltion', |
| 264 | [ |
| 265 | 'label' => __( 'Strings Translation' , 'premium-addons-for-elementor' ) |
| 266 | ] |
| 267 | ); |
| 268 | |
| 269 | $this->add_control( |
| 270 | 'premium_countdown_day_singular', |
| 271 | [ |
| 272 | 'label' => __( 'Day (Singular)', 'premium-addons-for-elementor' ), |
| 273 | 'type' => Controls_Manager::TEXT, |
| 274 | 'dynamic' => [ 'active' => true ], |
| 275 | 'default' => 'Day' |
| 276 | ] |
| 277 | ); |
| 278 | |
| 279 | $this->add_control( |
| 280 | 'premium_countdown_day_plural', |
| 281 | [ |
| 282 | 'label' => __( 'Day (Plural)', 'premium-addons-for-elementor' ), |
| 283 | 'type' => Controls_Manager::TEXT, |
| 284 | 'dynamic' => [ 'active' => true ], |
| 285 | 'default' => 'Days' |
| 286 | ] |
| 287 | ); |
| 288 | |
| 289 | $this->add_control( |
| 290 | 'premium_countdown_week_singular', |
| 291 | [ |
| 292 | 'label' => __( 'Week (Singular)', 'premium-addons-for-elementor' ), |
| 293 | 'type' => Controls_Manager::TEXT, |
| 294 | 'dynamic' => [ 'active' => true ], |
| 295 | 'default' => 'Week' |
| 296 | ] |
| 297 | ); |
| 298 | |
| 299 | $this->add_control( |
| 300 | 'premium_countdown_week_plural', |
| 301 | [ |
| 302 | 'label' => __( 'Weeks (Plural)', 'premium-addons-for-elementor' ), |
| 303 | 'type' => Controls_Manager::TEXT, |
| 304 | 'dynamic' => [ 'active' => true ], |
| 305 | 'default' => 'Weeks' |
| 306 | ] |
| 307 | ); |
| 308 | |
| 309 | |
| 310 | $this->add_control( |
| 311 | 'premium_countdown_month_singular', |
| 312 | [ |
| 313 | 'label' => __( 'Month (Singular)', 'premium-addons-for-elementor' ), |
| 314 | 'type' => Controls_Manager::TEXT, |
| 315 | 'dynamic' => [ 'active' => true ], |
| 316 | 'default' => 'Month' |
| 317 | ] |
| 318 | ); |
| 319 | |
| 320 | |
| 321 | $this->add_control( |
| 322 | 'premium_countdown_month_plural', |
| 323 | [ |
| 324 | 'label' => __( 'Months (Plural)', 'premium-addons-for-elementor' ), |
| 325 | 'type' => Controls_Manager::TEXT, |
| 326 | 'dynamic' => [ 'active' => true ], |
| 327 | 'default' => 'Months' |
| 328 | ] |
| 329 | ); |
| 330 | |
| 331 | |
| 332 | $this->add_control( |
| 333 | 'premium_countdown_year_singular', |
| 334 | [ |
| 335 | 'label' => __( 'Year (Singular)', 'premium-addons-for-elementor' ), |
| 336 | 'type' => Controls_Manager::TEXT, |
| 337 | 'dynamic' => [ 'active' => true ], |
| 338 | 'default' => 'Year' |
| 339 | ] |
| 340 | ); |
| 341 | |
| 342 | |
| 343 | $this->add_control( |
| 344 | 'premium_countdown_year_plural', |
| 345 | [ |
| 346 | 'label' => __( 'Years (Plural)', 'premium-addons-for-elementor' ), |
| 347 | 'type' => Controls_Manager::TEXT, |
| 348 | 'dynamic' => [ 'active' => true ], |
| 349 | 'default' => 'Years' |
| 350 | ] |
| 351 | ); |
| 352 | |
| 353 | |
| 354 | $this->add_control( |
| 355 | 'premium_countdown_hour_singular', |
| 356 | [ |
| 357 | 'label' => __( 'Hour (Singular)', 'premium-addons-for-elementor' ), |
| 358 | 'type' => Controls_Manager::TEXT, |
| 359 | 'dynamic' => [ 'active' => true ], |
| 360 | 'default' => 'Hour' |
| 361 | ] |
| 362 | ); |
| 363 | |
| 364 | |
| 365 | $this->add_control( |
| 366 | 'premium_countdown_hour_plural', |
| 367 | [ |
| 368 | 'label' => __( 'Hours (Plural)', 'premium-addons-for-elementor' ), |
| 369 | 'type' => Controls_Manager::TEXT, |
| 370 | 'dynamic' => [ 'active' => true ], |
| 371 | 'default' => 'Hours' |
| 372 | ] |
| 373 | ); |
| 374 | |
| 375 | |
| 376 | $this->add_control( |
| 377 | 'premium_countdown_minute_singular', |
| 378 | [ |
| 379 | 'label' => __( 'Minute (Singular)', 'premium-addons-for-elementor' ), |
| 380 | 'type' => Controls_Manager::TEXT, |
| 381 | 'dynamic' => [ 'active' => true ], |
| 382 | 'default' => 'Minute' |
| 383 | ] |
| 384 | ); |
| 385 | |
| 386 | $this->add_control( |
| 387 | 'premium_countdown_minute_plural', |
| 388 | [ |
| 389 | 'label' => __( 'Minutes (Plural)', 'premium-addons-for-elementor' ), |
| 390 | 'type' => Controls_Manager::TEXT, |
| 391 | 'dynamic' => [ 'active' => true ], |
| 392 | 'default' => 'Minutes' |
| 393 | ] |
| 394 | ); |
| 395 | |
| 396 | $this->add_control( |
| 397 | 'premium_countdown_second_singular', |
| 398 | [ |
| 399 | 'label' => __( 'Second (Singular)', 'premium-addons-for-elementor' ), |
| 400 | 'type' => Controls_Manager::TEXT, |
| 401 | 'dynamic' => [ 'active' => true ], |
| 402 | 'default' => 'Second', |
| 403 | ] |
| 404 | ); |
| 405 | |
| 406 | $this->add_control( |
| 407 | 'premium_countdown_second_plural', |
| 408 | [ |
| 409 | 'label' => __( 'Seconds (Plural)', 'premium-addons-for-elementor' ), |
| 410 | 'type' => Controls_Manager::TEXT, |
| 411 | 'dynamic' => [ 'active' => true ], |
| 412 | 'default' => 'Seconds' |
| 413 | ] |
| 414 | ); |
| 415 | |
| 416 | $this->end_controls_section(); |
| 417 | |
| 418 | $this->start_controls_section('section_pa_docs', |
| 419 | [ |
| 420 | 'label' => __('Helpful Documentations', 'premium-addons-for-elementor'), |
| 421 | ] |
| 422 | ); |
| 423 | |
| 424 | $doc1_url = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/docs/countdown-widget-tutorial/', 'editor-page', 'wp-editor', 'get-support' ); |
| 425 | |
| 426 | $this->add_control('doc_1', |
| 427 | [ |
| 428 | 'type' => Controls_Manager::RAW_HTML, |
| 429 | 'raw' => sprintf( '<a href="%s" target="_blank">%s</a>', $doc1_url ,__( 'Gettings started »', 'premium-addons-for-elementor' ) ), |
| 430 | 'content_classes' => 'editor-pa-doc', |
| 431 | ] |
| 432 | ); |
| 433 | |
| 434 | $this->end_controls_section(); |
| 435 | |
| 436 | $this->start_controls_section( |
| 437 | 'premium_countdown_typhography', |
| 438 | [ |
| 439 | 'label' => __( 'Digits' , 'premium-addons-for-elementor' ), |
| 440 | 'tab' => Controls_Manager::TAB_STYLE |
| 441 | ] |
| 442 | ); |
| 443 | |
| 444 | $this->add_control( |
| 445 | 'premium_countdown_digit_color', |
| 446 | [ |
| 447 | 'label' => __( 'Color', 'premium-addons-for-elementor' ), |
| 448 | 'type' => Controls_Manager::COLOR, |
| 449 | 'scheme' => [ |
| 450 | 'type' => Scheme_Color::get_type(), |
| 451 | 'value' => Scheme_Color::COLOR_2, |
| 452 | ], |
| 453 | 'selectors' => [ |
| 454 | '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-amount' => 'color: {{VALUE}};' |
| 455 | ] |
| 456 | ] |
| 457 | ); |
| 458 | |
| 459 | $this->add_group_control( |
| 460 | Group_Control_Typography::get_type(), |
| 461 | [ |
| 462 | 'name' => 'premium_countdown_digit_typo', |
| 463 | 'scheme' => Scheme_Typography::TYPOGRAPHY_3, |
| 464 | 'selector' => '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-amount', |
| 465 | 'separator' => 'after' |
| 466 | ] |
| 467 | ); |
| 468 | |
| 469 | $this->add_control( |
| 470 | 'premium_countdown_timer_digit_bg_color', |
| 471 | [ |
| 472 | 'label' => __( 'Background Color', 'premium-addons-for-elementor' ), |
| 473 | 'type' => Controls_Manager::COLOR, |
| 474 | 'scheme' => [ |
| 475 | 'type' => Scheme_Color::get_type(), |
| 476 | 'value' => Scheme_Color::COLOR_1, |
| 477 | ], |
| 478 | 'selectors' => [ |
| 479 | '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-amount' => 'background-color: {{VALUE}};' |
| 480 | ] |
| 481 | ] |
| 482 | ); |
| 483 | |
| 484 | $this->add_group_control( |
| 485 | Group_Control_Box_Shadow::get_type(), |
| 486 | [ |
| 487 | 'name' => 'premium_countdown_units_shadow', |
| 488 | 'selector' => '{{WRAPPER}} .countdown .pre_countdown-section', |
| 489 | ] |
| 490 | ); |
| 491 | |
| 492 | $this->add_responsive_control( |
| 493 | 'premium_countdown_digit_bg_size', |
| 494 | [ |
| 495 | 'label' => __( 'Background Size', 'premium-addons-for-elementor' ), |
| 496 | 'type' => Controls_Manager::SLIDER, |
| 497 | 'default' => [ |
| 498 | 'size' => 30 |
| 499 | ], |
| 500 | 'range' => [ |
| 501 | 'px' => [ |
| 502 | 'min' => 1, |
| 503 | 'max' => 400, |
| 504 | ] |
| 505 | ], |
| 506 | 'selectors' => [ |
| 507 | '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-amount' => 'padding: {{SIZE}}px;' |
| 508 | ] |
| 509 | ] |
| 510 | ); |
| 511 | |
| 512 | $this->add_group_control( |
| 513 | Group_Control_Border::get_type(), |
| 514 | [ |
| 515 | 'name' => 'premium_countdown_digits_border', |
| 516 | 'selector' => '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-amount', |
| 517 | ] |
| 518 | ); |
| 519 | |
| 520 | $this->add_control('premium_countdown_digit_border_radius', |
| 521 | [ |
| 522 | 'label' => __('Border Radius', 'premium-addons-for-elementor'), |
| 523 | 'type' => Controls_Manager::DIMENSIONS, |
| 524 | 'size_units' => ['px', '%', 'em'], |
| 525 | 'selectors' => [ |
| 526 | '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-amount' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 527 | ] |
| 528 | ] |
| 529 | ); |
| 530 | |
| 531 | $this->end_controls_section(); |
| 532 | |
| 533 | $this->start_controls_section('premium_countdown_unit_style', |
| 534 | [ |
| 535 | 'label' => __('Units', 'premium-addons-for-elementor'), |
| 536 | 'tab' => Controls_Manager::TAB_STYLE, |
| 537 | ] |
| 538 | ); |
| 539 | |
| 540 | $this->add_control( |
| 541 | 'premium_countdown_unit_color', |
| 542 | [ |
| 543 | 'label' => __( 'Color', 'premium-addons-for-elementor' ), |
| 544 | 'type' => Controls_Manager::COLOR, |
| 545 | 'scheme' => [ |
| 546 | 'type' => Scheme_Color::get_type(), |
| 547 | 'value' => Scheme_Color::COLOR_2, |
| 548 | ], |
| 549 | 'selectors' => [ |
| 550 | '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-period' => 'color: {{VALUE}};' |
| 551 | ] |
| 552 | ] |
| 553 | ); |
| 554 | |
| 555 | $this->add_group_control( |
| 556 | Group_Control_Typography::get_type(), |
| 557 | [ |
| 558 | 'name' => 'premium_countdown_unit_typo', |
| 559 | 'scheme' => Scheme_Typography::TYPOGRAPHY_3, |
| 560 | 'selector' => '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-period', |
| 561 | ] |
| 562 | ); |
| 563 | |
| 564 | $this->add_control( |
| 565 | 'premium_countdown_unit_backcolor', |
| 566 | [ |
| 567 | 'label' => __( 'Background Color', 'premium-addons-for-elementor' ), |
| 568 | 'type' => Controls_Manager::COLOR, |
| 569 | 'selectors' => [ |
| 570 | '{{WRAPPER}} .countdown .pre_countdown-section .pre_countdown-period' => 'background-color: {{VALUE}};' |
| 571 | ] |
| 572 | ] |
| 573 | ); |
| 574 | |
| 575 | $this->add_responsive_control( |
| 576 | 'premium_countdown_separator_width', |
| 577 | [ |
| 578 | 'label' => __( 'Spacing in Between', 'premium-addons-for-elementor' ), |
| 579 | 'type' => Controls_Manager::SLIDER, |
| 580 | 'default' => [ |
| 581 | 'size' => 40, |
| 582 | ], |
| 583 | 'range' => [ |
| 584 | 'px' => [ |
| 585 | 'min' => 0, |
| 586 | 'max' => 200, |
| 587 | ] |
| 588 | ], |
| 589 | 'selectors' => [ |
| 590 | '{{WRAPPER}} .countdown .pre_countdown-section' => 'margin-right: calc( {{SIZE}}{{UNIT}} / 2 ); margin-left: calc( {{SIZE}}{{UNIT}} / 2 );' |
| 591 | ], |
| 592 | 'condition' => [ |
| 593 | 'premium_countdown_separator!' => 'yes' |
| 594 | ], |
| 595 | ] |
| 596 | ); |
| 597 | |
| 598 | $this->end_controls_section(); |
| 599 | |
| 600 | $this->start_controls_section('premium_countdown_separator_style', |
| 601 | [ |
| 602 | 'label' => __('Separator', 'premium-addons-for-elementor'), |
| 603 | 'tab' => Controls_Manager::TAB_STYLE, |
| 604 | 'condition' => [ |
| 605 | 'premium_countdown_style' => 'd-u-u', |
| 606 | 'premium_countdown_separator' => 'yes' |
| 607 | ], |
| 608 | ] |
| 609 | ); |
| 610 | |
| 611 | $this->add_responsive_control( |
| 612 | 'premium_countdown_separator_size', |
| 613 | [ |
| 614 | 'label' => __( 'Size', 'premium-addons-for-elementor' ), |
| 615 | 'type' => Controls_Manager::SLIDER, |
| 616 | 'range' => [ |
| 617 | 'px' => [ |
| 618 | 'min' => 1, |
| 619 | 'max' => 100, |
| 620 | ] |
| 621 | ], |
| 622 | 'selectors' => [ |
| 623 | '{{WRAPPER}} .pre-countdown_separator' => 'font-size: {{SIZE}}px;' |
| 624 | ] |
| 625 | ] |
| 626 | ); |
| 627 | |
| 628 | $this->add_control( |
| 629 | 'premium_countdown_separator_color', |
| 630 | [ |
| 631 | 'label' => __( 'Color', 'premium-addons-for-elementor' ), |
| 632 | 'type' => Controls_Manager::COLOR, |
| 633 | 'scheme' => [ |
| 634 | 'type' => Scheme_Color::get_type(), |
| 635 | 'value' => Scheme_Color::COLOR_2, |
| 636 | ], |
| 637 | 'selectors' => [ |
| 638 | '{{WRAPPER}} .pre-countdown_separator' => 'color: {{VALUE}};' |
| 639 | ] |
| 640 | ] |
| 641 | ); |
| 642 | |
| 643 | $this->add_responsive_control('premium_countdown_separator_margin', |
| 644 | [ |
| 645 | 'label' => __('Margin', 'premium-addons-for-elementor'), |
| 646 | 'type' => Controls_Manager::DIMENSIONS, |
| 647 | 'size_units' => ['px', 'em'], |
| 648 | 'selectors' => [ |
| 649 | '{{WRAPPER}} .pre-countdown_separator' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 650 | ] |
| 651 | ] |
| 652 | ); |
| 653 | |
| 654 | $this->end_controls_section(); |
| 655 | |
| 656 | $this->start_controls_section( |
| 657 | 'premium_countdown_exp_message', |
| 658 | [ |
| 659 | 'label' => __( 'Expiration Message' , 'premium-addons-for-elementor' ), |
| 660 | 'tab' => Controls_Manager::TAB_STYLE, |
| 661 | 'condition' => [ |
| 662 | 'premium_countdown_expire_text_url' => 'text', |
| 663 | ] |
| 664 | ] |
| 665 | ); |
| 666 | |
| 667 | $this->add_control( |
| 668 | 'premium_countdown_message_color', |
| 669 | [ |
| 670 | 'label' => __( 'Color', 'premium-addons-for-elementor' ), |
| 671 | 'type' => Controls_Manager::COLOR, |
| 672 | 'scheme' => [ |
| 673 | 'type' => Scheme_Color::get_type(), |
| 674 | 'value' => Scheme_Color::COLOR_2, |
| 675 | ], |
| 676 | 'selectors' => [ |
| 677 | '{{WRAPPER}} .premium-countdown-exp-message' => 'color: {{VALUE}}' |
| 678 | ] |
| 679 | ] |
| 680 | ); |
| 681 | |
| 682 | $this->add_control( |
| 683 | 'premium_countdown_message_bg_color', |
| 684 | [ |
| 685 | 'label' => __( 'Background Color', 'premium-addons-for-elementor' ), |
| 686 | 'type' => Controls_Manager::COLOR, |
| 687 | 'selectors' => [ |
| 688 | '{{WRAPPER}} .premium-countdown-exp-message' => 'background-color: {{VALUE}};' |
| 689 | ] |
| 690 | ] |
| 691 | ); |
| 692 | |
| 693 | $this->add_group_control( |
| 694 | Group_Control_Typography::get_type(), |
| 695 | [ |
| 696 | 'name' => 'premium_countdown_message_typo', |
| 697 | 'scheme' => Scheme_Typography::TYPOGRAPHY_3, |
| 698 | 'selector' => '{{WRAPPER}} .premium-countdown-exp-message', |
| 699 | ] |
| 700 | ); |
| 701 | |
| 702 | $this->add_group_control( |
| 703 | Group_Control_Border::get_type(), |
| 704 | [ |
| 705 | 'name' => 'premium_countdown_message_border', |
| 706 | 'selector' => '{{WRAPPER}} .premium-countdown-exp-message', |
| 707 | ] |
| 708 | ); |
| 709 | |
| 710 | $this->add_control('premium_countdown_message_border_radius', |
| 711 | [ |
| 712 | 'label' => __('Border Radius', 'premium-addons-for-elementor'), |
| 713 | 'type' => Controls_Manager::DIMENSIONS, |
| 714 | 'size_units' => ['px', '%', 'em'], |
| 715 | 'selectors' => [ |
| 716 | '{{WRAPPER}} .premium-countdown-exp-message' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 717 | ] |
| 718 | ] |
| 719 | ); |
| 720 | |
| 721 | $this->add_group_control( |
| 722 | Group_Control_Box_Shadow::get_type(), |
| 723 | [ |
| 724 | 'name' => 'premium_countdown_message_shadow', |
| 725 | 'selector' => '{{WRAPPER}} .premium-countdown-exp-message', |
| 726 | ] |
| 727 | ); |
| 728 | |
| 729 | $this->add_responsive_control('premium_countdown_message_padding', |
| 730 | [ |
| 731 | 'label' => __('Padding', 'premium-addons-for-elementor'), |
| 732 | 'type' => Controls_Manager::DIMENSIONS, |
| 733 | 'size_units' => ['px', 'em'], |
| 734 | 'selectors' => [ |
| 735 | '{{WRAPPER}} .premium-countdown-exp-message' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 736 | ] |
| 737 | ] |
| 738 | ); |
| 739 | |
| 740 | $this->add_responsive_control('premium_countdown_message_margin', |
| 741 | [ |
| 742 | 'label' => __('Margin', 'premium-addons-for-elementor'), |
| 743 | 'type' => Controls_Manager::DIMENSIONS, |
| 744 | 'size_units' => ['px', 'em'], |
| 745 | 'selectors' => [ |
| 746 | '{{WRAPPER}} .premium-countdown-exp-message' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 747 | ] |
| 748 | ] |
| 749 | ); |
| 750 | |
| 751 | $this->end_controls_section(); |
| 752 | } |
| 753 | |
| 754 | /** |
| 755 | * Render Countdown widget output on the frontend. |
| 756 | * |
| 757 | * Written in PHP and used to generate the final HTML. |
| 758 | * |
| 759 | * @since 1.0.0 |
| 760 | * @access protected |
| 761 | */ |
| 762 | protected function render( ) { |
| 763 | |
| 764 | $settings = $this->get_settings_for_display(); |
| 765 | |
| 766 | $target_date = str_replace('-', '/', $settings['premium_countdown_date_time'] ); |
| 767 | |
| 768 | $formats = $settings['premium_countdown_units']; |
| 769 | $format = implode('', $formats ); |
| 770 | $time = str_replace('-', '/', current_time('mysql') ); |
| 771 | |
| 772 | if( $settings['premium_countdown_s_u_time'] == 'wp-time' ) : |
| 773 | $sent_time = $time; |
| 774 | else: |
| 775 | $sent_time = ''; |
| 776 | endif; |
| 777 | |
| 778 | // Singular labels set up |
| 779 | $y = !empty( $settings['premium_countdown_year_singular'] ) ? $settings['premium_countdown_year_singular'] : 'Year'; |
| 780 | $m = !empty( $settings['premium_countdown_month_singular'] ) ? $settings['premium_countdown_month_singular'] : 'Month'; |
| 781 | $w = !empty( $settings['premium_countdown_week_singular'] ) ? $settings['premium_countdown_week_singular'] : 'Week'; |
| 782 | $d = !empty( $settings['premium_countdown_day_singular'] ) ? $settings['premium_countdown_day_singular'] : 'Day'; |
| 783 | $h = !empty( $settings['premium_countdown_hour_singular'] ) ? $settings['premium_countdown_hour_singular'] : 'Hour'; |
| 784 | $mi = !empty( $settings['premium_countdown_minute_singular'] ) ? $settings['premium_countdown_minute_singular'] : 'Minute'; |
| 785 | $s = !empty( $settings['premium_countdown_second_singular'] ) ? $settings['premium_countdown_second_singular'] : 'Second'; |
| 786 | $label = $y."," . $m ."," . $w ."," . $d ."," . $h ."," . $mi ."," . $s; |
| 787 | |
| 788 | // Plural labels set up |
| 789 | $ys = !empty( $settings['premium_countdown_year_plural'] ) ? $settings['premium_countdown_year_plural'] : 'Years'; |
| 790 | $ms = !empty( $settings['premium_countdown_month_plural'] ) ? $settings['premium_countdown_month_plural'] : 'Months'; |
| 791 | $ws = !empty( $settings['premium_countdown_week_plural'] ) ? $settings['premium_countdown_week_plural'] : 'Weeks'; |
| 792 | $ds = !empty( $settings['premium_countdown_day_plural'] ) ? $settings['premium_countdown_day_plural'] : 'Days'; |
| 793 | $hs = !empty( $settings['premium_countdown_hour_plural'] ) ? $settings['premium_countdown_hour_plural'] : 'Hours'; |
| 794 | $mis = !empty( $settings['premium_countdown_minute_plural'] ) ? $settings['premium_countdown_minute_plural'] : 'Minutes'; |
| 795 | $ss = !empty( $settings['premium_countdown_second_plural'] ) ? $settings['premium_countdown_second_plural'] : 'Seconds'; |
| 796 | $labels1 = $ys."," . $ms ."," . $ws ."," . $ds ."," . $hs ."," . $mis ."," . $ss; |
| 797 | |
| 798 | // $expire_text = '<div class="premium-countdown-exp-message">'.$settings['premium_countdown_expiry_text_'].'</div>'; |
| 799 | |
| 800 | $pcdt_style = $settings['premium_countdown_style'] == 'd-u-s' ? ' side' : ' down'; |
| 801 | |
| 802 | $event = 'digit'; |
| 803 | $text = ''; |
| 804 | if( $settings['premium_countdown_expire_text_url'] === 'text' ) { |
| 805 | $event = 'onExpiry'; |
| 806 | $text = '<div class="premium-countdown-exp-message">'.$settings['premium_countdown_expiry_text_'].'</div>'; |
| 807 | } elseif( $settings['premium_countdown_expire_text_url'] === 'url' ) { |
| 808 | $redirect = ! empty( $settings['premium_countdown_expiry_redirection_'] ) ? esc_url( $settings['premium_countdown_expiry_redirection_'] ) : ''; |
| 809 | $event = 'expiryUrl'; |
| 810 | $text = $redirect; |
| 811 | } |
| 812 | |
| 813 | $separator_text = ! empty ( $settings['premium_countdown_separator_text'] ) ? $settings['premium_countdown_separator_text'] : ''; |
| 814 | |
| 815 | $countdown_settings = [ |
| 816 | 'label1' => $label, |
| 817 | 'label2' => $labels1, |
| 818 | 'until' => $target_date, |
| 819 | 'format' => $format, |
| 820 | 'event' => $event, |
| 821 | 'text' => $text, |
| 822 | 'serverSync'=> $sent_time, |
| 823 | 'separator' => $separator_text |
| 824 | ]; |
| 825 | |
| 826 | ?> |
| 827 | <div id="countDownContiner-<?php echo esc_attr($this->get_id()); ?>" class="premium-countdown premium-countdown-separator-<?php echo $settings['premium_countdown_separator']; ?>" data-settings='<?php echo wp_json_encode( $countdown_settings ); ?>'> |
| 828 | <div id="countdown-<?php echo esc_attr( $this->get_id() ); ?>" class="premium-countdown-init countdown<?php echo $pcdt_style; ?>"></div> |
| 829 | </div> |
| 830 | <?php |
| 831 | } |
| 832 | } |