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-timeline-three / Post_Timeline_Three.php

Post_Timeline_Three.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at blocks/includes/post-timeline-three/Post_Timeline_Three.php

165 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Timeline three block 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\Helper;
12
13 use SmartPostShow\Blocks\Block_Base;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Post_Timeline_Three
21 */
22 class Post_Timeline_Three extends Block_Base {
23 /**
24 * Set_block_properties
25 *
26 * @return void
27 */
28 protected function set_block_properties() {
29 $this->block_name = 'post-timeline-three';
30 $this->scripts = array( 'pcp_swiper', 'sp_smart_post_blocks_script_js' );
31 $this->styles = array( 'pcp_swiper', 'sp_smart_post_blocks_css', 'sp_smart_post_blocks_social_icons_style', 'sp_smart_post_blocks_google_fonts' );
32 $this->editor_scripts = array( 'sp_smart_post_blocks_index_js' );
33 $this->editor_styles = array( 'sp_smart_post_blocks_editor_style' );
34 $this->keywords = array( 'Smart post', 'Ticker', 'Carousel' );
35 }
36 /**
37 * Renders the Post Timeline Three block.
38 *
39 * @param array $attributes Block attributes.
40 * @param string $content Block content.
41 * @param array $blocks Inner blocks.
42 * @return string Rendered HTML output.
43 */
44 public function render_block( $attributes, $content = '', $blocks = array() ) {
45 if ( Helper::is_editor_page() ) {
46 return $content;
47 }
48
49 $attributes['page_id'] = get_the_ID();
50 unset(
51 $attributes['dynamicCss'],
52 $attributes['fontListsEditPage'],
53 $attributes['fontLists']
54 );
55
56 $unique_id = $attributes['uniqueId'] ?? '';
57 $sp_block_id = $attributes['spBlockId'] ?? ''; // Not changeable id.
58 $align = $attributes['align'] ?? '';
59 $sp_user_additional_class = $attributes['additionalCssClass'] ?? '';
60 $layout = $attributes['timelineLayout'] ?? '';
61 $block_name = $attributes['blockName'] ?? '';
62 $orientation = $attributes['contentOrientation'] ?? 'orientation_one';
63 $image_position = $attributes['imagePosition'] ?? 'top';
64 $nav_arrow_visibility_hover = $attributes['navArrowVisibilityOnHover'] ?? '';
65 $category_position = $attributes['catTabCategoryPosition'] ?? '';
66 $pagination_style = $attributes['carouselPaginationStyle'] ?? '';
67 $preloader_enable = $attributes['preloaderEnable'] ?? false;
68 $block_location = $attributes['blockLocation'] ?? '';
69 $post_not_found = ! empty( $attributes['noResultFoundResult'] ) ? $attributes['noResultFoundResult'] : 'No post found';
70 $preloader_svg = SP_PC_URL . 'public/assets/img/preloader.svg';
71 $query_attr = ( ! empty( $attributes['postQuery'] ) && isset( $attributes['postQuery'] ) ) ? (array) json_decode( $attributes['postQuery'] ) : $attributes;
72
73 $category_position = $attributes['catTabCategoryPosition'] ?? false;
74
75 $category_position = $category_position ? ' sp-cat-position-' . $category_position : '';
76
77 $post_query = $this->get_cached_post_query_result( $query_attr, $unique_id, $sp_block_id );
78 $post_query = $post_query[0];
79
80 $carousel_data = $attributes['carouselData'] ?? '';
81 $carousel_style = $attributes['carouselStyle'] ?? '';
82 $align_class = isset( $align ) ? 'align' . $align : '';
83 $equal_height = $attributes['equalHeightEnable'] ?? false;
84
85 $equal_height_class = $equal_height ? 'sp-equal-height-wrapper' : '';
86 ob_start();
87 ?>
88 <div class="<?php echo esc_attr( $align_class ); ?>">
89 <div id="<?php echo esc_attr( $unique_id ); ?>" class="sp-smart-post-wrapper smart-post-timeline-three sp-smart-<?php echo esc_attr( $block_name . $category_position ); ?> <?php echo esc_attr( $sp_user_additional_class ); ?>" data-blockid="<?php echo esc_attr( $sp_block_id ); ?>" data-pageid="<?php echo esc_attr( $attributes['page_id'] ); ?>" data-location="<?php echo esc_attr( $block_location ); ?>">
90 <div class="sp-smart-post-show-pro-pre-query">
91 <?php
92 if ( empty( $post_query ) ) {
93 Template_Part::no_posts_found_text( $post_not_found );}
94 Template_Part::preloader_front( $preloader_enable, $preloader_svg );
95 ?>
96 </div>
97 <div class="post-timeline-three smart-post-timeline-three <?php echo esc_attr( $layout ); ?>">
98 <div class="sp-smart-post-timeline-three-container sp-smart-post-swiper <?php echo esc_attr( $equal_height_class ); ?> <?php echo esc_attr( $layout ); ?>" data-equal-height="<?php echo esc_attr( $equal_height ); ?>">
99 <div class="sp-smart-post-timeline-border"></div>
100 <?php
101 if ( 'ticker' === $carousel_style ) {
102 ?>
103
104 <div class="sp_marquee-container sp-smart-post-ticker" data-options='<?php echo esc_attr( $carousel_data ); ?>'>
105 <div class="sp_marquee-content">
106 <?php
107 foreach ( $post_query as $data ) {
108 ?>
109 <div class="sp-smart-post-timeline-three-post-container sp_marquee-item ">
110 <div class="sp-smart-indicator">
111 <div class="sp-smart-indicator-circle"></div>
112 <div class="sp-smart-indicator-arrow"></div>
113 </div>
114 <?php Template::template_one( $attributes, $data ); ?>
115 </div>
116 <?php
117 }
118 ?>
119 </div>
120 </div>
121 <?php
122 } else {
123 ?>
124 <div class="swiper swiper-container" data-swiper-options='<?php echo esc_attr( $carousel_data ); ?>'>
125 <div class="swiper-wrapper">
126 <?php
127 foreach ( $post_query as $data ) {
128 ?>
129 <div class="sp-smart-post-timeline-three-post-container swiper-slide ">
130 <div class="sp-smart-indicator">
131 <div class="sp-smart-indicator-circle"></div>
132 <div class="sp-smart-indicator-arrow"></div>
133 </div>
134 <?php Template::template_one( $attributes, $data ); ?>
135 </div>
136 <?php
137 }
138 ?>
139 </div>
140 </div>
141 <?php
142 }
143 ?>
144 </div>
145 <?php
146 $attributes['carouselNavArrow'] && 'ticker' !== $carousel_style ? Template_part::swiper_nav_arrow( $nav_arrow_visibility_hover, $attributes['carouselArrowStyle'] ) : '';
147 ?>
148 </div>
149 <?php
150 // Moved modal rendering to footer.
151 add_action(
152 'wp_footer',
153 function () use ( $attributes, $post_query ) {
154 Template_Part::modal_lightbox( $attributes, $post_query );
155 },
156 20
157 );
158 ?>
159 </div>
160 </div>
161 <?php
162 return ob_get_clean();
163 }
164 }
165