PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.4
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.4
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.1.4, at inc/latest-post-block/posts-flash/index.php

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