PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.3.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.3.3
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / latest-post-block / posts-flash / index.php

index.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.3.3, at inc/latest-post-block/posts-flash/index.php

479 lines 18.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!function_exists('blockspare_flash_render_block')) {
3 function blockspare_flash_render_block($attributes)
4 {
5 ob_start();
6 $unq_class = mt_rand(100000, 999999);
7 $blockuniqueclass = '';
8
9 if (!empty($attributes['uniqueClass'])) {
10 $blockuniqueclass = $attributes['uniqueClass'];
11 } else {
12 $blockuniqueclass = 'blockspare-posts-block-list-' . $unq_class;
13 }
14
15
16
17 if (isset($attributes['categories']) && ! empty($attributes['categories']) && is_array($attributes['categories'])) {
18 $categories = array();
19 $i = 1;
20 foreach ($attributes['categories'] as $key => $value) {
21 $categories[] = $value['value'];
22 }
23 } else {
24 $categories = array();
25 }
26
27 if (isset($attributes['tags']) && ! empty($attributes['tags']) && is_array($attributes['tags'])) {
28 $tags = array();
29 $i = 1;
30 foreach ($attributes['tags'] as $key => $value) {
31 $tags[] = $value['value'];
32 }
33 } else {
34 $tags = array();
35 }
36
37 /* Setup the query */
38
39 $query_args = array(
40 'posts_per_page' => $attributes['postsToShow'],
41 'post_status' => 'publish',
42 'order' => $attributes['order'],
43 'orderby' => $attributes['orderBy'],
44 'offset' => $attributes['offset'],
45 'post_type' => $attributes['postType'],
46 'ignore_sticky_posts' => 1,
47 );
48
49 if ($attributes['taxType'] == 'category') {
50 $query_args['category__in'] = $categories;
51 }
52 if ($attributes['taxType'] == 'post_tag') {
53 $query_args['tag__in'] = $tags;
54 }
55
56
57 if ($attributes['taxType'] != 'category' && $attributes['taxType'] != 'post_tag') {
58
59 $tax_type = $attributes['taxType'];
60 if ($tax_type) {
61 $query_args['tax_query'][] = array(
62 'taxonomy' => (isset($tax_type)) ? $tax_type : 'category',
63 'field' => 'id',
64 'terms' => $categories,
65 'operator' => 'IN',
66 );
67 }
68 }
69
70 $grid_query = new WP_Query($query_args);
71
72
73
74 $responsivelayoutTab = 1;
75 $responsivelayoutMobile = 1;
76 $verticals = false;
77
78 if ($attributes['carouselType'] == 'vertical') {
79 $verticals = true;
80 }
81
82
83
84
85
86
87 /* Start the loop */
88 if ($grid_query->have_posts()) {
89 $alignclass = blockspare_checkalignment($attributes['align']);
90 /* Build the block classes */
91 $class = 'align' . $alignclass;
92
93 if (isset($attributes['class'])) {
94 $class .= ' ' . $attributes['class'];
95 }
96 if ($attributes['animation']) {
97 $class .= ' blockspare-block-animation ' . $attributes['animation'];
98 }
99
100
101
102
103 //$list_layout_class = $attributes['trending'];
104 $listgridClass = 'blockspare-posts-block-is-carousel';
105
106 /* Layout orientation class */
107 $block_post_wrap = $blockuniqueclass . ' blockspare-posts-block-post-wrap';
108 $count = 0;
109 $layout_class = 'bs-flash-wrap flash-layout ' . $attributes['layoutStyle'];
110
111 if ($attributes['fixedWidth']) {
112 $layout_class .= ' has-fixed-width';
113 }
114
115 $exclusive_posts = 'bs-exclusive-posts blockspare-hover-item';
116 if ($attributes['border']) {
117 $exclusive_posts .= ' bs-border-enabled bs-' . $attributes['borderStyle'];
118 } else {
119 $exclusive_posts .= ' bs-border-disabled';
120 }
121 $flash_spiner_class = 'bs-spinner ';
122 if ($attributes['spinnerOption'] == 'spinner-option-1') {
123 $flash_spiner_class .= $attributes['spinnerStyle'];
124 } else {
125 $flash_spiner_class .= $attributes['animationStyle'];
126 }
127 $spinner_icon = $attributes['spinnerIcon'];
128 $marquee_class = 'bs-marquee bs-flash-side ' . $attributes['direction'];
129 if ($attributes['pauseOnHover']) {
130 $marquee_class .= ' pause-on-hover';
131 }
132 ?>
133
134 <div class="<?php echo esc_attr($class); ?> <?php echo esc_attr($attributes['blockHoverEffect']) ?>">
135 <?php echo latest_posts_style_control_flash($blockuniqueclass, $attributes); ?>
136 <section class="<?php echo esc_attr($block_post_wrap); ?>">
137 <div class="<?php echo esc_attr($layout_class); ?>">
138 <div class="<?php echo esc_attr($exclusive_posts); ?>">
139 <div class="bs-exclusive-now">
140 <?php if ($attributes['exclusiveSubtitle']) { ?>
141 <span class="bs-exclusive-news-title"><span><?php echo esc_html($attributes['exclusiveSubtitleText']); ?></span></span>
142 <?php } ?>
143 <div class="bs-exclusive-now-txt-animation-wrap">
144 <?php if ($attributes['spinner']) { ?>
145 <span class="<?php echo esc_attr($flash_spiner_class); ?>">
146 <?php if ($attributes['spinnerOption'] == 'spinner-option-1') { ?>
147 <?php if ($attributes['spinnerStyle'] != 'spinner-style-4') { ?>
148 <div class="ring"></div>
149 <div class="ring"></div>
150 <div class="ring"></div>
151 <div class="ring"></div>
152 <?php } else { ?>
153 <div class="ring"></div>
154 <div class="ring"></div>
155 <div class="ring"></div>
156 <div class="ring"></div>
157 <?php } ?>
158 <?php } else { ?>
159 <i class="<?php echo esc_attr($spinner_icon); ?>" aria-hidden="true"></i>
160 <?php } ?>
161 </span>
162 <?php } ?>
163 <span class="bs-exclusive-texts-wrapper">
164 <?php echo $attributes['exclusiveText'] != "" ? $attributes['exclusiveText'] : "Breaking News"; ?>
165 </span>
166 </div>
167 </div>
168 <div class="bs-exclusive-slides">
169 <div class="<?php echo esc_attr($marquee_class); ?>">
170 <div class="bs-marquee-wrapper">
171 <?php while ($grid_query->have_posts()) {
172 $grid_query->the_post();
173
174 $count++;
175
176 /* Setup the post ID */
177 $post_id = get_the_ID();
178
179 /* Setup the featured image ID */
180 $post_thumb_id = get_post_thumbnail_id($post_id);
181
182
183 /* Setup the post classes */
184 $post_classes = 'bs-post-title ';
185
186 ?>
187
188 <h2 class="<?php echo esc_attr($post_classes) ?>">
189 <?php
190
191 if (!empty($attributes['imageSize'])) {
192 $post_thumb_size = 'thumbnail ';
193 } ?>
194 <a href="<?php echo esc_url(get_permalink($post_id)); ?>" rel="bookmark">
195 <span class="bs-circle-marq">
196 <?php if ($attributes['enableCount']) { ?>
197 <span class="bs-trending-no"><?php echo esc_html($count); ?></span>
198 <?php } ?>
199 <?php
200 if (has_post_thumbnail($post_id)) {
201 echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $post_thumb_size));
202 } else { ?>
203 <div class="bs-no-thumbnail-img"> </div>
204 <?php } ?>
205 </span>
206 <span class="bs-post-title">
207 <?php
208 $title = get_the_title($post_id);
209
210 if (!$title) {
211 $title = __('Untitled', 'blockspare');
212 }
213
214 echo ($title);
215 ?>
216 </span>
217 </a>
218 </h2>
219 <?php } ?>
220 </div>
221 <div class="bs-marquee-wrapper">
222 <?php while ($grid_query->have_posts()) {
223 $grid_query->the_post();
224
225 $count++;
226
227 /* Setup the post ID */
228 $post_id = get_the_ID();
229
230 /* Setup the featured image ID */
231 $post_thumb_id = get_post_thumbnail_id($post_id);
232
233
234 /* Setup the post classes */
235 $post_classes = 'bs-post-title ';
236
237 ?>
238
239 <h2 class="<?php echo esc_attr($post_classes) ?>">
240 <?php
241
242 if (!empty($attributes['imageSize'])) {
243 $post_thumb_size = 'thumbnail ';
244 } ?>
245 <a href="<?php echo esc_url(get_permalink($post_id)); ?>" rel="bookmark">
246 <span class="bs-circle-marq">
247 <?php if ($attributes['enableCount']) { ?>
248 <span class="bs-trending-no"><?php echo esc_html($count); ?></span>
249 <?php } ?>
250 <?php
251 if (has_post_thumbnail($post_id)) {
252 echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $post_thumb_size));
253 } else { ?>
254 <div class="bs-no-thumbnail-img"> </div>
255 <?php } ?>
256 </span>
257 <span class="bs-post-title">
258 <?php
259 $title = get_the_title($post_id);
260
261 if (!$title) {
262 $title = __('Untitled', 'blockspare');
263 }
264
265 echo ($title);
266 ?>
267 </span>
268 </a>
269 </h2>
270 <?php } ?>
271 </div>
272 </div>
273 </div>
274 </div>
275 </div>
276 </section>
277 </div>
278 <?php wp_reset_postdata();
279
280 return ob_get_clean();
281 }
282 }
283 }
284
285 /**
286 * Registers the post grid block on server
287 */
288 if (!function_exists('blockspare_flash_register_block_core')) {
289 function blockspare_flash_register_block_core()
290 {
291
292 if (!function_exists('register_block_type')) {
293 return;
294 }
295
296
297 ob_start();
298 include BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-flash/block.json';
299
300 $metadata = json_decode(ob_get_clean(), true);
301
302
303 /* Block attributes */
304 register_block_type(
305 'blockspare/latest-posts-flash',
306 array(
307 'attributes' => $metadata['attributes'],
308 'render_callback' => 'blockspare_flash_render_block',
309 )
310 );
311 }
312
313 add_action('init', 'blockspare_flash_register_block_core');
314 }
315
316
317
318
319 if (!function_exists('latest_posts_style_control_flash')) {
320 function latest_posts_style_control_flash($blockuniqueclass, $attributes)
321 {
322
323 $boxshadowcss = '';
324
325 $block_content = '';
326 $block_content .= '<style type="text/css">';
327
328 //post-flash-background
329 if ($attributes['background']) {
330 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts{
331 background-color:' . $attributes['backGroundColor'] . ';
332 }';
333 }
334
335 //post-flash-border-radius
336 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts{
337 border-radius:' . $attributes['borderRadius'] . 'px;
338 }';
339 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-now-txt-animation-wrap{
340 border-radius:' . $attributes['borderRadius'] . 'px;
341 }';
342 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides{
343 border-radius:' . $attributes['borderRadius'] . 'px;
344 }';
345
346 //post-image-border-radius
347 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides .bs-circle-marq{
348 border-radius:' . $attributes['imgBorderRadius'] . 'px;
349 }';
350
351 //post-flash-animation-speed
352 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides .bs-marquee .bs-marquee-wrapper{
353 animation-duration:' . $attributes['animationSpeed'] . 's;
354 }';
355
356 //post-widht
357 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap.has-fixed-width h2.bs-post-title{
358 width:' . $attributes['postWidth'] . 'px;
359 }';
360
361 //Title color
362 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides a .bs-post-title{
363 color:' . $attributes['postTitleColor'] . ';
364 }';
365
366 //Title hover color
367 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides a:hover .bs-post-title{
368 color:' . $attributes['titleOnHoverColor'] . ';
369 }';
370
371 //Exclusive News color and background
372 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap{
373 color:' . $attributes['newsColor'] . ';
374 background-color: ' . $attributes['newsBgColor'] . ';
375 }';
376 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap.flash-style-2 .bs-exclusive-posts .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap::after{
377 border-left-color:' . $attributes['newsBgColor'] . ';
378 }';
379 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap.flash-style-3 .bs-exclusive-posts .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap::after{
380 background-color:' . $attributes['newsBgColor'] . ';
381 }';
382 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap.flash-style-4 .bs-exclusive-posts .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap::after{
383 background-color:' . $attributes['newsBgColor'] . ';
384 }';
385
386 //Border
387 if ($attributes['border']) {
388 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts{
389 border-width:' . $attributes['borderWidth'] . 'px;
390 border-color:' . $attributes['borderColor'] . ';
391 }';
392 }
393
394 //Exclusive Subtitle color and background
395 if ($attributes['exclusiveSubtitle']) {
396 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-now > span{
397 color:' . $attributes['exclusiveColor'] . ';
398 background-color: ' . $attributes['exclusiveBgColor'] . ';
399 }';
400 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-now > span::before{
401 border-top-color:' . $attributes['exclusiveBgColor'] . ';
402 }';
403 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-now > span::after{
404 border-bottom-color:' . $attributes['exclusiveBgColor'] . ';
405 }';
406 }
407
408 //Block Gaps
409 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts{
410 margin-top:' . $attributes['marginTop'] . 'px;
411 margin-right:' . $attributes['marginRight'] . 'px;
412 margin-bottom:' . $attributes['marginBottom'] . 'px;
413 margin-left:' . $attributes['marginLeft'] . 'px;
414 }';
415
416 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-slides{
417 padding-top:' . $attributes['paddingTop'] . 'px;
418 padding-right:' . $attributes['paddingRight'] . 'px;
419 padding-bottom:' . $attributes['paddingBottom'] . 'px;
420 padding-left:' . $attributes['paddingLeft'] . 'px;
421 }';
422
423 // Post Number Color
424 if ($attributes['enableCount']) {
425 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides .bs-marquee h2.bs-post-title a .bs-circle-marq .bs-trending-no{
426 color: ' . $attributes['countColor'] . ';
427 }';
428 }
429
430 //Font Settings
431
432 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides a .bs-post-title{
433 font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . ';
434 ' . bscheckFontfamily($attributes['titleFontFamily']) . ';
435 ' . bscheckFontfamilyWeight($attributes['titleFontWeight']) . ';
436 line-height: ' . $attributes['postTitleLineHeight'] . ';
437 }';
438
439 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap .bs-exclusive-texts-wrapper{
440 font-size: ' . $attributes['exclusiveFontSize'] . $attributes['exclusiveFontSizeType'] . ';
441 ' . bscheckFontfamily($attributes['exclusiveFontFamily']) . ';
442 ' . bscheckFontfamilyWeight($attributes['exclusiveFontWeight']) . ';
443 }';
444
445 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-now .bs-exclusive-news-title{
446 font-size: ' . $attributes['exclusiveSubtitleFontSize'] . $attributes['exclusiveSubtitleFontSizeType'] . ';
447 ' . bscheckFontfamily($attributes['exclusiveSubtitleFontFamily']) . ';
448 ' . bscheckFontfamilyWeight($attributes['exclusiveSubtitleFontWeight']) . ';
449 }';
450
451 $block_content .= '@media (max-width: 1025px) { ';
452 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides a .bs-post-title{
453 font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . ';
454 }';
455 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap .bs-exclusive-texts-wrapper{
456 font-size: ' . $attributes['exclusiveFontSizeTablet'] . $attributes['exclusiveFontSizeType'] . ';
457 }';
458 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-now .bs-exclusive-news-title{
459 font-size: ' . $attributes['exclusiveSubtitleFontSizeTablet'] . $attributes['exclusiveSubtitleFontSizeType'] . ';
460 }';
461 $block_content .= '}';
462
463 $block_content .= '@media (max-width: 767px) { ';
464 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-posts .bs-exclusive-slides a .bs-post-title{
465 font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . ';
466 }';
467 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-now .bs-exclusive-now-txt-animation-wrap .bs-exclusive-texts-wrapper{
468 font-size: ' . $attributes['exclusiveFontSizeMobile'] . $attributes['exclusiveFontSizeType'] . ';
469 }';
470 $block_content .= ' .' . $blockuniqueclass . ' .bs-flash-wrap .bs-exclusive-now .bs-exclusive-news-title{
471 font-size: ' . $attributes['exclusiveSubtitleFontSizeMobile'] . $attributes['exclusiveSubtitleFontSizeType'] . ';
472 }';
473 $block_content .= '}';
474
475 $block_content .= '</style>';
476 return $block_content;
477 }
478 }
479