| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wpxero\Marqueex\Integrations\Elementor\Widgets; |
| 4 |
|
| 5 |
use Elementor\Widget_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Group_Control_Typography; |
| 8 |
use Elementor\Group_Control_Text_Stroke; |
| 9 |
use Elementor\Icons_Manager; |
| 10 |
use Wpxero\Marqueex\Traits\AnimatedWordRoller\ContentControls; |
| 11 |
use Wpxero\Marqueex\Traits\AnimatedWordRoller\AdditionalOptionsControls; |
| 12 |
use Wpxero\Marqueex\Traits\AnimatedWordRoller\StyleControls; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* MarqueeX Animated Word Roller Widget for Elementor |
| 20 |
*/ |
| 21 |
class AnimatedWordRoller extends Widget_Base { |
| 22 |
|
| 23 |
use ContentControls; |
| 24 |
use AdditionalOptionsControls; |
| 25 |
use StyleControls; |
| 26 |
|
| 27 |
/** |
| 28 |
* Get widget name |
| 29 |
*/ |
| 30 |
public function get_name() { |
| 31 |
return 'marqueex-animated-word-roller'; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get widget title |
| 36 |
*/ |
| 37 |
public function get_title() { |
| 38 |
return __('Animated Word Roller', 'marqueex'); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Get widget icon |
| 43 |
*/ |
| 44 |
public function get_icon() { |
| 45 |
return 'eicon-animated-headline eicon-marqueex'; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Get widget categories |
| 50 |
*/ |
| 51 |
public function get_categories() { |
| 52 |
return ['marqueex']; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Enqueue widget scripts and styles |
| 57 |
*/ |
| 58 |
public function get_script_depends() { |
| 59 |
return [ |
| 60 |
'marqueex-animated-word-roller' |
| 61 |
]; |
| 62 |
} |
| 63 |
|
| 64 |
public function get_style_depends() { |
| 65 |
return ['marqueex-animated-word-roller-style']; |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Get widget keywords |
| 70 |
*/ |
| 71 |
public function get_keywords() { |
| 72 |
return ['animated word roller', 'animated word', 'animated', 'word', 'smooth', 'roller', 'rotation', 'scroll', 'marquee']; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Register widget controls |
| 77 |
*/ |
| 78 |
protected function register_controls() { |
| 79 |
$this->register_content_section_controls(); |
| 80 |
$this->register_additional_options_section_controls(); |
| 81 |
$this->register_style_section_controls(); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Render widget output on the frontend |
| 86 |
*/ |
| 87 |
protected function render() { |
| 88 |
$settings = $this->get_settings_for_display(); |
| 89 |
$total_words = !empty($settings['marqueex_word_roller_words']) ? count($settings['marqueex_word_roller_words']) : 0; |
| 90 |
$rotation_delay = !empty($settings['marqueex_word_roller_delay']) ? $settings['marqueex_word_roller_delay'] : 1; |
| 91 |
$visible_words = !empty($settings['marqueex_word_roller_visible_words']) ? $settings['marqueex_word_roller_visible_words'] : 5; |
| 92 |
$html_tag = isset($settings['marqueex_word_roller_html_tag']) ? $settings['marqueex_word_roller_html_tag'] : 'h2'; |
| 93 |
$animation_type = $settings['marqueex_word_roller_animation_type'] ?? 'vertical'; |
| 94 |
$pause_on_hover = $settings['marqueex_word_roller_pause_on_hover'] ?? 'no'; |
| 95 |
|
| 96 |
// Check if MarqueeX Pro is active (single source of truth). |
| 97 |
$is_pro_active = class_exists('\\Wpxero\\Marqueex\\MarqueeX') |
| 98 |
&& \Wpxero\Marqueex\MarqueeX::is_premium_active(); |
| 99 |
|
| 100 |
// Pro animation types |
| 101 |
$pro_animations = ['horizontal', 'fade', 'slide', 'zoom']; |
| 102 |
|
| 103 |
// Fallback to basic animation if Pro feature is used without Pro plugin |
| 104 |
if (!$is_pro_active && in_array($animation_type, $pro_animations)) { |
| 105 |
$animation_type = 'vertical'; |
| 106 |
} |
| 107 |
?> |
| 108 |
<div class="marqueex-word-roller-main-wrapper"> |
| 109 |
<<?php echo esc_attr($html_tag); ?> class="marqueex-word-roller-container"> |
| 110 |
<?php if (!empty($settings['marqueex_word_roller_title'])): ?> |
| 111 |
<span class="marqueex-fixed-text marqueex-word-roller-heading"> |
| 112 |
<?php echo esc_html($settings['marqueex_word_roller_title']); ?> |
| 113 |
</span> |
| 114 |
<?php endif; ?> |
| 115 |
|
| 116 |
<div class="marqueex-text-rotator-container"> |
| 117 |
<div style="opacity: 0;" class="marqueex-vertical-scroll-track" |
| 118 |
data-total-words="<?php echo esc_attr($total_words); ?>" |
| 119 |
data-rotation-delay="<?php echo esc_attr($rotation_delay); ?>" |
| 120 |
data-visible-words="<?php echo esc_attr($visible_words); ?>" |
| 121 |
data-animation-type="<?php echo esc_attr($animation_type); ?>" |
| 122 |
data-pause-on-hover="<?php echo esc_attr($pause_on_hover); ?>"> |
| 123 |
|
| 124 |
<?php |
| 125 |
if (!empty($settings['marqueex_word_roller_words'])): |
| 126 |
foreach ($settings['marqueex_word_roller_words'] as $item): |
| 127 |
?> |
| 128 |
<div class="marqueex-rotate-text"> |
| 129 |
<div class="marqueex-rotating-word"> |
| 130 |
<?php echo esc_html($item['marqueex_word_roller_text']); ?> |
| 131 |
</div> |
| 132 |
<?php |
| 133 |
if (!empty($item['marqueex_word_roller_icon']['value'])) { |
| 134 |
Icons_Manager::render_icon( |
| 135 |
$item['marqueex_word_roller_icon'], |
| 136 |
['aria-hidden' => 'true'] |
| 137 |
); |
| 138 |
} |
| 139 |
?> |
| 140 |
</div> |
| 141 |
<?php |
| 142 |
endforeach; |
| 143 |
endif; |
| 144 |
?> |
| 145 |
|
| 146 |
</div> |
| 147 |
</div> |
| 148 |
</<?php echo esc_attr($html_tag); ?>> |
| 149 |
</div> |
| 150 |
<?php |
| 151 |
} |
| 152 |
} |
| 153 |
|