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