PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.11.84
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.11.84
4.11.84 4.11.83 4.11.82 4.11.80 4.11.81 4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / widgets / premium-post-ticker.php
premium-addons-for-elementor / widgets Last commit date
dep 3 weeks ago premium-banner.php 1 day ago premium-blog.php 2 weeks ago premium-button.php 2 weeks ago premium-carousel.php 2 weeks ago premium-contactform.php 2 weeks ago premium-countdown.php 2 weeks ago premium-counter.php 2 weeks ago premium-dual-header.php 2 weeks ago premium-fancytext.php 2 weeks ago premium-grid.php 2 weeks ago premium-icon-list.php 2 weeks ago premium-image-button.php 2 weeks ago premium-image-scroll.php 2 weeks ago premium-image-separator.php 2 weeks ago premium-lottie.php 2 weeks ago premium-maps.php 2 days ago premium-media-wheel.php 2 weeks ago premium-mobile-menu.php 2 weeks ago premium-modalbox.php 2 days ago premium-nav-menu.php 2 weeks ago premium-notifications.php 2 weeks ago premium-person.php 2 weeks ago premium-pinterest-feed.php 2 weeks ago premium-post-ticker.php 2 weeks ago premium-pricing-table.php 2 days ago premium-progressbar.php 2 weeks ago premium-search-form.php 2 days ago premium-svg-drawer.php 2 weeks ago premium-tcloud.php 2 weeks ago premium-testimonials.php 2 weeks ago premium-textual-showcase.php 2 weeks ago premium-tiktok-feed.php 2 weeks ago premium-title.php 2 days ago premium-videobox.php 2 weeks ago premium-vscroll.php 2 weeks ago premium-weather.php 2 weeks ago premium-world-clock.php 2 weeks ago
premium-post-ticker.php
4212 lines
1 <?php
2 /**
3 * Premium Post Ticker.
4 */
5
6 namespace PremiumAddons\Widgets;
7
8 // Elementor Classes.
9 use Elementor\Plugin;
10 use Elementor\Repeater;
11 use Elementor\Widget_Base;
12 use Elementor\Icons_Manager;
13 use Elementor\Controls_Manager;
14 use Elementor\Group_Control_Border;
15 use Elementor\Group_Control_Image_Size;
16 use PremiumAddons\Includes\Controls\Premium_Background;
17 use Elementor\Group_Control_Typography;
18 use Elementor\Group_Control_Box_Shadow;
19 use Elementor\Group_Control_Text_Shadow;
20 use Elementor\Group_Control_Text_Stroke;
21 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
22 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
23
24
25 // PremiumAddons Classes.
26 use PremiumAddons\Admin\Includes\Admin_Helper;
27 use PremiumAddons\Includes\Helper_Functions;
28 use PremiumAddons\Includes\Controls\Premium_Post_Filter;
29 use PremiumAddons\Includes\Premium_Template_Tags as Posts_Helper;
30
31 // PremiumAddonsPro Classes.
32 use PremiumAddonsPro\Includes\Pa_Post_Ticker_Helper as API_Handler;
33
34 if ( ! defined( 'ABSPATH' ) ) {
35 exit; // If this file is called directly, abort.
36 }
37
38 /**
39 * Class Premium_Post_Ticker.
40 */
41 class Premium_Post_Ticker extends Widget_Base {
42
43 /**
44 * Check if the icon draw is enabled.
45 *
46 * @since 4.9.26
47 * @access private
48 *
49 * @var bool
50 */
51 private $is_draw_enabled = null;
52
53 /**
54 * Options
55 *
56 * @var array
57 */
58 private $options = array();
59
60 /**
61 * Check Premium Addons Pro Version.
62 *
63 * @var bool $papro_activated
64 */
65 private $papro_activated;
66
67 /**
68 * Check Icon Draw Option.
69 *
70 * @since 4.9.26
71 * @access public
72 */
73 public function check_icon_draw() {
74
75 if ( null === $this->is_draw_enabled ) {
76 $this->is_draw_enabled = Admin_Helper::check_svg_draw( 'premium-post-ticker' );
77 }
78
79 return $this->is_draw_enabled;
80 }
81
82 /**
83 * Retrieve Widget Name.
84 *
85 * @since 1.0.0
86 * @access public
87 */
88 public function get_name() {
89 return 'premium-post-ticker';
90 }
91
92 /**
93 * Retrieve Widget Title.
94 *
95 * @since 1.0.0
96 * @access public
97 */
98 public function get_title() {
99 return __( 'News Ticker', 'premium-addons-for-elementor' );
100 }
101
102 /**
103 * Retrieve Widget Icon.
104 *
105 * @since 1.0.0
106 * @access public
107 *
108 * @return string widget icon.
109 */
110 public function get_icon() {
111 return 'pa-ticker';
112 }
113
114 /**
115 * Retrieve Widget Keywords.
116 *
117 * @since 1.0.0
118 * @access public
119 *
120 * @return array Widget keywords.
121 */
122 public function get_keywords() {
123 return array( 'pa', 'premium', 'premium news ticker', 'magazine', 'news', 'posts', 'listing', 'ticker', 'grid', 'blog' );
124 }
125
126 /**
127 * Retrieve Widget Categories.
128 *
129 * @since 1.5.1
130 * @access public
131 *
132 * @return array Widget categories.
133 */
134 public function get_categories() {
135 return array( 'premium-elements' );
136 }
137
138 /**
139 * Widget preview refresh button.
140 *
141 * @since 1.0.0
142 * @access public
143 */
144 public function is_reload_preview_required() {
145 return true;
146 }
147
148 /**
149 * Retrieve Widget Dependent CSS.
150 *
151 * @since 1.0.0
152 * @access public
153 *
154 * @return array CSS style handles.
155 */
156 public function get_style_depends() {
157
158 return array(
159 'pa-glass',
160 'font-awesome-5-all',
161 'pa-slick',
162 'premium-addons',
163 );
164 }
165
166 /**
167 * Retrieve Widget Dependent JS.
168 *
169 * @since 1.0.0
170 * @access public
171 *
172 * @return array JS script handles.
173 */
174 public function get_script_depends() {
175
176 $is_edit = Helper_Functions::is_edit_mode();
177
178 $scripts = array( 'pa-slick' );
179
180 if ( $is_edit ) {
181
182 $draw_scripts = $this->check_icon_draw() ? array( 'pa-tweenmax', 'pa-motionpath' ) : array();
183
184 $scripts = array_merge( $draw_scripts, array( 'pa-glass', 'lottie-js' ) );
185
186 } else {
187
188 $settings = $this->get_settings();
189
190 $draw_js = false;
191 $lottie_js = false;
192
193 if ( 'yes' === $settings['draw_svg'] ) {
194 $scripts[] = 'pa-tweenmax';
195 $scripts[] = 'pa-motionpath';
196 $draw_js = true;
197 }
198
199 if ( 'lottie' === $settings['icon_type'] ) {
200 $scripts[] = 'lottie-js';
201 $lottie_js = true;
202 }
203
204 if ( ! empty( $settings['text_content'] ) ) {
205
206 foreach ( $settings['text_content'] as $item ) {
207
208 if ( ! $draw_js && 'yes' === $item['draw_svg'] ) {
209 $scripts[] = 'pa-tweenmax';
210 $scripts[] = 'pa-motionpath';
211 $draw_js = true;
212 }
213
214 if ( ! $lottie_js && 'lottie' === $item['icon_type'] ) {
215 $scripts[] = 'lottie-js';
216 $lottie_js = true;
217 }
218 }
219 }
220
221 if ( 'none' !== $settings['post_lq_effect'] ) {
222 $scripts[] = 'pa-glass';
223 }
224 }
225
226 $scripts[] = 'premium-addons';
227
228 return $scripts;
229 }
230
231 /**
232 * Retrieve Widget Support URL.
233 *
234 * @access public
235 *
236 * @return string support URL.
237 */
238 public function get_custom_help_url() {
239 return 'https://premiumaddons.com/support/';
240 }
241
242 public function has_widget_inner_wrapper(): bool {
243 return ! Helper_Functions::check_elementor_experiment( 'e_optimized_markup' );
244 }
245
246 /**
247 * Register Smart Post Listing controls.
248 *
249 * @since 1.0.0
250 * @access protected
251 */
252 protected function register_controls() {
253
254 $this->options = apply_filters(
255 'pa_ticker_options',
256 array(
257 'layouts' => array(
258 'layout-1' => __( 'Layout 1', 'premium-addons-for-elementor' ),
259 'layout-2' => __( 'Layout 2', 'premium-addons-for-elementor' ),
260 'layout-3' => __( 'Layout 3 (Pro)', 'premium-addons-for-elementor' ),
261 'layout-4' => __( 'Layout 4 (Pro)', 'premium-addons-for-elementor' ),
262 ),
263 'layout_condition' => array( 'layout-3', 'layout-4' ),
264 )
265 );
266
267 $this->register_content_tab_controls();
268 $this->register_style_tab_controls();
269 }
270
271 /**
272 * Adds content tab controls.
273 *
274 * @access private
275 * @since 4.9.37
276 */
277 private function register_content_tab_controls() {
278
279 $this->add_general_section_controls();
280 $this->add_query_section_controls();
281 $this->add_posts_section_controls();
282
283 $this->papro_activated = Helper_Functions::check_papro_version();
284
285 if ( $this->papro_activated ) {
286 do_action( 'pa_ticker_stock_controls', $this );
287 }
288
289 $this->add_slider_section_controls();
290
291 $this->add_helpful_info_section();
292
293 Helper_Functions::register_papro_promotion_controls( $this, 'ticker' );
294 }
295
296 /**
297 * Adds style tab controls.
298 *
299 * @access private
300 * @since 4.9.37
301 */
302 private function register_style_tab_controls() {
303
304 $this->add_ticker_title_style();
305
306 $this->add_ticker_date_style();
307
308 $this->add_posts_style();
309
310 $this->add_posts_container_style();
311
312 $this->add_navigation_style();
313
314 $this->add_separator_style();
315 }
316
317 /**
318 * Adds General controls.
319 *
320 * @access private
321 * @since 4.9.37
322 */
323 private function add_general_section_controls() {
324
325 $draw_icon = $this->check_icon_draw();
326
327 $this->start_controls_section(
328 'pa_ticker_general_section',
329 array(
330 'label' => __( 'General', 'premium-addons-for-elementor' ),
331 )
332 );
333
334 $demo = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/elementor-news-ticker-widget/', 'ticker', 'wp-editor', 'demo' );
335 Helper_Functions::add_templates_controls( $this, 'news-ticker', $demo );
336
337 $this->add_control(
338 'layout',
339 array(
340 'label' => __( 'Layout', 'premium-addons-for-elementor' ),
341 'type' => Controls_Manager::SELECT,
342 'prefix_class' => 'premium-post-ticker__',
343 'render_type' => 'template',
344 'label_block' => true,
345 'options' => $this->options['layouts'],
346 'default' => 'layout-1',
347 )
348 );
349
350 $this->papro_activated = Helper_Functions::check_papro_version();
351 if ( ! $this->papro_activated ) {
352
353 $get_pro = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro', 'ticker-widget', 'wp-editor', 'get-pro' );
354
355 $this->add_control(
356 'ticker_notice',
357 array(
358 'type' => Controls_Manager::RAW_HTML,
359 'raw' => __( 'This option is available in Premium Addons Pro. ', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $get_pro ) . '" target="_blank">' . __( 'Upgrade now!', 'premium-addons-for-elementor' ) . '</a>',
360 'content_classes' => 'papro-upgrade-notice',
361 'condition' => array(
362 'layout' => $this->options['layout_condition'],
363 ),
364 )
365 );
366
367 }
368
369 $this->add_control(
370 'ticker_title',
371 array(
372 'label' => __( 'Ticker Title', 'premium-addons-for-elementor' ),
373 'type' => Controls_Manager::TEXT,
374 'label_block' => true,
375 'default' => __( 'TRENDING', 'premium-addons-for-elementor' ),
376 'dynamic' => array( 'active' => true ),
377 )
378 );
379
380 $this->add_control(
381 'ticker_icon_sw',
382 array(
383 'label' => __( 'Icon', 'premium-addons-for-elementor' ),
384 'type' => Controls_Manager::SWITCHER,
385 'render_type' => 'template',
386 'condition' => array(
387 'ticker_title!' => '',
388 ),
389 )
390 );
391
392 $this->add_control(
393 'icon_type',
394 array(
395 'label' => __( 'Icon Type', 'premium-addons-for-elementor' ),
396 'type' => Controls_Manager::SELECT,
397 'render_type' => 'template',
398 'options' => array(
399 'icon' => __( 'Icon', 'premium-addons-for-elementor' ),
400 'lottie' => __( 'Lottie Animation', 'premium-addons-for-elementor' ),
401 'image' => __( 'Image', 'premium-addons-for-elementor' ),
402 'svg' => __( 'SVG Code', 'premium-addons-for-elementor' ),
403 ),
404 'default' => 'icon',
405 'condition' => array(
406 'ticker_icon_sw' => 'yes',
407 'ticker_title!' => '',
408 ),
409 )
410 );
411
412 $common_conditions = array(
413 'ticker_icon_sw' => 'yes',
414 'ticker_title!' => '',
415 );
416
417 $this->add_control(
418 'pa_ticker_icon',
419 array(
420 'label' => __( 'Choose Icon', 'premium-addons-for-elementor' ),
421 'type' => Controls_Manager::ICONS,
422 'label_block' => false,
423 'skin' => 'inline',
424 'default' => array(
425 'value' => 'fas fa-star',
426 'library' => 'fa-solid',
427 ),
428 'condition' => array(
429 'ticker_icon_sw' => 'yes',
430 'ticker_title!' => '',
431 'icon_type' => 'icon',
432 ),
433 )
434 );
435
436 $this->add_control(
437 'custom_svg',
438 array(
439 'label' => __( 'SVG Code', 'premium-addons-for-elementor' ),
440 'type' => Controls_Manager::TEXTAREA,
441 'description' => 'You can use these sites to create SVGs: <a href="https://danmarshall.github.io/google-font-to-svg-path/" target="_blank">Google Fonts</a> and <a href="https://boxy-svg.com/" target="_blank">Boxy SVG</a>',
442 'condition' => array(
443 'ticker_icon_sw' => 'yes',
444 'ticker_title!' => '',
445 'icon_type' => 'svg',
446 ),
447 'ai' => array(
448 'active' => false,
449 ),
450 )
451 );
452
453 $this->add_control(
454 'image',
455 array(
456 'label' => __( 'Image', 'premium-addons-for-elementor' ),
457 'type' => Controls_Manager::MEDIA,
458 'media_types' => array( 'image' ),
459 'dynamic' => array( 'active' => true ),
460 'condition' => array(
461 'ticker_icon_sw' => 'yes',
462 'ticker_title!' => '',
463 'icon_type' => 'image',
464 ),
465 )
466 );
467
468 $this->add_control(
469 'lottie_url',
470 array(
471 'label' => __( 'Animation JSON URL', 'premium-addons-for-elementor' ),
472 'type' => Controls_Manager::TEXT,
473 'dynamic' => array( 'active' => true ),
474 'description' => 'Get JSON code URL from <a href="https://lottiefiles.com/" target="_blank">here</a>',
475 'label_block' => true,
476 'condition' => array(
477 'ticker_icon_sw' => 'yes',
478 'ticker_title!' => '',
479 'icon_type' => 'lottie',
480 ),
481 'ai' => array(
482 'active' => false,
483 ),
484 )
485 );
486
487 $animation_conds = array(
488 'terms' => array(
489 array(
490 'name' => 'ticker_icon_sw',
491 'value' => 'yes',
492 ),
493 array(
494 'name' => 'ticker_title',
495 'operator' => '!==',
496 'value' => '',
497 ),
498 array(
499 'relation' => 'or',
500 'terms' => array(
501 array(
502 'name' => 'icon_type',
503 'value' => 'lottie',
504 ),
505 array(
506 'terms' => array(
507 array(
508 'relation' => 'or',
509 'terms' => array(
510 array(
511 'name' => 'icon_type',
512 'value' => 'icon',
513 ),
514 array(
515 'name' => 'icon_type',
516 'value' => 'svg',
517 ),
518 ),
519 ),
520 array(
521 'name' => 'draw_svg',
522 'value' => 'yes',
523 ),
524 ),
525 ),
526 ),
527 ),
528 ),
529 );
530
531 $this->add_control(
532 'draw_svg',
533 array(
534 'label' => __( 'Draw Icon', 'premium-addons-for-elementor' ),
535 'type' => Controls_Manager::SWITCHER,
536 'description' => __( 'Enable this option to make the icon drawable. See ', 'premium-addons-for-elementor' ) . '<a href="https://www.youtube.com/watch?v=ZLr0bRe0RAY" target="_blank">tutorial</a>',
537 'classes' => $draw_icon ? '' : 'editor-pa-control-disabled',
538 'condition' => array_merge(
539 $common_conditions,
540 array(
541 'icon_type' => array( 'icon', 'svg' ),
542 'pa_ticker_icon[library]!' => 'svg',
543 )
544 ),
545 )
546 );
547
548 if ( $draw_icon ) {
549
550 $this->add_control(
551 'path_width',
552 array(
553 'label' => __( 'Path Thickness', 'premium-addons-for-elementor' ),
554 'type' => Controls_Manager::SLIDER,
555 'range' => array(
556 'px' => array(
557 'min' => 0,
558 'max' => 50,
559 'step' => 0.1,
560 ),
561 ),
562 'condition' => array_merge(
563 $common_conditions,
564 array(
565 'icon_type' => array( 'icon', 'svg' ),
566 )
567 ),
568 'selectors' => array(
569 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) svg *' => 'stroke-width: {{SIZE}}',
570 ),
571 )
572 );
573
574 $this->add_control(
575 'svg_sync',
576 array(
577 'label' => __( 'Draw All Paths Together', 'premium-addons-for-elementor' ),
578 'type' => Controls_Manager::SWITCHER,
579 'condition' => array_merge(
580 $common_conditions,
581 array(
582 'icon_type' => array( 'icon', 'svg' ),
583 'draw_svg' => 'yes',
584 )
585 ),
586 )
587 );
588
589 $this->add_control(
590 'frames',
591 array(
592 'label' => __( 'Speed', 'premium-addons-for-elementor' ),
593 'type' => Controls_Manager::NUMBER,
594 'description' => __( 'Larger value means longer animation duration.', 'premium-addons-for-elementor' ),
595 'default' => 5,
596 'min' => 1,
597 'max' => 100,
598 'condition' => array_merge(
599 $common_conditions,
600 array(
601 'icon_type' => array( 'icon', 'svg' ),
602 'draw_svg' => 'yes',
603 )
604 ),
605 )
606 );
607
608 } else {
609
610 Helper_Functions::get_draw_svg_notice(
611 $this,
612 'ticker',
613 array_merge(
614 $common_conditions,
615 array(
616 'icon_type' => array( 'icon', 'svg' ),
617 'pa_ticker_icon[library]!' => 'svg',
618 )
619 )
620 );
621
622 }
623
624 $this->add_control(
625 'lottie_loop',
626 array(
627 'label' => __( 'Loop', 'premium-addons-for-elementor' ),
628 'type' => Controls_Manager::SWITCHER,
629 'return_value' => 'true',
630 'default' => 'true',
631 'conditions' => $animation_conds,
632 )
633 );
634
635 $this->add_control(
636 'lottie_reverse',
637 array(
638 'label' => __( 'Reverse', 'premium-addons-for-elementor' ),
639 'type' => Controls_Manager::SWITCHER,
640 'return_value' => 'true',
641 'conditions' => $animation_conds,
642 )
643 );
644
645 if ( $draw_icon ) {
646
647 $this->add_control(
648 'start_point',
649 array(
650 'label' => __( 'Start Point (%)', 'premium-addons-for-elementor' ),
651 'type' => Controls_Manager::SLIDER,
652 'description' => __( 'Set the point that the SVG should start from.', 'premium-addons-for-elementor' ),
653 'default' => array(
654 'unit' => '%',
655 'size' => 0,
656 ),
657 'condition' => array(
658 'icon_type' => array( 'icon', 'svg' ),
659 'draw_svg' => 'yes',
660 'lottie_reverse!' => 'true',
661 ),
662
663 )
664 );
665
666 $this->add_control(
667 'end_point',
668 array(
669 'label' => __( 'End Point (%)', 'premium-addons-for-elementor' ),
670 'type' => Controls_Manager::SLIDER,
671 'description' => __( 'Set the point that the SVG should end at.', 'premium-addons-for-elementor' ),
672 'default' => array(
673 'unit' => '%',
674 'size' => 0,
675 ),
676 'condition' => array(
677 'icon_type' => array( 'icon', 'svg' ),
678 'draw_svg' => 'yes',
679 'lottie_reverse' => 'true',
680 ),
681
682 )
683 );
684
685 $this->add_control(
686 'svg_yoyo',
687 array(
688 'label' => __( 'Yoyo Effect', 'premium-addons-for-elementor' ),
689 'type' => Controls_Manager::SWITCHER,
690 'condition' => array(
691 'icon_type' => array( 'icon', 'svg' ),
692 'draw_svg' => 'yes',
693 'lottie_loop' => 'true',
694 ),
695 )
696 );
697 }
698
699 $this->add_control(
700 'icon_order',
701 array(
702 'label' => __( 'Icon Order', 'premium-addons-for-elementor' ),
703 'type' => Controls_Manager::CHOOSE,
704 'toggle' => false,
705 'options' => array(
706 '0' => array(
707 'title' => __( 'Before Title', 'premium-addons-for-elementor' ),
708 'icon' => is_rtl() ? 'eicon-order-end' : 'eicon-order-start',
709 ),
710 '2' => array(
711 'title' => __( 'After Title', 'premium-addons-for-elementor' ),
712 'icon' => is_rtl() ? 'eicon-order-start' : 'eicon-order-end',
713 ),
714 ),
715 'separator' => 'before',
716 'default' => '0',
717 'condition' => array(
718 'ticker_icon_sw' => 'yes',
719 'ticker_title!' => '',
720 ),
721 'selectors' => array(
722 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item)' => 'order: {{VALUE}}',
723 ),
724 )
725 );
726
727 $this->add_responsive_control(
728 'icon_size',
729 array(
730 'label' => __( 'Icon Size (px)', 'premium-addons-for-elementor' ),
731 'type' => Controls_Manager::SLIDER,
732 'size_units' => array( 'px' ),
733 'range' => array(
734 'px' => array(
735 'min' => 0,
736 'max' => 500,
737 ),
738 ),
739 'selectors' => array(
740 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) i' => 'font-size: {{SIZE}}px;',
741 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) img' => 'width: {{SIZE}}px',
742 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) > svg,
743 {{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) .premium-lottie-animation,
744 {{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) .premium-drawable-icon' => 'width: {{SIZE}}px; height: {{SIZE}}px; line-height: {{SIZE}}px;',
745 ),
746 'condition' => array(
747 'ticker_icon_sw' => 'yes',
748 'ticker_title!' => '',
749 ),
750 )
751 );
752
753 $this->add_group_control(
754 Group_Control_Image_Size::get_type(),
755 array(
756 'name' => 'thumbnail',
757 'default' => 'full',
758 'condition' => array(
759 'ticker_icon_sw' => 'yes',
760 'ticker_title!' => '',
761 'icon_type' => 'image',
762 ),
763 )
764 );
765
766 $this->add_responsive_control(
767 'icon_spacing',
768 array(
769 'label' => __( 'Spacing (px)', 'premium-addons-for-elementor' ),
770 'type' => Controls_Manager::SLIDER,
771 'size_units' => array( 'px' ),
772 'selectors' => array(
773 '{{WRAPPER}} .premium-post-ticker__title-wrapper' => 'column-gap: {{SIZE}}px',
774 ),
775 'condition' => array(
776 'ticker_icon_sw' => 'yes',
777 'ticker_title!' => '',
778 ),
779 )
780 );
781
782 $this->add_control(
783 'hide_title_on',
784 array(
785 'label' => __( 'Hide Title On', 'premium-addons-for-elementor' ),
786 'type' => Controls_Manager::SELECT2,
787 'options' => Helper_Functions::get_all_breakpoints(),
788 'separator' => 'after',
789 'multiple' => true,
790 'label_block' => true,
791 'default' => array(),
792 'condition' => array(
793 'ticker_title!' => '',
794 ),
795 )
796 );
797
798 $this->add_control(
799 'show_date',
800 array(
801 'label' => __( 'Show Current Date', 'premium-addons-for-elementor' ),
802 'type' => Controls_Manager::SWITCHER,
803 'default' => 'yes',
804 )
805 );
806
807 $this->add_control(
808 'ticker_date_pos',
809 array(
810 'label' => __( 'Position', 'premium-addons-for-elementor' ),
811 'type' => Controls_Manager::CHOOSE,
812 'toggle' => false,
813 'options' => array(
814 'flex-start' => array(
815 'title' => __( 'Start', 'premium-addons-for-elementor' ),
816 'icon' => is_rtl() ? 'eicon-order-end' : 'eicon-order-start',
817 ),
818 'flex-end' => array(
819 'title' => __( 'End', 'premium-addons-for-elementor' ),
820 'icon' => is_rtl() ? 'eicon-order-start' : 'eicon-order-end',
821 ),
822 ),
823 'default' => 'flex-start',
824 'condition' => array(
825 'show_date' => 'yes',
826 'layout' => 'layout-1',
827 ),
828 'selectors' => array(
829 '{{WRAPPER}}.premium-post-ticker__layout-1 .premium-post-ticker__header-wrapper' => 'align-self: {{VALUE}}',
830 ),
831 )
832 );
833
834 $this->add_control(
835 'ticker_date_order',
836 array(
837 'label' => __( 'Order', 'premium-addons-for-elementor' ),
838 'type' => Controls_Manager::CHOOSE,
839 'toggle' => false,
840 'options' => array(
841 '0' => array(
842 'title' => __( 'Before Title', 'premium-addons-for-elementor' ),
843 'icon' => 'eicon-order-start',
844 ),
845 '1' => array(
846 'title' => __( 'After Title', 'premium-addons-for-elementor' ),
847 'icon' => 'eicon-order-end',
848 ),
849 ),
850 'default' => '0',
851 'condition' => array(
852 'show_date' => 'yes',
853 'layout' => 'layout-4',
854 ),
855 'selectors' => array(
856 '{{WRAPPER}}.premium-post-ticker__layout-4 .premium-post-ticker__date-wrapper' => 'order: {{VALUE}}',
857 ),
858 )
859 );
860
861 $this->add_control(
862 'date_format',
863 array(
864 'label' => __( 'Date Format', 'premium-addons-for-elementor' ),
865 'type' => Controls_Manager::TEXT,
866 'label_block' => true,
867 'description' => __( 'Know more abour date format from ', 'premium-addons-for-elementor' ) . '<a href="https://wordpress.org/documentation/article/customize-date-and-time-format/" target="_blank">here</a>',
868 'default' => get_option( 'date_format' ),
869 'condition' => array(
870 'show_date' => 'yes',
871 ),
872 'ai' => array(
873 'active' => false,
874 ),
875 )
876 );
877
878 $this->add_control(
879 'hide_date_on',
880 array(
881 'label' => __( 'Hide Date On', 'premium-addons-for-elementor' ),
882 'type' => Controls_Manager::SELECT2,
883 'options' => Helper_Functions::get_all_breakpoints(),
884 'separator' => 'after',
885 'multiple' => true,
886 'label_block' => true,
887 'default' => array(),
888 'condition' => array(
889 'show_date' => 'yes',
890 ),
891 )
892 );
893
894 $this->add_control(
895 'premium_blog_number_of_posts',
896 array(
897 'label' => __( 'Posts To Load', 'premium-addons-for-elementor' ),
898 'type' => Controls_Manager::NUMBER,
899 'min' => 1,
900 'default' => 4,
901 'condition' => array(
902 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
903 ),
904 )
905 );
906
907 $this->add_control(
908 'additional_heading',
909 array(
910 'label' => __( 'Additional Settings', 'premium-addons-for-elementor' ),
911 'type' => Controls_Manager::HEADING,
912 'separator' => 'before',
913 )
914 );
915
916 $this->add_control(
917 'reverse',
918 array(
919 'label' => __( 'Reverse Direction', 'premium-addons-for-elementor' ),
920 'type' => Controls_Manager::SWITCHER,
921 'prefix_class' => 'premium-reversed-',
922 'render_type' => 'template',
923 )
924 );
925
926 $this->add_control(
927 'infinite',
928 array(
929 'label' => __( 'Marquee Effect', 'premium-addons-for-elementor' ),
930 'type' => Controls_Manager::SWITCHER,
931 'separator' => 'before',
932 'render_type' => 'template',
933 'default' => 'yes',
934 'prefix_class' => 'pa-infinite-ticker-',
935 )
936 );
937
938 $this->add_control(
939 'fade_color',
940 array(
941 'label' => __( 'Fade Color', 'premium-addons-for-elementor' ),
942 'type' => Controls_Manager::COLOR,
943 'separator' => 'after',
944 'condition' => array(
945 'infinite' => 'yes',
946 ),
947 'selectors' => array(
948 '{{WRAPPER}}.premium-post-ticker__layout-1 .premium-post-ticker__posts-wrapper::after, {{WRAPPER}}.premium-post-ticker__layout-2 .premium-post-ticker__posts-wrapper::after' => 'background: linear-gradient(to right, {{VALUE}}, {{VALUE}} 0%, transparent 10%, transparent 90%, {{VALUE}}) !important;',
949 '{{WRAPPER}}.premium-post-ticker__layout-3 .premium-post-ticker__content::after' => 'background: linear-gradient(to right, {{VALUE}}, {{VALUE}} 0%, transparent 10%, transparent 90%, {{VALUE}}) !important;',
950 '{{WRAPPER}}.premium-post-ticker__layout-4 .premium-post-ticker__posts-wrapper::after' => 'background: linear-gradient(to bottom, {{VALUE}}, {{VALUE}} 0%, transparent 15%, transparent 85%, {{VALUE}}) !important;',
951 ),
952 )
953 );
954
955 $this->add_control(
956 'separator',
957 array(
958 'label' => __( 'Separator', 'premium-addons-for-elementor' ),
959 'type' => Controls_Manager::SWITCHER,
960 'condition' => array(
961 'infinite' => 'yes',
962 'layout!' => 'layout-4',
963 ),
964 )
965 );
966
967 $this->add_control(
968 'typing',
969 array(
970 'label' => __( 'Typing Effect', 'premium-addons-for-elementor' ),
971 'type' => Controls_Manager::SWITCHER,
972 'render_type' => 'template',
973 'prefix_class' => 'premium-typing-',
974 'description' => __( 'Note: Set the<b> Animaiton Speed </b>option to 0 for better visual.', 'premium-addons-for-elementor' ),
975 'condition' => array(
976 'post_type_filter!' => array( 'stock', 'gold' ),
977 'infinite!' => 'yes',
978 'layout!' => 'layout-4',
979 ),
980 )
981 );
982
983 $this->add_control(
984 'cursor',
985 array(
986 'label' => __( 'Typing Cursor', 'premium-addons-for-elementor' ),
987 'type' => Controls_Manager::TEXT,
988 'label_block' => true,
989 'default' => '_',
990 'selectors' => array(
991 '{{WRAPPER}} .premium-text-typing::after' => 'content: "{{VALUE}}";',
992 ),
993 'condition' => array(
994 'post_type_filter!' => array( 'stock', 'gold' ),
995 'infinite!' => 'yes',
996 'typing' => 'yes',
997 'layout!' => 'layout-4',
998 ),
999 'ai' => array(
1000 'active' => false,
1001 ),
1002 )
1003 );
1004
1005 $this->add_control(
1006 'entrance_animation',
1007 array(
1008 'label' => __( 'Entrance Animation', 'premium-addons-for-elementor' ),
1009 'type' => Controls_Manager::ANIMATION,
1010 'render_type' => 'template',
1011 'default' => '',
1012 'label_block' => true,
1013 'condition' => array(
1014 'infinite!' => 'yes',
1015 'layout!' => 'layout-4',
1016 'typing!' => 'yes',
1017 ),
1018 )
1019 );
1020
1021 $this->add_control(
1022 'ticker_pointer',
1023 array(
1024 'label' => __( 'Title Pointer', 'premium-addons-for-elementor' ),
1025 'type' => Controls_Manager::SWITCHER,
1026 'prefix_class' => 'premium-ticker-pointer-',
1027 'condition' => array(
1028 'ticker_title!' => '',
1029 'layout' => array( 'layout-1', 'layout-2' ),
1030 ),
1031 )
1032 );
1033
1034 $this->add_control(
1035 'ticker_pointer_color',
1036 array(
1037 'label' => __( 'Pointer Color', 'premium-addons-for-elementor' ),
1038 'type' => Controls_Manager::COLOR,
1039 'separator' => 'before',
1040 'selectors' => array(
1041 'body:not(.rtl) {{WRAPPER}}.premium-ticker-pointer-yes:not(.premium-reversed-yes) .premium-post-ticker__content > div:first-child::after,
1042 .rtl {{WRAPPER}}.premium-ticker-pointer-yes.premium-reversed-yes .premium-post-ticker__content > div:first-child::after' => 'border-left-color: {{VALUE}};',
1043 'body:not(.rtl) {{WRAPPER}}.premium-ticker-pointer-yes.premium-reversed-yes .premium-post-ticker__content > div:first-child::after,
1044 .rtl {{WRAPPER}}.premium-ticker-pointer-yes:not(.premium-reversed-yes) .premium-post-ticker__content > div:first-child::after' => 'border-right-color: {{VALUE}};',
1045 ),
1046 'global' => array(
1047 'default' => Global_Colors::COLOR_PRIMARY,
1048 ),
1049 'condition' => array(
1050 'ticker_title!' => '',
1051 'ticker_pointer' => 'yes',
1052 'layout' => array( 'layout-1', 'layout-2' ),
1053 ),
1054 )
1055 );
1056
1057 $this->add_group_control(
1058 Premium_Background::get_type(),
1059 array(
1060 'name' => 'pointer_bg',
1061 'description' => __( 'Pointer Color', 'premium-addons-for-elementor' ),
1062 'types' => array( 'classic', 'gradient' ),
1063 'fields_options' => array(
1064 'background' => array(
1065 'default' => 'classic',
1066 ),
1067 'color' => array(
1068 'global' => array(
1069 'default' => Global_Colors::COLOR_TEXT,
1070 ),
1071 ),
1072 ),
1073 'selector' => '{{WRAPPER}}.premium-post-ticker__layout-3 .premium-post-ticker__header-wrapper::after',
1074 'condition' => array(
1075 'layout' => 'layout-3',
1076 'ticker_title' => '',
1077 ),
1078 )
1079 );
1080
1081 $this->add_responsive_control(
1082 'pointer_width',
1083 array(
1084 'label' => __( 'Pointer Width (px)', 'premium-addons-for-elementor' ),
1085 'type' => Controls_Manager::SLIDER,
1086 'size_units' => array( 'px' ),
1087 'selectors' => array(
1088 '{{WRAPPER}}.premium-ticker-pointer-yes .premium-post-ticker__content > div:first-child::after' => 'border-top-width: {{SIZE}}px; border-bottom-width: {{SIZE}}px;',
1089 ),
1090 'condition' => array(
1091 'ticker_title!' => '',
1092 'ticker_pointer' => 'yes',
1093 'layout' => array( 'layout-1', 'layout-2' ),
1094 ),
1095 )
1096 );
1097
1098 $this->add_responsive_control(
1099 'pointer_height',
1100 array(
1101 'label' => __( 'Pointer Height (px)', 'premium-addons-for-elementor' ),
1102 'type' => Controls_Manager::SLIDER,
1103 'size_units' => array( 'px' ),
1104 'selectors' => array(
1105 'body:not(.rtl) {{WRAPPER}}.premium-ticker-pointer-yes:not(.premium-reversed-yes) .premium-post-ticker__content > div:first-child::after,
1106 .rtl {{WRAPPER}}.premium-ticker-pointer-yes.premium-reversed-yes .premium-post-ticker__content > div:first-child::after' => 'border-left-width: {{SIZE}}px;',
1107 'body:not(.rtl) {{WRAPPER}}.premium-ticker-pointer-yes.premium-reversed-yes .premium-post-ticker__content > div:first-child::after,
1108 .rtl {{WRAPPER}}.premium-ticker-pointer-yes:not(.premium-reversed-yes) .premium-post-ticker__content > div:first-child::after' => 'border-right-width: {{SIZE}}px; left: calc(-1 * ({{SIZE}}px - 1px));',
1109
1110 ),
1111 'condition' => array(
1112 'ticker_title!' => '',
1113 'ticker_pointer' => 'yes',
1114 'layout' => array( 'layout-1', 'layout-2' ),
1115 ),
1116 )
1117 );
1118
1119 $this->add_control(
1120 'ticker_title_tag',
1121 array(
1122 'label' => __( 'Title HTML Tag', 'premium-addons-for-elementor' ),
1123 'type' => Controls_Manager::SELECT,
1124 'options' => array(
1125 'h1' => 'H1',
1126 'h2' => 'H2',
1127 'h3' => 'H3',
1128 'h4' => 'H4',
1129 'h5' => 'H5',
1130 'h6' => 'H6',
1131 'div' => 'div',
1132 'span' => 'span',
1133 'p' => 'p',
1134 ),
1135 'default' => 'h4',
1136 'label_block' => true,
1137 'conditions' => array(
1138 'relation' => 'or',
1139 'terms' => array(
1140 array(
1141 'name' => 'ticker_title',
1142 'operator' => '!==',
1143 'value' => '',
1144 ),
1145 array(
1146 'name' => 'post_type_filter',
1147 'value' => 'post',
1148 ),
1149 ),
1150 ),
1151 )
1152 );
1153
1154 $this->end_controls_section();
1155 }
1156
1157 /**
1158 * Adds query controls.
1159 *
1160 * @access private
1161 * @since 4.9.37
1162 */
1163 private function add_query_section_controls() {
1164
1165 $this->start_controls_section(
1166 'pa_spl_query_section',
1167 array(
1168 'label' => __( 'Query', 'premium-addons-for-elementor' ),
1169 )
1170 );
1171
1172 $post_types = Posts_Helper::get_posts_types();
1173
1174 $post_types = array_merge(
1175 $post_types,
1176 array(
1177 'related' => __( 'Related', 'premium-addons-for-elementor' ),
1178 'stock' => __( 'Stock Prices', 'premium-addons-for-elementor' ),
1179 'gold' => __( 'Gold Prices', 'premium-addons-for-elementor' ),
1180 'text' => __( 'Text Content', 'premium-addons-for-elementor' ),
1181 )
1182 );
1183
1184 foreach ( $post_types as $id => $label ) {
1185
1186 if ( ! in_array( $id, array( 'post', 'text' ), true ) ) {
1187 $post_types[ $id ] .= apply_filters( 'pa_pro_label', __( ' (Pro)', 'premium-addons-for-elementor' ) );
1188 }
1189 }
1190
1191 $this->add_control(
1192 'post_type_filter',
1193 array(
1194 'label' => __( 'Source', 'premium-addons-for-elementor' ),
1195 'type' => Controls_Manager::SELECT,
1196 'label_block' => true,
1197 'options' => $post_types,
1198 'default' => 'post',
1199 )
1200 );
1201
1202 foreach ( $post_types as $key => $type ) {
1203
1204 // Get all the taxonomies associated with the selected post type.
1205 $taxonomy = Posts_Helper::get_taxnomies( $key );
1206
1207 if ( ! empty( $taxonomy ) ) {
1208
1209 // Batch-fetch terms for all taxonomies of this post type in one query.
1210 $all_terms = get_terms(
1211 array(
1212 'taxonomy' => array_keys( $taxonomy ),
1213 'hide_empty' => false,
1214 )
1215 );
1216 $terms_by_tax = array();
1217 if ( ! is_wp_error( $all_terms ) ) {
1218 foreach ( $all_terms as $t ) {
1219 $terms_by_tax[ $t->taxonomy ][] = $t;
1220 }
1221 }
1222
1223 // Get all taxonomy values under the taxonomy.
1224 foreach ( $taxonomy as $index => $tax ) {
1225
1226 $terms = isset( $terms_by_tax[ $index ] ) ? $terms_by_tax[ $index ] : array();
1227
1228 $related_tax = array();
1229
1230 if ( ! empty( $terms ) ) {
1231
1232 foreach ( $terms as $t_index => $t_obj ) {
1233
1234 $related_tax[ $t_obj->slug ] = $t_obj->name;
1235 }
1236
1237 // Add filter rule for the each taxonomy.
1238 $this->add_control(
1239 $index . '_' . $key . '_filter_rule',
1240 array(
1241 /* translators: %s Taxnomy Label */
1242 'label' => sprintf( __( '%s Filter Rule', 'premium-addons-for-elementor' ), $tax->label ),
1243 'type' => Controls_Manager::SELECT,
1244 'default' => 'IN',
1245 'label_block' => true,
1246 'options' => array(
1247 /* translators: %s: Taxnomy Label */
1248 'IN' => sprintf( __( 'Match %s', 'premium-addons-for-elementor' ), $tax->label ),
1249 /* translators: %s: Taxnomy Label */
1250 'NOT IN' => sprintf( __( 'Exclude %s', 'premium-addons-for-elementor' ), $tax->label ),
1251 ),
1252 'condition' => array(
1253 'post_type_filter' => $key,
1254 ),
1255 )
1256 );
1257
1258 // Add select control for each taxonomy.
1259 $this->add_control(
1260 'tax_' . $index . '_' . $key . '_filter',
1261 array(
1262 /* translators: %s Taxnomy Label */
1263 'label' => sprintf( __( '%s Filter', 'premium-addons-for-elementor' ), $tax->label ),
1264 'type' => Controls_Manager::SELECT2,
1265 'default' => '',
1266 'multiple' => true,
1267 'label_block' => true,
1268 'options' => $related_tax,
1269 'condition' => array(
1270 'post_type_filter' => $key,
1271 ),
1272 )
1273 );
1274
1275 }
1276 }
1277 }
1278 }
1279
1280 $this->add_control(
1281 'author_filter_rule',
1282 array(
1283 'label' => __( 'Filter By Author Rule', 'premium-addons-for-elementor' ),
1284 'type' => Controls_Manager::SELECT,
1285 'default' => 'author__in',
1286 'label_block' => true,
1287 'options' => array(
1288 'author__in' => __( 'Match Authors', 'premium-addons-for-elementor' ),
1289 'author__not_in' => __( 'Exclude Authors', 'premium-addons-for-elementor' ),
1290 ),
1291 'condition' => array(
1292 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1293 ),
1294 )
1295 );
1296
1297 $this->add_control(
1298 'premium_blog_users',
1299 array(
1300 'label' => __( 'Authors', 'premium-addons-for-elementor' ),
1301 'type' => Controls_Manager::SELECT2,
1302 'label_block' => true,
1303 'multiple' => true,
1304 'options' => Posts_Helper::get_authors(),
1305 'condition' => array(
1306 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1307 ),
1308 )
1309 );
1310
1311 $this->add_control(
1312 'posts_filter_rule',
1313 array(
1314 'label' => __( 'Filter By Post Rule', 'premium-addons-for-elementor' ),
1315 'type' => Controls_Manager::SELECT,
1316 'default' => 'post__not_in',
1317 'label_block' => true,
1318 'options' => array(
1319 'post__in' => __( 'Match Post', 'premium-addons-for-elementor' ),
1320 'post__not_in' => __( 'Exclude Post', 'premium-addons-for-elementor' ), // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- Control option value, not a query argument.
1321 ),
1322 'condition' => array(
1323 'post_type_filter!' => array( 'stock', 'gold', 'related', 'text' ),
1324 ),
1325 )
1326 );
1327
1328 $this->add_control(
1329 'premium_blog_posts_exclude',
1330 array(
1331 'label' => __( 'Posts', 'premium-addons-for-elementor' ),
1332 'type' => Premium_Post_Filter::TYPE,
1333 'label_block' => true,
1334 'multiple' => true,
1335 'source' => 'post',
1336 'condition' => array(
1337 'post_type_filter' => 'post',
1338 ),
1339 )
1340 );
1341
1342 $this->add_control(
1343 'custom_posts_filter',
1344 array(
1345 'label' => __( 'Posts', 'premium-addons-for-elementor' ),
1346 'type' => Premium_Post_Filter::TYPE,
1347 'render_type' => 'template',
1348 'label_block' => true,
1349 'multiple' => true,
1350 'frontend_available' => true,
1351 'condition' => array(
1352 'post_type_filter!' => array( 'post', 'related', 'stock', 'gold', 'text' ),
1353 ),
1354
1355 )
1356 );
1357
1358 $this->add_control(
1359 'ignore_sticky_posts',
1360 array(
1361 'label' => __( 'Ignore Sticky Posts', 'premium-addons-for-elementor' ),
1362 'type' => Controls_Manager::SWITCHER,
1363 'label_on' => __( 'Yes', 'premium-addons-for-elementor' ),
1364 'label_off' => __( 'No', 'premium-addons-for-elementor' ),
1365 'default' => 'yes',
1366 'condition' => array(
1367 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1368 ),
1369 )
1370 );
1371
1372 $this->add_control(
1373 'premium_blog_offset',
1374 array(
1375 'label' => __( 'Offset', 'premium-addons-for-elementor' ),
1376 'description' => __( 'This option is used to exclude number of initial posts from being display.', 'premium-addons-for-elementor' ),
1377 'type' => Controls_Manager::NUMBER,
1378 'default' => '0',
1379 'min' => '0',
1380 'condition' => array(
1381 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1382 ),
1383 )
1384 );
1385
1386 $this->add_control(
1387 'query_exclude_current',
1388 array(
1389 'label' => __( 'Exclude Current Post', 'premium-addons-for-elementor' ),
1390 'type' => Controls_Manager::SWITCHER,
1391 'description' => __( 'This option will remove the current post from the query.', 'premium-addons-for-elementor' ),
1392 'label_on' => __( 'Yes', 'premium-addons-for-elementor' ),
1393 'label_off' => __( 'No', 'premium-addons-for-elementor' ),
1394 'condition' => array(
1395 'post_type_filter!' => array( 'stock', 'gold', 'related', 'text' ),
1396 ),
1397 )
1398 );
1399
1400 $this->add_control(
1401 'premium_blog_order_by',
1402 array(
1403 'label' => __( 'Order By', 'premium-addons-for-elementor' ),
1404 'type' => Controls_Manager::SELECT,
1405 'label_block' => true,
1406 'options' => array(
1407 'none' => __( 'None', 'premium-addons-for-elementor' ),
1408 'ID' => __( 'ID', 'premium-addons-for-elementor' ),
1409 'author' => __( 'Author', 'premium-addons-for-elementor' ),
1410 'title' => __( 'Title', 'premium-addons-for-elementor' ),
1411 'name' => __( 'Name', 'premium-addons-for-elementor' ),
1412 'date' => __( 'Date', 'premium-addons-for-elementor' ),
1413 'modified' => __( 'Last Modified', 'premium-addons-for-elementor' ),
1414 'rand' => __( 'Random', 'premium-addons-for-elementor' ),
1415 'comment_count' => __( 'Number of Comments', 'premium-addons-for-elementor' ),
1416 ),
1417 'default' => 'date',
1418 'condition' => array(
1419 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1420 ),
1421 )
1422 );
1423
1424 $this->add_control(
1425 'premium_blog_order',
1426 array(
1427 'label' => __( 'Order', 'premium-addons-for-elementor' ),
1428 'type' => Controls_Manager::SELECT,
1429 'label_block' => true,
1430 'options' => array(
1431 'DESC' => __( 'Descending', 'premium-addons-for-elementor' ),
1432 'ASC' => __( 'Ascending', 'premium-addons-for-elementor' ),
1433 ),
1434 'default' => 'DESC',
1435 'condition' => array(
1436 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1437 ),
1438 )
1439 );
1440
1441 $this->add_control(
1442 'empty_query_text',
1443 array(
1444 'label' => __( 'Empty Query Text', 'premium-addons-for-elementor' ),
1445 'type' => Controls_Manager::TEXT,
1446 'label_block' => true,
1447 'dynamic' => array( 'active' => true ),
1448 'condition' => array(
1449 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1450 ),
1451 )
1452 );
1453
1454 $this->add_responsive_control(
1455 'txt_align',
1456 array(
1457 'label' => __( 'Position', 'premium-addons-for-elementor' ),
1458 'type' => Controls_Manager::CHOOSE,
1459 'options' => array(
1460 'flex-start' => array(
1461 'title' => __( 'Start', 'premium-addons-for-elementor' ),
1462 'icon' => is_rtl() ? 'eicon-h-align-right' : 'eicon-h-align-left',
1463 ),
1464 'center' => array(
1465 'title' => __( 'Center', 'premium-addons-for-elementor' ),
1466 'icon' => 'eicon-h-align-center',
1467 ),
1468 'flex-end' => array(
1469 'title' => __( 'End', 'premium-addons-for-elementor' ),
1470 'icon' => is_rtl() ? 'eicon-h-align-left' : 'eicon-h-align-right',
1471 ),
1472 ),
1473 'default' => 'flex-start',
1474 'toggle' => false,
1475 'selectors' => array(
1476 '{{WRAPPER}} .premium-post-ticker__post-wrapper' => 'justify-content: {{VALUE}}',
1477 ),
1478 'condition' => array(
1479 'post_type_filter' => 'text',
1480 ),
1481 )
1482 );
1483
1484 $this->add_control(
1485 'txt_icon_order',
1486 array(
1487 'label' => __( 'Icon Order', 'premium-addons-for-elementor' ),
1488 'type' => Controls_Manager::CHOOSE,
1489 'toggle' => false,
1490 'options' => array(
1491 '0' => array(
1492 'title' => __( 'After Title', 'premium-addons-for-elementor' ),
1493 'icon' => is_rtl() ? 'eicon-order-end' : 'eicon-order-start',
1494 ),
1495 '2' => array(
1496 'title' => __( 'Before Title', 'premium-addons-for-elementor' ),
1497 'icon' => is_rtl() ? 'eicon-order-start' : 'eicon-order-end',
1498 ),
1499 ),
1500 'condition' => array(
1501 'post_type_filter' => 'text',
1502 ),
1503 'selectors' => array(
1504 '{{WRAPPER}} .premium-post-ticker__post-wrapper .premium-post-ticker__post-title' => 'order: {{VALUE}}',
1505 ),
1506 )
1507 );
1508
1509 $this->add_responsive_control(
1510 'txt_icon_size',
1511 array(
1512 'label' => __( 'Icon Size (px)', 'premium-addons-for-elementor' ),
1513 'type' => Controls_Manager::SLIDER,
1514 'size_units' => array( 'px' ),
1515 'range' => array(
1516 'px' => array(
1517 'min' => 0,
1518 'max' => 500,
1519 ),
1520 ),
1521 'selectors' => array(
1522 '{{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item i' => 'font-size: {{SIZE}}px;',
1523 '{{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item img' => 'width: {{SIZE}}px',
1524 '{{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item > svg,
1525 {{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item .premium-lottie-animation,
1526 {{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item .premium-drawable-icon' => 'width: {{SIZE}}px; height: {{SIZE}}px; line-height: {{SIZE}}px;',
1527 ),
1528 'condition' => array(
1529 'post_type_filter' => 'text',
1530 ),
1531 )
1532 );
1533
1534 $this->add_responsive_control(
1535 'txt_icon_spacing',
1536 array(
1537 'label' => __( 'Spacing (px)', 'premium-addons-for-elementor' ),
1538 'type' => Controls_Manager::SLIDER,
1539 'size_units' => array( 'px' ),
1540 'selectors' => array(
1541 '{{WRAPPER}} .premium-post-ticker__post-wrapper' => 'column-gap: {{SIZE}}px',
1542 ),
1543 'condition' => array(
1544 'post_type_filter' => 'text',
1545 ),
1546 )
1547 );
1548
1549 $draw_icon = $this->check_icon_draw();
1550
1551 $text_repeater = new Repeater();
1552
1553 $text_repeater->add_control(
1554 'text',
1555 array(
1556 'label' => __( 'Text', 'premium-addons-for-elementor' ),
1557 'type' => Controls_Manager::TEXT,
1558 'dynamic' => array( 'active' => true ),
1559 'label_block' => true,
1560 )
1561 );
1562
1563 $text_repeater->add_control(
1564 'item_link',
1565 array(
1566 'label' => __( 'Link', 'premium-addons-for-elementor' ),
1567 'type' => Controls_Manager::URL,
1568 'dynamic' => array( 'active' => true ),
1569 'default' => array(
1570 'url' => '#',
1571 ),
1572 'placeholder' => 'https://premiumaddons.com/',
1573 'label_block' => true,
1574 )
1575 );
1576
1577 $text_repeater->add_control(
1578 'txt_icon_sw',
1579 array(
1580 'label' => __( 'Text Icon', 'premium-addons-for-elementor' ),
1581 'type' => Controls_Manager::SWITCHER,
1582 'render_type' => 'template',
1583 )
1584 );
1585
1586 $text_repeater->add_control(
1587 'icon_type',
1588 array(
1589 'label' => __( 'Icon Type', 'premium-addons-for-elementor' ),
1590 'type' => Controls_Manager::SELECT,
1591 'render_type' => 'template',
1592 'options' => array(
1593 'icon' => __( 'Icon', 'premium-addons-for-elementor' ),
1594 'lottie' => __( 'Lottie Animation', 'premium-addons-for-elementor' ),
1595 'image' => __( 'Image', 'premium-addons-for-elementor' ),
1596 'svg' => __( 'SVG Code', 'premium-addons-for-elementor' ),
1597 ),
1598 'default' => 'icon',
1599 'condition' => array(
1600 'txt_icon_sw' => 'yes',
1601 ),
1602 )
1603 );
1604
1605 $common_conditions = array(
1606 'txt_icon_sw' => 'yes',
1607 );
1608
1609 $text_repeater->add_control(
1610 'pa_ticker_icon',
1611 array(
1612 'label' => __( 'Choose Icon', 'premium-addons-for-elementor' ),
1613 'type' => Controls_Manager::ICONS,
1614 'label_block' => false,
1615 'skin' => 'inline',
1616 'default' => array(
1617 'value' => 'fas fa-star',
1618 'library' => 'fa-solid',
1619 ),
1620 'condition' => array(
1621 'txt_icon_sw' => 'yes',
1622 'icon_type' => 'icon',
1623 ),
1624 )
1625 );
1626
1627 $text_repeater->add_control(
1628 'custom_svg',
1629 array(
1630 'label' => __( 'SVG Code', 'premium-addons-for-elementor' ),
1631 'type' => Controls_Manager::TEXTAREA,
1632 'description' => 'You can use these sites to create SVGs: <a href="https://danmarshall.github.io/google-font-to-svg-path/" target="_blank">Google Fonts</a> and <a href="https://boxy-svg.com/" target="_blank">Boxy SVG</a>',
1633 'condition' => array(
1634 'txt_icon_sw' => 'yes',
1635 'icon_type' => 'svg',
1636 ),
1637 'ai' => array(
1638 'active' => false,
1639 ),
1640 )
1641 );
1642
1643 $text_repeater->add_control(
1644 'image',
1645 array(
1646 'label' => __( 'Image', 'premium-addons-for-elementor' ),
1647 'type' => Controls_Manager::MEDIA,
1648 'media_types' => array( 'image' ),
1649 'dynamic' => array( 'active' => true ),
1650 'condition' => array(
1651 'txt_icon_sw' => 'yes',
1652 'icon_type' => 'image',
1653 ),
1654 )
1655 );
1656
1657 $text_repeater->add_control(
1658 'lottie_url',
1659 array(
1660 'label' => __( 'Animation JSON URL', 'premium-addons-for-elementor' ),
1661 'type' => Controls_Manager::TEXT,
1662 'dynamic' => array( 'active' => true ),
1663 'description' => 'Get JSON code URL from <a href="https://lottiefiles.com/" target="_blank">here</a>',
1664 'label_block' => true,
1665 'condition' => array(
1666 'txt_icon_sw' => 'yes',
1667 'icon_type' => 'lottie',
1668 ),
1669 'ai' => array(
1670 'active' => false,
1671 ),
1672 )
1673 );
1674
1675 $animation_conds = array(
1676 'terms' => array(
1677 array(
1678 'name' => 'txt_icon_sw',
1679 'value' => 'yes',
1680 ),
1681 array(
1682 'relation' => 'or',
1683 'terms' => array(
1684 array(
1685 'name' => 'icon_type',
1686 'value' => 'lottie',
1687 ),
1688 array(
1689 'terms' => array(
1690 array(
1691 'relation' => 'or',
1692 'terms' => array(
1693 array(
1694 'name' => 'icon_type',
1695 'value' => 'icon',
1696 ),
1697 array(
1698 'name' => 'icon_type',
1699 'value' => 'svg',
1700 ),
1701 ),
1702 ),
1703 array(
1704 'name' => 'draw_svg',
1705 'value' => 'yes',
1706 ),
1707 ),
1708 ),
1709 ),
1710 ),
1711 ),
1712 );
1713
1714 $text_repeater->add_control(
1715 'draw_svg',
1716 array(
1717 'label' => __( 'Draw Icon', 'premium-addons-for-elementor' ),
1718 'type' => Controls_Manager::SWITCHER,
1719 'description' => __( 'Enable this option to make the icon drawable. See ', 'premium-addons-for-elementor' ) . '<a href="https://www.youtube.com/watch?v=ZLr0bRe0RAY" target="_blank">tutorial</a>',
1720 'classes' => $draw_icon ? '' : 'editor-pa-control-disabled',
1721 'condition' => array(
1722 'txt_icon_sw' => 'yes',
1723 'icon_type' => array( 'icon', 'svg' ),
1724 'pa_ticker_icon[library]!' => 'svg',
1725 ),
1726 )
1727 );
1728
1729 if ( $draw_icon ) {
1730
1731 $text_repeater->add_control(
1732 'path_width',
1733 array(
1734 'label' => __( 'Path Thickness', 'premium-addons-for-elementor' ),
1735 'type' => Controls_Manager::SLIDER,
1736 'range' => array(
1737 'px' => array(
1738 'min' => 0,
1739 'max' => 50,
1740 'step' => 0.1,
1741 ),
1742 ),
1743 'condition' => array(
1744 'txt_icon_sw' => 'yes',
1745 'icon_type' => array( 'icon', 'svg' ),
1746 ),
1747 'selectors' => array(
1748 '{{WRAPPER}} {{CURRENT_ITEM}} .premium-post-ticker__icon-wrapper svg *' => 'stroke-width: {{SIZE}}',
1749 ),
1750 )
1751 );
1752
1753 } else {
1754 Helper_Functions::get_draw_svg_notice(
1755 $text_repeater,
1756 'ticker',
1757 array(
1758 'txt_icon_sw' => 'yes',
1759 'icon_type' => array( 'icon', 'svg' ),
1760 'pa_ticker_icon[library]!' => 'svg',
1761 )
1762 );
1763 }
1764
1765 $text_repeater->add_control(
1766 'lottie_loop',
1767 array(
1768 'label' => __( 'Loop', 'premium-addons-for-elementor' ),
1769 'type' => Controls_Manager::SWITCHER,
1770 'return_value' => 'true',
1771 'default' => 'true',
1772 'conditions' => $animation_conds,
1773 )
1774 );
1775
1776 $this->add_control(
1777 'text_content',
1778 array(
1779 'label' => __( 'Text', 'premium-addons-for-elementor' ),
1780 'type' => Controls_Manager::REPEATER,
1781 'default' => array(
1782 array(
1783 'text' => 'Premium News Ticker',
1784 ),
1785 array(
1786 'text' => 'Premium Addons For Elementor',
1787 ),
1788 ),
1789 'fields' => $text_repeater->get_controls(),
1790 'title_field' => '{{{ text }}}',
1791 'prevent_empty' => false,
1792 'condition' => array(
1793 'post_type_filter' => 'text',
1794 ),
1795 )
1796 );
1797
1798 $this->papro_activated = Helper_Functions::check_papro_version();
1799 if ( $this->papro_activated ) {
1800 do_action( 'pa_ticker_stock_query', $this );
1801
1802 }
1803
1804 $this->end_controls_section();
1805 }
1806
1807 /**
1808 * Adds Posts controls.
1809 *
1810 * @access private
1811 * @since 4.9.37
1812 */
1813 private function add_posts_section_controls() {
1814
1815 $this->start_controls_section(
1816 'pa_ticker_posts_section',
1817 array(
1818 'label' => __( 'Post Options', 'premium-addons-for-elementor' ),
1819 'condition' => array(
1820 'post_type_filter!' => array( 'stock', 'gold', 'text' ),
1821 ),
1822 )
1823 );
1824
1825 $this->add_control(
1826 'new_tab',
1827 array(
1828 'label' => __( 'Open Post Link in New Tab', 'premium-addons-for-elementor' ),
1829 'type' => Controls_Manager::SWITCHER,
1830 'default' => 'yes',
1831 )
1832 );
1833
1834 $this->add_control(
1835 'article_tag_switcher',
1836 array(
1837 'label' => __( 'Change Post HTML Tag To Article', 'premium-addons-for-elementor' ),
1838 'type' => Controls_Manager::SWITCHER,
1839 )
1840 );
1841
1842 $this->add_control(
1843 'content_length',
1844 array(
1845 'label' => __( 'Content Length (words)', 'premium-addons-for-elementor' ),
1846 'description' => __( 'Set the number of words of the content, leave it empty to display the full length.', 'premium-addons-for-elementor' ),
1847 'type' => Controls_Manager::NUMBER,
1848 'min' => '0',
1849 )
1850 );
1851
1852 $this->add_control(
1853 'post_img',
1854 array(
1855 'label' => __( 'Show Post Thumbnail', 'premium-addons-for-elementor' ),
1856 'type' => Controls_Manager::SWITCHER,
1857 )
1858 );
1859
1860 $this->add_group_control(
1861 Group_Control_Image_Size::get_type(),
1862 array(
1863 'name' => 'image',
1864 'default' => 'thumbnail',
1865 'condition' => array(
1866 'post_img' => 'yes',
1867 ),
1868 )
1869 );
1870
1871 $this->add_responsive_control(
1872 'img_width',
1873 array(
1874 'label' => __( 'Width (px)', 'premium-addons-for-elementor' ),
1875 'type' => Controls_Manager::SLIDER,
1876 'size_units' => array( 'px', 'em' ),
1877 'range' => array(
1878 'px' => array(
1879 'min' => 0,
1880 'max' => 500,
1881 ),
1882 ),
1883 'selectors' => array(
1884 '{{WRAPPER}} .premium-post-ticker__thumbnail-wrapper img' => 'width: {{SIZE}}{{UNIT}};',
1885 ),
1886 'condition' => array(
1887 'post_img' => 'yes',
1888 ),
1889 )
1890 );
1891
1892 $this->add_control(
1893 'hide_thumb_on',
1894 array(
1895 'label' => __( 'Hide Thumbnail On', 'premium-addons-for-elementor' ),
1896 'type' => Controls_Manager::SELECT2,
1897 'options' => Helper_Functions::get_all_breakpoints(),
1898 'separator' => 'after',
1899 'multiple' => true,
1900 'label_block' => true,
1901 'default' => array(),
1902 'condition' => array(
1903 'post_img' => 'yes',
1904 ),
1905 )
1906 );
1907
1908 $this->add_control(
1909 'author_meta',
1910 array(
1911 'label' => __( 'Author Meta', 'premium-addons-for-elementor' ),
1912 'type' => Controls_Manager::SWITCHER,
1913 )
1914 );
1915
1916 $this->add_control(
1917 'hide_author_on',
1918 array(
1919 'label' => __( 'Hide Author On', 'premium-addons-for-elementor' ),
1920 'type' => Controls_Manager::SELECT2,
1921 'options' => Helper_Functions::get_all_breakpoints(),
1922 'separator' => 'after',
1923 'multiple' => true,
1924 'label_block' => true,
1925 'default' => array(),
1926 'condition' => array(
1927 'author_meta' => 'yes',
1928 ),
1929 )
1930 );
1931
1932 $this->add_control(
1933 'date_meta',
1934 array(
1935 'label' => __( 'Date Meta', 'premium-addons-for-elementor' ),
1936 'type' => Controls_Manager::SWITCHER,
1937 'default' => 'yes',
1938 )
1939 );
1940
1941 $this->add_control(
1942 'post_date_format',
1943 array(
1944 'label' => __( 'Date Format', 'premium-addons-for-elementor' ),
1945 'type' => Controls_Manager::TEXT,
1946 'label_block' => true,
1947 'description' => __( 'Know more abour date format from ', 'premium-addons-for-elementor' ) . '<a href="https://wordpress.org/documentation/article/customize-date-and-time-format/" target="_blank">here</a>',
1948 'default' => get_option( 'date_format' ),
1949 'condition' => array(
1950 'date_meta' => 'yes',
1951 ),
1952 'ai' => array(
1953 'active' => false,
1954 ),
1955 )
1956 );
1957
1958 $this->add_control(
1959 'hide_post_date_on',
1960 array(
1961 'label' => __( 'Hide Date On', 'premium-addons-for-elementor' ),
1962 'type' => Controls_Manager::SELECT2,
1963 'options' => Helper_Functions::get_all_breakpoints(),
1964 'multiple' => true,
1965 'label_block' => true,
1966 'default' => array(),
1967 'condition' => array(
1968 'date_meta' => 'yes',
1969 ),
1970 )
1971 );
1972
1973 $this->end_controls_section();
1974 }
1975
1976 private function add_slider_section_controls() {
1977
1978 $this->start_controls_section(
1979 'slider_section_tab',
1980 array(
1981 'label' => __( 'Animation Settings', 'premium-addons-for-elementor' ),
1982 )
1983 );
1984
1985 $this->add_control(
1986 'slides_to_show',
1987 array(
1988 'label' => __( 'Slides To Show', 'premium-addons-for-elementor' ),
1989 'type' => Controls_Manager::NUMBER,
1990 'default' => 3,
1991 'condition' => array(
1992 'layout' => 'layout-4',
1993 ),
1994 )
1995 );
1996
1997 $this->add_control(
1998 'vertical',
1999 array(
2000 'label' => __( 'Vertical', 'premium-addons-for-elementor' ),
2001 'type' => Controls_Manager::SWITCHER,
2002 'condition' => array(
2003 'fade!' => 'yes',
2004 'typing!' => 'yes',
2005 'layout!' => 'layout-4',
2006 ),
2007 )
2008 );
2009
2010 $this->add_control(
2011 'fade',
2012 array(
2013 'label' => __( 'Fade', 'premium-addons-for-elementor' ),
2014 'type' => Controls_Manager::SWITCHER,
2015 'prefix_class' => 'premium-fade-',
2016 'render_type' => 'template',
2017 'condition' => array(
2018 'layout!' => 'layout-4',
2019 'infinite!' => 'yes',
2020 'typing!' => 'yes',
2021 ),
2022 )
2023 );
2024
2025 $this->add_control(
2026 'auto_play',
2027 array(
2028 'label' => __( 'Autoplay', 'premium-addons-for-elementor' ),
2029 'type' => Controls_Manager::SWITCHER,
2030 'default' => 'yes',
2031 'condition' => array(
2032 'infinite!' => 'yes',
2033 ),
2034 )
2035 );
2036
2037 $this->add_control(
2038 'autoplay_speed',
2039 array(
2040 'label' => __( 'Autoplay Speed (ms)', 'premium-addons-for-elementor' ),
2041 'type' => Controls_Manager::NUMBER,
2042 'default' => 5000,
2043 'condition' => array(
2044 'auto_play' => 'yes',
2045 'infinite!' => 'yes',
2046 ),
2047 )
2048 );
2049
2050 $this->add_control(
2051 'speed',
2052 array(
2053 'label' => __( 'Animation Speed (ms)', 'premium-addons-for-elementor' ),
2054 'description' => __( 'Set the speed of the animation in milliseconds (ms)', 'premium-addons-for-elementor' ),
2055 'type' => Controls_Manager::NUMBER,
2056 'default' => 5000,
2057 'render_type' => 'template',
2058 )
2059 );
2060
2061 $this->add_control(
2062 'carousel_arrows',
2063 array(
2064 'label' => __( 'Navigation Arrows', 'premium-addons-for-elementor' ),
2065 'type' => Controls_Manager::SWITCHER,
2066 'default' => 'yes',
2067 'condition' => array(
2068 'infinite!' => 'yes',
2069 ),
2070 )
2071 );
2072
2073 $this->add_control(
2074 'pause_on_hover',
2075 array(
2076 'label' => __( 'Pause On Hover', 'premium-addons-for-elementor' ),
2077 'type' => Controls_Manager::SWITCHER,
2078 'default' => 'yes',
2079 'conditions' => array(
2080 'relation' => 'or',
2081 'terms' => array(
2082 array(
2083 'name' => 'auto_play',
2084 'value' => 'yes',
2085 ),
2086 array(
2087 'name' => 'infinite',
2088 'value' => 'yes',
2089 ),
2090 ),
2091 ),
2092 )
2093 );
2094
2095 $this->end_controls_section();
2096 }
2097
2098 private function add_helpful_info_section() {
2099
2100 $this->start_controls_section(
2101 'section_pa_docs',
2102 array(
2103 'label' => __( 'Help & Docs', 'premium-addons-for-elementor' ),
2104 )
2105 );
2106
2107 $docs = array(
2108 'https://premiumaddons.com/docs/elementor-news-ticker-widget/' => __( 'Getting started »', 'premium-addons-for-elementor' ),
2109 );
2110
2111 $doc_index = 1;
2112 foreach ( $docs as $url => $title ) {
2113
2114 $doc_url = Helper_Functions::get_campaign_link( $url, 'ticker-widget', 'wp-editor', 'get-support' );
2115
2116 $this->add_control(
2117 'doc_' . $doc_index,
2118 array(
2119 'type' => Controls_Manager::RAW_HTML,
2120 'raw' => sprintf( '<a href="%s" target="_blank">%s</a>', $doc_url, $title ),
2121 'content_classes' => 'editor-pa-doc',
2122 )
2123 );
2124
2125 ++$doc_index;
2126
2127 }
2128
2129 Helper_Functions::register_element_feedback_controls( $this );
2130
2131 $this->end_controls_section();
2132 }
2133
2134 /** Style Controls.*/
2135
2136 /**
2137 * Adds posts title style controls.
2138 *
2139 * @access private
2140 * @since 4.9.37
2141 */
2142 private function add_ticker_title_style() {
2143
2144 $draw_icon = $this->check_icon_draw();
2145
2146 $this->start_controls_section(
2147 'pa_ticker_title_tab',
2148 array(
2149 'label' => __( 'Title', 'premium-addons-for-elementor' ),
2150 'tab' => Controls_Manager::TAB_STYLE,
2151 'condition' => array(
2152 'ticker_title!' => '',
2153 ),
2154 )
2155 );
2156
2157 $this->add_group_control(
2158 Group_Control_Typography::get_type(),
2159 array(
2160 'name' => 'ticker_title_typo',
2161 'selector' => '{{WRAPPER}} .premium-post-ticker__title',
2162 )
2163 );
2164
2165 $this->add_control(
2166 'ticker_title_color',
2167 array(
2168 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2169 'type' => Controls_Manager::COLOR,
2170 'selectors' => array(
2171 '{{WRAPPER}} .premium-post-ticker__title' => 'color: {{VALUE}}',
2172 ),
2173 )
2174 );
2175
2176 $this->add_control(
2177 'title_icon_color',
2178 array(
2179 'label' => __( 'Icon Color', 'premium-addons-for-elementor' ),
2180 'type' => Controls_Manager::COLOR,
2181 'selectors' => array(
2182 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) i' => 'color: {{VALUE}}',
2183 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) .premium-drawable-icon *,
2184 {{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) svg:not([class*="premium-"])' => 'fill: {{VALUE}};',
2185 ),
2186 'condition' => array(
2187 'ticker_icon_sw' => 'yes',
2188 'icon_type' => 'icon',
2189 ),
2190 )
2191 );
2192
2193 if ( $draw_icon ) {
2194 $this->add_control(
2195 'stroke_color',
2196 array(
2197 'label' => __( 'Stroke Color', 'premium-addons-for-elementor' ),
2198 'type' => Controls_Manager::COLOR,
2199 'global' => array(
2200 'default' => Global_Colors::COLOR_ACCENT,
2201 ),
2202 'condition' => array(
2203 'icon_type' => array( 'icon', 'svg' ),
2204 ),
2205 'selectors' => array(
2206 '{{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) .premium-drawable-icon *,
2207 {{WRAPPER}} .premium-post-ticker__icon-wrapper:not(.premium-repeater-item) svg:not([class*="premium-"])' => 'stroke: {{VALUE}};',
2208 ),
2209 )
2210 );
2211 }
2212
2213 $this->add_group_control(
2214 Group_Control_Text_Shadow::get_type(),
2215 array(
2216 'name' => 'ticker_title_text_shadow',
2217 'selector' => '{{WRAPPER}} .premium-post-ticker__title',
2218 )
2219 );
2220
2221 $this->add_group_control(
2222 Premium_Background::get_type(),
2223 array(
2224 'name' => 'ticker_title_bg',
2225 'types' => array( 'classic', 'gradient' ),
2226 'fields_options' => array(
2227 'background' => array(
2228 'default' => 'classic',
2229 ),
2230 'color' => array(
2231 'global' => array(
2232 'default' => Global_Colors::COLOR_PRIMARY,
2233 ),
2234 ),
2235 ),
2236 'selector' => '{{WRAPPER}} .premium-post-ticker__title-wrapper, {{WRAPPER}}.premium-post-ticker__layout-2 .premium-post-ticker__title-wrapper::after, {{WRAPPER}}.premium-post-ticker__layout-3 .premium-post-ticker__header-wrapper::after',
2237 )
2238 );
2239
2240 $this->add_group_control(
2241 Group_Control_Border::get_type(),
2242 array(
2243 'name' => 'ticker_title_border',
2244 'selector' => '{{WRAPPER}} .premium-post-ticker__title-wrapper',
2245 'condition' => array(
2246 'layout!' => 'layout-3',
2247 ),
2248 )
2249 );
2250
2251 $this->add_control(
2252 'ticker_title_border_radius',
2253 array(
2254 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2255 'type' => Controls_Manager::DIMENSIONS,
2256 'size_units' => array( 'px', 'em', '%' ),
2257 'selectors' => array(
2258 '{{WRAPPER}} .premium-post-ticker__title-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2259 ),
2260 'condition' => array(
2261 'layout!' => 'layout-3',
2262 'title_adv_radius!' => 'yes',
2263 ),
2264 )
2265 );
2266
2267 $this->add_control(
2268 'title_adv_radius',
2269 array(
2270 'label' => __( 'Advanced Border Radius', 'premium-addons-for-elementor' ),
2271 'type' => Controls_Manager::SWITCHER,
2272 'description' => __( 'Apply custom radius values. Get the radius value from ', 'premium-addons-for-elementor' ) . '<a href="https://9elements.github.io/fancy-border-radius/" target="_blank">here</a>' . __( '. See ', 'premium-addons-for-elementor' ) . '<a href="https://www.youtube.com/watch?v=S0BJazLHV-M" target="_blank">tutorial</a>',
2273 )
2274 );
2275
2276 $this->add_control(
2277 'title_adv_radius_value',
2278 array(
2279 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2280 'type' => Controls_Manager::TEXT,
2281 'dynamic' => array( 'active' => true ),
2282 'selectors' => array(
2283 '{{WRAPPER}} .premium-post-ticker__title-wrapper' => 'border-radius: {{VALUE}};',
2284 ),
2285 'condition' => array(
2286 'title_adv_radius' => 'yes',
2287 ),
2288 'ai' => array(
2289 'active' => false,
2290 ),
2291 )
2292 );
2293
2294 $this->add_responsive_control(
2295 'ticker_title_padding',
2296 array(
2297 'label' => __( 'Padding', 'premium-addons-for-elementor' ),
2298 'type' => Controls_Manager::DIMENSIONS,
2299 'size_units' => array( 'px', 'em', '%' ),
2300 'selectors' => array(
2301 '{{WRAPPER}} .premium-post-ticker__title-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2302 ),
2303 )
2304 );
2305
2306 $this->end_controls_section();
2307 }
2308
2309 private function add_ticker_date_style() {
2310
2311 $this->start_controls_section(
2312 'pa_ticker_date_tab',
2313 array(
2314 'label' => __( 'Date', 'premium-addons-for-elementor' ),
2315 'tab' => Controls_Manager::TAB_STYLE,
2316 'condition' => array(
2317 'show_date' => 'yes',
2318 ),
2319 )
2320 );
2321
2322 $this->add_group_control(
2323 Group_Control_Typography::get_type(),
2324 array(
2325 'name' => 'date_typo',
2326 'selector' => '{{WRAPPER}} .premium-post-ticker__date-wrapper',
2327 )
2328 );
2329
2330 $this->add_control(
2331 'date_color',
2332 array(
2333 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2334 'type' => Controls_Manager::COLOR,
2335 'selectors' => array(
2336 '{{WRAPPER}} .premium-post-ticker__date' => 'color: {{VALUE}}',
2337 ),
2338 )
2339 );
2340
2341 $this->add_group_control(
2342 Group_Control_Text_Shadow::get_type(),
2343 array(
2344 'name' => 'date_text_shadow',
2345 'selector' => '{{WRAPPER}} .premium-post-ticker__date-wrapper',
2346 )
2347 );
2348
2349 $this->add_group_control(
2350 Premium_Background::get_type(),
2351 array(
2352 'name' => 'date_bg',
2353 'types' => array( 'classic', 'gradient' ),
2354 'selector' => '{{WRAPPER}} .premium-post-ticker__date-wrapper',
2355 )
2356 );
2357
2358 $this->add_group_control(
2359 Group_Control_Border::get_type(),
2360 array(
2361 'name' => 'date_border',
2362 'selector' => '{{WRAPPER}} .premium-post-ticker__date-wrapper',
2363 'condition' => array(
2364 'layout!' => 'layout-3',
2365 ),
2366 )
2367 );
2368
2369 $this->add_control(
2370 'date_border_radius',
2371 array(
2372 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2373 'type' => Controls_Manager::DIMENSIONS,
2374 'size_units' => array( 'px', 'em', '%' ),
2375 'selectors' => array(
2376 '{{WRAPPER}} .premium-post-ticker__date-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2377 ),
2378 'condition' => array(
2379 'layout!' => 'layout-3',
2380 ),
2381 )
2382 );
2383
2384 $this->add_responsive_control(
2385 'date_padding',
2386 array(
2387 'label' => __( 'Padding', 'premium-addons-for-elementor' ),
2388 'type' => Controls_Manager::DIMENSIONS,
2389 'size_units' => array( 'px', 'em', '%' ),
2390 'selectors' => array(
2391 '{{WRAPPER}} .premium-post-ticker__date-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2392 ),
2393 )
2394 );
2395
2396 $this->add_responsive_control(
2397 'date_margin',
2398 array(
2399 'label' => __( 'Margin', 'premium-addons-for-elementor' ),
2400 'type' => Controls_Manager::DIMENSIONS,
2401 'size_units' => array( 'px', 'em', '%' ),
2402 'selectors' => array(
2403 '{{WRAPPER}} .premium-post-ticker__date-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2404 ),
2405 'condition' => array(
2406 'layout!' => 'layout-3',
2407 ),
2408 )
2409 );
2410
2411 $this->end_controls_section();
2412 }
2413
2414 private function add_posts_style() {
2415
2416 $draw_icon = $this->check_icon_draw();
2417
2418 $this->start_controls_section(
2419 'pa_posts_style',
2420 array(
2421 'label' => __( 'Ticker Element', 'premium-addons-for-elementor' ),
2422 'tab' => Controls_Manager::TAB_STYLE,
2423 )
2424 );
2425
2426 // content.
2427 $this->add_control(
2428 'pa_post_title_heading',
2429 array(
2430 'label' => __( 'Content', 'premium-addons-for-elementor' ),
2431 'type' => Controls_Manager::HEADING,
2432 'separator' => 'before',
2433 'condition' => array(
2434 'post_type_filter!' => array( 'gold', 'stock' ),
2435 ),
2436 )
2437 );
2438
2439 $this->add_group_control(
2440 Group_Control_Typography::get_type(),
2441 array(
2442 'name' => 'pa_post_title_typo',
2443 'selector' => '{{WRAPPER}} .premium-post-ticker__post-title a',
2444 'condition' => array(
2445 'post_type_filter!' => array( 'gold', 'stock' ),
2446 ),
2447 )
2448 );
2449
2450 $this->add_control(
2451 'pa_post_title_color',
2452 array(
2453 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2454 'type' => Controls_Manager::COLOR,
2455 'selectors' => array(
2456 '{{WRAPPER}} .premium-post-ticker__post-title a, {{WRAPPER}} .premium-text-typing::after' => 'color: {{VALUE}};',
2457 ),
2458 'condition' => array(
2459 'post_type_filter!' => array( 'gold', 'stock' ),
2460 ),
2461 )
2462 );
2463
2464 $this->add_control(
2465 'pa_post_title_color_hov',
2466 array(
2467 'label' => __( 'Hover Color', 'premium-addons-for-elementor' ),
2468 'type' => Controls_Manager::COLOR,
2469 'selectors' => array(
2470 '{{WRAPPER}} .premium-post-ticker__post-title:hover a, {{WRAPPER}} .premium-text-typing:hover::after' => 'color: {{VALUE}};',
2471 ),
2472 'condition' => array(
2473 'post_type_filter!' => array( 'gold', 'stock' ),
2474 ),
2475 )
2476 );
2477
2478 $this->add_group_control(
2479 Group_Control_Text_Stroke::get_type(),
2480 array(
2481 'name' => 'element_text_stroke',
2482 'separator' => 'after',
2483 'selector' => '{{WRAPPER}} .premium-post-ticker__post-title',
2484 'condition' => array(
2485 'post_type_filter!' => array( 'gold', 'stock' ),
2486 ),
2487 )
2488 );
2489
2490 $this->add_control(
2491 'text_icon_color',
2492 array(
2493 'label' => __( 'Icon Color', 'premium-addons-for-elementor' ),
2494 'type' => Controls_Manager::COLOR,
2495 'separator' => 'before',
2496 'selectors' => array(
2497 '{{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item i' => 'color: {{VALUE}}',
2498 '{{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item .premium-drawable-icon *,
2499 {{WRAPPER}} .premium-post-ticker__icon-wrapper.premium-repeater-item svg:not([class*="premium-"])' => 'fill: {{VALUE}};',
2500 ),
2501 'condition' => array(
2502 'post_type_filter' => 'text',
2503 ),
2504 )
2505 );
2506
2507 if ( $draw_icon ) {
2508 $this->add_control(
2509 'text_stroke_color',
2510 array(
2511 'label' => __( 'Stroke Color', 'premium-addons-for-elementor' ),
2512 'type' => Controls_Manager::COLOR,
2513 'global' => array(
2514 'default' => Global_Colors::COLOR_ACCENT,
2515 ),
2516 'condition' => array(
2517 'post_type_filter' => 'text',
2518 ),
2519 'selectors' => array(
2520 '{{WRAPPER}} .premium-drawable-icon *, {{WRAPPER}} svg:not([class*="premium-"])' => 'stroke: {{VALUE}};',
2521 ),
2522 )
2523 );
2524 }
2525
2526 // Date.
2527 $this->add_control(
2528 'pa_post_date_heading',
2529 array(
2530 'label' => __( 'Date', 'premium-addons-for-elementor' ),
2531 'type' => Controls_Manager::HEADING,
2532 'separator' => 'before',
2533 'condition' => array(
2534 'date_meta' => 'yes',
2535 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2536 ),
2537 )
2538 );
2539
2540 $this->add_group_control(
2541 Group_Control_Typography::get_type(),
2542 array(
2543 'name' => 'pa_post_date_typo',
2544 'global' => array(
2545 'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
2546 ),
2547 'selector' => '{{WRAPPER}} .premium-post-ticker__post-date span',
2548 'condition' => array(
2549 'date_meta' => 'yes',
2550 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2551 ),
2552 )
2553 );
2554
2555 $this->add_control(
2556 'pa_post_date_color',
2557 array(
2558 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2559 'type' => Controls_Manager::COLOR,
2560 'selectors' => array(
2561 '{{WRAPPER}} .premium-post-ticker__post-date span' => 'color: {{VALUE}};',
2562 ),
2563 'condition' => array(
2564 'date_meta' => 'yes',
2565 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2566 ),
2567 )
2568 );
2569
2570 // Author.
2571 $this->add_control(
2572 'pa_author_heading',
2573 array(
2574 'label' => __( 'Author', 'premium-addons-for-elementor' ),
2575 'type' => Controls_Manager::HEADING,
2576 'separator' => 'before',
2577 'condition' => array(
2578 'author_meta' => 'yes',
2579 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2580 ),
2581 )
2582 );
2583
2584 $this->add_group_control(
2585 Group_Control_Typography::get_type(),
2586 array(
2587 'name' => 'pa_author_typo',
2588 'global' => array(
2589 'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
2590 ),
2591 'fields_options' => array(
2592 'font_size' => array(
2593 'selectors' => array(
2594 '{{WRAPPER}} .premium-post-ticker__post-author a, {{WRAPPER}} .premium-post-ticker__post-author i' => 'font-size: {{SIZE}}{{UNIT}}',
2595 ),
2596 ),
2597 ),
2598 'selector' => '{{WRAPPER}} .premium-post-ticker__post-author a',
2599 'condition' => array(
2600 'author_meta' => 'yes',
2601 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2602 ),
2603 )
2604 );
2605
2606 $this->add_control(
2607 'pa_author_color',
2608 array(
2609 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2610 'type' => Controls_Manager::COLOR,
2611 'selectors' => array(
2612 '{{WRAPPER}} .premium-post-ticker__post-author *' => 'color: {{VALUE}};',
2613 ),
2614 'condition' => array(
2615 'author_meta' => 'yes',
2616 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2617 ),
2618 )
2619 );
2620
2621 $this->add_control(
2622 'pa_author_color_hov',
2623 array(
2624 'label' => __( 'Hover Color', 'premium-addons-for-elementor' ),
2625 'type' => Controls_Manager::COLOR,
2626 'selectors' => array(
2627 '{{WRAPPER}} .premium-post-ticker__post-author:hover *' => 'color: {{VALUE}};',
2628 ),
2629 'condition' => array(
2630 'author_meta' => 'yes',
2631 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2632 ),
2633 )
2634 );
2635
2636 // featured image.
2637 $this->add_control(
2638 'pa_post_img',
2639 array(
2640 'label' => __( 'Featured Image', 'premium-addons-for-elementor' ),
2641 'type' => Controls_Manager::HEADING,
2642 'separator' => 'before',
2643 'condition' => array(
2644 'post_img' => 'yes',
2645 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2646 ),
2647 )
2648 );
2649
2650 $this->add_group_control(
2651 Group_Control_Box_Shadow::get_type(),
2652 array(
2653 'name' => 'pa_post_img_shadow',
2654 'selector' => '{{WRAPPER}} .premium-post-ticker__thumbnail-wrapper',
2655 'condition' => array(
2656 'post_img' => 'yes',
2657 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2658 ),
2659 )
2660 );
2661
2662 $this->add_group_control(
2663 Group_Control_Border::get_type(),
2664 array(
2665 'name' => 'pa_post_img_border',
2666 'selector' => '{{WRAPPER}} .premium-post-ticker__thumbnail-wrapper',
2667 'condition' => array(
2668 'post_img' => 'yes',
2669 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2670 ),
2671 )
2672 );
2673
2674 $this->add_control(
2675 'pa_post_img_border_radius',
2676 array(
2677 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2678 'type' => Controls_Manager::SLIDER,
2679 'size_units' => array( 'px', 'em', '%' ),
2680 'selectors' => array(
2681 '{{WRAPPER}} .premium-post-ticker__thumbnail-wrapper, {{WRAPPER}} .premium-post-ticker__thumbnail-wrapper *' => 'border-radius: {{SIZE}}{{UNIT}};',
2682 ),
2683 'condition' => array(
2684 'post_img' => 'yes',
2685 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2686 ),
2687 )
2688 );
2689
2690 $this->add_responsive_control(
2691 'pa_post_img_margin',
2692 array(
2693 'label' => __( 'Margin', 'premium-addons-for-elementor' ),
2694 'type' => Controls_Manager::DIMENSIONS,
2695 'size_units' => array( 'px', 'em', '%' ),
2696 'selectors' => array(
2697 '{{WRAPPER}} .premium-post-ticker__thumbnail-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2698 ),
2699 'condition' => array(
2700 'post_img' => 'yes',
2701 'post_type_filter!' => array( 'gold', 'stock', 'text' ),
2702 ),
2703 )
2704 );
2705
2706 $this->papro_activated = Helper_Functions::check_papro_version();
2707 if ( $this->papro_activated ) {
2708 do_action( 'pa_ticker_stock_style', $this );
2709 }
2710
2711 // box / container.
2712 $this->add_control(
2713 'pa_post_box_heading',
2714 array(
2715 'label' => __( 'Container', 'premium-addons-for-elementor' ),
2716 'type' => Controls_Manager::HEADING,
2717 'separator' => 'before',
2718 )
2719 );
2720
2721 $this->add_group_control(
2722 Group_Control_Box_Shadow::get_type(),
2723 array(
2724 'name' => 'pa_post_box_shadow',
2725 'selector' => '{{WRAPPER}} .premium-post-ticker__post-wrapper',
2726 )
2727 );
2728
2729 $this->add_group_control(
2730 Premium_Background::get_type(),
2731 array(
2732 'name' => 'pa_post_box_bg',
2733 'types' => array( 'classic', 'gradient' ),
2734 'selector' => '{{WRAPPER}} .premium-post-ticker__post-wrapper, {{WRAPPER}}:not(.premium-post-ticker__layout-4) .premium-post-ticker__arrows, {{WRAPPER}}.premium-post-ticker__layout-3 .premium-post-ticker__content',
2735 )
2736 );
2737
2738 $this->add_group_control(
2739 Group_Control_Border::get_type(),
2740 array(
2741 'name' => 'pa_post_box_border',
2742 'selector' => '{{WRAPPER}} .premium-post-ticker__post-wrapper',
2743 )
2744 );
2745
2746 $this->add_control(
2747 'pa_post_box_border_radius',
2748 array(
2749 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2750 'type' => Controls_Manager::SLIDER,
2751 'size_units' => array( 'px', 'em', '%' ),
2752 'selectors' => array(
2753 '{{WRAPPER}} .premium-post-ticker__post-wrapper' => 'border-radius: {{SIZE}}{{UNIT}};',
2754 ),
2755 )
2756 );
2757
2758 $this->add_responsive_control(
2759 'pa_post_box_padding',
2760 array(
2761 'label' => __( 'Padding', 'premium-addons-for-elementor' ),
2762 'type' => Controls_Manager::DIMENSIONS,
2763 'size_units' => array( 'px', 'em', '%' ),
2764 'selectors' => array(
2765 '{{WRAPPER}} .premium-post-ticker__post-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2766 ),
2767 )
2768 );
2769
2770 $this->add_responsive_control(
2771 'pa_post_box_magin',
2772 array(
2773 'label' => __( 'Margin', 'premium-addons-for-elementor' ),
2774 'type' => Controls_Manager::DIMENSIONS,
2775 'size_units' => array( 'px', 'em', '%' ),
2776 'selectors' => array(
2777 '{{WRAPPER}} .premium-post-ticker__post-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2778 ),
2779 )
2780 );
2781
2782 $this->end_controls_section();
2783 }
2784
2785 private function add_posts_container_style() {
2786
2787 $this->start_controls_section(
2788 'posts_container_style',
2789 array(
2790 'label' => __( 'Ticker Elements Container', 'premium-addons-for-elementor' ),
2791 'tab' => Controls_Manager::TAB_STYLE,
2792 )
2793 );
2794
2795 $this->add_group_control(
2796 Premium_Background::get_type(),
2797 array(
2798 'name' => 'posts_container_background',
2799 'types' => array( 'classic', 'gradient' ),
2800 'selector' => '{{WRAPPER}} .premium-post-ticker__content',
2801 )
2802 );
2803
2804 $this->add_control(
2805 'post_lq_effect',
2806 array(
2807 'label' => __( 'Liquid Glass Effect', 'premium-addons-for-elementor' ),
2808 'type' => Controls_Manager::SELECT,
2809 'description' => sprintf(
2810 /* translators: 1: `<a>` opening tag, 2: `</a>` closing tag. */
2811 esc_html__( 'Important: Make sure this element has a semi-transparent background color to see the effect. See all presets from %1$shere%2$s.', 'premium-addons-for-elementor' ),
2812 '<a href="https://premiumaddons.com/liquid-glass/" target="_blank">',
2813 '</a>'
2814 ),
2815 'options' => array(
2816 'none' => __( 'None', 'premium-addons-for-elementor' ),
2817 'glass1' => __( 'Preset 01', 'premium-addons-for-elementor' ),
2818 'glass2' => __( 'Preset 02', 'premium-addons-for-elementor' ),
2819 'glass3' => apply_filters( 'pa_pro_label', __( 'Preset 03 (Pro)', 'premium-addons-for-elementor' ) ),
2820 'glass4' => apply_filters( 'pa_pro_label', __( 'Preset 04 (Pro)', 'premium-addons-for-elementor' ) ),
2821 'glass5' => apply_filters( 'pa_pro_label', __( 'Preset 05 (Pro)', 'premium-addons-for-elementor' ) ),
2822 'glass6' => apply_filters( 'pa_pro_label', __( 'Preset 06 (Pro)', 'premium-addons-for-elementor' ) ),
2823 ),
2824 'default' => 'none',
2825 'label_block' => true,
2826 'render_type' => 'template',
2827 )
2828 );
2829
2830 $this->add_group_control(
2831 Group_Control_Border::get_type(),
2832 array(
2833 'name' => 'posts_container_border',
2834 'selector' => '{{WRAPPER}} .premium-post-ticker__content',
2835 )
2836 );
2837
2838 $this->add_control(
2839 'posts_container_border_radius',
2840 array(
2841 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2842 'type' => Controls_Manager::SLIDER,
2843 'size_units' => array( 'px', '%', 'em' ),
2844 'selectors' => array(
2845 '{{WRAPPER}} .premium-post-ticker__content' => 'border-radius: {{SIZE}}{{UNIT}};',
2846 ),
2847 )
2848 );
2849
2850 $this->add_group_control(
2851 Group_Control_Box_Shadow::get_type(),
2852 array(
2853 'name' => 'posts_container_shadow',
2854 'selector' => '{{WRAPPER}} .premium-post-ticker__content',
2855 )
2856 );
2857
2858 $this->add_responsive_control(
2859 'posts_container_margin',
2860 array(
2861 'label' => __( 'Margin', 'premium-addons-for-elementor' ),
2862 'type' => Controls_Manager::DIMENSIONS,
2863 'size_units' => array( 'px', 'em', '%' ),
2864 'selectors' => array(
2865 '{{WRAPPER}} .premium-post-ticker__content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
2866 ),
2867 )
2868 );
2869
2870 $this->add_responsive_control(
2871 'posts_container_padding',
2872 array(
2873 'label' => __( 'Padding', 'premium-addons-for-elementor' ),
2874 'type' => Controls_Manager::DIMENSIONS,
2875 'size_units' => array( 'px', 'em', '%' ),
2876 'selectors' => array(
2877 '{{WRAPPER}} .premium-post-ticker__content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
2878 ),
2879 )
2880 );
2881
2882 $this->end_controls_section();
2883 }
2884
2885 /**
2886 * Adds pagination style controls.
2887 *
2888 * @access private
2889 * @since 4.9.37
2890 */
2891 private function add_navigation_style() {
2892
2893 $this->start_controls_section(
2894 'pa_nav_style',
2895 array(
2896 'label' => __( 'Arrows', 'premium-addons-for-elementor' ),
2897 'tab' => Controls_Manager::TAB_STYLE,
2898 'condition' => array(
2899 'carousel_arrows' => 'yes',
2900 ),
2901 )
2902 );
2903
2904 $this->add_responsive_control(
2905 'nav_icon_size',
2906 array(
2907 'label' => __( 'Icon Size', 'premium-addons-for-elementor' ),
2908 'type' => Controls_Manager::SLIDER,
2909 'size_units' => array( 'px', '%', 'em' ),
2910 'selectors' => array(
2911 '{{WRAPPER}} .premium-post-ticker__arrows i' => 'font-size: {{SIZE}}{{UNIT}};',
2912 '{{WRAPPER}} .premium-post-ticker__arrows a' => 'line-height: {{SIZE}}{{UNIT}};',
2913 ),
2914 )
2915 );
2916
2917 $this->start_controls_tabs( 'nav_colors' );
2918
2919 $this->start_controls_tab(
2920 'pa_nav_nomral',
2921 array(
2922 'label' => __( 'Normal', 'premium-addons-for-elementor' ),
2923 )
2924 );
2925
2926 $this->add_control(
2927 'pa_nav_color',
2928 array(
2929 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2930 'type' => Controls_Manager::COLOR,
2931 'global' => array(
2932 'default' => Global_Colors::COLOR_SECONDARY,
2933 ),
2934 'selectors' => array(
2935 '{{WRAPPER}} .premium-post-ticker__arrows a' => 'color: {{VALUE}};',
2936 ),
2937 )
2938 );
2939
2940 $this->add_control(
2941 'pa_nav_bg',
2942 array(
2943 'label' => __( 'Background Color', 'premium-addons-for-elementor' ),
2944 'type' => Controls_Manager::COLOR,
2945 'selectors' => array(
2946 '{{WRAPPER}} .premium-post-ticker__arrows a' => 'background-color: {{VALUE}};',
2947 ),
2948 )
2949 );
2950
2951 $this->add_group_control(
2952 Group_Control_Border::get_type(),
2953 array(
2954 'name' => 'pa_nav_border',
2955 'selector' => '{{WRAPPER}} .premium-post-ticker__arrows a',
2956 )
2957 );
2958
2959 $this->add_control(
2960 'pa_nav_border_radius',
2961 array(
2962 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
2963 'type' => Controls_Manager::SLIDER,
2964 'size_units' => array( 'px', '%', 'em' ),
2965 'selectors' => array(
2966 '{{WRAPPER}} .premium-post-ticker__arrows a' => 'border-radius: {{SIZE}}{{UNIT}};',
2967 ),
2968 )
2969 );
2970
2971 $this->end_controls_tab();
2972
2973 $this->start_controls_tab(
2974 'premium_blog_pa_nav_hover',
2975 array(
2976 'label' => __( 'Hover', 'premium-addons-for-elementor' ),
2977
2978 )
2979 );
2980
2981 $this->add_control(
2982 'pa_nav_color_hov',
2983 array(
2984 'label' => __( 'Color', 'premium-addons-for-elementor' ),
2985 'type' => Controls_Manager::COLOR,
2986 'global' => array(
2987 'default' => Global_Colors::COLOR_PRIMARY,
2988 ),
2989 'selectors' => array(
2990 '{{WRAPPER}} .premium-post-ticker__arrows a:hover' => 'color: {{VALUE}};',
2991 ),
2992 )
2993 );
2994
2995 $this->add_control(
2996 'pa_nav_bg_hov',
2997 array(
2998 'label' => __( 'Background Color', 'premium-addons-for-elementor' ),
2999 'type' => Controls_Manager::COLOR,
3000 'global' => array(
3001 'default' => Global_Colors::COLOR_SECONDARY,
3002 ),
3003 'selectors' => array(
3004 '{{WRAPPER}} .premium-post-ticker__arrows a:hover' => 'background-color: {{VALUE}};',
3005 ),
3006 )
3007 );
3008
3009 $this->add_group_control(
3010 Group_Control_Border::get_type(),
3011 array(
3012 'name' => 'pa_nav_border_hov',
3013 'selector' => '{{WRAPPER}} .premium-post-ticker__arrows a:hover',
3014 )
3015 );
3016
3017 $this->add_control(
3018 'pa_nav_border_radius_hov',
3019 array(
3020 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
3021 'type' => Controls_Manager::SLIDER,
3022 'size_units' => array( 'px', '%', 'em' ),
3023 'selectors' => array(
3024 '{{WRAPPER}} .premium-post-ticker__arrows a:hover' => 'border-radius: {{SIZE}}{{UNIT}};',
3025 ),
3026 )
3027 );
3028
3029 $this->end_controls_tab();
3030
3031 $this->end_controls_tabs();
3032
3033 $this->add_responsive_control(
3034 'pa_nav_margin',
3035 array(
3036 'label' => __( 'Spacing', 'premium-addons-for-elementor' ),
3037 'type' => Controls_Manager::SLIDER,
3038 'size_units' => array( 'px' ),
3039 'separator' => 'before',
3040 'selectors' => array(
3041 '{{WRAPPER}} .premium-post-ticker__arrows' => 'column-gap: {{SIZE}}px;',
3042 ),
3043 )
3044 );
3045
3046 $this->add_responsive_control(
3047 'pa_nav_padding',
3048 array(
3049 'label' => __( 'Padding', 'premium-addons-for-elementor' ),
3050 'type' => Controls_Manager::DIMENSIONS,
3051 'size_units' => array( 'px', 'em', '%' ),
3052 'selectors' => array(
3053 '{{WRAPPER}} .premium-post-ticker__arrows a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3054 ),
3055 )
3056 );
3057
3058 $this->add_control(
3059 'arrows_container',
3060 array(
3061 'label' => __( 'Outer Container', 'premium-addons-for-elementor' ),
3062 'type' => Controls_Manager::HEADING,
3063 'separator' => 'before',
3064 )
3065 );
3066
3067 $this->add_group_control(
3068 Group_Control_Border::get_type(),
3069 array(
3070 'name' => 'arrow_container_border',
3071 'selector' => '{{WRAPPER}} .premium-post-ticker__arrows',
3072 )
3073 );
3074
3075 $this->add_control(
3076 'arrow_container_rad',
3077 array(
3078 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
3079 'type' => Controls_Manager::SLIDER,
3080 'size_units' => array( 'px', '%', 'em' ),
3081 'selectors' => array(
3082 '{{WRAPPER}} .premium-post-ticker__arrows' => 'border-radius: {{SIZE}}{{UNIT}};',
3083 ),
3084 )
3085 );
3086
3087 $this->add_responsive_control(
3088 'arrow_container_padding',
3089 array(
3090 'label' => __( 'Padding', 'premium-addons-for-elementor' ),
3091 'type' => Controls_Manager::DIMENSIONS,
3092 'size_units' => array( 'px', 'em', '%' ),
3093 'selectors' => array(
3094 '{{WRAPPER}} .premium-post-ticker__arrows' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3095 ),
3096 )
3097 );
3098
3099 $this->add_responsive_control(
3100 'arrow_container_margin',
3101 array(
3102 'label' => __( 'Margin', 'premium-addons-for-elementor' ),
3103 'type' => Controls_Manager::DIMENSIONS,
3104 'size_units' => array( 'px', 'em', '%' ),
3105 'selectors' => array(
3106 '{{WRAPPER}} .premium-post-ticker__arrows' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3107 ),
3108 )
3109 );
3110
3111 $this->end_controls_section();
3112 }
3113
3114 /**
3115 * Adds separator style controls.
3116 *
3117 * @access private
3118 * @since 4.9.37
3119 */
3120 private function add_separator_style() {
3121
3122 $this->start_controls_section(
3123 'pa_separator_style',
3124 array(
3125 'label' => __( 'Separator', 'premium-addons-for-elementor' ),
3126 'tab' => Controls_Manager::TAB_STYLE,
3127 'condition' => array(
3128 'infinite' => 'yes',
3129 'separator' => 'yes',
3130 'layout!' => 'layout-4',
3131 ),
3132 )
3133 );
3134
3135 $this->add_responsive_control(
3136 'separator_position',
3137 array(
3138 'label' => __( 'Position', 'premium-addons-for-elementor' ),
3139 'type' => Controls_Manager::SLIDER,
3140 'size_units' => array( 'px', 'em', '%', 'custom' ),
3141 'selectors' => array(
3142 '{{WRAPPER}} .premium-post-ticker__separator' => 'right: {{SIZE}}{{UNIT}}',
3143 ),
3144 )
3145 );
3146
3147 $this->add_responsive_control(
3148 'separator_width',
3149 array(
3150 'label' => __( 'Width', 'premium-addons-for-elementor' ),
3151 'type' => Controls_Manager::SLIDER,
3152 'size_units' => array( 'px', 'em', 'custom' ),
3153 'selectors' => array(
3154 '{{WRAPPER}} .premium-post-ticker__separator' => 'width: {{SIZE}}{{UNIT}}',
3155 ),
3156 )
3157 );
3158
3159 $this->add_responsive_control(
3160 'separator_height',
3161 array(
3162 'label' => __( 'Height', 'premium-addons-for-elementor' ),
3163 'type' => Controls_Manager::SLIDER,
3164 'size_units' => array( 'px', 'em', 'custom' ),
3165 'selectors' => array(
3166 '{{WRAPPER}} .premium-post-ticker__separator' => 'height: {{SIZE}}{{UNIT}} !important',
3167 ),
3168 )
3169 );
3170
3171 $this->add_control(
3172 'separator_color',
3173 array(
3174 'label' => __( 'Color', 'premium-addons-for-elementor' ),
3175 'type' => Controls_Manager::COLOR,
3176 'selectors' => array(
3177 '{{WRAPPER}} .premium-post-ticker__separator' => 'background-color: {{VALUE}};',
3178 ),
3179 )
3180 );
3181
3182 $this->add_control(
3183 'separator_rad',
3184 array(
3185 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ),
3186 'type' => Controls_Manager::SLIDER,
3187 'size_units' => array( 'px', '%', 'em' ),
3188 'selectors' => array(
3189 '{{WRAPPER}} .premium-post-ticker__separator' => 'border-radius: {{SIZE}}{{UNIT}};',
3190 ),
3191 )
3192 );
3193
3194 $this->end_controls_section();
3195 }
3196
3197 /**
3198 * Render post ticker widget output on the frontend.
3199 * Written in PHP and used to generate the final HTML.
3200 *
3201 * @since 1.0.0
3202 * @access protected
3203 */
3204 protected function render() {
3205
3206 $settings = $this->get_settings_for_display();
3207
3208 $this->papro_activated = Helper_Functions::check_papro_version();
3209
3210 if ( ! $this->papro_activated && ( in_array( $settings['layout'], array( 'layout-3', 'layout-4' ), true ) || ! in_array( $settings['post_type_filter'], array( 'post', 'text' ), true ) ) ) {
3211 ?>
3212 <div class="premium-error-notice">
3213 <?php
3214 $message = __( 'This option is available in <b>Premium Addons Pro</b>.', 'premium-addons-for-elementor' );
3215 echo wp_kses_post( $message );
3216 ?>
3217 </div>
3218 <?php
3219 return false;
3220 }
3221
3222 $id = $this->get_id();
3223
3224 $settings['widget_id'] = $id;
3225 $settings['widget_type'] = 'premium-post-ticker';
3226
3227 $source = $settings['post_type_filter'];
3228
3229 if ( 'stock' === $source ) {
3230
3231 $api_key = apply_filters( 'pa_stock_api', $settings['api_key'] );
3232
3233 if ( empty( $api_key ) ) {
3234
3235 $notice = __( 'Please enter a valid API key.', 'premium-addons-for-elementor' );
3236 ?>
3237 <div class="premium-error-notice">
3238 <?php echo wp_kses_post( $notice ); ?>
3239 </div>
3240 <?php
3241 return;
3242 }
3243
3244 $function = $settings['req_function'];
3245 $symbol = 'CURRENCY_EXCHANGE_RATE' === $function ? $settings['from_currency'] : $settings['symbol'];
3246 $to_currency = '';
3247 $show_curr_change = false;
3248
3249 if ( empty( $symbol ) ) {
3250 $notice = __( 'Please Enter symbols/tokens to query of your choice.', 'premium-addons-for-elementor' );
3251 ?>
3252 <div class="premium-error-notice">
3253 <?php echo wp_kses_post( $notice ); ?>
3254 </div>
3255 <?php
3256 return;
3257 }
3258
3259 if ( 'CURRENCY_EXCHANGE_RATE' === $function ) {
3260 $to_currency = $settings['to_currency'];
3261 $show_curr_change = 'yes' === $settings['curr_change'] ? true : false;
3262
3263 if ( empty( $to_currency ) ) {
3264 $notice = __( 'Please Enter symbols/tokens to exchange to.', 'premium-addons-for-elementor' );
3265 ?>
3266 <div class="premium-error-notice">
3267 <?php echo wp_kses_post( $notice ); ?>
3268 </div>
3269 <?php
3270 return;
3271 }
3272 }
3273
3274 $transient_name = sprintf( 'papro_%s_%s_%s_%s_%s', $id, $api_key, $source, $symbol, $to_currency );
3275
3276 $req_data = get_transient( $transient_name );
3277
3278 if ( ! $req_data ) {
3279
3280 $api_settings = array(
3281 'id' => $id,
3282 'api_key' => $api_key,
3283 'source' => $source,
3284 'function' => $function,
3285 'symbols' => $this->extract_stock_symbols( $symbol ),
3286 'to_currency' => $this->extract_stock_symbols( $to_currency ),
3287 );
3288
3289 if ( $show_curr_change ) {
3290 $api_settings['old_data_key'] = $transient_name . '_old';
3291 }
3292
3293 $api_handler = new API_Handler( $api_settings );
3294
3295 $req_data = $api_handler::get_req_data( $api_settings );
3296
3297 if ( ! $req_data ) {
3298 return;
3299 }
3300
3301 $expire_time = HOUR_IN_SECONDS * apply_filters( 'pa_ticker_reload_' . $id, $settings['reload'] );
3302
3303 $api_handler::delete_existing_transient();
3304
3305 set_transient( $transient_name, $req_data, $expire_time );
3306
3307 if ( $show_curr_change ) {
3308 update_option( $transient_name . '_old', $req_data );
3309 }
3310 }
3311 } elseif ( 'gold' === $source ) {
3312
3313 $api_key = apply_filters( 'pa_gold_api', $settings['gold_api_key'] );
3314
3315 if ( empty( $api_key ) ) {
3316
3317 $notice = __( 'Please enter a valid API key.', 'premium-addons-for-elementor' );
3318 ?>
3319 <div class="premium-error-notice">
3320 <?php echo wp_kses_post( $notice ); ?>
3321 </div>
3322 <?php
3323 return;
3324 }
3325
3326 $currencies = $settings['currencies'];
3327
3328 if ( empty( $currencies ) ) {
3329 $notice = __( 'Please Enter Currencies of your choice to query.', 'premium-addons-for-elementor' );
3330 ?>
3331 <div class="premium-error-notice">
3332 <?php echo wp_kses_post( $notice ); ?>
3333 </div>
3334 <?php
3335 return;
3336 }
3337
3338 $transient_name = sprintf( 'papro_%s_%s_%s_%s', $id, $api_key, $source, $currencies );
3339
3340 $req_data = get_transient( $transient_name );
3341
3342 if ( ! $req_data ) {
3343
3344 $api_settings = array(
3345 'id' => $id,
3346 'api_key' => $api_key,
3347 'to_currency' => $currencies,
3348 );
3349
3350 $api_handler = new API_Handler( $api_settings );
3351
3352 $will_alter = false;
3353
3354 $req_data = $api_handler::get_gold_data( $api_settings, $will_alter );
3355
3356 if ( isset( $req_data['is_error_msg'] ) && $req_data['is_error_msg'] ) {
3357
3358 if ( ! empty( $settings['alter_api_key'] ) ) {
3359
3360 $will_alter = true;
3361
3362 $api_settings['api_key'] = $settings['alter_api_key'];
3363
3364 $req_data = $api_handler::get_gold_data( $api_settings, $will_alter );
3365
3366 if ( ! $req_data ) {
3367 return;
3368 }
3369 } else {
3370
3371 $err_msg = sprintf( 'Something went wrong: %s', $req_data['error_msg'] );
3372 ?>
3373 <div class="premium-error-notice">
3374 <?php echo wp_kses_post( $err_msg ); ?>
3375 </div>
3376 <?php
3377 return;
3378 }
3379 }
3380
3381 $expire_time = HOUR_IN_SECONDS * apply_filters( 'pa_ticker_reload_' . $id, $settings['gold_reload'] );
3382
3383 $api_handler::delete_existing_transient();
3384
3385 set_transient( $transient_name, $req_data, $expire_time );
3386 }
3387 } elseif ( 'text' === $source ) {
3388
3389 $text_content = $settings['text_content'];
3390
3391 } else {
3392 $posts_helper = Posts_Helper::getInstance();
3393
3394 $posts_helper->set_widget_settings( $settings, '*' );
3395
3396 $query = $posts_helper->get_query_posts();
3397
3398 if ( ! $query->have_posts() ) {
3399
3400 $query_notice = $settings['empty_query_text'];
3401
3402 $posts_helper->get_empty_query_message( $query_notice );
3403 return;
3404 }
3405 }
3406
3407 $layout = $settings['layout'];
3408 $title = ! empty( $settings['ticker_title'] ) ? $settings['ticker_title'] : false;
3409 $current_date = 'yes' === $settings['show_date'] ? true : false;
3410
3411 // slider settings.
3412 $infinite = 'yes' === $settings['infinite'];
3413 $auto_play = 'yes' === $settings['auto_play'];
3414 $arrows = 'yes' === $settings['carousel_arrows'];
3415 $fade = 'yes' === $settings['fade'] && 'layout-4' !== $layout ? true : false;
3416 $typing = ! in_array( $source, array( 'stock', 'gold' ), true ) && 'layout-4' !== $settings['layout'] && 'yes' === $settings['typing'] ? true : false;
3417 $vertical = 'yes' === $settings['vertical'];
3418 $speed = $settings['speed'];
3419
3420 if ( $fade ) {
3421 $vertical = false;
3422 }
3423
3424 if ( $typing ) {
3425 $vertical = false;
3426 $fade = false;
3427 }
3428
3429 if ( $infinite ) {
3430 $fade = false;
3431 $auto_play = true;
3432 $arrows = false;
3433 $typing = false;
3434 }
3435
3436 $should_be_rtl = false;
3437
3438 if ( 'layout-4' !== $layout && ! $fade ) {
3439 $is_reverse = isset( $settings['reverse'] ) && 'yes' === $settings['reverse'];
3440 $should_be_rtl = ( is_rtl() && ! $is_reverse ) || ( ! is_rtl() && $is_reverse );
3441
3442 // Special case: RTL + reversed + typing enabled
3443 if ( is_rtl() && $is_reverse && $typing ) {
3444 $should_be_rtl = true;
3445 }
3446
3447 $this->add_render_attribute( 'inner-wrapper', 'dir', $should_be_rtl ? 'rtl' : 'ltr' );
3448 }
3449
3450 $slider_settings = array(
3451 'layout' => $settings['layout'],
3452 'typing' => $typing,
3453 'fade' => $fade,
3454 'arrows' => $arrows,
3455 'infinite' => $infinite,
3456 'autoPlay' => $auto_play,
3457 'vertical' => $vertical,
3458 'speed' => $speed,
3459 'slidesToShow' => $settings['slides_to_show'],
3460 'pauseOnHover' => 'yes' === $settings['pause_on_hover'] ? true : false,
3461 'animation' => ! $infinite && ! $typing ? $settings['entrance_animation'] : '',
3462 'shouldBeRtl' => $should_be_rtl,
3463 );
3464
3465 if ( $auto_play ) {
3466 $slider_settings['autoplaySpeed'] = $settings['autoplay_speed'];
3467 }
3468
3469 $this->add_render_attribute(
3470 'outer-wrapper',
3471 array(
3472 'class' => 'premium-post-ticker__outer-wrapper premium-post-ticker__hidden ',
3473 'data-ticker-settings' => wp_json_encode( $slider_settings ),
3474 )
3475 );
3476
3477 $this->add_render_attribute( 'inner-wrapper', 'class', 'premium-post-ticker__posts-wrapper' );
3478
3479 $this->add_render_attribute( 'ticker_content', 'class', 'premium-post-ticker__content' );
3480
3481 if ( 'none' !== $settings['post_lq_effect'] ) {
3482 $this->add_render_attribute( 'ticker_content', 'class', 'premium-con-lq__' . $settings['post_lq_effect'] );
3483 }
3484
3485 ?>
3486 <div <?php $this->print_render_attribute_string( 'outer-wrapper' ); ?>>
3487 <?php if ( 'layout-1' === $layout ) { ?>
3488 <?php if ( $current_date ) : ?>
3489 <div class="premium-post-ticker__header-wrapper">
3490 <?php $this->render_ticker_date( $settings ); ?>
3491 </div>
3492 <?php endif; ?>
3493
3494 <div <?php $this->print_render_attribute_string( 'ticker_content' ); ?>>
3495 <?php
3496 if ( $title ) {
3497 $this->render_ticker_title( $settings );
3498 }
3499 ?>
3500
3501 <div <?php $this->print_render_attribute_string( 'inner-wrapper' ); ?>>
3502 <?php
3503 if ( in_array( $source, array( 'stock', 'gold' ), true ) ) {
3504 $this->render_detailed_stock_element( $req_data, $settings );
3505 } elseif ( 'text' === $source ) {
3506 $this->render_ticker_text_content( $text_content, $settings );
3507 } else {
3508 $this->render_ticker_post( $query, $settings );
3509 }
3510 ?>
3511 </div>
3512
3513 <?php
3514 if ( $arrows ) {
3515 $this->render_ticker_arrows( $settings );
3516 }
3517 ?>
3518 </div>
3519 <?php } elseif ( 'layout-2' === $layout ) { ?>
3520
3521 <?php if ( $title ) : ?>
3522 <div class="premium-post-ticker__header-wrapper">
3523 <?php $this->render_ticker_title( $settings ); ?>
3524 </div>
3525 <?php endif; ?>
3526
3527 <div <?php $this->print_render_attribute_string( 'ticker_content' ); ?>>
3528 <?php
3529 if ( $current_date ) {
3530 $this->render_ticker_date( $settings );
3531 }
3532 ?>
3533
3534 <div <?php $this->print_render_attribute_string( 'inner-wrapper' ); ?>>
3535 <?php
3536 if ( in_array( $source, array( 'stock', 'gold' ), true ) ) {
3537 $this->render_detailed_stock_element( $req_data, $settings );
3538 } elseif ( 'text' === $source ) {
3539 $this->render_ticker_text_content( $text_content, $settings );
3540 } else {
3541 $this->render_ticker_post( $query, $settings );
3542 }
3543 ?>
3544 </div>
3545
3546 <?php
3547 if ( $arrows ) {
3548 $this->render_ticker_arrows( $settings );
3549 }
3550 ?>
3551 </div>
3552
3553 <?php } elseif ( 'layout-3' === $layout ) { ?>
3554 <?php if ( $title || $current_date ) : ?>
3555 <div class="premium-post-ticker__header-wrapper">
3556 <?php
3557 if ( $current_date ) {
3558 $this->render_ticker_date( $settings );
3559 }
3560
3561 if ( $title ) {
3562 $this->render_ticker_title( $settings );
3563 }
3564 ?>
3565 </div>
3566 <?php endif; ?>
3567
3568 <div <?php $this->print_render_attribute_string( 'ticker_content' ); ?>>
3569 <div <?php $this->print_render_attribute_string( 'inner-wrapper' ); ?>>
3570 <?php
3571 if ( in_array( $source, array( 'stock', 'gold' ), true ) ) {
3572 $this->render_detailed_stock_element( $req_data, $settings );
3573 } elseif ( 'text' === $source ) {
3574 $this->render_ticker_text_content( $text_content, $settings );
3575 } else {
3576 $this->render_ticker_post( $query, $settings );
3577 }
3578 ?>
3579 </div>
3580
3581 <?php
3582 if ( $arrows ) {
3583 $this->render_ticker_arrows( $settings );
3584 }
3585 ?>
3586 </div>
3587 <?php } else { ?>
3588 <?php if ( $title || $current_date || $arrows ) : ?>
3589 <div class="premium-post-ticker__header-wrapper">
3590 <?php
3591 if ( $current_date ) {
3592 $this->render_ticker_date( $settings );
3593 }
3594
3595 if ( $title ) {
3596 $this->render_ticker_title( $settings );
3597 }
3598
3599 if ( $arrows ) {
3600 $this->render_ticker_arrows( $settings );
3601 }
3602 ?>
3603 </div>
3604 <?php endif; ?>
3605
3606 <div <?php $this->print_render_attribute_string( 'ticker_content' ); ?>>
3607 <div <?php $this->print_render_attribute_string( 'inner-wrapper' ); ?>>
3608 <?php
3609 if ( in_array( $source, array( 'stock', 'gold' ), true ) ) {
3610 $this->render_detailed_stock_element( $req_data, $settings );
3611 } elseif ( 'text' === $source ) {
3612 $this->render_ticker_text_content( $text_content, $settings );
3613 } else {
3614 $this->render_ticker_post( $query, $settings );
3615 }
3616 ?>
3617 </div>
3618 </div>
3619 <?php } ?>
3620 </div>
3621 <?php
3622 }
3623
3624 /**
3625 * Extracts Stock Symbols from a string separated by ",".
3626 *
3627 * @access public
3628 * @since 2.8.23
3629 *
3630 * @param string $symbol_str symbols strings.
3631 *
3632 * @return array
3633 */
3634 private function extract_stock_symbols( $symbol_str ) {
3635
3636 $symbols = explode( ',', $symbol_str );
3637
3638 $symbols = array_slice( $symbols, 0, 5 );
3639
3640 return $symbols;
3641 }
3642
3643 /**
3644 * Render stock elements.
3645 *
3646 * @access private
3647 * @since 2.8.22
3648 *
3649 * @param array $stock_symbols stock symbols data.
3650 * @param array $settings widget settings.
3651 */
3652 private function render_detailed_stock_element( $stock_symbols, $settings ) {
3653
3654 $is_stock_element = 'stock' === $settings['post_type_filter'];
3655 $function = $settings['req_function'];
3656 $is_equity = $is_stock_element && 'GLOBAL_QUOTE' === $function;
3657
3658 $symbols_names = false;
3659 $show_symbol = true;
3660 $show_price = 'yes' === $settings['show_price'];
3661
3662 $show_change = 'yes' === $settings['show_change'];
3663 $show_change_per = 'yes' === $settings['show_change_per'];
3664
3665 if ( $is_equity ) {
3666 if ( 'yes' === $settings['symbol_names_sw'] && ! empty( $settings['symbol_name'] ) ) {
3667 $symbols_names = $this->extract_stock_symbols( $settings['symbol_name'] );
3668 }
3669
3670 if ( 'yes' !== $settings['show_symbol'] ) {
3671 $show_symbol = false;
3672 }
3673 }
3674
3675 if ( $is_stock_element && 'CURRENCY_EXCHANGE_RATE' === $function ) {
3676 if ( 'yes' !== $settings['curr_change'] ) {
3677 $show_change = false;
3678 $show_change_per = false;
3679 }
3680 }
3681
3682 $change_indicator = $settings['change_indicator'];
3683 $decimal_places = empty( $settings['decimal_places'] ) ? 0 : $settings['decimal_places'];
3684
3685 foreach ( $stock_symbols as $symbol => $data ) {
3686
3687 $name = false;
3688 $dir_cls = '';
3689
3690 if ( $show_change || $show_change_per ) {
3691
3692 if ( 0 < $data['change'] ) {
3693 $dir_cls = 'up';
3694 } elseif ( 0 > $data['change'] ) {
3695 $dir_cls = 'down';
3696 }
3697 }
3698
3699 if ( $show_price || $show_change || $show_change_per ) {
3700
3701 if ( $show_price ) {
3702 $price = number_format( (float) $data['price'], $decimal_places, '.', ',' );
3703
3704 if ( $is_equity ) {
3705 $price = '&#36;' . $price;
3706 }
3707 }
3708
3709 if ( $show_change ) {
3710 $change = 'sign' === $change_indicator ? $data['change'] : abs( $data['change'] );
3711 $change = number_format( (float) $change, $decimal_places, '.', ',' );
3712 }
3713
3714 if ( $show_change_per ) {
3715
3716 $percent_change = str_replace( '%', '', $data['percent_change'] );
3717
3718 $change_percent = 'sign' === $change_indicator ? $percent_change : abs( (float) $percent_change );
3719
3720 $change_percent = number_format( (float) str_replace( '%', '', $change_percent ), $decimal_places, '.', ',' );
3721 }
3722 }
3723
3724 if ( false !== $symbols_names && isset( $symbols_names[ $symbol ] ) ) {
3725 $name = $symbols_names[ $symbol ];
3726 }
3727
3728 if ( 'yes' === $settings['show_symbol_icon'] ) {
3729
3730 $icons_repeater = $settings['symbol_icons_repeater'];
3731
3732 $currency_symbol = 'CURRENCY_EXCHANGE_RATE' === $function ? substr( $data['symbol'], 0, 3 ) : $data['symbol'];
3733
3734 $custom_icon = '';
3735
3736 if ( count( $icons_repeater ) > 0 ) {
3737 array_map(
3738 function ( $repeater_item ) use ( $currency_symbol, &$custom_icon ) {
3739 if ( $repeater_item['symbol_name'] === $currency_symbol ) {
3740 $custom_icon = $repeater_item['symbol_img']['url'];
3741 }},
3742 $icons_repeater
3743 );
3744 }
3745
3746 if ( ! empty( $custom_icon ) ) {
3747 $data['icon_src'] = $custom_icon;
3748 } else {
3749
3750 $currency_symbol = strtolower( $currency_symbol );
3751 if ( 'CURRENCY_EXCHANGE_RATE' === $function ) {
3752
3753 $data['icon_src'] = sprintf( 'https://assets.coincap.io/assets/icons/%s@2x.png', $currency_symbol );
3754 $data['icon_alternative'] = $data['icon_src'];
3755
3756 } else {
3757
3758 $data['icon_src'] = sprintf( 'https://eodhistoricaldata.com/img/logos/US/%s.png', $data['symbol'] );
3759 $data['icon_alternative'] = sprintf( 'https://eodhistoricaldata.com/img/logos/US/%s.png', $currency_symbol );
3760
3761 }
3762 }
3763 }
3764
3765 ?>
3766 <div class="premium-post-ticker__post-wrapper premium-post-sticker__stock-element-wrapper">
3767
3768 <?php if ( 'yes' === $settings['show_symbol_icon'] ) : ?>
3769 <img class='premium-post-ticker__symbol-icon' src='<?php echo esc_url( $data['icon_src'] ); ?>' alt='<?php echo esc_attr( $currency_symbol ); ?>' onerror="<?php echo 'CURRENCY_EXCHANGE_RATE' === $function ? '' : esc_attr( 'this.src="' . $data['icon_alternative'] . '"' ); ?>">
3770 <?php endif; ?>
3771
3772 <?php if ( false !== $name ) : ?>
3773 <span class='premium-post-ticker__symbol-name' title='Name' aria-label='<?php echo esc_attr( $name ); ?>'><?php echo esc_html( $name ); ?></span>
3774 <?php endif; ?>
3775
3776 <?php if ( $show_symbol ) : ?>
3777 <span class='premium-post-ticker__symbol' title='Symbol' aria-label='<?php echo esc_attr( $data['symbol'] ); ?>'> <?php echo esc_html( $data['symbol'] ); ?></span>
3778 <?php endif; ?>
3779
3780 <span class="premium-post-ticker__change-wrapper">
3781
3782 <?php if ( $show_price ) : ?>
3783 <span class="premium-post-ticker__price" title="Price
3784 <?php
3785 if ( ! $is_stock_element ) {
3786 echo 'Per Ounce'; }
3787 ?>
3788 " aria-label="<?php echo esc_attr( $price ); ?>"><?php echo esc_html( $price ); ?></span>
3789 <?php endif; ?>
3790
3791 <?php if ( $show_change ) : ?>
3792 <span class="premium-post-ticker__change <?php echo esc_attr( $dir_cls ); ?>" title="Change" aria-label="<?php echo esc_attr( $data['change'] ); ?>"><?php echo esc_html( $change ); ?></span>
3793 <?php endif; ?>
3794
3795 <?php if ( $show_change_per ) : ?>
3796 <span class="premium-post-ticker__change-percent <?php echo esc_attr( $dir_cls ); ?>" title="Change Percent" aria-label="<?php echo esc_attr( $data['percent_change'] ); ?>">
3797 <?php
3798 echo esc_html( $change_percent . '%' );
3799
3800 if ( 'arrow' === $change_indicator ) {
3801 if ( 0 < $data['change'] ) {
3802 ?>
3803 <i class="<?php echo esc_attr( $settings['arrow_style'] ); ?>-up" aria-hidden="true"></i>
3804 <?php
3805 } elseif ( 0 > $data['change'] ) {
3806 ?>
3807 <i class="<?php echo esc_attr( $settings['arrow_style'] ); ?>-down" aria-hidden="true"></i>
3808 <?php
3809 }
3810 }
3811 ?>
3812 </span>
3813 <?php endif; ?>
3814
3815 </span>
3816 </div>
3817 <?php
3818 }
3819 }
3820
3821 /**
3822 * Render Ticker Title.
3823 *
3824 * @access private
3825 * @since 2.8.22
3826 *
3827 * @param array $settings widget settings.
3828 */
3829 private function render_ticker_title( $settings ) {
3830
3831 $title = ! empty( $settings['ticker_title'] ) ? $settings['ticker_title'] : false;
3832
3833 $title_tag = Helper_Functions::validate_html_tag( $settings['ticker_title_tag'] );
3834 $title_classes = ! $title ? array() : Helper_Functions::get_element_classes( $settings['hide_title_on'], array( 'premium-post-ticker__title-wrapper' ) );
3835
3836 $icon_enabled = 'yes' === $settings['ticker_icon_sw'] ? true : false;
3837
3838 $this->add_render_attribute( 'title', 'class', $title_classes );
3839
3840 ?>
3841 <div <?php $this->print_render_attribute_string( 'title' ); ?>>
3842 <?php
3843 if ( $icon_enabled ) {
3844 $this->render_ticker_icon( $settings );
3845 }
3846 ?>
3847
3848 <<?php echo wp_kses_post( $title_tag ); ?> class="premium-post-ticker__title"> <?php echo esc_html( $title ); ?> </<?php echo wp_kses_post( $title_tag ); ?>>
3849 </div>
3850 <?php
3851 }
3852
3853 /**
3854 * Render Ticker Data.
3855 *
3856 * @access private
3857 * @since 2.8.22
3858 *
3859 * @param array $settings widget settings.
3860 */
3861 private function render_ticker_date( $settings ) {
3862
3863 $current_date = 'yes' === $settings['show_date'] ? true : false;
3864 $date_format = ! empty( $settings['date_format'] ) ? $settings['date_format'] : get_option( 'date_format' );
3865 $date_classes = ! $current_date ? array() : Helper_Functions::get_element_classes( $settings['hide_date_on'], array( 'premium-post-ticker__date-wrapper' ) );
3866
3867 $this->add_render_attribute( 'date', 'class', $date_classes );
3868
3869 ?>
3870 <div <?php $this->print_render_attribute_string( 'date' ); ?>>
3871 <span class="premium-post-ticker__date"> <?php echo esc_html( date_i18n( $date_format ) ); ?></span>
3872 </div>
3873 <?php
3874 }
3875
3876 /**
3877 * Render Ticker Arrows.
3878 *
3879 * @access private
3880 * @since 2.8.22
3881 *
3882 * @param array $settings widget settings.
3883 */
3884 private function render_ticker_arrows( $settings ) {
3885
3886 $prev = 'layout-4' === $settings['layout'] ? 'eicon-arrow-down' : 'fas fa-angle-left';
3887 $next = 'layout-4' === $settings['layout'] ? 'eicon-arrow-up' : 'fas fa-angle-right';
3888 ?>
3889 <div class="premium-post-ticker__arrows">
3890 <a class="prev-arrow" type="button" role="button" aria-label="Previous">
3891 <i class="<?php echo esc_attr( $prev ); ?>" aria-hidden="true"></i>
3892 </a>
3893 <a class="next-arrow" type="button" role="button" aria-label="Next">
3894 <i class="<?php echo esc_attr( $next ); ?>" aria-hidden="true"></i>
3895 </a>
3896 </div>
3897 <?php
3898 }
3899
3900 /**
3901 * Render Ticker Icon.
3902 *
3903 * @access private
3904 * @since 2.8.22
3905 *
3906 * @param array $settings widget settings.
3907 * @param boolean $is_repeater_item is repeater item.
3908 */
3909 private function render_ticker_icon( $settings, $is_repeater_item = false ) {
3910 $index = $is_repeater_item ? $settings['_id'] : '';
3911 ?>
3912 <div class="premium-post-ticker__icon-wrapper <?php echo $is_repeater_item ? 'premium-repeater-item' : ''; ?>">
3913 <?php
3914 $icon_type = $settings['icon_type'];
3915
3916 if ( 'icon' === $icon_type || 'svg' === $icon_type ) {
3917
3918 if ( 'icon' === $icon_type && 'yes' !== $settings['draw_svg'] ) {
3919
3920 Icons_Manager::render_icon(
3921 $settings['pa_ticker_icon'],
3922 array(
3923 'class' => array( 'premium-svg-nodraw', 'premium-drawable-icon' ),
3924 'aria-hidden' => 'true',
3925 )
3926 );
3927
3928 } else {
3929
3930 $this->add_render_attribute( 'icon' . $index, 'class', 'premium-drawable-icon' );
3931
3932 if ( 'yes' === $settings['draw_svg'] ) {
3933
3934 $this->add_render_attribute( 'outer-wrapper' . $index, 'class', 'elementor-invisible' );
3935
3936 $this->add_render_attribute(
3937 'icon' . $index,
3938 array(
3939 'class' => 'premium-svg-drawer',
3940 'data-svg-reverse' => $is_repeater_item ? 'false' : $settings['lottie_reverse'],
3941 'data-svg-loop' => $settings['lottie_loop'],
3942 'data-svg-sync' => $is_repeater_item ? 'true' : $settings['svg_sync'],
3943 'data-svg-fill' => $is_repeater_item ? $settings['text_icon_color'] : $settings['title_icon_color'],
3944 'data-svg-frames' => $is_repeater_item ? '5' : $settings['frames'],
3945 'data-svg-yoyo' => $is_repeater_item ? 'false' : $settings['svg_yoyo'],
3946 )
3947 );
3948
3949 if ( $is_repeater_item ) {
3950 $this->add_render_attribute( 'icon' . $index, 'data-svg-point', '0' );
3951 } else {
3952 $this->add_render_attribute( 'icon' . $index, 'data-svg-point', $settings['lottie_reverse'] ? $settings['end_point']['size'] : $settings['start_point']['size'] );
3953 }
3954 } else {
3955 $this->add_render_attribute( 'icon' . $index, 'class', 'premium-svg-nodraw' );
3956 }
3957
3958 if ( 'icon' === $icon_type ) {
3959
3960 echo Helper_Functions::get_svg_by_icon( $settings['pa_ticker_icon'], $this->get_render_attribute_string( 'icon' . $index ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_svg_by_icon() returns sanitized inline SVG/icon markup.
3961
3962 }
3963 }
3964
3965 if ( 'svg' === $icon_type ) {
3966 ?>
3967 <div <?php $this->print_render_attribute_string( 'icon' . $index ); ?>>
3968 <?php
3969 if ( $is_repeater_item ) {
3970 echo Helper_Functions::sanitize_svg( $settings['custom_svg'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sanitize_svg passes through wp_kses with a strict SVG allowlist.
3971 } else {
3972 echo Helper_Functions::sanitize_svg( $this->get_settings_for_display( 'custom_svg' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sanitize_svg passes through wp_kses with a strict SVG allowlist.
3973 }
3974 ?>
3975 </div>
3976 <?php
3977 }
3978 } elseif ( 'image' === $icon_type ) {
3979
3980 if ( ! empty( $settings['image']['url'] ) ) {
3981 $image_html = Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'image' );
3982 echo wp_kses_post( $image_html );
3983 }
3984 } elseif ( 'lottie' === $icon_type ) {
3985
3986 $this->add_render_attribute(
3987 'pa_ticker_lottie',
3988 array(
3989 'class' => array(
3990 'premium-lottie-animation',
3991 ),
3992 'data-lottie-url' => $settings['lottie_url'],
3993 'data-lottie-loop' => $settings['lottie_loop'],
3994 'data-lottie-reverse' => $is_repeater_item ? false : $settings['lottie_reverse'],
3995 )
3996 );
3997 ?>
3998 <div <?php $this->print_render_attribute_string( 'pa_ticker_lottie' ); ?>></div>
3999 <?php
4000 }
4001
4002 ?>
4003 </div>
4004 <?php
4005 }
4006
4007 /**
4008 * Render Ticker Post.
4009 *
4010 * @access private
4011 * @since 2.8.22
4012 *
4013 * @param object $query query results.
4014 * @param array $settings widget settings.
4015 */
4016 private function render_ticker_post( $query, $settings ) {
4017
4018 $posts = $query->posts;
4019
4020 global $post;
4021
4022 foreach ( $posts as $post ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Standard WP loop; global $post is restored via wp_reset_postdata().
4023
4024 setup_postdata( $post );
4025
4026 $this->get_ticker_post_layout( $settings );
4027 }
4028
4029 wp_reset_postdata();
4030 }
4031
4032 /**
4033 * Render Ticker Text Content.
4034 *
4035 * @access private
4036 * @since 2.8.22
4037 *
4038 * @param object $content text content.
4039 * @param array $settings widget settings.
4040 */
4041 private function render_ticker_text_content( $content, $settings ) {
4042
4043 $typing_enabled = 'yes' === $settings['typing'] && 'layout-4' !== $settings['layout'] ? true : false;
4044
4045 foreach ( $content as $index => $item ) {
4046
4047 $txt_id = $item['_id'];
4048
4049 $this->add_render_attribute( 'post-title' . $txt_id, 'class', 'premium-post-ticker__post-title' );
4050
4051 $this->add_render_attribute( 'post-wrapper' . $txt_id, 'class', array( 'premium-post-ticker__post-wrapper', 'elementor-repeater-item-' . $txt_id ) );
4052
4053 $this->add_link_attributes( 'post-link' . $txt_id, $item['item_link'] );
4054
4055 if ( $typing_enabled ) {
4056 $this->add_render_attribute( 'post-link' . $txt_id, 'data-typing', esc_attr( $item['text'] ) );
4057 }
4058
4059 if ( '' !== $settings['entrance_animation'] ) {
4060 $this->add_render_attribute( 'post-wrapper' . $txt_id, 'class', 'animated ' . $settings['entrance_animation'] );
4061 }
4062
4063 ?>
4064 <div <?php $this->print_render_attribute_string( 'post-wrapper' . $txt_id ); ?>>
4065 <div <?php $this->print_render_attribute_string( 'post-title' . $txt_id ); ?>>
4066 <a <?php $this->print_render_attribute_string( 'post-link' . $txt_id ); ?>>
4067 <?php echo wp_kses_post( $item['text'] ); ?>
4068 </a>
4069 </div>
4070 <?php
4071 if ( 'yes' === $item['txt_icon_sw'] ) {
4072 $item['text_icon_color'] = isset( $settings['text_icon_color'] ) ? $settings['text_icon_color'] : '';
4073 $item['index'] = $index;
4074 $this->render_ticker_icon( $item, true );
4075 }
4076 ?>
4077 <?php if ( 'yes' === $settings['separator'] && 'yes' === $settings['infinite'] && 'layout-4' !== $settings['layout'] ) : ?>
4078 <div class="premium-post-ticker__separator"></div>
4079 <?php endif; ?>
4080 </div>
4081 <?php
4082 }
4083 }
4084
4085 /**
4086 * Render Post Layout.
4087 *
4088 * @access private
4089 * @since 2.8.22
4090 *
4091 * @param array $settings widget settings.
4092 */
4093 private function get_ticker_post_layout( $settings ) {
4094
4095 $post_id = get_the_ID();
4096
4097 $show_thumbnail = 'yes' === $settings['post_img'] ? true : false;
4098
4099 $show_author = 'yes' === $settings['author_meta'] ? true : false;
4100
4101 $show_date = 'yes' === $settings['date_meta'] ? true : false;
4102
4103 $title_tag = Helper_Functions::validate_html_tag( $settings['ticker_title_tag'] );
4104
4105 $link_target = 'yes' === $settings['new_tab'] ? '_blank' : '_self';
4106
4107 $post_tag = 'yes' === $settings['article_tag_switcher'] ? 'article' : 'div';
4108
4109 $content_length = ! empty( $settings['content_length'] ) ? $settings['content_length'] : false;
4110
4111 $typing_enabled = 'yes' === $settings['typing'] && 'layout-4' !== $settings['layout'] ? true : false;
4112
4113 if ( ! $content_length ) {
4114 $title = the_title( '', '', false );
4115 } else {
4116 $title = implode( ' ', array_slice( explode( ' ', the_title( '', '', false ) ), 0, $content_length ) ) . '...';
4117 }
4118
4119 if ( $show_thumbnail ) {
4120
4121 $settings['image'] = array(
4122 'id' => get_post_thumbnail_id(),
4123 );
4124
4125 $thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings, 'image' );
4126
4127 $author_classes = Helper_Functions::get_element_classes( $settings['hide_thumb_on'], array( 'premium-post-ticker__thumbnail-wrapper' ) );
4128
4129 $this->add_render_attribute( 'thumbnail' . $post_id, 'class', $author_classes );
4130 }
4131
4132 if ( $show_author ) {
4133 $author_classes = Helper_Functions::get_element_classes( $settings['hide_author_on'], array( 'premium-post-ticker__post-author' ) );
4134
4135 $this->add_render_attribute( 'author' . $post_id, 'class', $author_classes );
4136 }
4137
4138 if ( $show_date ) {
4139
4140 $date_format = ! empty( $settings['post_date_format'] ) ? $settings['post_date_format'] : get_option( 'date_format' );
4141
4142 $author_classes = Helper_Functions::get_element_classes( $settings['hide_post_date_on'], array( 'premium-post-ticker__post-date' ) );
4143
4144 $this->add_render_attribute( 'post-date' . $post_id, 'class', $author_classes );
4145 }
4146
4147 $this->add_render_attribute( 'post-title' . $post_id, 'class', 'premium-post-ticker__post-title' );
4148
4149 $this->add_render_attribute( 'post-wrapper' . $post_id, 'class', 'premium-post-ticker__post-wrapper' );
4150
4151 $this->add_render_attribute(
4152 'post-link' . $post_id,
4153 array(
4154 'href' => esc_url( get_permalink() ),
4155 'target' => esc_attr( $link_target ),
4156 )
4157 );
4158
4159 if ( $typing_enabled ) {
4160 $this->add_render_attribute( 'post-link' . $post_id, 'data-typing', esc_attr( $title ) );
4161 }
4162
4163 if ( '' !== $settings['entrance_animation'] ) {
4164 $this->add_render_attribute( 'post-wrapper' . $post_id, 'class', 'animated ' . $settings['entrance_animation'] );
4165 }
4166 ?>
4167
4168 <<?php echo wp_kses_post( $post_tag . ' ' . $this->get_render_attribute_string( 'post-wrapper' . $post_id ) ); ?>>
4169
4170 <?php if ( $show_thumbnail ) : ?>
4171 <div <?php $this->print_render_attribute_string( 'thumbnail' . $post_id ); ?>>
4172 <a href="<?php the_permalink(); ?>" target="<?php echo esc_attr( $link_target ); ?>">
4173 <?php echo wp_kses_post( $thumbnail_html ); ?>
4174 </a>
4175 </div>
4176 <?php endif; ?>
4177
4178 <?php if ( $show_author ) : ?>
4179 <div>
4180 <span <?php $this->print_render_attribute_string( 'author' . $post_id ); ?>>
4181 <i class="fa fa-user fa-fw" aria-hidden="true"></i>
4182 <?php the_author_posts_link(); ?>
4183 </span>
4184 </div>
4185 <?php endif; ?>
4186
4187 <div>
4188 <<?php echo wp_kses_post( $title_tag . ' ' . $this->get_render_attribute_string( 'post-title' . $post_id ) ); ?>>
4189 <a <?php $this->print_render_attribute_string( 'post-link' . $post_id ); ?>>
4190 <?php echo wp_kses_post( $title ); ?>
4191 </a>
4192 </<?php echo wp_kses_post( $title_tag ); ?>>
4193 </div>
4194
4195 <?php if ( $show_date ) : ?>
4196 <div>
4197 <span <?php $this->print_render_attribute_string( 'post-date' . $post_id ); ?>>
4198 <span><?php the_time( $date_format ); ?></span>
4199 </span>
4200 </div>
4201 <?php endif; ?>
4202
4203 <?php if ( 'yes' === $settings['separator'] && 'yes' === $settings['infinite'] && 'layout-4' !== $settings['layout'] ) : ?>
4204 <div class="premium-post-ticker__separator"></div>
4205 <?php endif; ?>
4206
4207 </<?php echo wp_kses_post( $post_tag ); ?>>
4208
4209 <?php
4210 }
4211 }
4212