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-archive.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-archive.php
283 lines
1 <?php
2 /**
3 * Grid 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 * Grid Layout Archive Class
17 */
18 class TPGGridLayoutArchive 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 Archive', 'the-post-grid' );
33 $this->tpg_base = 'tpg-grid-layout-archive';
34 $this->tpg_icon = 'eicon-posts-grid 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 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, 'archive' );
65
66 // Query.
67 rtTPGElementorHelper::query_builder( $this );
68
69 // Filter Settings.
70 // rtTPGElementorHelper::filter_settings( $this, 'archive' );
71
72 // Pagination Settings.
73 rtTPGElementorHelper::pagination_settings( $this, 'archive' );
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, '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 /** Style TAB */
108
109 // Section Title Style.
110 rtTPGElementorHelper::sectionTitle( $this, 'archive' );
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 Share Settings.
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 - Loadmore Style.
137 rtTPGElementorHelper::paginationStyle( $this );
138
139 // Box Settings.
140 rtTPGElementorHelper::articlBoxSettings( $this );
141
142 // Promotions.
143 rtTPGElementorHelper::promotions( $this );
144 }
145
146 protected function render() {
147 $data = $this->get_settings();
148 $_prefix = $this->prefix;
149 $data['post_type'] = 'post';
150
151 if ( ! rtTPG()->hasPro() && ! in_array( $data[ $_prefix . '_layout' ], [ 'grid-layout1', 'grid-layout2' ] ) ) {
152 $data[ $_prefix . '_layout' ] = 'grid-layout1';
153 }
154
155 if ( rtTPG()->hasPro() && ( 'popup' == $data['post_link_type'] || 'multi_popup' == $data['post_link_type'] ) ) {
156 wp_enqueue_style( 'rt-magnific-popup' );
157 wp_enqueue_script( 'rt-scrollbar' );
158 wp_enqueue_script( 'rt-magnific-popup' );
159 add_action( 'wp_footer', [ Fns::class, 'get_modal_markup' ] );
160 }
161
162 if ( 'masonry' === $data['grid_layout_style'] ) {
163 wp_enqueue_script( 'rt-isotope-js' );
164 wp_enqueue_script( 'jquery-masonry' );
165 }
166
167 if ( 'show' == $data['show_pagination'] && 'pagination_ajax' == $data['pagination_type'] ) {
168 wp_enqueue_script( 'rt-pagination' );
169 }
170
171 // Query.
172 $query_args = rtTPGElementorQuery::post_query_builder( $data, $_prefix );
173 $query = new WP_Query( $query_args );
174 $rand = wp_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
182 $post_data = Fns::get_render_data_set( $data, $query->max_num_pages, $posts_per_page, $_prefix );
183
184
185 /**
186 * Post type render
187 */
188 $post_types = Fns::get_post_types();
189
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 $template_path = Fns::tpg_template_path( $post_data );
202 $_layout = $data[ $_prefix . '_layout' ];
203 $_layout_style = $data[ $_prefix . '_layout_style' ];
204
205 ?>
206
207 <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper clearfix <?php echo esc_attr( $_layout . '-main' ); ?>"
208 id="<?php echo esc_attr( $layoutID ); ?>"
209 data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>"
210 data-grid-style="<?php echo esc_attr( $data[ $_prefix . '_layout_style' ] ); ?>"
211 data-sc-id="elementor"
212 data-el-settings='<?php Fns::print_html( htmlspecialchars( wp_json_encode( $post_data, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES ) ), true ); ?>'
213 data-el-query='<?php Fns::print_html( htmlspecialchars( wp_json_encode( $query_args ) ), true ); ?>'
214 data-el-path='<?php echo esc_attr( $template_path ); ?>'
215 >
216 <?php
217
218 $settings = get_option( rtTPG()->options['settings'] );
219 if ( isset( $settings['tpg_load_script'] ) && isset( $settings['tpg_enable_preloader'] ) ) {
220 ?>
221 <div id="bottom-script-loader" class="bottom-script-loader">
222 <div class="rt-ball-clip-rotate">
223 <div></div>
224 </div>
225 </div>
226 <?php
227 }
228
229 $wrapper_class = [];
230 $wrapper_class[] = str_replace( '-2', null, $_layout );
231 $wrapper_class[] = 'grid-behaviour';
232 $wrapper_class[] = ( in_array( $_layout, [ 'grid-layout2' ] ) ) ? 'tpg-even' : $_layout_style;
233 $wrapper_class[] = $_prefix . '_layout_wrapper';
234
235 if ( 'masonry' === $_layout_style && ! in_array( $_layout, [ $this->prefix . '-layout2', $this->prefix . '-layout5', $this->prefix . '-layout6' ] ) ) {
236 $wrapper_class[] = 'tpg-masonry';
237 }
238
239 // section title settings.
240 echo "<div class='tpg-header-wrapper '>";
241 Fns::get_section_title( $data );
242 echo "</div>";
243
244 ?>
245
246 <div data-title="Loading ..." class="rt-row rt-content-loader <?php echo esc_attr( implode( ' ', $wrapper_class ) ); ?>">
247 <?php
248 if ( $query->have_posts() ) {
249 $pCount = 1;
250
251 while ( $query->have_posts() ) {
252 $query->the_post();
253 set_query_var( 'tpg_post_count', $pCount );
254 set_query_var( 'tpg_total_posts', $query->post_count );
255 Fns::tpg_template( $post_data );
256 $pCount ++;
257 // rtTPGElementorHelper::tpg_template($data, $this->tpg_dir);
258 }
259 } else {
260 if ( $data['no_posts_found_text'] ) {
261 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
262 } else {
263 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
264 }
265 }
266 wp_reset_postdata();
267 ?>
268 </div>
269
270 <?php Fns::print_html( Fns::get_pagination_markup( $query, $data ) ); ?>
271 </div>
272
273 <?php
274 if ( 'masonry' === $data[ $_prefix . '_layout_style' ] && \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
275 ?>
276 <script>jQuery('.rt-row.rt-content-loader.tpg-masonry').isotope();</script>
277 <?php
278 }
279 do_action( 'tpg_elementor_script' );
280 }
281
282 }
283