PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 7.0.2
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v7.0.2
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.php
the-post-grid / app / Widgets / elementor / widgets Last commit date
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.php
388 lines
1 <?php
2 /**
3 * Slider Layout 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 Class
17 */
18 class TPGSliderLayout 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', 'the-post-grid' );
33 $this->tpg_base = 'tpg-slider-layout';
34 $this->tpg_icon = 'eicon-post-slider tpg-grid-icon'; // .tpg-grid-icon class for just style
35 }
36
37 public function get_script_depends() {
38 $scripts = [];
39
40 array_push( $scripts, 'imagesloaded' );
41 array_push( $scripts, 'swiper' );
42 array_push( $scripts, 'rt-tpg' );
43 array_push( $scripts, 'rttpg-block-pro' );
44
45 return $scripts;
46 }
47
48 public function get_style_depends() {
49 $settings = get_option( rtTPG()->options['settings'] );
50 $style = [];
51
52 if ( isset( $settings['tpg_load_script'] ) ) {
53 array_push( $style, 'rt-fontawsome' );
54 array_push( $style, 'rt-flaticon' );
55 array_push( $style, 'rt-tpg-block' );
56 array_push( $style, 'swiper' );
57 }
58
59 return $style;
60 }
61
62 protected function register_controls() {
63 /**
64 * Content Tabs
65 * =============
66 */
67
68 // Layout.
69 rtTPGElementorHelper::grid_layouts( $this );
70
71 // Query.
72 rtTPGElementorHelper::query( $this );
73
74 // Links.
75 rtTPGElementorHelper::links( $this );
76
77 /**
78 * Settings Tabs
79 * =============
80 */
81
82 // Field Selection.
83 rtTPGElementorHelper::field_selection( $this );
84
85 // Section Title Settings.
86 rtTPGElementorHelper::section_title_settings( $this );
87
88 // Title Settings.
89 rtTPGElementorHelper::post_title_settings( $this );
90
91 // Thumbnail Settings.
92 rtTPGElementorHelper::post_thumbnail_settings( $this );
93
94 // Excerpt Settings.
95 rtTPGElementorHelper::post_excerpt_settings( $this );
96
97 // Meta Settings.
98 rtTPGElementorHelper::post_meta_settings( $this );
99
100 // Advanced Custom Field ACF Settings.
101 rtTPGElementorHelper::tpg_acf_settings( $this );
102
103 // Readmore Settings.
104 rtTPGElementorHelper::post_readmore_settings( $this );
105
106 // Slider Settings.
107 rtTPGElementorHelper::slider_settings( $this );
108
109 /**
110 * Style Tabs
111 * =============
112 */
113
114 // Section Title.
115 rtTPGElementorHelper::sectionTitle( $this );
116
117 // Title Style.
118 rtTPGElementorHelper::titleStyle( $this );
119
120 // Thumbnail Style.
121 rtTPGElementorHelper::thumbnailStyle( $this );
122
123 // Content Style.
124 rtTPGElementorHelper::contentStyle( $this );
125
126 // Meta Info Style.
127 rtTPGElementorHelper::metaInfoStyle( $this );
128
129 // Social Style.
130 rtTPGElementorHelper::socialShareStyle( $this );
131
132 // ACF Style.
133 rtTPGElementorHelper::tpg_acf_style( $this );
134
135 // Read more style.
136 rtTPGElementorHelper::readmoreStyle( $this );
137
138 // Slider Style.
139 rtTPGElementorHelper::slider_style( $this );
140 rtTPGElementorHelper::slider_thumb_style( $this );
141
142 // Link Style.
143 rtTPGElementorHelper::linkStyle( $this );
144
145 // Box Settings.
146 rtTPGElementorHelper::articlBoxSettings( $this );
147
148 // Promotions.
149 rtTPGElementorHelper::promotions( $this );
150 }
151
152 protected function render() {
153 $data = $this->get_settings();
154 $_prefix = $this->prefix;
155 if ( ! rtTPG()->hasPro() ) { ?>
156 <h3 style="text-align: center"><?php echo esc_html__( 'Please upgrade to pro for slider layout!', 'the-post-grid' ); ?></h3>
157 <?php
158 return;
159 }
160
161 if ( rtTPG()->hasPro() && ( 'popup' == $data['post_link_type'] || 'multi_popup' == $data['post_link_type'] ) ) {
162 wp_enqueue_style( 'rt-magnific-popup' );
163 wp_enqueue_script( 'rt-scrollbar' );
164 wp_enqueue_script( 'rt-magnific-popup' );
165 add_action( 'wp_footer', [ Fns::class, 'get_modal_markup' ], 1 );
166 }
167
168 // Query.
169 $query_args = rtTPGElementorQuery::post_query( $data, $_prefix );
170 $query = new WP_Query( $query_args );
171 $rand = mt_rand();
172 $layoutID = 'rt-tpg-container-' . $rand;
173 $posts_per_page = $data['post_limit'];
174
175 /**
176 * TODO: Get Post Data for render post
177 */
178 $post_data = Fns::get_render_data_set( $data, $query->max_num_pages, $posts_per_page, $_prefix );
179 $_layout = $data[ $_prefix . '_layout' ];
180
181 $post_data['lazy_load'] = $data['lazyLoad'];
182
183 /**
184 * Post type render
185 */
186 $post_types = Fns::get_post_types();
187 foreach ( $post_types as $post_type => $label ) {
188 $_taxonomies = get_object_taxonomies( $post_type, 'object' );
189
190 if ( empty( $_taxonomies ) ) {
191 continue;
192 }
193
194 $post_data[ $data['post_type'] . '_taxonomy' ] = isset( $data[ $data['post_type'] . '_taxonomy' ] ) ? $data[ $data['post_type'] . '_taxonomy' ] : '';
195 $post_data[ $data['post_type'] . '_tags' ] = isset( $data[ $data['post_type'] . '_tags' ] ) ? $data[ $data['post_type'] . '_tags' ] : '';
196 }
197
198 $post_data['enable_2_rows'] = $data['enable_2_rows'];
199
200 $default_grid_column_desktop = '3';
201 $default_grid_column_tab = '2';
202 $default_grid_column_mobile = '1';
203
204
205 if ( $_layout == 'slider-layout13' ) {
206 $default_grid_column_desktop = '1';
207 $default_grid_column_tab = '1';
208 $default_grid_column_mobile = '1';
209 }
210
211 $grid_column_desktop = '0' !== $post_data['grid_column'] ? $post_data['grid_column'] : $default_grid_column_desktop;
212 $grid_column_tab = '0' !== $post_data['grid_column_tablet'] ? $post_data['grid_column_tablet'] : $default_grid_column_tab;
213 $grid_column_mobile = '0' !== $post_data['grid_column_mobile'] ? $post_data['grid_column_mobile'] : $default_grid_column_mobile;
214
215 if ( in_array( $_layout, [ 'slider-layout10', 'slider-layout11' ] ) ) {
216 $grid_column_desktop = $grid_column_tab = $grid_column_mobile = '1';
217 }
218
219 ?>
220 <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper slider-layout-main <?php echo esc_attr( $_layout . '-main' ); ?>"
221 id="<?php echo esc_attr( $layoutID ); ?>"
222 data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>"
223 data-grid-style=""
224 data-desktop-col="<?php echo esc_attr( $grid_column_desktop ); ?>"
225 data-tab-col="<?php echo esc_attr( $grid_column_tab ); ?>"
226 data-mobile-col="<?php echo esc_attr( $grid_column_mobile ); ?>"
227 data-sc-id="elementor"
228 data-el-query=''
229 >
230 <?php
231
232 $wrapper_class = [];
233 $wrapper_class[] = 'rt-content-loader grid-behaviour';
234
235 if ( $_layout == 'slider-layout1' ) {
236 $wrapper_class[] = 'grid-layout1 ';
237 } elseif ( $_layout == 'slider-layout2' ) {
238 $wrapper_class[] = 'grid-layout3';
239 } elseif ( $_layout == 'slider-layout3' ) {
240 $wrapper_class[] = 'grid-layout4';
241 } elseif ( $_layout == 'slider-layout4' ) {
242 $wrapper_class[] = 'grid-layout7';
243 } elseif ( $_layout == 'slider-layout5' ) {
244 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout1 grid_hover_layout_wrapper';
245 } elseif ( $_layout == 'slider-layout6' ) {
246 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout3 grid_hover_layout_wrapper';
247 } elseif ( $_layout == 'slider-layout7' ) {
248 $wrapper_class[] = 'grid_hover-layout5 grid_hover_layout_wrapper';
249 } elseif ( $_layout == 'slider-layout8' ) {
250 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout10 grid_hover_layout_wrapper';
251 } elseif ( $_layout == 'slider-layout9' ) {
252 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout11 grid_hover_layout_wrapper';
253 } elseif ( $_layout == 'slider-layout10' ) {
254 $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout7 grid_hover_layout_wrapper';
255 } elseif ( $_layout == 'slider-layout11' ) {
256 $wrapper_class[] = ' grid_hover-layout5 slider-layout';
257 } elseif ( $_layout == 'slider-layout12' ) {
258 $wrapper_class[] = ' grid_hover-layout5 slider-layout';
259 }
260
261 $wrapper_class[] = $_prefix . '_layout_wrapper';
262
263 //Slider Options
264 $slider_data = [
265 'speed' => $data['speed'],
266 'autoPlayTimeOut' => $data['autoplaySpeed'],
267 'autoPlay' => $data['autoplay'] == 'yes' ? true : false,
268 'stopOnHover' => $data['stopOnHover'] == 'yes' ? true : false,
269 'nav' => $data['arrows'] == 'yes' ? true : false,
270 'dots' => $data['dots'] == 'yes' ? true : false,
271 'loop' => $data['infinite'] == 'yes' ? true : false,
272 'lazyLoad' => $data['lazyLoad'] == 'yes' ? true : false,
273 'autoHeight' => $data['autoHeight'] == 'yes' ? true : false,
274 'dynamic_dots' => $data['dynamic_dots'] == 'yes' ? true : false,
275 'grabCursor' => $data['grabCursor'] == 'yes' ? true : false,
276 ];
277
278 if ( $data['enable_2_rows'] == 'yes' ) {
279 $slider_data['autoHeight'] = false;
280 }
281
282 //section title settings
283 Fns::get_section_title( $data );
284 ?>
285
286 <div class="slider-main-wrapper <?php echo esc_attr( $_layout ); ?>">
287 <div class="rt-swiper-holder swiper"
288 data-rtowl-options='<?php echo wp_json_encode( $slider_data ); ?>'
289 dir="<?php echo esc_attr( $data['slider_direction'] ); ?>"
290 >
291 <div class="swiper-wrapper <?php echo esc_attr( implode( ' ', $wrapper_class ) ); ?>">
292 <?php
293 if ( $query->have_posts() ) {
294 $pCount = 1;
295
296 while ( $query->have_posts() ) {
297 $query->the_post();
298 set_query_var( 'tpg_post_count', $pCount );
299 set_query_var( 'tpg_total_posts', $query->post_count );
300 Fns::tpg_template( $post_data );
301
302 if ( $_layout == 'slider-layout10' && $pCount == 5 ) {
303 $pCount = 0;
304 }
305
306 $pCount ++;
307 }
308 } else {
309 if ( $data['no_posts_found_text'] ) {
310 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
311 } else {
312 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
313 }
314 }
315 wp_reset_postdata();
316 ?>
317 </div>
318
319 </div>
320
321
322 <?php if ( ! in_array( $_layout, [ 'slider-layout11', 'slider-layout12' ] ) ) : ?>
323 <!--swiper-pagination-horizontal-->
324 <?php if ( $data['dots'] == 'yes' ) : ?>
325 <div class="swiper-pagination"></div>
326 <?php endif; ?>
327
328 <?php if ( $data['arrows'] == 'yes' ) : ?>
329 <div class="swiper-navigation">
330 <div class="slider-btn swiper-button-prev"></div>
331 <div class="slider-btn swiper-button-next"></div>
332 </div>
333 <?php endif; ?>
334 <?php endif; ?>
335
336 <?php if ( in_array( $_layout, [ 'slider-layout11', 'slider-layout12' ] ) ) : ?>
337 <div class="slider-thumb-main-wrapper">
338 <div class="swiper-thumb-wrapper gallery-thumbs swiper">
339 <div class="swiper-wrapper">
340 <?php
341 if ( $query->have_posts() ) {
342 $pCount = 1;
343 while ( $query->have_posts() ) {
344 $query->the_post();
345 set_query_var( 'tpg_post_count', $pCount );
346 set_query_var( 'tpg_total_posts', $query->post_count );
347 ?>
348 <div class="swiper-slide">
349 <div class="post-thumbnail-wrap">
350 <div class="p-thumbnail">
351 <?php echo get_the_post_thumbnail( get_the_ID(), 'thumbnail' ); ?>
352 </div>
353 <div class="p-content">
354 <div class="post-taxonomy">
355 <?php
356 $_cat_id = $data['post_type'] . '_taxonomy';
357 echo get_the_term_list( get_the_ID(), $data[ $_cat_id ], null, '<span class="rt-separator">,</span>' );
358 ?>
359 </div>
360 <h3 class="thumb-title"><?php echo get_the_title(); ?></h3>
361 <span class="thumb-date"><?php echo get_the_date(); ?></span>
362 </div>
363 </div>
364 </div>
365 <?php
366 $pCount ++;
367 }
368 } else {
369 if ( $data['no_posts_found_text'] ) {
370 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
371 } else {
372 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
373 }
374 }
375 wp_reset_postdata();
376 ?>
377 </div>
378 <div class="swiper-thumb-pagination"></div>
379 </div>
380 </div>
381 <?php endif; ?>
382 </div>
383 </div>
384 <?php
385 do_action( 'tpg_elementor_script' );
386 }
387 }
388