PluginProbe
MarqueeX – Smooth Marquee Slider, News Ticker & Post Marquee for Block Editor & Elementor / 0.6.0
MarqueeX – Smooth Marquee Slider, News Ticker & Post Marquee for Block Editor & Elementor v0.6.0
0.6.0 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.0 0.3.3 0.3.2 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.1.0 0.1.1 0.1.2 0.2.0 0.2.1 0.2.2 0.2.3 0.3.0 0.3.1
marqueex / includes / Integrations / Elementor / Widgets / AnimatedHeading.php

AnimatedHeading.php in MarqueeX – Smooth Marquee Slider, News Ticker & Post Marquee for Block Editor & Elementor 0.6.0, at includes/Integrations/Elementor/Widgets/AnimatedHeading.php

191 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_Border;
9 use Elementor\Group_Control_Box_Shadow;
10 use Elementor\Group_Control_Background;
11 use Elementor\Group_Control_Text_Shadow;
12 use Elementor\Icons_Manager;
13 use Wpxero\Marqueex\Traits\AnimatedHeading\TitleControls;
14 use Wpxero\Marqueex\Traits\AnimatedHeading\AnimationControls;
15 use Wpxero\Marqueex\Traits\AnimatedHeading\TextStylesControls;
16 use Wpxero\Marqueex\Traits\AnimatedHeading\AnimatedTextEffectControls;
17
18 if (!defined('ABSPATH')) {
19 exit;
20 }
21
22 /**
23 * MarqueeX Animated Heading Widget for Elementor
24 */
25 class AnimatedHeading extends Widget_Base {
26
27 use TitleControls;
28 use AnimationControls;
29 use TextStylesControls;
30 use AnimatedTextEffectControls;
31
32 /**
33 * Get widget name
34 */
35 public function get_name() {
36 return 'marqueex-animated-heading';
37 }
38
39 /**
40 * Get widget title
41 */
42 public function get_title() {
43 return __('Animated Heading', 'marqueex');
44 }
45
46 /**
47 * Get widget icon
48 */
49 public function get_icon() {
50 return 'eicon-animated-headline eicon-marqueex';
51 }
52
53 /**
54 * Get widget categories
55 */
56 public function get_categories() {
57 return ['marqueex'];
58 }
59
60 /**
61 * Enqueue widget scripts and styles
62 */
63 public function get_script_depends() {
64 return [
65 'marqueex-animated-heading'
66 ];
67 }
68
69 public function get_style_depends() {
70 return ['marqueex-animated-heading-style'];
71 }
72
73 /**
74 * Get widget keywords
75 */
76 public function get_keywords() {
77 return ['animation', 'animated', 'heading', 'head', 'header', 'marquee'];
78 }
79
80 /**
81 * Register widget controls
82 */
83 protected function register_controls() {
84 $this->register_title_section_controls();
85 $this->register_animation_section_controls();
86 $this->register_text_styles_section_controls();
87 $this->register_animated_text_effect_section_controls();
88 }
89
90 /**
91 * Render widget output on the frontend
92 */
93 protected function render() {
94 $settings = $this->get_settings_for_display();
95 $tag = $settings['marqueex_heading_tag'] ?? 'h2';
96 $before = $settings['marqueex_before_text'] ?? '';
97 $after = $settings['marqueex_after_text'] ?? '';
98 $texts = $settings['marqueex_animated_texts'] ?? [];
99 $animation = $settings['marqueex_animation_type'] ?? '';
100 $animationSpeed = $settings['marqueex_animation_speed'] ?? '';
101 $isPauseOnHover = $settings['marqueex_animation_pause_on_hover'] ?? '';
102 $textEffectType = $settings['marqueex_animated_text_effect_type'] ?? '';
103 $pauseBetweenWords = $settings['marqueex_pause_between_words'] ?? '';
104 $pauseAfterTyped = $settings['marqueex_pause_after_typed'] ?? '';
105 $delayPerWord = $settings['marqueex_delay_per_word'] ?? '';
106 $lineType = $settings['marqueex_line_type'] ?? '';
107 $delayBeforeErase = $settings['marqueex_delay_before_erase'] ?? '';
108
109 // Check if MarqueeX Pro is active (single source of truth).
110 $is_pro_active = class_exists('\\Wpxero\\Marqueex\\MarqueeX')
111 && \Wpxero\Marqueex\MarqueeX::is_premium_active();
112
113 // Pro animation types
114 $pro_animations = ['rotation-3d', 'construct', 'twist', 'line', 'wave', 'swing', 'tilt', 'lean'];
115 $pro_effects = ['marqueex-gradient-text', 'marqueex-masked-text'];
116
117 // Fallback to basic animation if Pro feature is used without Pro plugin
118 if (!$is_pro_active && in_array($animation, $pro_animations)) {
119 $animation = 'slide';
120 }
121
122 // Fallback to basic effect if Pro feature is used without Pro plugin
123 if (!$is_pro_active && in_array($textEffectType, $pro_effects)) {
124 $textEffectType = 'fill';
125 }
126
127 $slideDirection = '';
128 if ($animation === 'slide') {
129 $slideDirection = $settings['marqueex_slide_vertical_direction'] ?? '';
130 } elseif ($animation === 'slide-horizontal') {
131 $slideDirection = $settings['marqueex_slide_horizontal_direction'] ?? '';
132 }
133 ?>
134 <div class="marqueex-animated-heading marqueex-animation-on">
135 <<?php echo esc_html($tag); ?> class="marqueex-heading <?php echo esc_attr($animation); ?><?php echo ($animation === 'line') ? ' ' . esc_attr($lineType) : ''; ?>">
136 <?php if ($before): ?>
137 <span class="marqueex-before-text"><?php echo esc_html($before); ?></span>
138 <?php endif; ?>
139
140 <?php if (in_array($animation, ['slide', 'slide-horizontal', 'rotation-3d'])): ?>
141 <div class="marqueex-animated-text-container">
142 <?php endif; ?>
143
144 <?php if (!empty($texts)): ?>
145 <span class="marqueex-texts-wrapper <?php echo esc_attr($textEffectType); ?>"
146 data-animation="<?php echo esc_attr($animation); ?>"
147 data-animation-speed="<?php echo esc_attr($animationSpeed); ?>"
148 data-is-pause-on-hover="<?php echo esc_attr($isPauseOnHover); ?>"
149 <?php if ($animation === 'construct'): ?>
150 data-pause-between-words="<?php echo esc_attr($pauseBetweenWords); ?>"
151 <?php endif; ?>
152 <?php if ($animation === 'typing'): ?>
153 data-pause-after-typed="<?php echo esc_attr($pauseAfterTyped); ?>"
154 <?php endif; ?>
155 <?php if (in_array($animation, ['slide', 'slide-horizontal'])): ?>
156 data-delay-per-word="<?php echo esc_attr($delayPerWord); ?>"
157 data-slide-direction="<?php echo esc_attr($slideDirection); ?>"
158 <?php endif; ?>
159 <?php if ($animation === 'line'): ?>
160 data-line-type="<?php echo esc_attr($lineType); ?>"
161 data-delay-before-erase="<?php echo esc_attr($delayBeforeErase); ?>"
162 <?php endif; ?>>
163 <?php foreach ($texts as $item): ?>
164 <span class="marqueex-animated-text"><?php echo esc_html($item['marqueex_animated_text'] ?? ''); ?></span>
165 <?php endforeach; ?>
166
167 <?php if ($animation === 'line'): ?>
168 <svg
169 height="100%"
170 width="100%"
171 class="marqueex-animated-lines"
172 xmlns="http://www.w3.org/2000/svg"
173 viewBox="0 0 500 200"
174 preserveAspectRatio="none"></svg>
175 <?php endif; ?>
176 </span>
177 <?php endif; ?>
178
179 <?php if (in_array($animation, ['slide', 'slide-horizontal', 'rotation-3d'])): ?>
180 </div>
181 <?php endif; ?>
182
183 <?php if ($after): ?>
184 <span class="marqueex-after-text"><?php echo esc_html($after); ?></span>
185 <?php endif; ?>
186 </<?php echo esc_html($tag); ?>>
187 </div>
188 <?php
189 }
190 }
191