PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / blocks / includes / post-carousel-two / Post_Carousel_Two.php

Post_Carousel_Two.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at blocks/includes/post-carousel-two/Post_Carousel_Two.php

162 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post carousel class for Smart Post Show Blocks.
4 *
5 * @package Smart_Post_Show_Pro
6 * @subpackage Smart_Post_Show_Pro/blocks/includes
7 */
8
9 namespace SmartPostShow\Blocks;
10
11 use SmartPostShow\Blocks\Block_Base;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Post Carousel Block Class.
19 */
20 class Post_Carousel_Two extends Block_Base {
21
22
23
24 /**
25 * Set_block_properties
26 *
27 * @return void
28 */
29 protected function set_block_properties() {
30 $this->block_name = 'post-carousel-two';
31 $this->scripts = array( 'pcp_swiper', 'sp_smart_post_blocks_script_js' );
32 $this->styles = array( 'pcp_swiper', 'sp_smart_post_blocks_css', 'sp_smart_post_blocks_style', 'sp_smart_post_blocks_social_icons_style', 'sp_smart_post_blocks_social_icons_style', 'pcp-font-awesome', 'sp_smart_post_blocks_google_fonts' );
33 $this->editor_scripts = array( 'sp_smart_post_blocks_index_js' );
34 $this->editor_styles = array( 'sp_smart_post_blocks_editor_style' );
35 $this->keywords = array( 'Smart post', 'Carousel', 'Live Filter', 'pagination', 'ticker', 'multi row', ' Ajax Live Filter' );
36 }
37 /**
38 * Render_block
39 *
40 * @param array $attributes attributes.
41 * @param string $content Content to be rendered.
42 * @param string $blocks Nested blocks.
43 * @return string Rendered HTML content.
44 */
45 public function render_block( $attributes, $content = '', $blocks = array() ) {
46
47 $attributes['page_id'] = get_the_ID();
48 $unique_id = isset( $attributes['uniqueId'] ) ? $attributes['uniqueId'] : '';
49 $sp_block_id = $attributes['spBlockId'] ?? ''; // Not changeable id.
50 $align = isset( $attributes['align'] ) ? $attributes['align'] : '';
51 $layout = isset( $attributes['blockLayoutName'] ) ? $attributes['blockLayoutName'] : '';
52 $block_name = isset( $attributes['blockName'] ) ? $attributes['blockName'] : '';
53 $orientation = isset( $attributes['contentOrientation'] ) ? $attributes['contentOrientation'] : 'orientation_one';
54 $image_position = isset( $attributes['imagePosition'] ) ? $attributes['imagePosition'] : 'top';
55 $category_position = isset( $attributes['catTabCategoryPosition'] ) ? $attributes['catTabCategoryPosition'] : '';
56 $carousel_style = isset( $attributes['carouselStyle'] ) ? $attributes['carouselStyle'] : '';
57 $carousel_pagination_style = isset( $attributes['carouselPaginationStyle'] ) ? $attributes['carouselPaginationStyle'] : '';
58 $carousel_data = isset( $attributes['carouselData'] ) ? $attributes['carouselData'] : '';
59 $nav_arrow_visibility_hover = isset( $attributes['navArrowVisibilityOnHover'] ) ? $attributes['navArrowVisibilityOnHover'] : '';
60 $pagination_style = isset( $attributes['carouselPaginationStyle'] ) ? $attributes['carouselPaginationStyle'] : '';
61 $additional_css_class = isset( $attributes['additionalCssClass'] ) ? $attributes['additionalCssClass'] : '';
62 $align_class = isset( $align ) ? 'align' . $align : '';
63 unset( $attributes['dynamicCss'] );
64 unset( $attributes['fontListsEditPage'] );
65 unset( $attributes['fontLists'] );
66
67 $query_attr = ( ! empty( $attributes['postQuery'] ) && isset( $attributes['postQuery'] ) ) ? (array) json_decode( $attributes['postQuery'] ) : $attributes;
68
69 $post_query = $this->get_cached_post_query_result( $query_attr, $unique_id, $sp_block_id );
70 $post_query = $post_query[0];
71
72 $equal_height = isset( $attributes['equalHeightEnable'] ) ? $attributes['equalHeightEnable'] : false;
73
74 $equal_height_class = $equal_height ? 'sp-equal-height-wrapper' : '';
75
76 $preloader_enable = $attributes['preloaderEnable'] ?? false;
77 $post_not_found = ! empty( $attributes['noResultFoundResult'] ) ? $attributes['noResultFoundResult'] : 'No post found';
78 $preloader_svg = SP_PC_URL . 'public/assets/img/preloader.svg';
79
80 ob_start();
81 ?>
82 <?php if ( empty( $post_query ) ) : ?>
83 <div class="sp-smart-post-show-pro-pre-query">
84 <?php if ( $preloader_enable ) : ?>
85 <div class="sp-smart-post-preloader sp-d-block">
86 <img src="<?php echo esc_url( $preloader_svg ); ?>" alt="smart post preloader" />
87 </div>
88 <?php endif; ?>
89 <div class="sp-smart-post-no-post sp-d-hidden">
90 <h4>
91 <?php
92 echo esc_html( $post_not_found );
93 ?>
94 </h4>
95 </div>
96 </div>
97 <?php endif; ?>
98 <div class="<?php echo esc_attr( $align_class ); ?>">
99 <div id="<?php echo esc_attr( $unique_id ); ?>" class="sp-smart-post-wrapper sp-smart-<?php echo esc_attr( $block_name ); ?> <?php echo esc_attr( $additional_css_class ); ?>" data-blockid="<?php echo esc_attr( $sp_block_id ); ?>" data-pageid="<?php echo esc_attr( $attributes['page_id'] ); ?>">
100
101 <div class="sp-smart-post-show-pro-pre-query">
102 <?php
103 if ( empty( $post_query ) ) {
104 Template_Part::no_posts_found_text( $post_not_found );
105 }
106 Template_Part::preloader_front( $preloader_enable, $preloader_svg );
107 ?>
108 </div>
109 <div class="sp-smart-post-carousel-two sp-smart-post-block-wrapper sp-smart-post-carousel-<?php echo esc_attr( $carousel_style ); ?> img-position-<?php echo esc_attr( $image_position ); ?> <?php echo esc_attr( $orientation . ' ' . $layout ); ?> sp-cat-position-<?php echo esc_attr( $category_position ); ?> <?php echo ( 'background' === $image_position ) ? 'sp-smart-post-background-layout' : ''; ?>">
110 <div class="sp-smart-post-swiper sp-relative <?php echo esc_attr( $equal_height_class ); ?>" data-equal-height="<?php echo esc_attr( $equal_height ); ?>">
111 <?php
112 if ( 'ticker' === $carousel_style ) {
113 ?>
114 <div class="sp_marquee-container sp-smart-post-ticker" data-options='<?php echo esc_attr( $carousel_data ); ?>'>
115 <div class="sp_marquee-content">
116 <?php
117 foreach ( $post_query as $data ) {
118 ?>
119 <div class="sp_marquee-item sp-slide-item">
120 <?php
121 Template::template_one( $attributes, $data );
122 ?>
123 </div>
124 <?php
125 }
126 ?>
127 </div>
128 </div>
129 <?php
130 } else {
131 ?>
132 <div class="swiper-container swiper pagination-<?php echo esc_attr( $carousel_pagination_style ); ?> layout-<?php echo esc_attr( $carousel_style ); ?>" data-swiper-options='<?php echo esc_attr( $carousel_data ); ?>'>
133 <div class="swiper-wrapper">
134 <?php
135 foreach ( $post_query as $data ) {
136 ?>
137 <div class="swiper-slide sp-slide-item">
138 <?php Template::template_one( $attributes, $data ); ?>
139 </div>
140 <?php
141 }
142 ?>
143 </div>
144 </div>
145 <?php
146 $attributes['carouselNavArrow'] ? Template_part::swiper_nav_arrow( $nav_arrow_visibility_hover, $attributes['carouselArrowStyle'] ) : '';
147 ?>
148 <?php $attributes['carouselPaginationDot'] && 'scrollbar' !== $pagination_style ? Template_part::pagination( $pagination_style ) : ''; ?>
149 <?php if ( $attributes['carouselPaginationDot'] && 'scrollbar' === $pagination_style ) { ?>
150 <div class="swiper-scrollbar sp-pagination-horizontal swiper-scrollbar-horizontal"></div>
151 <?php } ?>
152 <?php } ?>
153 </div>
154 </div>
155 <?php Template_Part::modal_lightbox( $attributes, $post_query ); ?>
156 </div>
157 </div>
158 <?php
159 return ob_get_clean();
160 }
161 }
162