← All changes
|
includes/widgets/Styled_Text_Builder/Styled_Text_Builder.php
+226
-3
51.1.35
→
51.1.83
View file →
| @@ -44,8 +44,18 @@ | ||
| 44 | 44 | { |
| 45 | 45 | return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-styled-text-builder-style']; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | + /** | |
| 49 | + * Script dependencies. | |
| 50 | + * | |
| 51 | + * @return array<int, string> | |
| 52 | + */ | |
| 53 | + public function get_script_depends(): array | |
| 54 | + { | |
| 55 | + return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-styled-text-builder-script']; | |
| 56 | + } | |
| 57 | + | |
| 48 | 58 | public function get_categories(): array |
| 49 | 59 | { |
| 50 | 60 | return ['king-addons']; |
| 51 | 61 | } |
| @@ -119,9 +129,8 @@ | ||
| 119 | 129 | 'kng_styled_txt_content_section_content', |
| 120 | 130 | [ |
| 121 | 131 | 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Content', 'king-addons'), |
| 122 | 132 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 123 | - 'frontend_available' => true, | |
| 124 | 133 | ] |
| 125 | 134 | ); |
| 126 | 135 | |
| 127 | 136 | $repeater = new Repeater(); |
| @@ -413,8 +422,9 @@ | ||
| 413 | 422 | ); |
| 414 | 423 | |
| 415 | 424 | /** ====================================================== */ |
| 416 | 425 | /** TEXT EFFECTS ========================================== */ |
| 426 | + $pro_icon = king_addons_freemius()->can_use_premium_code() ? '' : '<i class="eicon-pro-icon"></i>'; | |
| 417 | 427 | $repeater->add_control( |
| 418 | 428 | 'kng_styled_txt_effect', |
| 419 | 429 | [ |
| 420 | 430 | 'label' => '<b>' . esc_html__('Text Effect', 'king-addons') . '</b>', |
| @@ -423,8 +433,10 @@ | ||
| 423 | 433 | 'none' => esc_html__('None', 'king-addons'), |
| 424 | 434 | 'text-gradient' => esc_html__('Text Gradient', 'king-addons'), |
| 425 | 435 | 'underline-gradient' => esc_html__('Underline Gradient', 'king-addons'), |
| 426 | 436 | 'outline-stroke' => esc_html__('Outline Stroke', 'king-addons'), |
| 437 | + 'spoiler-thanos' => sprintf(__('Spoiler / Thanos Snap %s', 'king-addons'), $pro_icon), | |
| 438 | + 'typing' => sprintf(__('Typing Text %s', 'king-addons'), $pro_icon), | |
| 427 | 439 | ], |
| 428 | 440 | 'label_block' => true, |
| 429 | 441 | 'default' => 'none', |
| 430 | 442 | 'separator' => 'before', |
| @@ -433,8 +445,193 @@ | ||
| 433 | 445 | ] |
| 434 | 446 | ] |
| 435 | 447 | ); |
| 436 | 448 | |
| 449 | + if (!king_addons_freemius()->can_use_premium_code()) { | |
| 450 | + $repeater->add_control( | |
| 451 | + 'kng_styled_txt_effect_spoiler_notice', | |
| 452 | + [ | |
| 453 | + 'type' => Controls_Manager::RAW_HTML, | |
| 454 | + 'raw' => esc_html__('Spoiler / Thanos effect is available in Pro.', 'king-addons'), | |
| 455 | + 'content_classes' => 'king-addons-pro-notice', | |
| 456 | + 'condition' => [ | |
| 457 | + 'kng_styled_txt_effect' => 'spoiler-thanos', | |
| 458 | + 'kng_styled_txt_content_type' => 'text', | |
| 459 | + 'kng_styled_txt_effect!' => 'outline-stroke', | |
| 460 | + ], | |
| 461 | + ] | |
| 462 | + ); | |
| 463 | + } | |
| 464 | + | |
| 465 | + if (!king_addons_freemius()->can_use_premium_code()) { | |
| 466 | + $repeater->add_control( | |
| 467 | + 'kng_styled_txt_effect_typing_notice', | |
| 468 | + [ | |
| 469 | + 'type' => Controls_Manager::RAW_HTML, | |
| 470 | + 'raw' => esc_html__('Typing Text effect is available in Pro.', 'king-addons'), | |
| 471 | + 'content_classes' => 'king-addons-pro-notice', | |
| 472 | + 'condition' => [ | |
| 473 | + 'kng_styled_txt_effect' => 'typing', | |
| 474 | + 'kng_styled_txt_content_type' => 'text', | |
| 475 | + ], | |
| 476 | + ] | |
| 477 | + ); | |
| 478 | + } | |
| 479 | + | |
| 480 | + $repeater->add_control( | |
| 481 | + 'kng_styled_txt_spoiler_trigger_desktop', | |
| 482 | + [ | |
| 483 | + 'label' => esc_html__('Reveal on Desktop', 'king-addons'), | |
| 484 | + 'type' => Controls_Manager::SELECT, | |
| 485 | + 'default' => 'hover', | |
| 486 | + 'options' => [ | |
| 487 | + 'hover' => esc_html__('Hover', 'king-addons'), | |
| 488 | + 'hover-click' => esc_html__('Hover + Click (Remove)', 'king-addons'), | |
| 489 | + 'click' => esc_html__('Click', 'king-addons'), | |
| 490 | + ], | |
| 491 | + 'condition' => [ | |
| 492 | + 'kng_styled_txt_effect' => 'spoiler-thanos', | |
| 493 | + 'kng_styled_txt_content_type' => 'text' | |
| 494 | + ] | |
| 495 | + ] | |
| 496 | + ); | |
| 497 | + | |
| 498 | + $repeater->add_control( | |
| 499 | + 'kng_styled_txt_spoiler_trigger_mobile', | |
| 500 | + [ | |
| 501 | + 'label' => esc_html__('Reveal on Mobile', 'king-addons'), | |
| 502 | + 'type' => Controls_Manager::SELECT, | |
| 503 | + 'default' => 'tap', | |
| 504 | + 'options' => [ | |
| 505 | + 'tap' => esc_html__('Tap', 'king-addons'), | |
| 506 | + 'hover' => esc_html__('Hover', 'king-addons'), | |
| 507 | + 'hover-click' => esc_html__('Hover + Tap (Remove)', 'king-addons'), | |
| 508 | + ], | |
| 509 | + 'condition' => [ | |
| 510 | + 'kng_styled_txt_effect' => 'spoiler-thanos', | |
| 511 | + 'kng_styled_txt_content_type' => 'text' | |
| 512 | + ] | |
| 513 | + ] | |
| 514 | + ); | |
| 515 | + | |
| 516 | + $repeater->add_control( | |
| 517 | + 'kng_styled_txt_spoiler_color', | |
| 518 | + [ | |
| 519 | + 'label' => esc_html__('Spoiler Dots Color', 'king-addons'), | |
| 520 | + 'type' => Controls_Manager::COLOR, | |
| 521 | + 'default' => '#9ca3af', | |
| 522 | + 'condition' => [ | |
| 523 | + 'kng_styled_txt_effect' => 'spoiler-thanos', | |
| 524 | + 'kng_styled_txt_content_type' => 'text' | |
| 525 | + ] | |
| 526 | + ] | |
| 527 | + ); | |
| 528 | + | |
| 529 | + $repeater->add_control( | |
| 530 | + 'kng_styled_txt_spoiler_opacity', | |
| 531 | + [ | |
| 532 | + 'label' => esc_html__('Spoiler Opacity', 'king-addons'), | |
| 533 | + 'type' => Controls_Manager::SLIDER, | |
| 534 | + 'size_units' => ['custom'], | |
| 535 | + 'range' => [ | |
| 536 | + 'custom' => [ | |
| 537 | + 'min' => 0.1, | |
| 538 | + 'max' => 1, | |
| 539 | + 'step' => 0.05, | |
| 540 | + ], | |
| 541 | + ], | |
| 542 | + 'default' => [ | |
| 543 | + 'size' => 0.92, | |
| 544 | + 'unit' => 'custom', | |
| 545 | + ], | |
| 546 | + 'condition' => [ | |
| 547 | + 'kng_styled_txt_effect' => 'spoiler-thanos', | |
| 548 | + 'kng_styled_txt_content_type' => 'text' | |
| 549 | + ] | |
| 550 | + ] | |
| 551 | + ); | |
| 552 | + | |
| 553 | + $repeater->add_control( | |
| 554 | + 'kng_styled_txt_spoiler_speed', | |
| 555 | + [ | |
| 556 | + 'label' => esc_html__('Animation Speed (s)', 'king-addons'), | |
| 557 | + 'type' => Controls_Manager::SLIDER, | |
| 558 | + 'size_units' => ['custom'], | |
| 559 | + 'range' => [ | |
| 560 | + 'custom' => [ | |
| 561 | + 'min' => 0.5, | |
| 562 | + 'max' => 5, | |
| 563 | + 'step' => 0.1, | |
| 564 | + ], | |
| 565 | + ], | |
| 566 | + 'default' => [ | |
| 567 | + 'size' => 1.6, | |
| 568 | + 'unit' => 'custom', | |
| 569 | + ], | |
| 570 | + 'condition' => [ | |
| 571 | + 'kng_styled_txt_effect' => 'spoiler-thanos', | |
| 572 | + 'kng_styled_txt_content_type' => 'text' | |
| 573 | + ] | |
| 574 | + ] | |
| 575 | + ); | |
| 576 | + | |
| 577 | + $repeater->add_control( | |
| 578 | + 'kng_styled_txt_typing_speed', | |
| 579 | + [ | |
| 580 | + 'label' => esc_html__('Typing Speed (ms)', 'king-addons'), | |
| 581 | + 'type' => Controls_Manager::NUMBER, | |
| 582 | + 'default' => 80, | |
| 583 | + 'min' => 10, | |
| 584 | + 'max' => 500, | |
| 585 | + 'condition' => [ | |
| 586 | + 'kng_styled_txt_effect' => 'typing', | |
| 587 | + 'kng_styled_txt_content_type' => 'text' | |
| 588 | + ] | |
| 589 | + ] | |
| 590 | + ); | |
| 591 | + | |
| 592 | + $repeater->add_control( | |
| 593 | + 'kng_styled_txt_typing_delay', | |
| 594 | + [ | |
| 595 | + 'label' => esc_html__('Loop Delay (ms)', 'king-addons'), | |
| 596 | + 'type' => Controls_Manager::NUMBER, | |
| 597 | + 'default' => 1200, | |
| 598 | + 'min' => 0, | |
| 599 | + 'max' => 10000, | |
| 600 | + 'condition' => [ | |
| 601 | + 'kng_styled_txt_effect' => 'typing', | |
| 602 | + 'kng_styled_txt_content_type' => 'text' | |
| 603 | + ] | |
| 604 | + ] | |
| 605 | + ); | |
| 606 | + | |
| 607 | + $repeater->add_control( | |
| 608 | + 'kng_styled_txt_typing_loop', | |
| 609 | + [ | |
| 610 | + 'label' => esc_html__('Loop Typing', 'king-addons'), | |
| 611 | + 'type' => Controls_Manager::SWITCHER, | |
| 612 | + 'return_value' => 'yes', | |
| 613 | + 'default' => 'yes', | |
| 614 | + 'condition' => [ | |
| 615 | + 'kng_styled_txt_effect' => 'typing', | |
| 616 | + 'kng_styled_txt_content_type' => 'text' | |
| 617 | + ] | |
| 618 | + ] | |
| 619 | + ); | |
| 620 | + | |
| 621 | + $repeater->add_control( | |
| 622 | + 'kng_styled_txt_typing_cursor', | |
| 623 | + [ | |
| 624 | + 'label' => esc_html__('Cursor', 'king-addons'), | |
| 625 | + 'type' => Controls_Manager::TEXT, | |
| 626 | + 'default' => '|', | |
| 627 | + 'condition' => [ | |
| 628 | + 'kng_styled_txt_effect' => 'typing', | |
| 629 | + 'kng_styled_txt_content_type' => 'text' | |
| 630 | + ] | |
| 631 | + ] | |
| 632 | + ); | |
| 633 | + | |
| 437 | 634 | /** Outline Stroke ========================================== */ |
| 438 | 635 | $repeater->add_control( |
| 439 | 636 | 'kng_styled_txt_effect_stroke_txt_color', |
| 440 | 637 | [ |
| @@ -1195,9 +1392,9 @@ | ||
| 1195 | 1392 | } |
| 1196 | 1393 | |
| 1197 | 1394 | protected function render(): void |
| 1198 | 1395 | { |
| 1199 | - $settings = $this->get_settings(); | |
| 1396 | + $settings = Core::displaySettings($this); | |
| 1200 | 1397 | |
| 1201 | 1398 | // Get the wrapper HTML tag, default to 'div' if not set |
| 1202 | 1399 | $wrapper_tag = isset($settings['kng_styled_txt_wrapper_html_tag']) ? $settings['kng_styled_txt_wrapper_html_tag'] : 'div'; |
| 1203 | 1400 | ?> |
| @@ -1243,9 +1440,15 @@ | ||
| 1243 | 1440 | if ('text' === $content_type) { |
| 1244 | 1441 | |
| 1245 | 1442 | $txt_effect = $item['kng_styled_txt_effect']; |
| 1246 | 1443 | $txt_effect_class = ''; |
| 1444 | + $data_attrs = ''; | |
| 1445 | + $inline_style = ''; | |
| 1247 | 1446 | |
| 1447 | + if (in_array($txt_effect, ['spoiler-thanos', 'typing'], true) && !king_addons_freemius()->can_use_premium_code__premium_only()) { | |
| 1448 | + $txt_effect = 'none'; | |
| 1449 | + } | |
| 1450 | + | |
| 1248 | 1451 | switch ($txt_effect) { |
| 1249 | 1452 | case 'text-gradient': |
| 1250 | 1453 | $txt_effect_class = ' king-addons-styled-text-gradient'; |
| 1251 | 1454 | break; |
| @@ -1251,8 +1454,28 @@ | ||
| 1251 | 1454 | break; |
| 1252 | 1455 | case 'underline-gradient': |
| 1253 | 1456 | $txt_effect_class = ' king-addons-styled-text-underline-gradient'; |
| 1254 | 1457 | break; |
| 1458 | + case 'spoiler-thanos': | |
| 1459 | + $txt_effect_class = ' king-addons-styled-text--spoiler'; | |
| 1460 | + | |
| 1461 | + $spoiler_color = $item['kng_styled_txt_spoiler_color'] ?? '#9ca3af'; | |
| 1462 | + $spoiler_opacity = isset($item['kng_styled_txt_spoiler_opacity']['size']) ? (float) $item['kng_styled_txt_spoiler_opacity']['size'] : 0.92; | |
| 1463 | + $spoiler_speed = isset($item['kng_styled_txt_spoiler_speed']['size']) ? (float) $item['kng_styled_txt_spoiler_speed']['size'] : 1.6; | |
| 1464 | + $trigger_desktop = $item['kng_styled_txt_spoiler_trigger_desktop'] ?? 'hover'; | |
| 1465 | + $trigger_mobile = $item['kng_styled_txt_spoiler_trigger_mobile'] ?? 'tap'; | |
| 1466 | + | |
| 1467 | + $data_attrs = ' data-effect="spoiler" data-spoiler-desktop="' . esc_attr($trigger_desktop) . '" data-spoiler-mobile="' . esc_attr($trigger_mobile) . '"'; | |
| 1468 | + $inline_style = ' style="--kng-spoiler-color:' . esc_attr($spoiler_color) . ';--kng-spoiler-opacity:' . esc_attr($spoiler_opacity) . ';--kng-spoiler-speed:' . esc_attr($spoiler_speed) . 's;"'; | |
| 1469 | + break; | |
| 1470 | + case 'typing': | |
| 1471 | + $txt_effect_class = ' king-addons-styled-text--typing'; | |
| 1472 | + $typing_speed = isset($item['kng_styled_txt_typing_speed']) ? (int) $item['kng_styled_txt_typing_speed'] : 80; | |
| 1473 | + $typing_delay = isset($item['kng_styled_txt_typing_delay']) ? (int) $item['kng_styled_txt_typing_delay'] : 1200; | |
| 1474 | + $typing_loop = ($item['kng_styled_txt_typing_loop'] ?? 'yes') === 'yes'; | |
| 1475 | + $typing_cursor = $item['kng_styled_txt_typing_cursor'] ?? '|'; | |
| 1476 | + $data_attrs = ' data-effect="typing" data-typing-speed="' . esc_attr($typing_speed) . '" data-typing-delay="' . esc_attr($typing_delay) . '" data-typing-loop="' . ($typing_loop ? 'yes' : 'no') . '" data-typing-cursor="' . esc_attr($typing_cursor) . '"'; | |
| 1477 | + break; | |
| 1255 | 1478 | } |
| 1256 | 1479 | |
| 1257 | 1480 | if ('' !== $item['kng_styled_txt_content']) { |
| 1258 | 1481 | |
| @@ -1257,9 +1480,9 @@ | ||
| 1257 | 1480 | if ('' !== $item['kng_styled_txt_content']) { |
| 1258 | 1481 | |
| 1259 | 1482 | echo '<span class="elementor-repeater-item-' . |
| 1260 | 1483 | esc_attr($item['_id']) . |
| 1261 | - esc_attr($txt_effect_class) . ' king-addons-styled-text">'; | |
| 1484 | + esc_attr($txt_effect_class) . ' king-addons-styled-text"' . $data_attrs . $inline_style . '>'; | |
| 1262 | 1485 | |
| 1263 | 1486 | $html = '<' . esc_attr($item_tag) . ' ' . $this->get_render_attribute_string('kng_styled_txt_content_inner_attribute' . $item_count) . '>'; |
| 1264 | 1487 | echo wp_kses($html, wp_kses_allowed_html('post')); |
| 1265 | 1488 | |