PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.0
Post Grid Gutenberg Blocks – PostX v5.1.0
5.1.1 5.1.0 5.0.41 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 All 240 releases
← All changes | blocks/Post_Slider_2.php +122 -127 5.0.34 → 5.1.0 View file →
@@ -164,9 +164,9 @@
164 164 }
165 165
166 166 public function content( $attr, $noAjax ) {
167 167 $attr = wp_parse_args( $attr, $this->get_attributes() );
168 - global $unique_ID;
168 + global $ultp_unique_ID;
169 169
170 170 if ( ! $noAjax ) {
171 171 $paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
172 172 $attr['paged'] = $paged ? $paged : 1;
@@ -171,164 +171,159 @@
171 171 $paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
172 172 $attr['paged'] = $paged ? $paged : 1;
173 173 }
174 174
175 - $is_visible = false;
176 - if ( isset( $attr['blockPubDate'] ) && $attr['blockPubDate'] != 'empty' ) {
177 - $is_visible = ultimate_post()->is_pro_feature_visible( $attr['blockPubDate'] );
178 - }
175 + $block_name = 'post-slider-2';
176 + $wraper_before = $wraper_after = $post_loop = '';
177 + $attr['queryNumber'] = ultimate_post()->get_post_number( 5, $attr['queryNumber'], $attr['queryNumPosts'] );
178 + $recent_posts = new \WP_Query( ultimate_post()->get_query( $attr ) );
179 + $pageNum = ultimate_post()->get_page_number( $attr, $recent_posts->found_posts );
180 + // Dummy Img Url
181 + $dummy_url = ULTP_URL . 'assets/img/ultp-fallback-img.png';
179 182
180 - $is_active = ultimate_post()->is_lc_active();
183 + $slides = is_object( $attr['slidesToShow'] ) ? json_decode( wp_json_encode( $attr['slidesToShow'] ), true ) : $attr['slidesToShow'];
181 184
182 - if ( $is_active || $is_visible ) {
183 - $block_name = 'post-slider-2';
184 - $wraper_before = $wraper_after = $post_loop = '';
185 - $attr['queryNumber'] = ultimate_post()->get_post_number( 5, $attr['queryNumber'], $attr['queryNumPosts'] );
186 - $recent_posts = new \WP_Query( ultimate_post()->get_query( $attr ) );
187 - $pageNum = ultimate_post()->get_page_number( $attr, $recent_posts->found_posts );
188 - // Dummy Img Url
189 - $dummy_url = ULTP_URL . 'assets/img/ultp-fallback-img.png';
185 + $centerPadd = is_object( $attr['slidesCenterPadding'] ) ? json_decode( wp_json_encode( $attr['slidesCenterPadding'] ), true ) : $attr['slidesCenterPadding'];
186 + if ( $recent_posts->have_posts() ) {
187 + $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : '';
188 + $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : '';
189 + $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : '';
190 + $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : '';
191 + $attr['contentTag'] = in_array( $attr['contentTag'], ultimate_post()->ultp_allowed_block_tags() ) ? $attr['contentTag'] : 'div';
192 + $attr['layout'] = sanitize_html_class( $attr['layout'] );
193 + // Free ships slide1 only. Further layouts are added through this filter by PostX Pro.
194 + if ( ! in_array( $attr['layout'], (array) apply_filters( 'ultp_post_slider_2_layouts', array( 'slide1' ) ), true ) ) {
195 + $attr['layout'] = 'slide1';
196 + }
197 + $attr['imgOverlayType'] = sanitize_html_class( $attr['imgOverlayType'] );
198 + $attr['slideSpeed'] = sanitize_html_class( $attr['slideSpeed'] );
199 + $attr['arrows'] = $attr['arrows'] == true;
200 + $attr['dots'] = $attr['dots'] == true;
201 + $attr['autoPlay'] = $attr['autoPlay'] == true;
202 + $attr['fade'] = $attr['fade'] == true;
203 + $attr['readMoreText'] = wp_kses( $attr['readMoreText'], ultimate_post()->ultp_allowed_html_tags() );
204 + $attr['contentVerticalPosition'] = sanitize_html_class( $attr['contentVerticalPosition'] );
205 + $attr['contentHorizontalPosition'] = sanitize_html_class( $attr['contentHorizontalPosition'] );
190 206
191 - $slides = is_object( $attr['slidesToShow'] ) ? json_decode( wp_json_encode( $attr['slidesToShow'] ), true ) : $attr['slidesToShow'];
207 + $wraper_before .= '<div ' . ( $attr['advanceId'] ? 'id="' . $attr['advanceId'] . '" ' : '' ) . ' class="wp-block-ultimate-post-' . $block_name . ' ultp-block-' . $attr['blockId'] . '' . ( $attr['align'] ? ' align' . $attr['align'] : '' ) . '' . ( $attr['className'] ? ' ' . $attr['className'] : '' ) . '">';
208 + $wraper_before .= '<div class="ultp-block-wrapper">';
209 + if ( $attr['headingShow'] ) {
210 + $wraper_before .= '<div class="ultp-heading-filter">';
211 + $wraper_before .= '<div class="ultp-heading-filter-in">';
212 + include ULTP_PATH . 'blocks/template/heading.php';
213 + $wraper_before .= '</div>';
214 + $wraper_before .= '</div>';
215 + }
216 + $wraper_before .= '<div class="ultp-block-items-wrap ultp-slide-' . $attr['layout'] . '" data-layout="' . $attr['layout'] . '" data-arrows="' . $attr['arrows'] . '" data-dots="' . $attr['dots'] . '" data-autoplay="' . $attr['autoPlay'] . '" data-slidespeed="' . $attr['slideSpeed'] . '" data-fade="' . $attr['fade'] . '" data-slidelg="' . ( isset( $slides['lg'] ) ? sanitize_html_class( $slides['lg'] ) : 1 ) . '" data-slidesm="' . ( isset( $slides['sm'] ) ? sanitize_html_class( $slides['sm'] ) : 1 ) . '" data-slidexs="' . ( isset( $slides['xs'] ) ? sanitize_html_class( $slides['xs'] ) : 1 ) . '"
217 + data-paddlg="' . ( isset( $centerPadd['lg'] ) ? sanitize_html_class( $centerPadd['lg'] ) : 100 ) . '" data-paddsm="' . ( isset( $centerPadd['sm'] ) ? sanitize_html_class( $centerPadd['sm'] ) : 100 ) . '" data-paddxs="' . ( isset( $centerPadd['xs'] ) ? sanitize_html_class( $centerPadd['xs'] ) : 50 ) . '">';
218 + $idx = $noAjax ? 1 : 0;
219 + while ( $recent_posts->have_posts() ) :
220 + $recent_posts->the_post();
192 221
193 - $centerPadd = is_object( $attr['slidesCenterPadding'] ) ? json_decode( wp_json_encode( $attr['slidesCenterPadding'] ), true ) : $attr['slidesCenterPadding'];
194 - if ( $recent_posts->have_posts() ) {
195 - $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : '';
196 - $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : '';
197 - $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : '';
198 - $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : '';
199 - $attr['contentTag'] = in_array( $attr['contentTag'], ultimate_post()->ultp_allowed_block_tags() ) ? $attr['contentTag'] : 'div';
200 - $attr['layout'] = sanitize_html_class( $attr['layout'] );
201 - $attr['imgOverlayType'] = sanitize_html_class( $attr['imgOverlayType'] );
202 - $attr['slideSpeed'] = sanitize_html_class( $attr['slideSpeed'] );
203 - $attr['arrows'] = $attr['arrows'] == true;
204 - $attr['dots'] = $attr['dots'] == true;
205 - $attr['autoPlay'] = $attr['autoPlay'] == true;
206 - $attr['fade'] = $attr['fade'] == true;
207 - $attr['readMoreText'] = wp_kses( $attr['readMoreText'], ultimate_post()->ultp_allowed_html_tags() );
208 - $attr['contentVerticalPosition'] = sanitize_html_class( $attr['contentVerticalPosition'] );
209 - $attr['contentHorizontalPosition'] = sanitize_html_class( $attr['contentHorizontalPosition'] );
222 + $dcContent = array_fill( 0, $attr['dcSize'], '' );
210 223
211 - $wraper_before .= '<div ' . ( $attr['advanceId'] ? 'id="' . $attr['advanceId'] . '" ' : '' ) . ' class="wp-block-ultimate-post-' . $block_name . ' ultp-block-' . $attr['blockId'] . '' . ( $attr['align'] ? ' align' . $attr['align'] : '' ) . '' . ( $attr['className'] ? ' ' . $attr['className'] : '' ) . '">';
212 - $wraper_before .= '<div class="ultp-block-wrapper">';
213 - if ( $attr['headingShow'] ) {
214 - $wraper_before .= '<div class="ultp-heading-filter">';
215 - $wraper_before .= '<div class="ultp-heading-filter-in">';
216 - include ULTP_PATH . 'blocks/template/heading.php';
217 - $wraper_before .= '</div>';
218 - $wraper_before .= '</div>';
224 + if ( ultimate_post()->is_dc_active( $attr ) ) {
225 + $dcContent = \ULTP\DCService::get_dc_content_for_block( $attr, $dcContent );
219 226 }
220 - $wraper_before .= '<div class="ultp-block-items-wrap ultp-slide-' . $attr['layout'] . '" data-layout="' . $attr['layout'] . '" data-arrows="' . $attr['arrows'] . '" data-dots="' . $attr['dots'] . '" data-autoplay="' . $attr['autoPlay'] . '" data-slidespeed="' . $attr['slideSpeed'] . '" data-fade="' . $attr['fade'] . '" data-slidelg="' . ( isset( $slides['lg'] ) ? sanitize_html_class( $slides['lg'] ) : 1 ) . '" data-slidesm="' . ( isset( $slides['sm'] ) ? sanitize_html_class( $slides['sm'] ) : 1 ) . '" data-slidexs="' . ( isset( $slides['xs'] ) ? sanitize_html_class( $slides['xs'] ) : 1 ) . '"
221 - data-paddlg="' . ( isset( $centerPadd['lg'] ) ? sanitize_html_class( $centerPadd['lg'] ) : 100 ) . '" data-paddsm="' . ( isset( $centerPadd['sm'] ) ? sanitize_html_class( $centerPadd['sm'] ) : 100 ) . '" data-paddxs="' . ( isset( $centerPadd['xs'] ) ? sanitize_html_class( $centerPadd['xs'] ) : 50 ) . '">';
222 - $idx = $noAjax ? 1 : 0;
223 - while ( $recent_posts->have_posts() ) :
224 - $recent_posts->the_post();
225 227
226 - $dcContent = array_fill( 0, $attr['dcSize'], '' );
228 + include ULTP_PATH . 'blocks/template/data.php';
227 229
228 - if ( ultimate_post()->is_dc_active( $attr ) ) {
229 - $dcContent = \ULTP\DCService::get_dc_content_for_block( $attr, $dcContent );
230 - }
230 + if ( $attr['queryUnique'] ) {
231 + $ultp_unique_ID[ $attr['queryUnique'] ][] = $post_id;
232 + }
231 233
232 - include ULTP_PATH . 'blocks/template/data.php';
234 + $post_loop .= '<' . $attr['contentTag'] . ' class="ultp-block-item post-id-' . $post_id . '">';
235 + if ( $attr['preLoader'] ) {
236 + $post_loop .= '<div class="ultp-post-slider-loader-container">';
237 + $post_loop .= ultimate_post()->postx_loading();
238 + $post_loop .= '</div>';
239 + }
240 + $post_loop .= '<div>';
241 + $post_loop .= '<div class="ultp-block-slider-wrap">';
233 242
234 - if ( $attr['queryUnique'] ) {
235 - $unique_ID[ $attr['queryUnique'] ][] = $post_id;
243 + $post_loop .= '<div class="ultp-block-image-inner">';
244 + if ( $post_thumb_id || $attr['fallbackEnable'] ) {
245 + $post_loop .= '<div class="ultp-block-image ' . ( $attr['imgOverlay'] ? ' ultp-block-image-overlay ultp-block-image-' . $attr['imgOverlayType'] . ' ultp-block-image-' . $attr['imgOverlayType'] . $idx : '' ) . '">';
246 + $post_loop .= '<a href="' . $titlelink . '" ' . ( $attr['openInTab'] ? 'target="_blank"' : '' ) . '>';
247 + // Post Image Id
248 + $block_img_id = $post_thumb_id ? $post_thumb_id : ( $attr['fallbackEnable'] && isset( $attr['fallbackImg']['id'] ) ? $attr['fallbackImg']['id'] : '' );
249 + // Post Image
250 + if ( $post_thumb_id || ( $attr['fallbackEnable'] && $block_img_id ) ) {
251 + $post_loop .= ultimate_post()->get_image( $block_img_id, $attr['imgCrop'], '', $title, $attr['imgSrcset'], $attr['imgLazy'] );
252 + } else {
253 + $post_loop .= '<img src="' . $dummy_url . '" alt="dummy-img" />';
236 254 }
255 + $post_loop .= '</a></div>'; // .ultp-block-image
256 + }
257 + $post_loop .= '</div>'; // .ultp-block-image-inner
258 + $post_loop .= '<div class="ultp-block-content ultp-block-content-' . $attr['contentVerticalPosition'] . ' ultp-block-content-' . $attr['contentHorizontalPosition'] . '">';
259 + $post_loop .= '<div class="ultp-block-content-inner">';
237 260
238 - $post_loop .= '<' . $attr['contentTag'] . ' class="ultp-block-item post-id-' . $post_id . '">';
239 - if ( $attr['preLoader'] ) {
240 - $post_loop .= '<div class="ultp-post-slider-loader-container">';
241 - $post_loop .= ultimate_post()->postx_loading();
242 - $post_loop .= '</div>';
243 - }
244 - $post_loop .= '<div>';
245 - $post_loop .= '<div class="ultp-block-slider-wrap">';
261 + $post_loop .= $dcContent[7];
246 262
247 - $post_loop .= '<div class="ultp-block-image-inner">';
248 - if ( $post_thumb_id || $attr['fallbackEnable'] ) {
249 - $post_loop .= '<div class="ultp-block-image ' . ( $attr['imgOverlay'] ? ' ultp-block-image-overlay ultp-block-image-' . $attr['imgOverlayType'] . ' ultp-block-image-' . $attr['imgOverlayType'] . $idx : '' ) . '">';
250 - $post_loop .= '<a href="' . $titlelink . '" ' . ( $attr['openInTab'] ? 'target="_blank"' : '' ) . '>';
251 - // Post Image Id
252 - $block_img_id = $post_thumb_id ? $post_thumb_id : ( $attr['fallbackEnable'] && isset( $attr['fallbackImg']['id'] ) ? $attr['fallbackImg']['id'] : '' );
253 - // Post Image
254 - if ( $post_thumb_id || ( $attr['fallbackEnable'] && $block_img_id ) ) {
255 - $post_loop .= ultimate_post()->get_image( $block_img_id, $attr['imgCrop'], '', $title, $attr['imgSrcset'], $attr['imgLazy'] );
256 - } else {
257 - $post_loop .= '<img src="' . $dummy_url . '" alt="dummy-img" />';
258 - }
259 - $post_loop .= '</a></div>'; // .ultp-block-image
260 - }
261 - $post_loop .= '</div>'; // .ultp-block-image-inner
262 - $post_loop .= '<div class="ultp-block-content ultp-block-content-' . $attr['contentVerticalPosition'] . ' ultp-block-content-' . $attr['contentHorizontalPosition'] . '">';
263 - $post_loop .= '<div class="ultp-block-content-inner">';
263 + include ULTP_PATH . 'blocks/template/category.php';
264 + $post_loop .= $category;
264 265
265 - $post_loop .= $dcContent[7];
266 + $post_loop .= $dcContent[6];
266 267
267 - include ULTP_PATH . 'blocks/template/category.php';
268 - $post_loop .= $category;
268 + if ( $title && $attr['titleShow'] && $attr['titlePosition'] ) {
269 + include ULTP_PATH . 'blocks/template/title.php';
270 + }
269 271
270 - $post_loop .= $dcContent[6];
272 + $post_loop .= $dcContent[5];
271 273
272 - if ( $title && $attr['titleShow'] && $attr['titlePosition'] ) {
273 - include ULTP_PATH . 'blocks/template/title.php';
274 - }
274 + if ( $attr['metaPosition'] == 'top' ) {
275 + include ULTP_PATH . 'blocks/template/meta.php';
276 + }
275 277
276 - $post_loop .= $dcContent[5];
278 + $post_loop .= $dcContent[4];
277 279
278 - if ( $attr['metaPosition'] == 'top' ) {
279 - include ULTP_PATH . 'blocks/template/meta.php';
280 - }
280 + if ( $title && $attr['titleShow'] && ! $attr['titlePosition'] ) {
281 + include ULTP_PATH . 'blocks/template/title.php';
282 + }
281 283
282 - $post_loop .= $dcContent[4];
284 + $post_loop .= $dcContent[3];
283 285
284 - if ( $title && $attr['titleShow'] && ! $attr['titlePosition'] ) {
285 - include ULTP_PATH . 'blocks/template/title.php';
286 - }
286 + if ( $attr['excerptShow'] ) {
287 + $post_loop .= '<div class="ultp-block-excerpt">' . ultimate_post()->get_excerpt( $post_id, $attr['showSeoMeta'], $attr['showFullExcerpt'], $attr['excerptLimit'] ) . '</div>';
288 + }
287 289
288 - $post_loop .= $dcContent[3];
290 + $post_loop .= $dcContent[2];
289 291
290 - if ( $attr['excerptShow'] ) {
291 - $post_loop .= '<div class="ultp-block-excerpt">' . ultimate_post()->get_excerpt( $post_id, $attr['showSeoMeta'], $attr['showFullExcerpt'], $attr['excerptLimit'] ) . '</div>';
292 - }
292 + if ( $attr['readMore'] ) {
293 + $post_loop .= '<div class="ultp-block-readmore"><a aria-label="' . $title . '" href="' . $titlelink . '" ' . ( $attr['openInTab'] ? 'target="_blank"' : '' ) . '>' . ( $attr['readMoreText'] ? $attr['readMoreText'] : esc_html__( 'Read More', 'ultimate-post' ) ) . ultimate_post()->get_svg_icon( $attr['readMoreIcon'] ) . '</a></div>';
294 + }
293 295
294 - $post_loop .= $dcContent[2];
296 + $post_loop .= $dcContent[1];
295 297
296 - if ( $attr['readMore'] ) {
297 - $post_loop .= '<div class="ultp-block-readmore"><a aria-label="' . $title . '" href="' . $titlelink . '" ' . ( $attr['openInTab'] ? 'target="_blank"' : '' ) . '>' . ( $attr['readMoreText'] ? $attr['readMoreText'] : esc_html__( 'Read More', 'ultimate-post' ) ) . ultimate_post()->get_svg_icon( $attr['readMoreIcon'] ) . '</a></div>';
298 - }
298 + if ( $attr['metaPosition'] == 'bottom' ) {
299 + include ULTP_PATH . 'blocks/template/meta.php';
300 + }
299 301
300 - $post_loop .= $dcContent[1];
302 + $post_loop .= $dcContent[0];
301 303
302 - if ( $attr['metaPosition'] == 'bottom' ) {
303 - include ULTP_PATH . 'blocks/template/meta.php';
304 - }
304 + $post_loop .= '</div>';
305 + $post_loop .= '</div>';
305 306
306 - $post_loop .= $dcContent[0];
307 + $post_loop .= '</div>';
308 + $post_loop .= '</div>';
309 + $post_loop .= '</' . $attr['contentTag'] . '>';
310 + endwhile;
311 + $wraper_after .= '</div>';
307 312
308 - $post_loop .= '</div>';
309 - $post_loop .= '</div>';
310 -
311 - $post_loop .= '</div>';
312 - $post_loop .= '</div>';
313 - $post_loop .= '</' . $attr['contentTag'] . '>';
314 - endwhile;
313 + if ( $attr['arrows'] ) {
314 + $wraper_after .= '<div class="ultp-slick-nav" style="display:none">';
315 + $nav = explode( '#', $attr['arrowStyle'] );
316 + $wraper_after .= '<div class="ultp-slick-prev"><div class="slick-arrow slick-prev">' . ultimate_post()->get_svg_icon( $nav[0] ) . '</div></div>';
317 + $wraper_after .= '<div class="ultp-slick-next"><div class="slick-arrow slick-next">' . ultimate_post()->get_svg_icon( $nav[1] ) . '</div></div>';
315 318 $wraper_after .= '</div>';
316 -
317 - if ( $attr['arrows'] ) {
318 - $wraper_after .= '<div class="ultp-slick-nav" style="display:none">';
319 - $nav = explode( '#', $attr['arrowStyle'] );
320 - $wraper_after .= '<div class="ultp-slick-prev"><div class="slick-arrow slick-prev">' . ultimate_post()->get_svg_icon( $nav[0] ) . '</div></div>';
321 - $wraper_after .= '<div class="ultp-slick-next"><div class="slick-arrow slick-next">' . ultimate_post()->get_svg_icon( $nav[1] ) . '</div></div>';
322 - $wraper_after .= '</div>';
323 - }
324 - $wraper_after .= '</div>';
325 - $wraper_after .= '</div>';
326 - wp_reset_query();
327 - } else {
328 - $wraper_before .= ultimate_post()->get_no_result_found_html( $attr['notFoundMessage'] );
329 319 }
320 + $wraper_after .= '</div>';
321 + $wraper_after .= '</div>';
322 + wp_reset_postdata();
323 + } else {
324 + $wraper_before .= ultimate_post()->get_no_result_found_html( $attr['notFoundMessage'] );
325 + }
330 326
331 - return $noAjax ? $post_loop : $wraper_before . $post_loop . $wraper_after;
332 - }
327 + return $noAjax ? $post_loop : $wraper_before . $post_loop . $wraper_after;
333 328 }
334 329 }