PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 4.2.0
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v4.2.0
7.9.3 7.9.2 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.2.0 4.2.1 4.2.2 4.2.3 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 6.0.0 7.0.0 7.0.1 7.0.2 7.1.0 7.2.0 7.2.1 7.2.10 7.2.11 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 7.2.7 7.2.8 7.2.9 7.3.0 7.3.1 7.4.0 7.4.1 7.4.2 7.4.3 7.5.0 7.6.0 7.6.1 7.7.0 7.7.1 7.7.10 7.7.11 7.7.12 7.7.13 7.7.14 7.7.15 7.7.16 7.7.17 7.7.18 7.7.19 7.7.2 7.7.20 7.7.21 7.7.22 7.7.3 7.7.4 7.7.5 7.7.6 7.7.7 7.7.8 7.7.9 7.8.0 7.8.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1
the-post-grid / app / Widgets / elementor / widgets / slider-layout-archive.php
the-post-grid / app / Widgets / elementor / widgets Last commit date
default.php 3 years ago grid-hover-layout-archive.php 3 years ago grid-hover-layout.php 3 years ago grid-layout-archive.php 3 years ago grid-layout.php 3 years ago list-layout-archive.php 3 years ago list-layout.php 3 years ago related-post.php 3 years ago slider-layout-archive.php 3 years ago slider-layout.php 3 years ago
slider-layout-archive.php
399 lines
1 <?php
2 /**
3 * Slider Layout Archive Class
4 *
5 * @package RT_TPG
6 */
7
8 use RT\ThePostGrid\Helpers\Fns;
9
10 // Do not allow directly accessing this file.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit( 'This script cannot be accessed directly.' );
13 }
14
15 /**
16 * Slider Layout Archive Class
17 */
18 class TPGSliderLayoutArchive extends Custom_Widget_Base {
19
20 /**
21 * GridLayout constructor.
22 *
23 * @param array $data
24 * @param null $args
25 *
26 * @throws \Exception
27 */
28
29 public function __construct( $data = [], $args = null ) {
30 parent::__construct( $data, $args );
31 $this->prefix = 'slider';
32 $this->tpg_name = esc_html__( 'TPG - Slider Layout Archive', 'the-post-grid' );
33 $this->tpg_base = 'tpg-slider-layout-archive';
34 $this->tpg_icon = 'eicon-post-slider tpg-grid-icon'; // .tpg-grid-icon class for just style
35 $this->tpg_category = $this->tpg_archive_category;
36 }
37
38 public function get_script_depends() {
39 $scripts = [];
40
41 array_push( $scripts, 'imagesloaded' );
42 array_push( $scripts, 'swiper' );
43 array_push( $scripts, 'rt-tpg' );
44 array_push( $scripts, 'rt-tpg-el-pro' );
45
46 return $scripts;
47 }
48
49 public function get_style_depends() {
50 $settings = get_option( rtTPG()->options['settings'] );
51 $style = [];
52
53 if ( isset( $settings['tpg_load_script'] ) ) {
54 array_push( $style, 'rt-fontawsome' );
55 array_push( $style, 'rt-tpg-elementor' );
56 array_push( $style, 'swiper' );
57
58 }
59
60 return $style;
61 }
62
63 protected function register_controls() {
64 /**
65 * Content Tabs
66 * =============
67 */
68
69 // Layout.
70 rtTPGElementorHelper::grid_layouts( $this, 'archive' );
71
72 // Query.
73 rtTPGElementorHelper::query_builder( $this );
74
75 // Links.
76 rtTPGElementorHelper::links( $this );
77
78 /**
79 * Settings Tabs
80 * =============
81 */
82
83 // Field Selection.
84 rtTPGElementorHelper::field_selection( $this );
85
86 // Section Title Settings.
87 rtTPGElementorHelper::section_title_settings( $this, 'archive' );
88
89 // Title Settings.
90 rtTPGElementorHelper::post_title_settings( $this );
91
92 // Thumbnail Settings.
93 rtTPGElementorHelper::post_thumbnail_settings( $this );
94
95 // Excerpt Settings.
96 rtTPGElementorHelper::post_excerpt_settings( $this );
97
98 // Meta Settings.
99 rtTPGElementorHelper::post_meta_settings( $this );
100
101 // Advanced Custom Field ACF Settings.
102 rtTPGElementorHelper::tpg_acf_settings( $this );
103
104 // Readmore Settings.
105 rtTPGElementorHelper::post_readmore_settings( $this );
106
107 // Slider Settings.
108 rtTPGElementorHelper::slider_settings( $this );
109
110 /**
111 * Style Tabs
112 * =============
113 */
114
115 // Section Title.
116 rtTPGElementorHelper::sectionTitle( $this, 'archive' );
117
118 // Title Style.
119 rtTPGElementorHelper::titleStyle( $this );
120
121 // Thumbnail Style.
122 rtTPGElementorHelper::thumbnailStyle( $this );
123
124 // Content Style.
125 rtTPGElementorHelper::contentStyle( $this );
126
127 // Meta Info Style.
128 rtTPGElementorHelper::metaInfoStyle( $this );
129
130 // Social Style.
131 rtTPGElementorHelper::socialShareStyle( $this );
132
133 // ACF Style.
134 rtTPGElementorHelper::tpg_acf_style( $this );
135
136 // Read more style.
137 rtTPGElementorHelper::readmoreStyle( $this );
138
139 // Link Style.
140 rtTPGElementorHelper::linkStyle( $this );
141
142 // Slider Style.
143 rtTPGElementorHelper::slider_style( $this );
144 rtTPGElementorHelper::slider_thumb_style( $this );
145
146 // Box Settings.
147 rtTPGElementorHelper::articlBoxSettings( $this );
148
149 // Promotions.
150 rtTPGElementorHelper::promotions( $this );
151 }
152
153 protected function render() {
154 $data = $this->get_settings();
155 $_prefix = $this->prefix;
156 $data['post_type'] = 'post';
157
158 if ( ! rtTPG()->hasPro() ) { ?>
159 <h3 style="text-align: center"><?php echo esc_html__( 'Please upgrade to pro for slider layout!', 'the-post-grid' ); ?></h3>
160 <?php
161 return;
162 }
163
164 if ( rtTPG()->hasPro() && ( 'popup' == $data['post_link_type'] || 'multi_popup' == $data['post_link_type'] ) ) {
165 wp_enqueue_style( 'rt-magnific-popup' );
166 wp_enqueue_script( 'rt-scrollbar' );
167 wp_enqueue_script( 'rt-magnific-popup' );
168 add_action( 'wp_footer', [ $this, 'get_modal_markup' ], 1 );
169 }
170
171 // Query.
172 $query_args = rtTPGElementorQuery::post_query_builder( $data, $_prefix );
173 $query = new WP_Query( $query_args );
174 $rand = mt_rand();
175 $layoutID = 'rt-tpg-container-' . $rand;
176 $posts_per_page = $data['post_limit'];
177
178 /**
179 * TODO: Get Post Data for render post
180 */
181 $post_data = $this->get_render_data_set( $data, $query->max_num_pages, $posts_per_page );
182 $_layout = $data[ $_prefix . '_layout' ];
183
184 $post_data['lazy_load'] = $data['lazyLoad'];
185
186 /**
187 * Post type render
188 */
189 $post_types = Fns::get_post_types();
190 foreach ( $post_types as $post_type => $label ) {
191 $_taxonomies = get_object_taxonomies( $post_type, 'object' );
192
193 if ( empty( $_taxonomies ) ) {
194 continue;
195 }
196
197 $post_data[ $data['post_type'] . '_taxonomy' ] = isset( $data[ $data['post_type'] . '_taxonomy' ] ) ? $data[ $data['post_type'] . '_taxonomy' ] : '';
198 $post_data[ $data['post_type'] . '_tags' ] = isset( $data[ $data['post_type'] . '_tags' ] ) ? $data[ $data['post_type'] . '_tags' ] : '';
199 }
200
201 $post_data['enable_2_rows'] = $data['enable_2_rows'];
202
203 $default_gird_column_desktop = '3';
204 $default_gird_column_tab = '2';
205 $default_gird_column_mobile = '1';
206
207 if ( $_layout == 'slider-layout13' ) {
208 $default_gird_column_desktop = '1';
209 $default_gird_column_tab = '1';
210 $default_gird_column_mobile = '1';
211 }
212
213 $gird_column_desktop = '0' !== $post_data['gird_column'] ? $post_data['gird_column'] : $default_gird_column_desktop;
214 $gird_column_tab = '0' !== $post_data['gird_column_tablet'] ? $post_data['gird_column_tablet'] : $default_gird_column_tab;
215 $gird_column_mobile = '0' !== $post_data['gird_column_mobile'] ? $post_data['gird_column_mobile'] : $default_gird_column_mobile;
216
217 if ( in_array( $_layout, [ 'slider-layout10', 'slider-layout11' ] ) ) {
218 $gird_column_desktop = $gird_column_tab = $gird_column_mobile = '1';
219 }
220
221 ?>
222 <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper slider-layout-main loading <?php echo esc_attr( $_layout . '-main' ); ?>"
223 id="<?php echo esc_attr( $layoutID ); ?>"
224 data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>"
225 data-grid-style=""
226 data-desktop-col="<?php echo esc_attr( $gird_column_desktop ); ?>"
227 data-tab-col="<?php echo esc_attr( $gird_column_tab ); ?>"
228 data-mobile-col="<?php echo esc_attr( $gird_column_mobile ); ?>"
229 data-sc-id="elementor"
230 data-el-query=''
231 >
232 <?php
233
234 $settings = get_option( rtTPG()->options['settings'] );
235 if ( isset( $settings['tpg_load_script'] ) && isset( $settings['tpg_enable_preloader'] ) ) {
236 ?>
237 <div id="bottom-script-loader" class="bottom-script-loader">
238 <div class="rt-ball-clip-rotate">
239 <div></div>
240 </div>
241 </div>
242 <?php
243 }
244
245 $wrapper_class = [];
246 $wrapper_class[] = 'rt-content-loader grid-behaviour';
247
248 if ( $_layout == 'slider-layout1' ) {
249 $wrapper_class[] = 'grid-layout1 ';
250 } elseif ( $_layout == 'slider-layout2' ) {
251 $wrapper_class[] = 'grid-layout3';
252 } elseif ( $_layout == 'slider-layout3' ) {
253 $wrapper_class[] = 'grid-layout4';
254 } elseif ( $_layout == 'slider-layout4' ) {
255 $wrapper_class[] = 'grid-layout7';
256 } elseif ( $_layout == 'slider-layout5' ) {
257 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout1 grid_hover_layout_wrapper';
258 } elseif ( $_layout == 'slider-layout6' ) {
259 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout3 grid_hover_layout_wrapper';
260 } elseif ( $_layout == 'slider-layout7' ) {
261 $wrapper_class[] = 'grid_hover-layout5 grid_hover_layout_wrapper';
262 } elseif ( $_layout == 'slider-layout8' ) {
263 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout10 grid_hover_layout_wrapper';
264 } elseif ( $_layout == 'slider-layout9' ) {
265 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout11 grid_hover_layout_wrapper';
266 } elseif ( $_layout == 'slider-layout10' ) {
267 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout7 grid_hover_layout_wrapper';
268 } elseif ( $_layout == 'slider-layout11' ) {
269 $wrapper_class[] = ' grid_hover-layout5 slider-layout';
270 } elseif ( $_layout == 'slider-layout12' ) {
271 $wrapper_class[] = ' grid_hover-layout5 slider-layout';
272 }
273
274 $wrapper_class[] = $_prefix . '_layout_wrapper';
275
276 // section title settings.
277 $this->get_section_title( $data );
278
279 $slider_data = [
280 'speed' => $data['speed'],
281 'autoPlayTimeOut' => $data['autoplaySpeed'],
282 'autoPlay' => $data['autoplay'] == 'yes' ? true : false,
283 'stopOnHover' => $data['stopOnHover'] == 'yes' ? true : false,
284 'nav' => $data['arrows'] == 'yes' ? true : false,
285 'dots' => $data['dots'] == 'yes' ? true : false,
286 'loop' => $data['infinite'] == 'yes' ? true : false,
287 'lazyLoad' => $data['lazyLoad'] == 'yes' ? true : false,
288 'autoHeight' => $data['autoHeight'] == 'yes' ? true : false,
289 'dynamic_dots' => $data['dynamic_dots'] == 'yes' ? true : false,
290 'grabCursor' => $data['grabCursor'] == 'yes' ? true : false,
291 ];
292
293 if ( $data['enable_2_rows'] == 'yes' ) {
294 $slider_data['autoHeight'] = false;
295 }
296 ?>
297
298 <div class="slider-main-wrapper <?php echo esc_attr( $_layout ); ?>">
299 <div class="rt-swiper-holder swiper"
300 data-rtowl-options='<?php echo wp_json_encode( $slider_data ); ?>'
301 dir="<?php echo esc_attr( $data['slider_direction'] ); ?>">
302 <div class="swiper-wrapper <?php echo esc_attr( implode( ' ', $wrapper_class ) ); ?>">
303 <?php
304 if ( $query->have_posts() ) {
305 $pCount = 1;
306
307 while ( $query->have_posts() ) {
308 $query->the_post();
309 set_query_var( 'tpg_post_count', $pCount );
310 set_query_var( 'tpg_total_posts', $query->post_count );
311 $this->tpg_template( $post_data );
312
313 if ( $_layout == 'slider-layout10' && $pCount == 5 ) {
314 $pCount = 0;
315 }
316 $pCount ++;
317 }
318 } else {
319 if ( $data['no_posts_found_text'] ) {
320 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
321 } else {
322 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
323 }
324 }
325 wp_reset_postdata();
326 ?>
327 </div>
328
329 </div>
330
331
332 <?php if ( ! in_array( $_layout, [ 'slider-layout11', 'slider-layout12' ] ) ) : ?>
333 <!--swiper-pagination-horizontal-->
334 <?php if ( $data['dots'] == 'yes' ) : ?>
335 <div class="swiper-pagination"></div>
336 <?php endif; ?>
337
338 <?php if ( $data['arrows'] == 'yes' ) : ?>
339 <div class="swiper-navigation">
340 <div class="slider-btn swiper-button-prev"></div>
341 <div class="slider-btn swiper-button-next"></div>
342 </div>
343 <?php endif; ?>
344 <?php endif; ?>
345
346 <?php if ( in_array( $_layout, [ 'slider-layout11', 'slider-layout12' ] ) ) : ?>
347 <div class="slider-thumb-main-wrapper">
348 <div class="swiper-thumb-wrapper gallery-thumbs swiper">
349 <div class="swiper-wrapper">
350 <?php
351 if ( $query->have_posts() ) {
352 $pCount = 1;
353
354 while ( $query->have_posts() ) {
355 $query->the_post();
356 set_query_var( 'tpg_post_count', $pCount );
357 set_query_var( 'tpg_total_posts', $query->post_count );
358 ?>
359 <div class="swiper-slide">
360 <div class="post-thumbnail-wrap">
361 <div class="p-thumbnail">
362 <?php echo get_the_post_thumbnail( get_the_ID(), 'thumbnail' ); ?>
363 </div>
364 <div class="p-content">
365 <div class="post-taxonomy">
366 <?php
367 $_cat_id = $data['post_type'] . '_taxonomy';
368 echo get_the_term_list( get_the_ID(), $data[ $_cat_id ], null, '<span class="rt-separator">,</span>' );
369 ?>
370 </div>
371 <h3 class="thumb-title"><?php echo get_the_title(); ?></h3>
372 <span class="thumb-date"><?php echo get_the_date(); ?></span>
373 </div>
374 </div>
375 </div>
376 <?php
377 $pCount ++;
378 }
379 } else {
380 if ( $data['no_posts_found_text'] ) {
381 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
382 } else {
383 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
384 }
385 }
386 wp_reset_postdata();
387 ?>
388 </div>
389 <div class="swiper-thumb-pagination"></div>
390 </div>
391 </div>
392 <?php endif; ?>
393 </div>
394 </div>
395 <?php
396 do_action( 'tpg_elementor_script' );
397 }
398 }
399