PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
← All changes | includes/widgets/post-grid.php +226 -240 1.0.71.3.17 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements;
3 4
4 5 use Elementor\Controls_Manager;
5 6 use Elementor\Group_Control_Border;
@@ -17,10 +18,12 @@
17 18
18 19 defined('ABSPATH') || exit();
19 20
20 21 /**
21 - * Scripts and Styles Class
22 + * Post Grid
23 + *
22 24 */
25 +
23 26 class PostGrid extends UiCoreWidget
24 27 {
25 28 private $_query;
26 29
@@ -49,14 +52,31 @@
49 52 return ['post', 'grid', 'blog', 'recent', 'news'];
50 53 }
51 54 public function get_styles()
52 55 {
53 - return [];
56 + return [
57 + 'post-grid',
58 + // get framework assets
59 + 'uicore-blog-st' => [
60 + 'external' => true,
61 + ],
62 + 'uicore-portfolio-st' => [
63 + 'external' => true,
64 + 'condition' => [
65 + 'posts-filter_post_type' => 'portfolio',
66 + ]
67 + ]
68 + ];
54 69 }
55 70 public function get_scripts()
56 71 {
57 72 return [];
58 73 }
74 + public function has_widget_inner_wrapper(): bool
75 + {
76 + // TODO: remove after Optmized Markup experiment is merged to the core
77 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
78 + }
59 79
60 80 public function on_import($element)
61 81 {
62 82 if (!get_post_type_object($element['settings']['posts-filter_post_type'])) {
@@ -124,236 +144,236 @@
124 144 $this->start_controls_section('section_post_grid_layout', [
125 145 'label' => esc_html__('Layout', 'uicore-elements'),
126 146 ]);
127 147 $this->add_control(
128 - 'layout',
129 - [
130 - 'label' => __( 'Item Style', 'uicore-elements' ),
131 - 'type' => Controls_Manager::SELECT,
132 - 'default' => 'default',
133 - 'options' => [
134 - 'default' => __( 'Default', 'uicore-elements' ),
135 - 'classic' => __( 'classic', 'uicore-elements' ),
136 - 'grid' => __( 'Grid', 'uicore-elements' ),
137 - 'horizontal' => __( 'Horizontal', 'uicore-elements' ),
138 - 'masonry' => __( 'Masonry', 'uicore-elements' ),
139 - ],
148 + 'layout',
149 + [
150 + 'label' => __('Item Style', 'uicore-elements'),
151 + 'type' => Controls_Manager::SELECT,
152 + 'default' => 'default',
153 + 'options' => [
154 + 'default' => __('Default', 'uicore-elements'),
155 + 'classic' => __('classic', 'uicore-elements'),
156 + 'grid' => __('Grid', 'uicore-elements'),
157 + 'horizontal' => __('Horizontal', 'uicore-elements'),
158 + 'masonry' => __('Masonry', 'uicore-elements'),
159 + ],
140 160 'condition' => array(
141 161 'posts-filter_post_type!' => 'portfolio',
142 162 ),
143 - ]
144 - );
163 + ]
164 + );
145 165
146 166 $this->add_control(
147 - 'box_style',
148 - [
149 - 'label' => __( 'layout', 'uicore-elements' ),
150 - 'type' => Controls_Manager::SELECT,
151 - 'default' => 'default',
152 - 'options' => [
153 - 'default' => __( 'Default', 'uicore-elements' ),
154 - 'boxed' => __( 'Boxed', 'uicore-elements' ),
155 - 'boxed-creative' => __( 'Boxed Creative', 'uicore-elements' ),
156 - 'cover' => __( 'Cover', 'uicore-elements' ),
157 - ],
167 + 'box_style',
168 + [
169 + 'label' => __('layout', 'uicore-elements'),
170 + 'type' => Controls_Manager::SELECT,
171 + 'default' => 'default',
172 + 'options' => [
173 + 'default' => __('Default', 'uicore-elements'),
174 + 'boxed' => __('Boxed', 'uicore-elements'),
175 + 'boxed-creative' => __('Boxed Creative', 'uicore-elements'),
176 + 'cover' => __('Cover', 'uicore-elements'),
177 + ],
158 178 'condition' => array(
159 179 'posts-filter_post_type!' => 'portfolio',
160 180 ),
161 - ]
162 - );
181 + ]
182 + );
163 183
164 184 $this->add_control(
165 - 'box_ratio',
166 - [
167 - 'label' => __( 'Image Ratio', 'uicore-elements' ),
168 - 'type' => Controls_Manager::SELECT,
169 - 'default' => 'default',
170 - 'options' => [
171 - 'default' => __( 'Default', 'uicore-elements' ),
172 - 'square' => __( 'Square', 'uicore-elements' ),
173 - 'landscape' => __( 'Landscape', 'uicore-elements' ),
174 - 'portrait' => __( 'Portrait', 'uicore-elements' ),
175 - ],
185 + 'box_ratio',
186 + [
187 + 'label' => __('Image Ratio', 'uicore-elements'),
188 + 'type' => Controls_Manager::SELECT,
189 + 'default' => 'default',
190 + 'options' => [
191 + 'default' => __('Default', 'uicore-elements'),
192 + 'square' => __('Square', 'uicore-elements'),
193 + 'landscape' => __('Landscape', 'uicore-elements'),
194 + 'portrait' => __('Portrait', 'uicore-elements'),
195 + ],
176 196 'condition' => array(
177 197 'posts-filter_post_type!' => 'portfolio',
178 198 ),
179 - ]
180 - );
199 + ]
200 + );
181 201 $this->add_control(
182 - 'extra_author',
183 - [
184 - 'label' => __( 'Author', 'uicore-elements' ),
185 - 'type' => Controls_Manager::SWITCHER,
186 - 'return_value' => 'yes',
187 - 'default' => '',
202 + 'extra_author',
203 + [
204 + 'label' => __('Author', 'uicore-elements'),
205 + 'type' => Controls_Manager::SWITCHER,
206 + 'return_value' => 'yes',
207 + 'default' => '',
188 208 'reder_type' => 'template',
189 - 'condition' => array(
209 + 'condition' => array(
190 210 'posts-filter_post_type!' => 'portfolio',
191 211 ),
192 - ]
193 - );
212 + ]
213 + );
194 214 $this->add_control(
195 - 'extra_date',
196 - [
197 - 'label' => __( 'Date', 'uicore-elements' ),
198 - 'type' => Controls_Manager::SWITCHER,
199 - 'return_value' => 'yes',
200 - 'default' => '',
215 + 'extra_date',
216 + [
217 + 'label' => __('Date', 'uicore-elements'),
218 + 'type' => Controls_Manager::SWITCHER,
219 + 'return_value' => 'yes',
220 + 'default' => '',
201 221 'reder_type' => 'template',
202 - 'condition' => array(
222 + 'condition' => array(
203 223 'posts-filter_post_type!' => 'portfolio',
204 224 ),
205 - ]
206 - );
225 + ]
226 + );
207 227 $this->add_control(
208 - 'extra_excerpt',
209 - [
210 - 'label' => __( 'Excerpt', 'uicore-elements' ),
211 - 'type' => Controls_Manager::SWITCHER,
212 - 'return_value' => 'yes',
213 - 'default' => '',
228 + 'extra_excerpt',
229 + [
230 + 'label' => __('Excerpt', 'uicore-elements'),
231 + 'type' => Controls_Manager::SWITCHER,
232 + 'return_value' => 'yes',
233 + 'default' => '',
214 234 'reder_type' => 'template',
215 - 'condition' => array(
235 + 'condition' => array(
216 236 'posts-filter_post_type!' => 'portfolio',
217 237 ),
218 - ]
219 - );
238 + ]
239 + );
220 240 $this->add_control(
221 - 'extra_category',
222 - [
223 - 'label' => __( 'Category', 'uicore-elements' ),
224 - 'type' => Controls_Manager::SWITCHER,
225 - 'return_value' => 'yes',
226 - 'default' => '',
241 + 'extra_category',
242 + [
243 + 'label' => __('Category', 'uicore-elements'),
244 + 'type' => Controls_Manager::SWITCHER,
245 + 'return_value' => 'yes',
246 + 'default' => '',
227 247 'reder_type' => 'template',
228 - 'condition' => array(
248 + 'condition' => array(
229 249 'posts-filter_post_type!' => 'portfolio',
230 250 ),
231 - ]
232 - );
251 + ]
252 + );
233 253
234 254 $this->end_controls_section();
235 255
236 256
237 257 $this->start_controls_section(
238 - 'section_style_typo',
239 - [
240 - 'label' => __( 'Content Style', 'uicore-elements' ),
241 - 'tab' => Controls_Manager::TAB_STYLE,
242 - ]
243 - );
258 + 'section_style_typo',
259 + [
260 + 'label' => __('Content Style', 'uicore-elements'),
261 + 'tab' => Controls_Manager::TAB_STYLE,
262 + ]
263 + );
244 264
245 265 $this->add_control(
246 - 'post_heading_title',
247 - [
248 - 'label' => esc_html__( 'Post Title', 'uicore-elements' ),
249 - 'type' => Controls_Manager::HEADING,
250 - 'separator' => 'before',
251 - ]
252 - );
266 + 'post_heading_title',
267 + [
268 + 'label' => esc_html__('Post Title', 'uicore-elements'),
269 + 'type' => Controls_Manager::HEADING,
270 + 'separator' => 'before',
271 + ]
272 + );
253 273
254 - $this->add_control(
255 - 'post_title_color',
256 - [
257 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
258 - 'type' => Controls_Manager::COLOR,
259 - 'default' => '',
260 - 'selectors' => [
261 - '{{WRAPPER}} .uicore-post-title' => 'color: {{VALUE}};',
262 - ],
263 - ]
264 - );
274 + $this->add_control(
275 + 'post_title_color',
276 + [
277 + 'label' => esc_html__('Color', 'uicore-elements'),
278 + 'type' => Controls_Manager::COLOR,
279 + 'default' => '',
280 + 'selectors' => [
281 + '{{WRAPPER}} .uicore-post-title' => 'color: {{VALUE}};',
282 + ],
283 + ]
284 + );
265 285
266 - $this->add_group_control(
267 - Group_Control_Typography::get_type(),
268 - [
269 - 'name' => 'post_title_typography',
270 - 'selector' => '{{WRAPPER}} .uicore-post-title, {{WRAPPER}} .uicore-post-title',
271 - ]
272 - );
286 + $this->add_group_control(
287 + Group_Control_Typography::get_type(),
288 + [
289 + 'name' => 'post_title_typography',
290 + 'selector' => '{{WRAPPER}} .uicore-post-title, {{WRAPPER}} .uicore-post-title',
291 + ]
292 + );
273 293
274 294
275 - $this->add_control(
276 - 'extra_excerpt_heading',
277 - [
278 - 'label' => esc_html__( 'Excerpt', 'uicore-elements' ),
279 - 'type' => Controls_Manager::HEADING,
280 - 'separator' => 'before',
281 - ]
282 - );
295 + $this->add_control(
296 + 'extra_excerpt_heading',
297 + [
298 + 'label' => esc_html__('Excerpt', 'uicore-elements'),
299 + 'type' => Controls_Manager::HEADING,
300 + 'separator' => 'before',
301 + ]
302 + );
283 303 $this->add_responsive_control(
284 - 'extra_excerpt_bottom_space',
285 - [
286 - 'label' => esc_html__( 'Spacing', 'uicore-elements' ),
287 - 'type' => Controls_Manager::SLIDER,
288 - 'range' => [
289 - 'px' => [
290 - 'min' => 0,
291 - 'max' => 100,
292 - ],
293 - ],
294 - 'selectors' => [
295 - '{{WRAPPER}} .uicore-post-info-wrapper > p' => 'margin-top: {{SIZE}}{{UNIT}};',
296 - ],
297 - ]
298 - );
304 + 'extra_excerpt_bottom_space',
305 + [
306 + 'label' => esc_html__('Spacing', 'uicore-elements'),
307 + 'type' => Controls_Manager::SLIDER,
308 + 'range' => [
309 + 'px' => [
310 + 'min' => 0,
311 + 'max' => 100,
312 + ],
313 + ],
314 + 'selectors' => [
315 + '{{WRAPPER}} .uicore-post-info-wrapper > p' => 'margin-top: {{SIZE}}{{UNIT}};',
316 + ],
317 + ]
318 + );
299 319
300 - $this->add_control(
301 - 'extra_excerpt_color',
302 - [
303 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
304 - 'type' => Controls_Manager::COLOR,
305 - 'default' => '',
306 - 'selectors' => [
307 - '{{WRAPPER}} .uicore-post-info-wrapper > p' => 'color: {{VALUE}};',
308 - ],
309 - ]
310 - );
320 + $this->add_control(
321 + 'extra_excerpt_color',
322 + [
323 + 'label' => esc_html__('Color', 'uicore-elements'),
324 + 'type' => Controls_Manager::COLOR,
325 + 'default' => '',
326 + 'selectors' => [
327 + '{{WRAPPER}} .uicore-post-info-wrapper > p' => 'color: {{VALUE}};',
328 + ],
329 + ]
330 + );
311 331
312 - $this->add_group_control(
313 - Group_Control_Typography::get_type(),
314 - [
315 - 'name' => 'extra_excerpt_typography',
316 - 'selector' => '{{WRAPPER}} .uicore-post-info-wrapper > p',
317 - ]
318 - );
332 + $this->add_group_control(
333 + Group_Control_Typography::get_type(),
334 + [
335 + 'name' => 'extra_excerpt_typography',
336 + 'selector' => '{{WRAPPER}} .uicore-post-info-wrapper > p',
337 + ]
338 + );
319 339
320 340
321 341 $this->add_responsive_control(
322 - 'box_padding',
323 - [
324 - 'label' => esc_html__( 'Content Padding', 'uicore-elements' ),
325 - 'type' => Controls_Manager::DIMENSIONS,
326 - 'size_units' => [ 'px', 'em', '%', 'rem' ],
342 + 'box_padding',
343 + [
344 + 'label' => esc_html__('Content Padding', 'uicore-elements'),
345 + 'type' => Controls_Manager::DIMENSIONS,
346 + 'size_units' => ['px', 'em', '%', 'rem'],
327 347 'separator' => 'before',
328 - 'selectors' => [
329 - '{{WRAPPER}} .uicore-blog-grid .uicore-post .uicore-post-info' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
330 - ],
331 - ]
332 - );
348 + 'selectors' => [
349 + '{{WRAPPER}} .uicore-blog-grid .uicore-post .uicore-post-info' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
350 + ],
351 + ]
352 + );
333 353
334 354 $this->add_group_control(
335 - Group_Control_Background::get_type(),
336 - [
337 - 'name' => 'box_background',
338 - 'selector' => '{{WRAPPER}} .uicore-blog-grid .uicore-post',
339 - ]
340 - );
355 + Group_Control_Background::get_type(),
356 + [
357 + 'name' => 'box_background',
358 + 'selector' => '{{WRAPPER}} .uicore-blog-grid .uicore-post',
359 + ]
360 + );
341 361
342 362 $this->add_group_control(
343 - Group_Control_Border::get_type(),
344 - [
345 - 'name' => 'box_border',
346 - 'selector' => '{{WRAPPER}} .uicore-blog-grid .uicore-post',
363 + Group_Control_Border::get_type(),
364 + [
365 + 'name' => 'box_border',
366 + 'selector' => '{{WRAPPER}} .uicore-blog-grid .uicore-post',
347 367 'separator' => 'before',
348 - ]
349 - );
368 + ]
369 + );
350 370
351 - $this->add_control(
352 - 'box_border_radius',
353 - [
354 - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
355 - 'type' => Controls_Manager::SLIDER,
371 + $this->add_control(
372 + 'box_border_radius',
373 + [
374 + 'label' => esc_html__('Border Radius', 'uicore-elements'),
375 + 'type' => Controls_Manager::SLIDER,
356 376 'range' => [
357 377 'px' => [
358 378 'min' => 0,
359 379 'max' => 100,
@@ -358,21 +378,21 @@
358 378 'min' => 0,
359 379 'max' => 100,
360 380 ],
361 381 ],
362 - 'selectors' => [
363 - '{{WRAPPER}} .uicore-blog-grid .uicore-post' => '--uicore-blog--radius: {{SIZE}}{{UNIT}};',
364 - ],
365 - ]
366 - );
382 + 'selectors' => [
383 + '{{WRAPPER}} .uicore-blog-grid .uicore-post' => '--uicore-blog--radius: {{SIZE}}{{UNIT}};',
384 + ],
385 + ]
386 + );
367 387
368 - $this->add_group_control(
369 - Group_Control_Box_Shadow::get_type(),
370 - [
371 - 'name' => 'box_shadow_style',
372 - 'selector' => '{{WRAPPER}} .uicore-blog-grid .uicore-post',
373 - ]
374 - );
388 + $this->add_group_control(
389 + Group_Control_Box_Shadow::get_type(),
390 + [
391 + 'name' => 'box_shadow_style',
392 + 'selector' => '{{WRAPPER}} .uicore-blog-grid .uicore-post',
393 + ]
394 + );
375 395
376 396
377 397 $this->end_controls_section();
378 398 }
@@ -380,11 +400,11 @@
380 400 public function query_posts($posts_per_page, $type = null)
381 401 {
382 402 $query_args = Query::get_query_args('posts-filter', $this->get_settings());
383 403
384 - if($type === 'portfolio') {
385 - $query_args['orderby'] = 'menu_order date';
386 - }
404 + if ($type === 'portfolio') {
405 + $query_args['orderby'] = 'menu_order date';
406 + }
387 407
388 408 $query_args['posts_per_page'] = $posts_per_page;
389 409
390 410 $this->_query = new \WP_Query($query_args);
@@ -396,33 +416,10 @@
396 416
397 417 $col = $settings['col_number']['size'];
398 418 $type = $settings['posts-filter_post_type'];
399 419
400 - $blog_item_style = $settings['box_style'];
401 -
402 - if($type != 'portfolio'){
403 -
404 - $type = str_replace(' ', '-', $blog_item_style);
405 - if( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
406 - $content = '';
407 -
408 - $content .= \file_get_contents( Assets::get_global('uicore-blog.css') );
409 - if($blog_item_style != 'default'){
410 - $content .= \file_get_contents(UICORE_ELEMENTS_ASSETS . '/css/post-grid.css');
411 - }
412 -
413 - ?>
414 - <style>
415 - <?php echo esc_html(wp_strip_all_tags($content)); ?>
416 - </style>
417 - <?php
418 - }
419 - else{
420 - if($blog_item_style != 'default'){
421 - wp_enqueue_style('uicore_blog_grid_'.$type, UICORE_ELEMENTS_ASSETS . '/css/post-grid.css', UICORE_ELEMENTS_VERSION);
422 - }
423 - }
424 -
420 + if ($type != 'portfolio') {
421 + $type = str_replace(' ', '-', $settings['box_style']);
425 422 }
426 423
427 424 $this->query_posts($settings['item_limit']['size'], $type);
428 425 $wp_query = $this->get_query();
@@ -434,18 +431,9 @@
434 431
435 432
436 433 if ($type === 'portfolio') {
437 434
438 - if( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
439 - $content = '';
440 - $content .= \file_get_contents( Assets::get_global('uicore-portfolio.css') );
441 - ?>
442 - <style>
443 - <?php echo wp_strip_all_tags($content); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
444 - </style>
445 - <?php
446 - }
447 - if(!class_exists('\UiCore\Portfolio\Frontend')){
435 + if (!class_exists('\UiCore\Portfolio\Frontend')) {
448 436 require_once UICORE_INCLUDES . '/portfolio/class-template.php';
449 437 require_once UICORE_INCLUDES . '/portfolio/class-frontend.php';
450 438 }
451 439 Portfolio\Frontend::frontend_css(true);
@@ -450,26 +438,25 @@
450 438 }
451 439 Portfolio\Frontend::frontend_css(true);
452 440 $portfolio = new Portfolio\Template('display');
453 441 $portfolio->portfolio_layout($wp_query, null, $col);
454 -
455 442 } else {
456 443 $layout = $settings['layout'] === 'default' ? null : $settings['layout'];
457 - $style = $blog_item_style === 'default' ? null : $blog_item_style;
444 + $style = $settings['box_style'] === 'default' ? null : $settings['box_style'];
458 445
459 - if(isset($settings['box_ratio'])){
446 + if (isset($settings['box_ratio'])) {
460 447 $ratio = $settings['box_ratio'] === 'default' ? null : $settings['box_ratio'];
461 - }else{//Fallback for older versions
448 + } else { //Fallback for older versions
462 449 $ratio = null;
463 450 }
464 - if(isset($settings['extra_author'])){
451 + if (isset($settings['extra_author'])) {
465 452 $extra = [
466 - 'author' => $settings['extra_author'] === 'yes' ? true : false,
467 - 'date' => $settings['extra_date'] === 'yes' ? true : false,
468 - 'excerpt' => $settings['extra_excerpt'] === 'yes' ? true : false,
469 - 'category' => $settings['extra_category'] === 'yes' ? true : false
453 + 'author' => $this->is_option('extra_author', 'yes'),
454 + 'date' => $this->is_option('extra_date', 'yes'),
455 + 'excerpt' => $this->is_option('extra_excerpt', 'yes'),
456 + 'category' => $this->is_option('extra_category', 'yes')
470 457 ];
471 - }else{ //Fallback for older versions
458 + } else { //Fallback for older versions
472 459 $extra = [
473 460 'author' => null,
474 461 'date' => null,
475 462 'excerpt' => null,
@@ -477,16 +464,15 @@
477 464 ];
478 465 }
479 466
480 467
481 - if(!class_exists('\UiCore\Blog\Frontend')){
468 + if (!class_exists('\UiCore\Blog\Frontend')) {
482 469 require_once UICORE_INCLUDES . '/blog/class-template.php';
483 470 require_once UICORE_INCLUDES . '/blog/class-frontend.php';
484 471 }
485 472 Blog\Frontend::frontend_css(true);
486 473 $blog = new Blog\Template('display');
487 - $blog->blog_layout($wp_query, $layout, $col,null,$ratio,$extra, $style);
474 + $blog->blog_layout($wp_query, $layout, $col, null, $ratio, $extra, $style);
488 475 }
489 -
490 476 }
491 477 }
492 478 \Elementor\Plugin::instance()->widgets_manager->register(new PostGrid());