PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / post-grid / post-grid.php
elementskit-lite / widgets / post-grid Last commit date
post-grid-handler.php 6 months ago post-grid.php 3 weeks ago
post-grid.php
302 lines
1 <?php
2 namespace Elementor;
3
4 use \Elementor\ElementsKit_Widget_Post_Grid_Handler as Handler;
5 use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9 class ElementsKit_Widget_Post_Grid extends Widget_Base {
10 use \ElementsKit_Lite\Widgets\Widget_Notice;
11
12 public $base;
13
14 public function get_name() {
15 return Handler::get_name();
16 }
17
18 public function get_title() {
19 return Handler::get_title();
20 }
21
22 public function get_icon() {
23 return Handler::get_icon();
24 }
25
26 public function get_keywords() {
27 return Handler::get_keywords();
28 }
29
30 public function get_categories() {
31 return Handler::get_categories();
32 }
33
34 public function get_help_url() {
35 return 'https://wpmet.com/doc/post-grid/';
36 }
37
38 public function get_style_depends() {
39 return ['ekit-post-tab' , 'ekit-post-grid'];
40 }
41
42 protected function is_dynamic_content(): bool {
43 return false;
44 }
45
46 protected function register_controls() {
47
48 $this->start_controls_section(
49 'content_tab',
50 [
51 'label' => esc_html__('Widget settings', 'elementskit-lite'),
52 'tab' => Controls_Manager::TAB_CONTENT,
53 ]
54 );
55
56 $this->add_control(
57 'post_cat',
58 [
59 'label' =>esc_html__('Select Categories', 'elementskit-lite'),
60 'type' => ElementsKit_Controls_Manager::AJAXSELECT2,
61 'description' => esc_html__('To avail this option you need to set/add a featured image to posts..', 'elementskit-lite'),
62 'options' =>'ajaxselect2/category',
63 'label_block' => true,
64 'multiple' => true,
65 ]
66 );
67 $this->add_control(
68 'post_count',
69 [
70 'label' => esc_html__( 'Post count', 'elementskit-lite' ),
71 'type' => Controls_Manager::NUMBER,
72 'default' => esc_html__( '3', 'elementskit-lite' )
73 ]
74 );
75
76 $this->add_responsive_control(
77 'count_col',
78 [
79 'label' => esc_html__( 'Select Column', 'elementskit-lite' ),
80 'type' => Controls_Manager::SELECT,
81 'default' => 'ekit___column-2',
82 'tablet_default' => 'ekit___column-2',
83 'mobile_default' => 'ekit___column-2',
84 'options' => [
85 'ekit___column-2' => esc_html__( '2 Column', 'elementskit-lite' ),
86 'ekit___column-3' => esc_html__( '3 Column', 'elementskit-lite' ),
87 'ekit___column-4' => esc_html__( '4 Column', 'elementskit-lite' ),
88 ],
89 ]
90 );
91
92 $this->add_control(
93 'ekit_post_grid_title_word_wrap',
94 [
95 'label' => esc_html__( 'Word Wrap', 'elementskit-lite' ),
96 'type' => Controls_Manager::SWITCHER,
97 'label_on' => esc_html__( 'Show', 'elementskit-lite' ),
98 'label_off' => esc_html__( 'Hide', 'elementskit-lite' ),
99 'return_value' => 'yes',
100 'default' => 'no',
101 'selectors' => [
102 '{{WRAPPER}} .ekit-post_grid-title' => 'white-space: nowrap; overflow: hidden; text-overflow: ellipsis;',
103 ],
104 ]
105 );
106
107 $this->end_controls_section();
108
109 // Style
110 $this->start_controls_section(
111 'style_tab',
112 [
113 'label' => esc_html__( 'Grid Styles', 'elementskit-lite' ),
114 'tab' => Controls_Manager::TAB_STYLE
115 ]
116 );
117
118 $this->add_responsive_control(
119 'post_grid_item_height',
120 [
121 'label' => esc_html__( 'Use Fixed Height', 'elementskit-lite' ),
122 'type' => Controls_Manager::SLIDER,
123 'size_units' => [ 'px' ],
124 'range' => [
125 'px' => [
126 'min' => 30,
127 'max' => 1000,
128 'step' => 1,
129 ]
130 ],
131 'devices' => [ 'desktop', 'tablet', 'mobile' ],
132 'desktop_default' => [
133 'size' => 350,
134 'unit' => 'px',
135 ],
136 'tablet_default' => [
137 'size' => 200,
138 'unit' => 'px',
139 ],
140 'mobile_default' => [
141 'size' => 150,
142 'unit' => 'px',
143 ],
144 'selectors' => [
145 '{{WRAPPER}} .post_grid_img_thumb' => 'height: {{SIZE}}{{UNIT}};',
146 ],
147 ]
148 );
149
150 $this->add_control(
151 'bottom_space',
152 [
153 'label' => esc_html__( 'Bottom Space', 'elementskit-lite' ),
154 'type' => Controls_Manager::SLIDER,
155 'size_units' => [ 'px' ],
156 'range' => [
157 'px' => [
158 'min' => 10,
159 'max' => 100,
160 'step' => 1,
161 ]
162 ],
163 'selectors' => [
164 '{{WRAPPER}} .tab__post__single--item' => 'margin-bottom: {{SIZE}}{{UNIT}};',
165 ],
166 ]
167 );
168
169 $this->end_controls_section();
170
171
172 $this->start_controls_section(
173 'title_style',
174 [
175 'label' => esc_html__( 'Title', 'elementskit-lite' ),
176 'tab' => Controls_Manager::TAB_STYLE
177 ]
178 );
179 $this->add_group_control(
180 Group_Control_Typography::get_type(),
181 [
182 'name' => 'title_font',
183 'label' => esc_html__( 'Typography', 'elementskit-lite' ),
184 'selector' => '{{WRAPPER}} .ekit-post_grid-title',
185 ]
186 );
187
188 $this->start_controls_tabs(
189 'title_style_tabs'
190 );
191
192 $this->add_control(
193 'title_color_normal',
194 [
195 'label' => esc_html__( 'Color', 'elementskit-lite' ),
196 'type' => Controls_Manager::COLOR,
197 'default' => 'inherit',
198 'selectors' => [
199 '{{WRAPPER}} .tab__post__single--item .ekit-post_grid-title > a' => 'color: {{VALUE}}; transition: all 0.3s ease;',
200 ],
201 ]
202 );
203 $this->add_control(
204 'title_color_hover',
205 [
206 'label' => esc_html__( 'Hover Color', 'elementskit-lite' ),
207 'type' => Controls_Manager::COLOR,
208 'selectors' => [
209 '{{WRAPPER}} .tab__post__single--item:hover .ekit-post_grid-title > a' => 'color: {{VALUE}}',
210 ],
211 ]
212 );
213
214 $this->add_responsive_control(
215 'ekit-post_grid-title_margin',
216 [
217 'label' => esc_html__( 'Margin', 'elementskit-lite' ),
218 'type' => Controls_Manager::DIMENSIONS,
219 'size_units' => [ 'px', '%', 'em' ],
220 'selectors' => [
221 '{{WRAPPER}} .ekit-post_grid-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
222 ],
223 ]
224 );
225
226 $this->end_controls_section();
227 $this->insert_pro_message();
228 }
229
230 protected function render( ) {
231 echo '<div class="ekit-wid-con" >';
232 $this->render_raw();
233 echo '</div>';
234 }
235
236 protected function render_raw( ) {
237 $settings = $this->get_settings();
238
239 extract($settings);
240
241 $query = array(
242 'post_type' => 'post',
243 'post_status' => 'publish',
244 'cat' => $post_cat,
245 'posts_per_page' => $post_count,
246 );
247
248 $tablet_responsive_class = isset($settings['count_col_tablet']) ? $settings['count_col_tablet'] : 'ekit___column-2';
249 $mobile_responsive_class = isset($settings['count_col_mobile']) ? $settings['count_col_mobile'] : 'ekit___column-2';
250
251 $this->add_render_attribute(
252 [
253 'ekit-single-item' => [
254 'class' => [
255 'tab__post__single--item',
256 $count_col,
257 'tablet-' . $tablet_responsive_class,
258 'mobile-' . $mobile_responsive_class,
259 'post-count-' . $post_count
260 ],
261 ],
262 ]
263 );
264
265 ?>
266
267 <div class="ekit--tab__post__details ekit-post_grid">
268 <?php $xs_query = new \WP_Query( $query ); ?>
269 <?php if($xs_query->have_posts()): ?>
270 <?php while ($xs_query->have_posts()) : ?>
271 <?php $xs_query->the_post(); ?>
272 <?php if(has_post_thumbnail()): ?>
273 <div <?php echo $this->get_render_attribute_string('ekit-single-item'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped by elementor ?>>
274 <a href="<?php echo esc_url(get_the_permalink()); ?>" class="tab__post--header" aria-label="<?php echo esc_attr( get_the_title() ); ?>">
275 <?php
276 echo get_the_post_thumbnail(
277 get_the_ID(),
278 'medium',
279 [
280 'class' => 'post_grid_img_thumb',
281 'style' => 'display: block; width: 100%; object-fit: cover;',
282 ]
283 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Generated and escaped by WordPress.
284 ?>
285 <?php if(get_post_format() == 'video') : ?>
286 <div class="tab__post--icon">
287 <span class="fa fa-play-circle-o"></span>
288 </div>
289 <?php endif; ?>
290 </a>
291 <h3 class="tab__post--title ekit-post_grid-title"><a href="<?php echo esc_url(get_the_permalink()); ?>"><?php the_title(); ?></a></h3>
292 </div>
293 <?php endif; ?>
294
295 <?php endwhile;
296 endif;
297 wp_reset_postdata(); ?>
298 </div>
299 <?php
300 }
301 }
302