PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.5.2
Post Grid Gutenberg Blocks – PostX v2.5.2
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / blocks / News_Ticker.php

News_Ticker.php in Post Grid Gutenberg Blocks – PostX 2.5.2, at blocks/News_Ticker.php

1,026 lines 45.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ULTP\blocks;
3
4 defined('ABSPATH') || exit;
5
6 class News_Ticker{
7 public function __construct() {
8 add_action('init', array($this, 'register'));
9 }
10 public function get_attributes($default = false){
11 $attributes = array(
12 'blockId' => [
13 'type' => 'string',
14 'default' => '',
15 ],
16 'previewImg' => [
17 'type' => 'string',
18 'default' => '',
19 ],
20
21 //--------------------------
22 // Label Style
23 //--------------------------
24 'tickLabelColor' => [
25 'type' => 'string',
26 'default' => '#fff',
27 'style' => [
28 (object)[
29 'selector'=>'{{ULTP}} .ultp-news-ticker-label { color:{{tickLabelColor}}; } '
30 ],
31 ],
32 ],
33 'tickLabelBg' => [
34 'type' => 'string',
35 'default' => '#1974d2',
36 'style' => [
37 (object)[
38 'selector'=>'{{ULTP}} .ultp-news-ticker-label{background-color:{{tickLabelBg}};}'
39 ],
40 (object)[
41 'depends' => [
42 (object)['key'=>'tickShapeStyle','condition'=>'!=','value'=>'normal'],
43 ],
44 'selector'=>'{{ULTP}} .ultp-news-ticker-label::after{border-color:transparent transparent transparent {{tickLabelBg}} !important}'
45 ],
46 ],
47 ],
48 'tickLabelTypo' => [
49 'type' => 'object',
50 'default' => (object)['openTypography'=>1,'size'=>(object)['lg'=>'16', 'unit'=>'px'], 'spacing'=>(object)[ 'lg'=>'0', 'unit'=>'px'], 'height'=>(object)[ 'lg'=>'27', 'unit'=>'px'],'decoration'=>'none','transform' => 'capitalize','family'=>'','weight'=>'500'],
51 'style' => [
52 (object)[
53 'selector'=>'{{ULTP}} .ultp-news-ticker-label'
54 ],
55 ],
56 ],
57 'tickLabelPadding' => [
58 'type' => 'string',
59 'default' => '15',
60 'style' => [
61 (object)[
62 'selector'=>'{{ULTP}} .ultp-news-ticker-label { padding:0px {{tickLabelPadding}}px; }'
63 ],
64 ],
65 ],
66 'tickLabelSpace' => [
67 'type' => 'string',
68 'default' => '160',
69 'style' => [
70 (object)[
71 'selector'=>'{{ULTP}} .ultp-news-ticker-box { padding-left:{{tickLabelSpace}}px; }'
72 ],
73 ],
74 ],
75 'tickShapeStyle' => [
76 'type' => 'string',
77 'default' => 'normal',
78 'style' => [
79
80 (object)[
81 'depends' => [
82 (object)['key'=>'tickShapeStyle','condition'=>'==','value'=>'large'],
83 ],
84 'selector'=>'{{ULTP}} .ultp-news-ticker-label::after {border-top: 23px solid; border-left: 24px solid; border-bottom: 23px solid; right: -24px;border-color:transparent; }'
85 ],
86 (object)[
87 'depends' => [
88 (object)['key'=>'tickShapeStyle','condition'=>'==','value'=>'medium'],
89 ],
90 'selector'=>'{{ULTP}} .ultp-news-ticker-label::after { border-top: 17px solid; border-left: 20px solid;border-bottom: 17px solid;border-color:transparent;right:-20px;}'
91 ],
92 (object)[
93 'depends' => [
94 (object)['key'=>'tickShapeStyle','condition'=>'==','value'=>'small'],
95 ],
96 'selector'=>'{{ULTP}} .ultp-news-ticker-label::after { border-top: 12px solid;border-left: 15px solid;
97 border-bottom: 12px solid;border-color: transparent;right: -15px; }'
98 ],
99 (object)[
100 'depends' => [
101 (object)['key'=>'tickShapeStyle','condition'=>'==','value'=>'normal'],
102 ],
103 'selector'=>'{{ULTP}} .ultp-news-ticker-label::after {display:none !important;}'
104 ],
105 ],
106 ],
107 //--------------------------
108 // Ticker body Style
109 //--------------------------
110 'tickerContentHeight' => [
111 'type' => 'string',
112 'default' =>'45',
113 'style' => [
114 (object)[
115 'selector'=>'{{ULTP}} .ultp-news-ticker li ,.editor-styles-wrapper {{ULTP}} .ultp-newsTicker-wrap ul li ,{{ULTP}} .ultp-news-ticker-label ,{{ULTP}} .ultp-newsTicker-wrap ,{{ULTP}} .ultp-news-ticker-controls ,{{ULTP}} .ultp-news-ticker-controls button { height:{{tickerContentHeight}}px; }'
116 ],
117 ],
118 ],
119 'tickBodyColor' => [
120 'type' => 'string',
121 'default' => '#444',
122 'style' => [
123 (object)[
124 'selector'=>'{{ULTP}} .ultp-news-ticker li a, {{ULTP}} .ultp-news-ticker li div { color:{{tickBodyColor}}; }'
125 ],
126 ],
127 ],
128 'tickBodyHovColor' => [
129 'type' => 'string',
130 'default' => '#7d7d7d',
131 'style' => [
132 (object)[
133 'selector'=>'{{ULTP}} .ultp-news-ticker li a:hover, {{ULTP}} .ultp-news-ticker li div:hover { color:{{tickBodyHovColor}}; }'
134 ],
135 ],
136 ],
137 'tickBodyListColor' => [
138 'type' => 'string',
139 'default' => '#037fff',
140 'style' => [
141 (object)[
142 'depends' => [
143 (object)['key'=>'tickTxtStyle','condition'=>'==','value'=>'box'],
144 ],
145 'selector'=>'{{ULTP}} .ultp-list-box::before { background-color:{{tickBodyListColor}};}'
146 ],
147 (object)[
148 'depends' => [
149 (object)['key'=>'tickTxtStyle','condition'=>'==','value'=>'circle'],
150 ],
151 'selector'=>'{{ULTP}} .ultp-list-circle::before { background-color:{{tickBodyListColor}};}'
152 ],
153 (object)[
154 'depends' => [
155 (object)['key'=>'tickTxtStyle','condition'=>'==','value'=>'hand'],
156 ],
157 'selector'=>'{{ULTP}} .ultp-list-hand::before { color:{{tickBodyListColor}};}'
158 ],
159 (object)[
160 'depends' => [
161 (object)['key'=>'tickTxtStyle','condition'=>'==','value'=>'right-sign'],
162 ],
163 'selector'=>'{{ULTP}} .ultp-list-right-sign::before { color:{{tickBodyListColor}};}'
164 ],
165 (object)[
166 'depends' => [
167 (object)['key'=>'tickTxtStyle','condition'=>'==','value'=>'right-bold'],
168 ],
169 'selector'=>'{{ULTP}} .ultp-list-right-bold::before { color:{{tickBodyListColor}};}'
170 ],
171 ],
172 ],
173 'tickerBodyBg' => [
174 'type' => 'string',
175 'default' => '#eeeeee',
176 'style' => [
177 (object)[
178 'selector'=>'{{ULTP}} .ultp-newsTicker-wrap .ultp-news-ticker-box , {{ULTP}} .ultp-news-ticker-controls {background-color:{{tickerBodyBg}}}'
179 ],
180 ],
181 ],
182 'tickBodyTypo' => [
183 'type' => 'object',
184 'default' => (object)['openTypography'=>1,'size'=>(object)['lg'=>'16', 'unit'=>'px'], 'spacing'=>(object)[ 'lg'=>'0', 'unit'=>'px'], 'height'=>(object)[ 'lg'=>'16', 'unit'=>'px'],'decoration'=>'none','transform' => 'capitalize','family'=>'','weight'=>'500'],
185 'style' => [
186 (object)[
187 'selector'=>'{{ULTP}} .ultp-news-ticker li a'
188 ],
189 ],
190 ],
191 'tickBodyBorderColor' => [
192 'type' => 'string',
193 'default' => '',
194 'style' => [
195 (object)[
196 'selector'=>'{{ULTP}} .ultp-newsTicker-wrap { background-color:{{tickBodyBorderColor}};border-color:{{tickBodyBorderColor}} }'
197 ],
198 ],
199 ],
200 'tickBodyBorder' => [
201 'type' => 'object',
202 'default' => (object)['openBorder'=>0,'disableColor'=> true, 'width' => (object)[ 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0],'type' => 'solid' ],
203 'style' => [
204 (object)[
205 'selector'=>'{{ULTP}} .ultp-block-items-wrap .ultp-newsTicker-wrap'
206 ],
207 ],
208 ],
209 'tickBodyRadius' => [
210 'type' => 'object',
211 'default' => (object)['lg' =>'', 'unit' =>'px'],
212 'style' => [
213 (object)[
214 'selector'=>'{{ULTP}} .ultp-newsTicker-wrap ,{{ULTP}} .ultp-news-ticker-label ,{{ULTP}} .ultp-news-ticker-box { border-radius:{{tickBodyRadius}}; }{{ULTP}} .ultp-news-ticker-prev { border-top-right-radius:0px !important; border-bottom-right-radius:0px !important; border-radius: {{tickBodyRadius}}; }'
215 ],
216 ],
217 ],
218 'tickTxtStyle' => [
219 'type' => 'string',
220 'default' => 'normal',
221 'style' => [
222 (object)[
223 'selector'=>'{{ULTP}} .ultp-news-ticker li { list-style-type:none; }'
224 ],
225 ],
226 ],
227 'tickImgWidth' => [
228 'type' => 'string',
229 'default' => '30',
230 'style' => [
231 (object)[
232 'depends' => [
233 (object)['key'=>'tickImageShow','condition'=>'==','value'=>true],
234 ],
235 'selector'=>'{{ULTP}} .ultp-news-ticker li div img {width:{{tickImgWidth}}px}'
236 ],
237 ],
238 ],
239 'tickImgSpace' => [
240 'type' => 'string',
241 'default' => '10',
242 'style' => [
243 (object)[
244 'depends' => [
245 (object)['key'=>'tickImageShow','condition'=>'==','value'=>true],
246 ],
247 'selector'=>'{{ULTP}} .ultp-news-ticker li div img {margin-right: {{tickImgSpace}}px}'
248 ],
249 ],
250 ],
251 'tickImgRadius' => [
252 'type' => 'object',
253 'default' => (object)['lg' =>(object)['top' => "30",'bottom' => "30",'left' => "30",'right' => "30", 'unit' =>'px']],
254 'style' => [
255 (object)[
256 'selector'=>'{{ULTP}} .ultp-news-ticker li div img { border-radius:{{tickImgRadius}}; }'
257 ],
258 ],
259 ],
260 'tickBodySpace' => [
261 'type' => 'object',
262 'default' => (object)['lg'=>'21'],
263 'style' => [
264 (object)[
265 'depends' => [
266 (object)['key'=>'tickerType','condition'=>'==','value'=> 'marquee'],
267 ],
268 'selector'=>'{{ULTP}} .ultp-news-ticker { gap:{{tickBodySpace}}px; }'
269 ],
270 ],
271 ],
272 //--------------------------
273 // body time badge style
274 //--------------------------
275 'tickTimeBadge' => [
276 'type' => 'string',
277 'default' => 'Time Badge',
278 'style' => [
279 (object)[
280 'depends' => [
281 (object)['key'=>'tickTimeShow','condition'=>'==','value'=>true],
282 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
283 ],
284 ],
285 ],
286 ],
287 'timeBadgeColor' => [
288 'type' => 'string',
289 'default' => '#fff',
290 'style' => [
291 (object)[
292 'depends' => [
293 (object)['key'=>'tickTimeShow','condition'=>'==','value'=>true],
294 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
295 ],
296 'selector'=>'{{ULTP}} .ultp-news-ticker li .ultp-ticker-timebadge { color:{{timeBadgeColor}}; }'
297 ],
298 ],
299 ],
300 'timeBadgeBg' => [
301 'type' => 'object',
302 'default' => (object)['openColor' => 1, 'type' => 'color', 'color' => '#444'],
303 'style' => [
304 (object)[
305 'depends' => [
306 (object)['key'=>'tickTimeShow','condition'=>'==','value'=>true],
307 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
308 ],
309 'selector'=>'{{ULTP}} .ultp-news-ticker li .ultp-ticker-timebadge'
310 ],
311 ],
312 ],
313 'timeBadgeTypo' => [
314 'type' => 'object',
315 'default' => (object)['openTypography'=>1,'size'=>(object)['lg'=>'12', 'unit'=>'px'], 'spacing'=>(object)[ 'lg'=>'0', 'unit'=>'px'], 'height'=>(object)[ 'lg'=>'16', 'unit'=>'px'],'decoration'=>'none','transform' => 'lowercase','family'=>'','weight'=>'500'],
316 'style' => [
317 (object)[
318 'depends' => [
319 (object)['key'=>'tickTimeShow','condition'=>'==','value'=>true],
320 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
321 ],
322 'selector'=>'{{ULTP}} .ultp-news-ticker li .ultp-ticker-timebadge'
323 ],
324 ],
325 ],
326 'timeBadgeRadius' => [
327 'type' => 'object',
328 'default' => (object)['lg' =>(object)['top' => "100",'bottom' => "100",'left' => "100",'right' => "100", 'unit' =>'px']],
329 'style' => [
330 (object)[
331 'depends' => [
332 (object)['key'=>'tickTimeShow','condition'=>'==','value'=>true],
333 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
334 ],
335 'selector'=>'{{ULTP}} .ultp-news-ticker li .ultp-ticker-timebadge { border-radius:{{timeBadgeRadius}}; }'
336 ],
337 ],
338 ],
339 'timeBadgePadding' => [
340 'type' => 'object',
341 'default' => (object)['lg'=>(object)['top'=>3,'bottom'=>3, 'left'=>6, 'right'=>6, 'unit'=>'px']],
342 'style' => [
343 (object)[
344 'selector'=>'{{ULTP}} .ultp-news-ticker li .ultp-ticker-timebadge { padding: {{timeBadgePadding}} }'
345 ],
346 ],
347 ],
348 //--------------------------
349 // Icon Navigator
350 //--------------------------
351 'TickNavStyle' => [
352 'type' => 'string',
353 'default' => 'nav1',
354 'style' => [
355 (object)[
356 'depends' => [
357 (object)['key'=>'navControlToggle','condition'=>'==','value'=> true],
358 ],
359 ],
360 ],
361 ],
362 'TickNavIconStyle' => [
363 'type' => 'string',
364 'default' => 'Angle2',
365 'style' => [
366 (object)[
367 'depends' => [
368 (object)['key'=>'navControlToggle','condition'=>'==','value'=> true],
369 ],
370 ],
371 ],
372 ],
373 'TickNavColor' => [
374 'type' => 'string',
375 'default' => '#fff',
376 'style' => [
377 (object)[
378 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow:after{border-color:{{TickNavColor}}} {{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow svg { fill:{{TickNavColor}}}'
379 ],
380 (object)[
381 'depends' => [
382 (object)['key'=>'TickNavIconStyle','condition'=>'==','value'=>'icon2'],
383
384 ],
385 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow:after , {{ULTP}} button.ultp-news-ticker-arrow:before{ border-right-color:{{TickNavColor}};border-left-color: {{TickNavColor}}; } '
386 ],
387
388 ],
389 ],
390 'TickNavBg' => [
391 'type' => 'object',
392 'default' => (object)['openColor' => 1, 'type' => 'color', 'color' => '#037fff'],
393 'style' => [
394 (object)[
395 'depends' => [
396 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav1'],
397 ],
398 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow'
399 ],
400 (object)[
401 'depends' => [
402 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav2'],
403 ],
404 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow'
405 ],
406 (object)[
407 'depends' => [
408 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav1'],
409 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav2'],
410 ],
411 'selector'=>'{{ULTP}} .ultp-news-ticker-controls'
412 ],
413 ],
414 ],
415 'TickNavHovColor' => [
416 'type' => 'string',
417 'default' => '#d0d0d0f4',
418 'style' => [
419 (object)[
420 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow:hover:after{border-color:{{TickNavHovColor}}} {{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow svg:hover { fill:{{TickNavHovColor}}}'
421 ],
422 (object)[
423 'depends' => [
424 (object)['key'=>'TickNavIconStyle','condition'=>'==','value'=>'icon2'],
425 ],
426 'selector'=>'{{ULTP}} button.ultp-news-ticker-arrow:hover:after
427 , {{ULTP}} button.ultp-news-ticker-arrow:hover:before{ border-right-color:{{TickNavHovColor}};border-left-color:{{TickNavHovColor}}; }
428 '
429 ],
430
431 ],
432 ],
433 'TickNavHovBg' => [
434 'type' => 'object',
435 'default' => (object)['openColor' => 1, 'type' => 'color', 'color' => '#53a0ff'],
436 'style' => [
437 (object)[
438 'depends' => [
439 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav1'],
440 ],
441 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow:hover'
442 ],
443 (object)[
444 'depends' => [
445 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav2'],
446 ],
447 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow:hover'
448 ],
449 (object)[
450 'depends' => [
451 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav3'],
452 ],
453 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-arrow:hover'
454 ],
455 (object)[
456 'depends' => [
457 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav1'],
458 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav2'],
459 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav3'],
460 ],
461 'selector'=>'{{ULTP}} .ultp-news-ticker-controls:hover'
462 ],
463 ],
464 ],
465 // Pause Style
466 'TickNavPause' => [
467 'type' => 'string',
468 'default' => 'Pause Icon Style',
469 'style' => [
470 (object)[
471 'depends' => [
472 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav2'],
473 (object)['key'=>'controlToggle','condition'=>'==','value'=>true],
474 ],
475 ],
476 ],
477 ],
478 'PauseColor' => [
479 'type' => 'string',
480 'default' => '#fff',
481 'style' => [
482 (object)[
483 'depends' => [
484 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav2'],
485 (object)['key'=>'controlToggle','condition'=>'==','value'=>true],
486 ],
487 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-pause:before , {{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-pause:before , {{ULTP}} .ultp-news-ticker-nav4 button.ultp-news-ticker-pause:before { border-color:{{PauseColor}};}'
488 ],
489 ],
490 ],
491 'PauseHovColor' => [
492 'type' => 'string',
493 'default' => '#d0d0d0f4',
494 'style' => [
495 (object)[
496 'depends' => [
497 (object)['key'=>'TickNavIconStyle','condition'=>'!=','value'=>'icon2'],
498 (object)['key'=>'controlToggle','condition'=>'==','value'=> true],
499 ],
500 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-pause:hover:before { border-color:{{PauseHovColor}};}'
501 ],
502 ]
503 ],
504 'PauseBg' => [
505 'type' => 'object',
506 'default' => (object)['openColor' => 1, 'type' => 'color', 'color' => '#2163ff'],
507 'style' => [
508 (object)[
509 'depends' => [
510 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav1'],
511 (object)['key'=>'controlToggle','condition'=>'==','value'=>true],
512 ],
513 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-pause'
514 ],
515 (object)[
516 'depends' => [
517 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav3'],
518 (object)['key'=>'controlToggle','condition'=>'==','value'=>true],
519 ],
520 'selector'=>'{{ULTP}} .ultp-news-ticker-controls button.ultp-news-ticker-pause'
521 ],
522 ],
523 ],
524
525 'PauseHovBg' => [
526 'type' => 'object',
527 'default' => (object)['openColor' => 1, 'type' => 'color', 'color' => '#53a0ff'],
528 'style' => [
529 (object)[
530 'depends' => [
531 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav1'],
532 (object)['key'=>'controlToggle','condition'=>'==','value'=>true],
533 ],
534 'selector'=>'{{ULTP}} .ultp-news-ticker-controls .ultp-news-ticker-pause:hover'
535 ],
536 (object)[
537 'depends' => [
538 (object)['key'=>'TickNavStyle','condition'=>'==','value'=>'nav3'],
539 (object)['key'=>'controlToggle','condition'=>'==','value'=>true],
540 ],
541 'selector'=>'{{ULTP}} .ultp-news-ticker-controls .ultp-news-ticker-pause:hover'
542 ],
543 ],
544 ],
545 //--------------------------
546 // Query Setting
547 //--------------------------
548 'queryQuick' => [
549 'type' => 'string',
550 'default' =>'',
551 ],
552 'queryNumber' => [
553 'type' => 'string',
554 'default' =>4,
555 ],
556 'queryType' => [
557 'type' => 'string',
558 'default' => 'post'
559 ],
560 'queryTax' => [
561 'type' => 'string',
562 'default' => 'category'
563 ],
564 'queryTaxValue' => [
565 'type' => 'string',
566 'default' => '[]',
567 'style' => [
568 (object)[
569 'depends' => [(object)['key' => 'queryTax','condition' => '!=','value' => '']]
570 ],
571 ],
572 ],
573 'queryRelation' => [
574 'type' => 'string',
575 'default' => 'OR'
576 ],
577 'queryCat' => [ // for compatibility
578 'type' => 'string',
579 'default' => '[]'
580 ],
581 'queryTag' => [ // for compatibility
582 'type' => 'string',
583 'default' => '[]'
584 ],
585 'queryOrderBy' => [
586 'type' => 'string',
587 'default' => 'date',
588 ],
589 'metaKey' => [
590 'type' => 'string',
591 'default' => 'custom_meta_key',
592 'style' => [
593 (object)[
594 'depends' => [(object)['key' => 'queryOrderBy','condition' => '==','value' => 'meta_value_num']]
595 ],
596 ],
597 ],
598 'queryOrder' => [
599 'type' => 'string',
600 'default' => 'desc',
601 ],
602 'queryInclude' => [
603 'type' => 'string',
604 'default' => ''
605 ],
606 'queryExclude' => [
607 'type' => 'string',
608 'default' => ''
609 ],
610 'queryAuthor' => [
611 'type' => 'string',
612 'default' => ''
613 ],
614 'queryOffset' => [
615 'type' => 'string',
616 'default' => '0',
617 ],
618 //--------------------------
619 // General Setting
620 //--------------------------
621 'tickerType' => [
622 'type' => 'string',
623 'default' => 'vertical',
624 ],
625 'tickerPositionEna' => [
626 'type' => 'boolean',
627 'default' => false,
628 ],
629 'tickerPosition' => [
630 'type' => 'string',
631 'default' => 'up',
632 'style' => [
633 (object)[
634 'depends' => [
635 (object)['key'=>'tickerPositionEna','condition'=>'==','value'=> true],
636 (object)['key'=>'tickerPosition','condition'=>'==','value'=> 'up'],
637 ],
638 'selector'=>'{{ULTP}} .ultp-news-sticky .ultp-newsTicker-wrap { position: fixed;width: 100%;top: 0;z-index: 9999999; left: 0; }'
639 ],
640 (object)[
641 'depends' => [
642 (object)['key'=>'tickerPositionEna','condition'=>'==','value'=> true],
643 (object)['key'=>'tickerPosition','condition'=>'==','value'=> 'down'],
644 ],
645 'selector'=>'{{ULTP}} .ultp-news-sticky .ultp-newsTicker-wrap { position: fixed;width: 100%;bottom: 0; z-index: 9999999;left: 0; }'
646 ],
647 ],
648 ],
649 'tickerHeading' => [
650 'type' => 'boolean',
651 'default' => true,
652 ],
653 'tickTimeShow' => [
654 'type' => 'boolean',
655 'default' => true,
656 'style' => [
657 (object)[
658 'depends' => [
659 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
660 ],
661 ],
662 ],
663 ],
664 'tickImageShow' => [
665 'type' => 'boolean',
666 'default' => false,
667 ],
668 'navControlToggle' => [
669 'type' => 'boolean',
670 'default' => true,
671 ],
672 'controlToggle' => [
673 'type' => 'boolean',
674 'default' => true,
675 'style' => [
676 (object)[
677 'depends' => [
678 (object)['key'=>'navControlToggle','condition'=>'==','value'=>true],
679 (object)['key'=>'TickNavStyle','condition'=>'!=','value'=>'nav2'],
680 ],
681 ],
682 ],
683 ],
684 'pauseOnHover' => [
685 'type' => 'boolean',
686 'default' => true,
687 ],
688 'tickerDirectionVer' => [
689 'type' => 'string',
690 'default' => 'up',
691 'style' => [
692 (object)[
693 'depends' => [
694 (object)['key'=>'tickerType','condition'=>'==','value'=>'vertical'],
695 (object)['key'=>'tickerAnimation','condition'=>'==','value'=>'slide']
696 ],
697 ],
698 ],
699 ],
700 'tickerDirectionHorizon' => [
701 'type' => 'string',
702 'default' => 'left',
703 'style' => [
704 (object)[
705 'depends' => [
706 (object)['key'=>'tickerType','condition'=>'==','value'=>'horizontal'],
707 (object)['key'=>'tickerAnimation','condition'=>'==','value'=>'slide']
708 ],
709 ],
710 (object)[
711 'depends' => [
712 (object)['key'=>'tickerType','condition'=>'==','value'=>'marquee'],
713 ],
714 ],
715 ],
716 ],
717 'tickerSpeed' => [
718 'type' => 'string',
719 'default' => '4000',
720 'style' => [
721 (object)[
722 'depends' => [(object)['key' => 'tickerType','condition' => '!=','value' => "marquee"]]
723 ],
724 ],
725 ],
726 'tickerSpeedTypewriter' => [
727 'type' => 'string',
728 'default' => '50',
729 'style' => [
730 (object)[
731 'depends' => [(object)['key' => 'tickerType','condition' => '==','value' => 'typewriter']]
732 ],
733 ],
734 ],
735 'tickerAnimation' => [
736 'type' => 'string',
737 'default' => 'slide',
738 'style' => [
739 (object)[
740 'depends' => [
741 (object)['key'=>'tickerType','condition'=>'!=','value'=>'marquee'],
742 (object)['key'=>'tickerType','condition'=>'!=','value'=>'typewriter'],
743 ],
744 ],
745 ],
746 ],
747 'typeAnimation' => [
748 'type' => 'string',
749 'default' => 'fadein',
750 'style' => [
751 (object)[
752 'depends' => [
753 (object)['key'=>'tickerType','condition'=>'==','value'=>'typewriter'],
754 ],
755 ],
756 ],
757 ],
758 'openInTab' => [
759 'type' => 'boolean',
760 'default' => false,
761 ],
762
763 //--------------------------
764 // Heading Setting/Style
765 //--------------------------
766 'headingText' => [
767 'type' => 'string',
768 'default' => 'News Ticker',
769 ],
770 //--------------------------
771 // Title Setting/Style
772 //--------------------------
773 'titleColor' => [
774 'type' => 'string',
775 'default' => '#037fff',
776 'style' => [
777 (object)[
778 'selector'=>'{{ULTP}} { color:{{headingBtnColor}}; } {{ULTP}} .ultp-heading-wrap .ultp-heading-btn svg { fill:{{headingBtnColor}}; }'
779 ],
780 ],
781 ],
782 'titleTypo' => [
783 'type' => 'object',
784 'default' => (object)['openTypography'=>1,'size'=>(object)['lg'=>'16', 'unit'=>'px'], 'spacing'=>(object)[ 'lg'=>'0', 'unit'=>'px'], 'height'=>(object)[ 'lg'=>'27', 'unit'=>'px'],'decoration'=>'none','transform' => 'capitalize','family'=>'','weight'=>'500'],
785 'style' => [
786 (object)[
787 'selector'=>'{{ULTP}} '
788 ],
789 ],
790 ],
791 //--------------------------
792 // Advanced
793 //--------------------------
794 'advanceId' => [
795 'type' => 'string',
796 'default' => '',
797 ],
798 'advanceZindex' => [
799 'type' => 'number',
800 'default' => '',
801 'style' => [
802 (object)[
803 'selector' => '{{ULTP}} {z-index:{{advanceZindex}};}'
804 ],
805 ],
806 ],
807 //
808 'wrapBg' => [
809 'type' => 'object',
810 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#f5f5f5'],
811 'style' => [
812 (object)[
813 'selector'=>'{{ULTP}} .ultp-block-wrapper'
814 ],
815 ],
816 ],
817 'wrapBorder' => [
818 'type' => 'object',
819 'default' => (object)['openBorder'=>0, 'width' =>(object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
820 'style' => [
821 (object)[
822 'selector'=>'{{ULTP}} .ultp-block-wrapper'
823 ],
824 ],
825 ],
826 'wrapShadow' => [
827 'type' => 'object',
828 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
829 'style' => [
830 (object)[
831 'selector'=>'{{ULTP}} .ultp-block-wrapper'
832 ],
833 ],
834 ],
835 'wrapRadius' => [
836 'type' => 'object',
837 'default' => (object)['lg' =>'', 'unit' =>'px'],
838 'style' => [
839 (object)[
840 'selector'=>'{{ULTP}} .ultp-block-wrapper { border-radius:{{wrapRadius}}; }'
841 ],
842 ],
843 ],
844 'wrapHoverBackground' => [
845 'type' => 'object',
846 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#037fff'],
847 'style' => [
848 (object)[
849 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
850 ],
851 ],
852 ],
853 'wrapHoverBorder' => [
854 'type' => 'object',
855 'default' => (object)['openBorder'=>0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
856 'style' => [
857 (object)[
858 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
859 ],
860 ],
861 ],
862 'wrapHoverRadius' => [
863 'type' => 'object',
864 'default' => (object)['lg' =>'', 'unit' =>'px'],
865 'style' => [
866 (object)[
867 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover { border-radius:{{wrapHoverRadius}}; }'
868 ],
869 ],
870 ],
871 'wrapHoverShadow' => [
872 'type' => 'object',
873 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
874 'style' => [
875 (object)[
876 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
877 ],
878 ],
879 ],
880 //
881 'hideExtraLarge' => [
882 'type' => 'boolean',
883 'default' => false,
884 'style' => [
885 (object)[
886 'selector' => '{{ULTP}} {display:none;}'
887 ],
888 ],
889 ],
890 'hideDesktop' => [
891 'type' => 'boolean',
892 'default' => false,
893 'style' => [
894 (object)[
895 'selector' => '{{ULTP}} {display:none;}'
896 ],
897 ],
898 ],
899 'hideTablet' => [
900 'type' => 'boolean',
901 'default' => false,
902 'style' => [
903 (object)[
904 'selector' => '{{ULTP}} {display:none;}'
905 ],
906 ],
907 ],
908 'hideMobile' => [
909 'type' => 'boolean',
910 'default' => false,
911 'style' => [
912 (object)[
913 'selector' => '{{ULTP}} {display:none;}'
914 ],
915 ],
916 ],
917 'advanceCss' => [
918 'type' => 'string',
919 'default' => '',
920 'style' => [(object)['selector' => '']],
921 ]
922 );
923
924 if( $default ){
925 $temp = array();
926 foreach ($attributes as $key => $value) {
927 if( isset($value['default']) ){
928 $temp[$key] = $value['default'];
929 }
930 }
931 return $temp;
932 }else{
933 return $attributes;
934 }
935 }
936
937 public function register() {
938 register_block_type( 'ultimate-post/news-ticker',
939 array(
940 'title' => __('News Ticker', 'ultimate-post'),
941 'attributes' => $this->get_attributes(),
942 'render_callback' => array($this, 'content')
943 )
944 );
945 }
946
947 public function content($attr, $noAjax) {
948
949 if(!$noAjax){
950 $paged = is_front_page() ? get_query_var('page') : get_query_var('paged');
951 $attr['paged'] = $paged ? $paged : 1;
952 }
953
954 $block_name = 'news-ticker';
955 $page_post_id = ultimate_post()->get_ID();
956 $wraper_before = $wraper_after = $post_loop = '';
957 $recent_posts = new \WP_Query( ultimate_post()->get_query( $attr ) );
958 $arrowLeft = "";
959 $arrowRight = "";
960 if($attr['TickNavIconStyle'] != "icon2"){
961 $arrowLeft .= ultimate_post()->svg_icon('left'.$attr['TickNavIconStyle']);
962 $arrowRight .= ultimate_post()->svg_icon('right'.$attr['TickNavIconStyle']);
963 }
964
965 if ($recent_posts->have_posts()) {
966 $wraper_before .= '<div '.($attr['advanceId']?'id="'.$attr['advanceId'].'" ':'').' class="wp-block-ultimate-post-'.$block_name.' ultp-block-'.$attr["blockId"].''.(isset($attr["className"])?' '.$attr["className"]:'').'">';
967 $wraper_before .= '<div class="ultp-block-wrapper ultp-news-sticky">';
968 $wraper_before .= '<div class="ultp-block-items-wrap">';
969
970 $post_loop .= '<div class="ultp-news-ticker-'.$attr['TickNavStyle'].' ultp-nav-'.$attr['TickNavIconStyle'].' ultp-newsTicker-wrap ultp-newstick-'.$attr['tickerType'].' ">';
971 if ($attr['tickerHeading'] && $attr['headingText']) {
972 $post_loop .= '<div class="ultp-news-ticker-label">'.$attr['headingText'].'</div>';
973 }
974
975 $post_loop .= '<div class="ultp-news-ticker-box ultp-animation-'.($attr['tickerType'] == 'typewriter' ? $attr['typeAnimation'] : $attr['tickerAnimation'] ).' ultp-sliderDir-'.($attr['tickerType'] == 'vertical' ? $attr['tickerDirectionVer'] : $attr['tickerDirectionHorizon'] ).'">';
976 $speed = $attr['tickerType'] != 'marquee' ? $attr['tickerSpeed'] : '';
977 $post_loop .= '<ul class="ultp-news-ticker" data-type="'.$attr['tickerType'].'" data-hover="'.$attr['pauseOnHover'].'" data-direction="'.($attr['tickerType'] == 'vertical' ? $attr['tickerDirectionVer'] : $attr['tickerDirectionHorizon'] ).'" data-speed="'.$speed.'">';
978 while ( $recent_posts->have_posts() ): $recent_posts->the_post();
979 $post_id = get_the_ID();
980 $title = get_the_title( $post_id );
981 $titlelink = get_permalink( $post_id );
982 $style= "";
983 if($attr['tickerType'] != 'marquee' && $attr['tickerType'] != 'typewriter' && $attr['tickerAnimation'] == "fadeout"){
984 $style .= 'animation-delay:'.($speed - 1000).'ms';
985 }
986 if($attr['tickerType'] == 'typewriter' && $attr['typeAnimation'] == "fadeout"){
987 $style .= 'animation-delay:'.($speed - 1000).'ms';
988 }
989 $post_loop .= '<li style='.$style.'>';
990 $post_loop .= '<div class="ultp-list-'.$attr['tickTxtStyle'].'">';
991 $post_loop .= '<a '.($attr['openInTab'] ? 'target="_blank"' : '').' href="'.$titlelink.'">';
992 if ($attr['tickImageShow'] && has_post_thumbnail()) {
993 $post_loop .= ultimate_post()->get_image( get_post_thumbnail_id( $post_id ), 'thumbnail', '', $title, '' , '' );
994 }
995 $post_loop .= '<span class="title-text" data-text="'.$title.'">'.$title.'</span>';
996 $post_loop .= '</a>';
997 if ( $attr['tickTimeShow'] && ($attr['tickerType'] != 'typewriter' ) ) {
998 $post_loop .= '<span class="ultp-ticker-timebadge" >'.human_time_diff(get_the_time('U'),current_time('U')).' ago</span>';
999 }
1000 $post_loop .= '</div>';
1001 $post_loop .= '</li>';
1002 endwhile;
1003 $post_loop .= '</ul>';
1004 $post_loop .= '</div>';
1005
1006 if ($attr['navControlToggle'] && $attr['TickNavStyle'] ) {
1007 $post_loop .= '<div class="ultp-news-ticker-controls ultp-news-ticker-vertical-controls">';
1008 $post_loop .= '<button class="ultp-news-ticker-arrow ultp-news-ticker-prev prev">'.$arrowLeft.'</button>';
1009 if ($attr['controlToggle'] && ( $attr['TickNavStyle'] == "nav1" || $attr['TickNavStyle'] == "nav3" || $attr['TickNavStyle'] == "nav4" )) {
1010 $post_loop .= '<button id="ultp-pause-btn" class="ultp-news-ticker-pause pause"></button>';
1011 }
1012 $post_loop .= '<button class="ultp-news-ticker-arrow ultp-news-ticker-next next">'.$arrowRight.'</button>';
1013 $post_loop .= '</div>';
1014 }
1015 $post_loop .= '</div>';
1016 $wraper_after .= '</div>';
1017 $wraper_after .= '</div>';
1018 $wraper_after .= '</div>';
1019
1020 wp_reset_query();
1021 }
1022
1023 return $noAjax ? $post_loop : $wraper_before.$post_loop.$wraper_after;
1024 }
1025
1026 }