PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 5.0.3
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v5.0.3
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 / Controllers / Blocks / GridHoverLayout.php
the-post-grid / app / Controllers / Blocks Last commit date
BlockController 3 years ago BlockBase.php 3 years ago GridHoverLayout.php 3 years ago GridLayout.php 3 years ago ListLayout.php 3 years ago
GridHoverLayout.php
212 lines
1 <?php
2
3 namespace RT\ThePostGrid\Controllers\Blocks;
4
5 use RT\ThePostGrid\Controllers\Blocks\BlockController\SettingsTabController;
6 use RT\ThePostGrid\Controllers\Blocks\BlockController\StyleTabController;
7 use RT\ThePostGrid\Controllers\Blocks\BlockController\ContentTabController;
8 use RT\ThePostGrid\Helpers\Fns;
9
10 class GridHoverLayout extends BlockBase {
11
12 private $prefix;
13 private $attribute_args;
14 private $block_type;
15
16 public function __construct() {
17 add_action( 'init', [ $this, 'register_blocks' ] );
18 $this->prefix = 'grid_hover';
19 $this->block_type = 'rttpg/tpg-grid-hover-layout';
20 $this->attribute_args = [
21 'prefix' => $this->prefix,
22 'default_layout' => 'grid_hover-layout1'
23 ];
24 }
25
26 /**
27 * Register Block
28 * @return void
29 */
30 public function register_blocks() {
31 if ( ! function_exists( 'register_block_type' ) ) {
32 return;
33 }
34 register_block_type(
35 $this->block_type,
36 [
37 'attributes' => $this->get_attributes(),
38 'render_callback' => [ $this, 'render_block' ],
39 ]
40 );
41 }
42
43 /**
44 * Get attributes
45 *
46 * @param bool $default
47 *
48 * @return array
49 */
50 public function get_attributes() {
51
52 /**
53 * All Attribute
54 * Content Tab | Settings Tab | Style Tab
55 */
56 $content_attribute = ContentTabController::get_controller( $this->attribute_args );
57 $settings_attribute = SettingsTabController::get_controller();
58 $style_attribute = StyleTabController::get_controller();
59
60 return array_merge( $content_attribute, $settings_attribute, $style_attribute );
61 }
62
63 /**
64 * @param array $data
65 *
66 * @return false|string
67 */
68 public function render_block( $data ) {
69
70 $this->get_script_depends( $data );
71
72 $_prefix = $data['prefix'];
73
74 if ( ! rtTPG()->hasPro() && ! in_array(
75 $data[ $_prefix . '_layout' ],
76 [
77 'grid_hover-layout1',
78 'grid_hover-layout2',
79 'grid_hover-layout3',
80 ]
81 ) ) {
82 $data[ $_prefix . '_layout' ] = 'grid_hover-layout1';
83 }
84
85 //Query
86 $query_args = $this->post_query_guten( $data, $_prefix );
87 $query = new \WP_Query( $query_args );
88 $rand = mt_rand();
89 $layoutID = "rt-tpg-container-" . $rand;
90 $posts_per_page = $data['display_per_page'] ? $data['display_per_page'] : $data['post_limit'];
91
92 /**
93 * TODO: Get Post Data for render post
94 */
95
96 $post_data = Fns::get_render_data_set( $data, $query->max_num_pages, $posts_per_page, $_prefix, 'yes' );
97
98 /**
99 * Post type render
100 */
101
102 //TODO: Taxonomy filter ================================================
103 /*
104 $post_types = Fns::get_post_types();
105 foreach ( $post_types as $post_type => $label ) {
106 $_taxonomies = get_object_taxonomies( $post_type, 'object' );
107 if ( empty( $_taxonomies ) ) {
108 continue;
109 }
110 $post_data[ $data['post_type'] . '_taxonomy' ] = $data[ $data['post_type'] . '_taxonomy' ];
111 $post_data[ $data['post_type'] . '_tags' ] = $data[ $data['post_type'] . '_tags' ];
112 }
113 */
114
115
116 $template_path = Fns::tpg_template_path( $post_data, 'gutenberg' );
117 $_layout = $data[ $_prefix . '_layout' ];
118 $dynamicClass = Fns::get_dynamic_class_gutenberg( $data );
119
120
121 ob_start();
122 ?>
123 <div class="<?php echo esc_attr( $dynamicClass ) ?>">
124 <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper clearfix <?php echo esc_attr( $_layout . '-main' ); ?>"
125 id="<?php echo esc_attr( $layoutID ); ?>"
126 data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>"
127 data-grid-style="<?php echo esc_attr( $data['grid_layout_style'] ); ?>" data-sc-id="elementor"
128 data-el-settings='<?php echo Fns::is_filter_enable( $data ) ? htmlspecialchars( wp_json_encode( $post_data ) ) : ''; ?>'
129 data-el-query='<?php echo Fns::is_filter_enable( $data ) ? htmlspecialchars( wp_json_encode( $query_args ) ) : ''; ?>'
130 data-el-path='<?php echo Fns::is_filter_enable( $data ) ? esc_attr( $template_path ) : ''; ?>'>
131 <?php
132
133 $settings = get_option( rtTPG()->options['settings'] );
134 if ( isset( $settings['tpg_load_script'] ) && isset( $settings['tpg_enable_preloader'] ) ) {
135 ?>
136 <div id="bottom-script-loader" class="bottom-script-loader">
137 <div class="rt-ball-clip-rotate">
138 <div></div>
139 </div>
140 </div>
141 <?php
142 }
143
144 $wrapper_class = [];
145 if ( in_array(
146 $_layout,
147 [
148 'grid_hover-layout6',
149 'grid_hover-layout7',
150 'grid_hover-layout8',
151 'grid_hover-layout9',
152 'grid_hover-layout10',
153 'grid_hover-layout11',
154 'grid_hover-layout5-2',
155 'grid_hover-layout6-2',
156 'grid_hover-layout7-2',
157 'grid_hover-layout9-2',
158 ]
159 ) ) {
160 $wrapper_class[] = 'grid_hover-layout5';
161 }
162 $wrapper_class[] = str_replace( '-2', null, $_layout );
163 $wrapper_class[] = 'tpg-even grid-behaviour';
164 $wrapper_class[] = $_prefix . '_layout_wrapper';
165
166 //section title settings
167 $is_carousel = '';
168 if ( rtTPG()->hasPro() && 'carousel' == $data['filter_btn_style'] && 'button' == $data['filter_type'] ) {
169 $is_carousel = 'carousel';
170 }
171
172 echo "<div class='tpg-header-wrapper {$is_carousel}'>";
173 Fns::get_section_title( $data );
174 Fns::print_html( Fns::get_frontend_filter_markup( $data, true ) );
175 echo "</div>";
176 ?>
177
178 <div class="rt-row rt-content-loader gutenberg-inner <?php echo esc_attr( implode( ' ', $wrapper_class ) ) ?>">
179 <?php
180 if ( $query->have_posts() ) {
181 $pCount = 1;
182 while ( $query->have_posts() ) {
183 $query->the_post();
184 set_query_var( 'tpg_post_count', $pCount );
185 set_query_var( 'tpg_total_posts', $query->post_count );
186 Fns::tpg_template( $post_data, 'gutenberg' );
187 $pCount ++;
188 }
189 } else {
190 if ( $data['no_posts_found_text'] ) {
191 printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) );
192 } else {
193 printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) );
194 }
195 }
196 wp_reset_postdata();
197 ?>
198 </div>
199
200 <?php echo Fns::get_pagination_markup( $query, $data ); ?>
201
202 </div>
203 </div>
204 <?php
205
206 do_action( 'tpg_elementor_script' );
207
208 return ob_get_clean();
209 }
210
211
212 }