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 / grid-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
grid-layout.php
309 lines
1 <?php
2 /**
3 * Grid 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 * Grid Layout Class
17 */
18 class TPGGridLayout 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 = 'grid';
32 $this->tpg_name = esc_html__( 'TPG - Grid Layout', 'the-post-grid' );
33 $this->tpg_base = 'tpg-grid-layout';
34 $this->tpg_icon = 'eicon-posts-grid tpg-grid-icon'; // .tpg-grid-icon class for just style
35 }
36
37
38 public function get_script_depends() {
39 $scripts = [];
40 array_push( $scripts, 'imagesloaded' );
41 array_push( $scripts, 'rt-tpg' );
42 array_push( $scripts, 'rttpg-block-pro' );
43
44 return $scripts;
45 }
46
47 public function get_style_depends() {
48 $settings = get_option( rtTPG()->options['settings'] );
49 $style = [];
50
51 if ( isset( $settings['tpg_load_script'] ) ) {
52 array_push( $style, 'rt-fontawsome' );
53 array_push( $style, 'rt-flaticon' );
54 array_push( $style, 'rt-tpg-block' );
55 }
56
57 return $style;
58 }
59
60 protected function register_controls() {
61 /** Content TAB */
62
63 // Layout.
64 rtTPGElementorHelper::grid_layouts( $this );
65
66 // Query.
67 rtTPGElementorHelper::query( $this );
68
69 // Filter Settings.
70 rtTPGElementorHelper::filter_settings( $this );
71
72 // Pagination Settings.
73 rtTPGElementorHelper::pagination_settings( $this );
74
75 // Links.
76 rtTPGElementorHelper::links( $this );
77
78 /**
79 * Settings Tab
80 * ===========
81 */
82
83 // Field Selection.
84 rtTPGElementorHelper::field_selection( $this );
85
86 // Section Title Settings.
87 rtTPGElementorHelper::section_title_settings( $this );
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 /** Style TAB */
108
109 // Section Title Style.
110 rtTPGElementorHelper::sectionTitle( $this );
111
112 // Title Style.
113 rtTPGElementorHelper::titleStyle( $this );
114
115 // Thumbnail Style.
116 rtTPGElementorHelper::thumbnailStyle( $this );
117
118 // Content Style.
119 rtTPGElementorHelper::contentStyle( $this );
120
121 // Meta Info Style.
122 rtTPGElementorHelper::metaInfoStyle( $this );
123
124 //Social Icon Style
125 rtTPGElementorHelper::socialShareStyle( $this );
126
127 // ACF Style.
128 rtTPGElementorHelper::tpg_acf_style( $this );
129
130 // Read More Style.
131 rtTPGElementorHelper::readmoreStyle( $this );
132
133 // Link Style.
134 rtTPGElementorHelper::linkStyle( $this );
135
136 // Pagination - Load more Style.
137 rtTPGElementorHelper::paginationStyle( $this );
138
139 //Front-end Filter Style
140 rtTPGElementorHelper::frontEndFilter( $this );
141
142 // Box Settings.
143 rtTPGElementorHelper::articlBoxSettings( $this );
144
145 // Promotions.
146 rtTPGElementorHelper::promotions( $this );
147 }
148
149 protected function render() {
150 $data = $this->get_settings();
151 $_prefix = $this->prefix;
152
153 if ( ! rtTPG()->hasPro() && ! in_array(
154 $data[ $_prefix . '_layout' ],
155 [
156 'grid-layout1',
157 'grid-layout4',
158 'grid-layout3',
159 ]
160 ) ) {
161 $data[ $_prefix . '_layout' ] = 'grid-layout1';
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', [ Fns::class, 'get_modal_markup' ] );
169 }
170
171 if ( rtTPG()->hasPro() && 'button' == $data['filter_type'] && 'carousel' == $data['filter_btn_style'] ) {
172 wp_enqueue_script( 'swiper' );
173 }
174
175 if ( 'masonry' === $data['grid_layout_style'] ) {
176 wp_enqueue_script( 'rt-isotope-js' );
177 wp_enqueue_script( 'jquery-masonry' );
178 }
179
180 if ( 'show' == $data['show_pagination'] && 'pagination_ajax' == $data['pagination_type'] ) {
181 wp_enqueue_script( 'rt-pagination' );
182 }
183
184
185 // Query.
186 $query_args = rtTPGElementorQuery::post_query( $data, $_prefix );
187 $query = new WP_Query( $query_args );
188 $rand = wp_rand();
189 $layoutID = 'rt-tpg-container-' . $rand;
190 $posts_per_page = $data['display_per_page'] ? $data['display_per_page'] : $data['post_limit'];
191
192 /**
193 * TODO: Get Post Data for render post
194 */
195
196 $post_data = Fns::get_render_data_set( $data, $query->max_num_pages, $posts_per_page, $_prefix );
197
198 /**
199 * Post type render
200 */
201 $post_types = Fns::get_post_types();
202 foreach ( $post_types as $post_type => $label ) {
203 $_taxonomies = get_object_taxonomies( $post_type, 'object' );
204
205 if ( empty( $_taxonomies ) ) {
206 continue;
207 }
208
209 $post_data[ $data['post_type'] . '_taxonomy' ] = isset( $data[ $data['post_type'] . '_taxonomy' ] ) ? $data[ $data['post_type'] . '_taxonomy' ] : '';
210 $post_data[ $data['post_type'] . '_tags' ] = isset( $data[ $data['post_type'] . '_tags' ] ) ? $data[ $data['post_type'] . '_tags' ] : '';
211 }
212
213 $template_path = Fns::tpg_template_path( $post_data );
214 $_layout = $data[ $_prefix . '_layout' ];
215 $_layout_style = $data[ $_prefix . '_layout_style' ];
216 ?>
217 <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper clearfix <?php echo esc_attr( $_layout . '-main' ); ?>"
218 id="<?php echo esc_attr( $layoutID ); ?>"
219 data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>"
220 data-grid-style="<?php echo esc_attr( $data[ $_prefix . '_layout_style' ] ); ?>"
221 data-sc-id="elementor"
222 data-el-settings='<?php Fns::is_filter_enable( $data ) ? Fns::print_html( htmlspecialchars( wp_json_encode( $post_data, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES ) ), true ) : ''; ?>'
223 data-el-query='<?php Fns::is_filter_enable( $data ) ? Fns::print_html( htmlspecialchars( wp_json_encode( $query_args ) ), true ) : ''; ?>'
224 data-el-path='<?php echo Fns::is_filter_enable( $data ) ? esc_attr( $template_path ) : ''; ?>'
225 >
226
227 <?php
228 $settings = get_option( rtTPG()->options['settings'] );
229 if ( isset( $settings['tpg_load_script'] ) && isset( $settings['tpg_enable_preloader'] ) ) {
230 ?>
231 <div id="bottom-script-loader" class="bottom-script-loader">
232 <div class="rt-ball-clip-rotate">
233 <div></div>
234 </div>
235 </div>
236 <?php
237 }
238
239 $wrapper_class = [];
240 $wrapper_class[] = str_replace( '-2', '', $_layout );
241 $wrapper_class[] = 'grid-behaviour';
242 $wrapper_class[] = ( in_array( $_layout, [ 'grid-layout2' ] ) ) ? 'tpg-even' : $_layout_style;
243 $wrapper_class[] = $_prefix . '_layout_wrapper';
244
245 if ( 'masonry' === $_layout_style && in_array(
246 $_layout,
247 [
248 'grid-layout1',
249 'grid-layout3',
250 'grid-layout4',
251 ]
252 ) ) {
253 $wrapper_class[] = 'tpg-masonry';
254 }
255
256 if ( in_array( $_layout, [ 'grid-layout6', 'grid-layout6-2' ] ) && $data['middle_border'] === 'no' ) {
257 $wrapper_class[] = 'disable-middle-border';
258 }
259
260 // section title settings.
261 $is_carousel = '';
262 if ( rtTPG()->hasPro() && 'carousel' == $data['filter_btn_style'] && 'button' == $data['filter_type'] ) {
263 $is_carousel = 'carousel';
264 }
265
266 echo "<div class='tpg-header-wrapper {$is_carousel}'>";
267 Fns::get_section_title( $data );
268 Fns::print_html( Fns::get_frontend_filter_markup( $data ) );
269 echo '</div>';
270
271 ?>
272
273 <div data-title="Loading ..." class="rt-row rt-content-loader <?php echo esc_attr( implode( ' ', $wrapper_class ) ); ?>">
274 <?php
275 if ( $query->have_posts() ) {
276 $pCount = 1;
277
278 while ( $query->have_posts() ) {
279 $query->the_post();
280 set_query_var( 'tpg_post_count', $pCount );
281 set_query_var( 'tpg_total_posts', $query->post_count );
282 Fns::tpg_template( $post_data );
283 $pCount ++;
284 }
285 } else {
286 if ( $data['no_posts_found_text'] ) {
287 printf( "<div class='no_posts_found_text rt-col-xs-12'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
288 } else {
289 printf( "<div class='no_posts_found_text rt-col-xs-12'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
290 }
291 }
292 wp_reset_postdata();
293 ?>
294 </div>
295 <?php Fns::print_html( Fns::get_pagination_markup( $query, $data ) ); ?>
296
297 </div>
298 <?php
299 if ( 'masonry' === $data[ $_prefix . '_layout_style' ] && \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
300 ?>
301 <script>jQuery('.rt-row.rt-content-loader.tpg-masonry').isotope();</script>
302 <?php
303 }
304
305 do_action( 'tpg_elementor_script' );
306 }
307
308 }
309