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