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 / grid-layout.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
grid-layout.php
305 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
41 array_push( $scripts, 'imagesloaded' );
42 array_push( $scripts, 'rt-tpg' );
43 array_push( $scripts, 'rt-tpg-el-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-tpg-elementor' );
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 // Box 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 // Box 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', [ $this, '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 // Query.
185 $query_args = rtTPGElementorQuery::post_query( $data, $_prefix );
186 $query = new WP_Query( $query_args );
187 $rand = wp_rand();
188 $layoutID = 'rt-tpg-container-' . $rand;
189 $posts_per_page = $data['display_per_page'] ? $data['display_per_page'] : $data['post_limit'];
190
191 /**
192 * TODO: Get Post Data for render post
193 */
194 $post_data = $this->get_render_data_set( $data, $query->max_num_pages, $posts_per_page );
195
196 /**
197 * Post type render
198 */
199 $post_types = Fns::get_post_types();
200 foreach ( $post_types as $post_type => $label ) {
201 $_taxonomies = get_object_taxonomies( $post_type, 'object' );
202
203 if ( empty( $_taxonomies ) ) {
204 continue;
205 }
206
207 $post_data[ $data['post_type'] . '_taxonomy' ] = isset( $data[ $data['post_type'] . '_taxonomy' ] ) ? $data[ $data['post_type'] . '_taxonomy' ] : '';
208 $post_data[ $data['post_type'] . '_tags' ] = isset( $data[ $data['post_type'] . '_tags' ] ) ? $data[ $data['post_type'] . '_tags' ] : '';
209 }
210
211 $template_path = $this->tpg_template_path( $post_data );
212 $_layout = $data[ $_prefix . '_layout' ];
213 $_layout_style = $data[ $_prefix . '_layout_style' ];
214
215 ?>
216 <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper clearfix <?php echo esc_attr( $_layout . '-main' ); ?>"
217 id="<?php echo esc_attr( $layoutID ); ?>"
218 data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>"
219 data-grid-style="<?php echo esc_attr( $data[ $_prefix . '_layout_style' ] ); ?>"
220 data-sc-id="elementor"
221 data-el-settings='<?php Fns::is_filter_enable( $data ) ? Fns::print_html( htmlspecialchars( wp_json_encode( $post_data ) ), true ) : ''; ?>'
222 data-el-query='<?php Fns::is_filter_enable( $data ) ? Fns::print_html( htmlspecialchars( wp_json_encode( $query_args ) ), true ) : ''; ?>'
223 data-el-path='<?php echo Fns::is_filter_enable( $data ) ? esc_attr( $template_path ) : ''; ?>'
224 >
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 // section title settings.
257 $is_carousel = '';
258 if ( rtTPG()->hasPro() && 'carousel' == $data['filter_btn_style'] && 'button' == $data['filter_type'] ) {
259 $is_carousel = 'carousel';
260 }
261
262 echo "<div class='tpg-header-wrapper {$is_carousel}'>";
263 $this->get_section_title( $data );
264 Fns::print_html( $this->get_frontend_filter_markup( $data ) );
265 echo '</div>';
266 ?>
267
268 <div data-title="Loading ..." class="rt-row rt-content-loader <?php echo esc_attr( implode( ' ', $wrapper_class ) ); ?>">
269 <?php
270 if ( $query->have_posts() ) {
271 $pCount = 1;
272
273 while ( $query->have_posts() ) {
274 $query->the_post();
275 set_query_var( 'tpg_post_count', $pCount );
276 set_query_var( 'tpg_total_posts', $query->post_count );
277 $this->tpg_template( $post_data );
278 $pCount ++;
279 }
280 } else {
281 if ( $data['no_posts_found_text'] ) {
282 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
283 } else {
284 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
285 }
286 }
287 wp_reset_postdata();
288 ?>
289 </div>
290
291 <?php Fns::print_html( $this->get_pagination_markup( $query, $data ) ); ?>
292
293 </div>
294 <?php
295 if ( 'masonry' === $data[ $_prefix . '_layout_style' ] && \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
296 ?>
297 <script>jQuery( '.rt-row.rt-content-loader.tpg-masonry' ).isotope();</script>
298 <?php
299 }
300
301 do_action( 'tpg_elementor_script' );
302 }
303
304 }
305