PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / trunk
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites vtrunk
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 / build / block / latest-posts-flash / render.php

render.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites trunk, at build/block/latest-posts-flash/render.php

275 lines 9.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $unq_class = mt_rand(100000, 999999);
3 $blockuniqueclass = '';
4
5 if (!empty($attributes['uniqueClass'])) {
6 $blockuniqueclass = $attributes['uniqueClass'];
7 } else {
8 $blockuniqueclass = 'blockspare-posts-block-list-' . $unq_class;
9 }
10
11
12
13 if (isset($attributes['categories']) && ! empty($attributes['categories']) && is_array($attributes['categories'])) {
14 $categories = array();
15 $i = 1;
16 foreach ($attributes['categories'] as $key => $value) {
17 $categories[] = $value['value'];
18 }
19 } else {
20 $categories = array();
21 }
22
23 if (isset($attributes['tags']) && ! empty($attributes['tags']) && is_array($attributes['tags'])) {
24 $tags = array();
25 $i = 1;
26 foreach ($attributes['tags'] as $key => $value) {
27 $tags[] = $value['value'];
28 }
29 } else {
30 $tags = array();
31 }
32
33 /* Setup the query */
34
35 $query_args = array(
36 'posts_per_page' => $attributes['postsToShow'],
37 'post_status' => 'publish',
38 'order' => $attributes['order'],
39 'orderby' => $attributes['orderBy'],
40 'offset' => $attributes['offset'],
41 'post_type' => $attributes['postType'],
42 'ignore_sticky_posts' => 1,
43 );
44
45 if ($attributes['taxType'] == 'category') {
46 $query_args['category__in'] = $categories;
47 }
48 if ($attributes['taxType'] == 'post_tag') {
49 $query_args['tag__in'] = $tags;
50 }
51
52
53 if ($attributes['taxType'] != 'category' && $attributes['taxType'] != 'post_tag') {
54
55 $tax_type = $attributes['taxType'];
56 if ($tax_type) {
57 $query_args['tax_query'][] = array(
58 'taxonomy' => (isset($tax_type)) ? $tax_type : 'category',
59 'field' => 'id',
60 'terms' => $categories,
61 'operator' => 'IN',
62 );
63 }
64 }
65
66 $grid_query = new WP_Query($query_args);
67
68
69
70 $responsivelayoutTab = 1;
71 $responsivelayoutMobile = 1;
72 $verticals = false;
73
74 if ($attributes['carouselType'] == 'vertical') {
75 $verticals = true;
76 }
77
78
79
80
81
82
83 /* Start the loop */
84 if ($grid_query->have_posts()) {
85 $alignclass = blockspare_checkalignment($attributes['align'], $attributes);
86 /* Build the block classes */
87 $class = 'align' . $alignclass;
88
89 if (isset($attributes['class'])) {
90 $class .= ' ' . $attributes['class'];
91 }
92 if ($attributes['animation']) {
93 $class .= ' blockspare-block-animation ' . $attributes['animation'];
94 }
95
96
97
98
99 //$list_layout_class = $attributes['trending'];
100 $listgridClass = 'blockspare-posts-block-is-carousel';
101
102 /* Layout orientation class */
103 $block_post_wrap = $blockuniqueclass . ' blockspare-posts-block-post-wrap';
104 $count = 0;
105 $layout_class = 'bs-flash-wrap flash-layout ' . $attributes['layoutStyle'];
106
107 if ($attributes['fixedWidth']) {
108 $layout_class .= ' has-fixed-width';
109 }
110
111 $exclusive_posts = 'bs-exclusive-posts blockspare-hover-item';
112 if ($attributes['border']) {
113 $exclusive_posts .= ' bs-border-enabled bs-' . $attributes['borderStyle'];
114 } else {
115 $exclusive_posts .= ' bs-border-disabled';
116 }
117 $flash_spiner_class = 'bs-spinner ';
118 if ($attributes['spinnerOption'] == 'spinner-option-1') {
119 $flash_spiner_class .= $attributes['spinnerStyle'];
120 } else {
121 $flash_spiner_class .= $attributes['animationStyle'];
122 }
123 $spinner_icon = $attributes['spinnerIcon'];
124 $marquee_class = 'bs-marquee bs-flash-side ' . $attributes['direction'];
125 if ($attributes['pauseOnHover']) {
126 $marquee_class .= ' pause-on-hover';
127 }
128 ?>
129
130 <div class="<?php echo esc_attr($class); ?> <?php echo esc_attr($attributes['blockHoverEffect']) ?>">
131 <?php latest_posts_style_control_flash($blockuniqueclass, $attributes); ?>
132 <section class="<?php echo esc_attr($block_post_wrap); ?>">
133 <div class="<?php echo esc_attr($layout_class); ?>">
134 <div class="<?php echo esc_attr($exclusive_posts); ?>">
135 <div class="bs-exclusive-now">
136 <?php if ($attributes['exclusiveSubtitle']) { ?>
137 <span class="bs-exclusive-news-title"><span><?php echo esc_html($attributes['exclusiveSubtitleText']); ?></span></span>
138 <?php } ?>
139 <div class="bs-exclusive-now-txt-animation-wrap">
140 <?php if ($attributes['spinner']) { ?>
141 <span class="<?php echo esc_attr($flash_spiner_class); ?>">
142 <?php if ($attributes['spinnerOption'] == 'spinner-option-1') { ?>
143 <?php if ($attributes['spinnerStyle'] != 'spinner-style-4') { ?>
144 <div class="ring"></div>
145 <div class="ring"></div>
146 <div class="ring"></div>
147 <div class="ring"></div>
148 <?php } else { ?>
149 <div class="ring"></div>
150 <div class="ring"></div>
151 <div class="ring"></div>
152 <div class="ring"></div>
153 <?php } ?>
154 <?php } else { ?>
155 <i class="<?php echo esc_attr($spinner_icon); ?>" aria-hidden="true"></i>
156 <?php } ?>
157 </span>
158 <?php } ?>
159 <span class="bs-exclusive-texts-wrapper">
160 <?php echo $attributes['exclusiveText'] != "" ? $attributes['exclusiveText'] : "Breaking News"; ?>
161 </span>
162 </div>
163 </div>
164 <div class="bs-exclusive-slides">
165 <div class="<?php echo esc_attr($marquee_class); ?>">
166 <div class="bs-marquee-wrapper">
167 <?php while ($grid_query->have_posts()) {
168 $grid_query->the_post();
169
170 $count++;
171
172 /* Setup the post ID */
173 $post_id = get_the_ID();
174
175 /* Setup the featured image ID */
176 $post_thumb_id = get_post_thumbnail_id($post_id);
177
178
179 /* Setup the post classes */
180 $post_classes = 'bs-post-title ';
181
182 ?>
183
184 <h2 class="<?php echo esc_attr($post_classes) ?>">
185 <?php
186
187 if (!empty($attributes['imageSize'])) {
188 $post_thumb_size = 'thumbnail ';
189 } ?>
190 <a href="<?php echo esc_url(get_permalink($post_id)); ?>" rel="bookmark">
191 <span class="bs-circle-marq">
192 <?php if ($attributes['enableCount']) { ?>
193 <span class="bs-trending-no"><?php echo esc_html($count); ?></span>
194 <?php } ?>
195 <?php
196 if (has_post_thumbnail($post_id)) {
197 echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $post_thumb_size));
198 } else { ?>
199 <div class="bs-no-thumbnail-img"> </div>
200 <?php } ?>
201 </span>
202 <span class="bs-post-title">
203 <?php
204 $title = get_the_title($post_id);
205
206 if (!$title) {
207 $title = __('Untitled', 'blockspare');
208 }
209
210 echo ($title);
211 ?>
212 </span>
213 </a>
214 </h2>
215 <?php } ?>
216 </div>
217 <div class="bs-marquee-wrapper">
218 <?php while ($grid_query->have_posts()) {
219 $grid_query->the_post();
220
221 $count++;
222
223 /* Setup the post ID */
224 $post_id = get_the_ID();
225
226 /* Setup the featured image ID */
227 $post_thumb_id = get_post_thumbnail_id($post_id);
228
229
230 /* Setup the post classes */
231 $post_classes = 'bs-post-title ';
232
233 ?>
234
235 <h2 class="<?php echo esc_attr($post_classes) ?>">
236 <?php
237
238 if (!empty($attributes['imageSize'])) {
239 $post_thumb_size = 'thumbnail ';
240 } ?>
241 <a href="<?php echo esc_url(get_permalink($post_id)); ?>" rel="bookmark">
242 <span class="bs-circle-marq">
243 <?php if ($attributes['enableCount']) { ?>
244 <span class="bs-trending-no"><?php echo esc_html($count); ?></span>
245 <?php } ?>
246 <?php
247 if (has_post_thumbnail($post_id)) {
248 echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $post_thumb_size));
249 } else { ?>
250 <div class="bs-no-thumbnail-img"> </div>
251 <?php } ?>
252 </span>
253 <span class="bs-post-title">
254 <?php
255 $title = get_the_title($post_id);
256
257 if (!$title) {
258 $title = __('Untitled', 'blockspare');
259 }
260
261 echo ($title);
262 ?>
263 </span>
264 </a>
265 </h2>
266 <?php } ?>
267 </div>
268 </div>
269 </div>
270 </div>
271 </div>
272 </section>
273 </div>
274 <?php }
275