PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.5.0
Spider Elements – Premium Elementor Widgets & Addons Library v1.5.0
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / widgets / Blog_Grid.php
spider-elements / widgets Last commit date
templates 1 year ago Accordion.php 1 year ago Alerts_Box.php 1 year ago Animated_Heading.php 1 year ago Before_after.php 1 year ago Blog_Grid.php 1 year ago Buttons.php 1 year ago Cheat_sheet.php 1 year ago Counter.php 1 year ago Fullscreen_Slider.php 1 year ago Icon_box.php 1 year ago Instagram.php 1 year ago Integrations.php 1 year ago List_Item.php 1 year ago Pricing_Table_Switcher.php 1 year ago Pricing_Table_Tabs.php 1 year ago Tabs.php 1 year ago Team_Carousel.php 1 year ago Testimonial.php 1 year ago Timeline.php 1 year ago Video_Playlist.php 1 year ago Video_Popup.php 1 year ago
Blog_Grid.php
1469 lines
1 <?php
2 /**
3 * Use namespace to avoid conflict
4 */
5
6 namespace SPEL\Widgets;
7
8 use Elementor\Icons_Manager;
9 use Elementor\Widget_Base;
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Typography;
12 use \Elementor\Group_Control_Background;
13 use \Elementor\Group_Control_Border;
14 use \Elementor\Group_Control_Box_shadow;
15 use WP_Query;
16
17 // Exit if accessed directly
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22
23 /**
24 * Blog Grid
25 *
26 * Elementor widget for Blog Grid.
27 *
28 * @since 1.7.0
29 */
30 class Blog_Grid extends Widget_Base {
31
32 public static function get_taxonomies( $cate = 'post', $type = 0 ) {
33 $post_cat = self::_get_terms( $cate );
34
35 $tag = isset( $post_cat[ $type ] ) && ! empty( $post_cat[ $type ] ) ? $post_cat[ $type ] : 'category';
36 $terms = get_terms( array(
37 'taxonomy' => $tag,
38 'orderby' => 'name',
39 'order' => 'DESC',
40 'hide_empty' => false,
41 'number' => 1500
42 ) );
43
44 return $terms;
45 }
46
47 public function get_name() {
48 return 'docy_blog_grid'; // ID of the widget (Don't change this name)
49 }
50
51 public function get_title() {
52 return esc_html__( 'Blog Grid', 'spider-elements' );
53 }
54
55 public function get_icon() {
56 return 'eicon-post spel-icon';
57 }
58
59 public function get_categories() {
60 return [ 'spider-elements' ];
61 }
62
63 /**
64 * Name: get_style_depends()
65 * Desc: Register the required CSS dependencies for the frontend.
66 */
67 public function get_style_depends() {
68 return [ 'slick', 'slick-theme', 'ionicons', 'spel-main' ];
69 }
70
71 /**
72 * Name: get_script_depends()
73 * Desc: Register the required JS dependencies for the frontend.
74 */
75 public function get_script_depends() {
76 return [ 'slick', 'ionicons', 'spel-el-widgets' ];
77 }
78
79 /**
80 * Name: register_controls()
81 * Desc: Register controls for these widgets
82 * Params: no params
83 * Return: @void
84 * Since: @1.0.0
85 * Package: @spider-elements
86 * Author: spider-themes
87 */
88 protected function register_controls() {
89 $this->elementor_layout_setting();
90 $this->elementor_post_setting();
91 //style section
92 $this->elementor_blog_style_section();
93
94 }
95
96 /**
97 * Name: elementor_layout_setting()
98 * Desc: Register the Content Tab output on the Elementor editor.
99 * Params: no params
100 * Return: @void
101 * Since: @1.0.0
102 * Package: @spider-elements
103 * Author: spider-themes
104 */
105 public function elementor_layout_setting() {
106
107 //============================= Filter Options =================================== //
108 $this->start_controls_section(
109 'blog_layout', [
110 'label' => esc_html__( 'Layout', 'spider-elements' ),
111 ]
112 );
113
114 // Style
115 $this->add_control(
116 'style', [
117 'label' => esc_html__( 'Skin', 'spider-elements' ),
118 'type' => Controls_Manager::CHOOSE,
119 'options' => [
120 '1' => [
121 'title' => esc_html__( 'Style 01', 'spider-elements' ),
122 'icon' => 'blog_1',
123 ],
124 '2' => [
125 'title' => esc_html__( 'Style 02', 'spider-elements' ),
126 'icon' => 'blog_2',
127 ],
128 '3' => [
129 'title' => esc_html__( 'Style 03', 'spider-elements' ),
130 'icon' => 'blog_3',
131 ],
132 '4' => [
133 'title' => esc_html__( 'Style 04', 'spider-elements' ),
134 'icon' => 'blog_4',
135 ],
136 '5' => [
137 'title' => esc_html__( 'Blog Carousel', 'spider-elements' ),
138 'icon' => 'blog_5',
139 ],
140 ],
141 'toggle' => false,
142 'default' => '1',
143 ]
144 );
145
146 $this->add_control(
147 'column_grid', [
148 'label' => esc_html__( 'Column', 'spider-elements' ),
149 'type' => Controls_Manager::SELECT,
150 'options' => [
151 '6' => esc_html__( 'Two Column', 'spider-elements' ),
152 '4' => esc_html__( 'Three Column', 'spider-elements' ),
153 '3' => esc_html__( 'Four Column', 'spider-elements' ),
154 '2' => esc_html__( 'Six Column', 'spider-elements' ),
155 ],
156 'default' => '4 ',
157 'condition' => [
158 'style' => [ '1', '2', '3', '4', ],
159 'style!' => [ '5' ]
160 ]
161 ]
162 );
163
164 $this->add_control(
165 'left_arrow_icon', [
166 'label' => esc_html__( 'Left Icon', 'spider-elements' ),
167 'type' => Controls_Manager::ICONS,
168 'label_block' => true,
169 'default' => [
170 'value' => 'arrow_carrot-left',
171 'library' => 'bi',
172 ],
173 'separator' => 'before',
174 'condition' => [
175 'style' => [ '5' ],
176 'style!' => [ '1', '2', '3', '4', ]
177 ]
178 ]
179 );
180
181 $this->add_control(
182 'right_arrow_icon', [
183 'label' => esc_html__( 'Right Icon', 'spider-elements' ),
184 'type' => Controls_Manager::ICONS,
185 'default' => [
186 'value' => 'arrow_carrot-right',
187 'library' => 'bi',
188 ],
189 'condition' => [
190 'style' => [ '5' ],
191 'style!' => [ '1', '2', '3', '4', ]
192 ]
193 ]
194 );
195
196
197 $this->end_controls_section(); //End Filter
198 }
199
200 /**
201 * Name: elementor_post_setting()
202 * Desc: Register the Content Tab output on the Elementor editor.
203 * Params: no params
204 * Return: @void
205 * Since: @1.0.0
206 * Package: @spider-elements
207 * Author: spider-themes
208 */
209
210 public function elementor_post_setting() {
211
212 $this->start_controls_section(
213 'settings_section',
214 [
215 'label' => esc_html__( 'Query Settings', 'spider-elements' ),
216 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
217 ]
218 );
219 $this->add_control(
220 'blog_queryby', [
221 'label' => esc_html__( 'Query by', 'spider-elements' ),
222 'type' => \Elementor\Controls_Manager::CHOOSE,
223 'options' => apply_filters( 'blog_query_by', [
224 'all' => [
225 'title' => esc_html__( 'All', 'spider-elements' ),
226 'icon' => 'fas fa-border-none',
227 ],
228 'categories' => [
229 'title' => esc_html__( 'By Categories', 'spider-elements' ),
230 'icon' => 'eicon-product-categories',
231 ],
232 'posts' => [
233 'title' => esc_html__( 'By Posts', 'spider-elements' ),
234 'icon' => 'eicon-post-list',
235 ],
236 'postype' => [
237 'title' => esc_html__( 'By Posttype', 'spider-elements' ),
238 'icon' => 'eicon-editor-list-ul',
239 ],
240
241 ] ),
242 'default' => 'all',
243
244 ]
245 );
246
247 $this->add_control(
248 'blog_bycategories',
249 [
250 'label' => esc_html__( 'By Categories', 'spider-elements' ),
251 'type' => \Elementor\Controls_Manager::HEADING,
252 'condition' => [
253 'blog_queryby' => [ 'categories' ]
254 ],
255 ]
256 );
257
258 $this->add_control(
259 'blog_categories',
260 [
261 'label' => esc_html__( 'Select Categories', 'spider-elements' ),
262 'type' => \Elementor\Controls_Manager::SELECT2,
263 'multiple' => true,
264 'options' => self::get_category(),
265 'default' => [],
266 'condition' => [
267 'blog_queryby' => [ 'categories' ]
268 ],
269 ]
270 );
271
272 $this->add_control(
273 'blog_byposts',
274 [
275 'label' => esc_html__( 'By Posts', 'spider-elements' ),
276 'type' => \Elementor\Controls_Manager::HEADING,
277 'condition' => [
278 'blog_queryby' => [ 'posts' ]
279 ],
280 ]
281 );
282
283 $this->add_control(
284 'blog_post',
285 [
286 'label' => esc_html__( 'Select Posts', 'spider-elements' ),
287 'type' => \Elementor\Controls_Manager::SELECT2,
288 'multiple' => true,
289 'options' => self::get_posts(),
290 'default' => [],
291 'condition' => [
292 'blog_queryby' => [ 'posts' ]
293 ],
294 ]
295 );
296
297 $this->add_control(
298 'blog_byposttype',
299 [
300 'label' => esc_html__( 'By Posttype', 'spider-elements' ),
301 'type' => \Elementor\Controls_Manager::HEADING,
302 'condition' => [
303 'blog_queryby' => [ 'postype' ]
304 ],
305 ]
306 );
307
308 $this->add_control(
309 'blog_posttype',
310 [
311 'label' => esc_html__( 'Select Postype', 'spider-elements' ),
312 'type' => \Elementor\Controls_Manager::SELECT2,
313 'multiple' => true,
314 'options' => self::get_posttype(),
315 'default' => [],
316 'condition' => [
317 'blog_queryby' => [ 'postype' ]
318 ],
319 ]
320 );
321
322 $this->add_control(
323 'blog_otherquery',
324 [
325 'label' => esc_html__( 'Others Filter', 'spider-elements' ),
326 'type' => \Elementor\Controls_Manager::HEADING,
327 'separator' => 'before',
328 ]
329 );
330
331 $this->add_control(
332 'blog_order_by',
333 [
334 'label' => esc_html__( 'Order by', 'spider-elements' ),
335 'type' => \Elementor\Controls_Manager::SELECT,
336 'options' => [
337 'date' => esc_html__( 'Date', 'spider-elements' ),
338 'title' => esc_html__( 'Title', 'spider-elements' ),
339 'author' => esc_html__( 'Author', 'spider-elements' ),
340 'comment_count' => esc_html__( 'Comments', 'spider-elements' ),
341 ],
342 'default' => 'date',
343 ]
344 );
345
346 $this->add_control(
347 'blog_order',
348 [
349 'label' => esc_html__( 'Order', 'spider-elements' ),
350 'type' => \Elementor\Controls_Manager::SELECT,
351 'options' => [
352 'ASC' => esc_html__( 'ASC', 'spider-elements' ),
353 'DESC' => esc_html__( 'DESC', 'spider-elements' ),
354 ],
355 'default' => 'DESC',
356 ]
357 );
358
359 $this->add_control(
360 'blog_offset',
361 [
362 'label' => esc_html__( 'Offset', 'spider-elements' ),
363 'type' => \Elementor\Controls_Manager::NUMBER,
364 'min' => 0,
365 'max' => 15,
366 'default' => 0,
367 ]
368 );
369
370 $this->add_control(
371 'blog_limit',
372 [
373 'label' => esc_html__( 'Limit Display', 'spider-elements' ),
374 'type' => \Elementor\Controls_Manager::NUMBER,
375 'min' => 1,
376 'max' => 100,
377 'default' => 5,
378 ]
379 );
380 $this->add_control(
381 'content_limit',
382 [
383 'label' => esc_html__( 'Content Limit Display', 'spider-elements' ),
384 'type' => \Elementor\Controls_Manager::NUMBER,
385 'min' => 1,
386 'max' => 100,
387 'default' => 11,
388 'condition' => [
389 'style' => [ '2' ]
390 ]
391 ]
392 );
393
394 $this->add_control(
395 'title_length', [
396 'label' => esc_html__( 'Title Length', 'spider-elements' ),
397 'type' => Controls_Manager::NUMBER,
398 'default' => 8
399 ]
400 );
401
402 $this->end_controls_section();
403 }
404
405 public static function get_category( $cate = 'post' ) {
406 $post_cat = self::_get_terms( $cate );
407
408 $taxonomy = isset( $post_cat[0] ) && ! empty( $post_cat[0] ) ? $post_cat[0] : [ 'category' ];
409 $query_args = [
410 'taxonomy' => $taxonomy,
411 'orderby' => 'name',
412 'order' => 'DESC',
413 'hide_empty' => false,
414 'number' => 1500
415 ];
416 $terms = get_terms( $query_args );
417
418 $options = [];
419 $count = count( (array) $terms );
420 if ( $count > 0 ):
421 foreach ( $terms as $term ) {
422 if ( $term->parent == 0 ) {
423 $options[ $term->term_id ] = $term->name;
424 foreach ( $terms as $subcategory ) {
425 if ( $subcategory->parent == $term->term_id ) {
426 $options[ $subcategory->term_id ] = $subcategory->name;
427 }
428 }
429 }
430 }
431 endif;
432
433 return $options;
434 }
435
436 public static function _get_terms( $post = 'post' ) {
437 $taxonomy_objects = get_object_taxonomies( $post );
438
439 return $taxonomy_objects;
440 }
441
442 public static function get_posts() {
443 $post_args = get_posts(
444 array(
445 'posts_per_page' => - 1,
446 'post_status' => 'publish',
447 )
448 );
449
450 $posts = get_posts( $post_args );
451 $posts_list = [];
452 if ( is_array( $posts ) ) {
453 foreach ( $posts as $_key => $object ) {
454 $posts_list[ $object->ID ] = $object->post_title;
455 }
456 }
457
458 return $posts_list;
459 }
460
461 public static function get_posttype() {
462 $post_types = get_post_types(
463 array(
464 'public' => true,
465 ),
466 'objects'
467 );
468
469 $options = array();
470
471 if ( is_array( $post_types ) ) {
472 foreach ( $post_types as $post_type ) {
473 $options[ $post_type->name ] = $post_type->label;
474 }
475 }
476
477 return $options;
478 }
479
480 /**
481 * Name: elementor_blog_style_section()
482 * Desc: Register the Content Tab output on the Elementor editor.
483 * Params: no params
484 * Return: @void
485 * Since: @1.0.0
486 * Package: @spider-elements
487 * Author: spider-themes
488 */
489 public function elementor_blog_style_section() {
490 $this->blog_general_style();
491 $this->blog_image_style();
492 $this->blog_content_style();
493 $this->button_style();
494 $this->meta_style();
495 $this->icon_style();
496 }
497
498 public function blog_general_style() {
499 $this->start_controls_section(
500 'blog_general_styles',
501 [
502 'label' => esc_html__( 'Blog Item', 'spider-elements' ),
503 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
504 ]
505 );
506
507 $this->add_group_control(
508 \Elementor\Group_Control_Background::get_type(),
509 [
510 'name' => 'background',
511 'types' => [ 'classic', 'gradient' ],
512 'exclude' => [ 'image' ],
513 'selector' => '{{WRAPPER}} .blog-meta-two,
514 {{WRAPPER}} .blog-meta-one',
515 'condition' => [
516 'style' => [ '1', '2', '3', '4', ],
517 'style!' => [ '5' ]
518 ]
519 ]
520 );
521
522 $this->add_responsive_control(
523 'blog_margin',
524 [
525 'label' => esc_html__( 'Margin', 'spider-elements' ),
526 'type' => Controls_Manager::DIMENSIONS,
527 'size_units' => [ 'px' ],
528 'range' => [
529 'px' => [
530 'min' => - 100,
531 'max' => 100,
532 'step' => 5,
533 ],
534 ],
535 'default' => [
536 'unit' => 'px',
537 'size' => 10,
538 ],
539 'selectors' => [
540 '{{WRAPPER}} .blog-grid' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
541 ],
542 'condition' => [
543 'style' => [ '1', '2', '3', '4', ],
544 'style!' => [ '5' ]
545 ]
546 ]
547 );
548
549 $this->add_responsive_control(
550 'blog_item_padding',
551 [
552 'label' => esc_html__( 'Padding', 'spider-elements' ),
553 'type' => Controls_Manager::DIMENSIONS,
554 'size_units' => [ 'px' ],
555 'range' => [
556 'px' => [
557 'min' => - 100,
558 'max' => 100,
559 'step' => 5,
560 ],
561 ],
562 'default' => [
563 'unit' => 'px',
564 'size' => 10,
565 ],
566 'selectors' => [
567 '{{WRAPPER}} .blog-meta-two' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
568 '{{WRAPPER}} .blog-meta-one' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
569 '{{WRAPPER}} .card-style-six .blog-item-six' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
570 ],
571 ]
572 );
573
574 $this->add_responsive_control(
575 'blog_item_radius',
576 [
577 'label' => esc_html__( 'Border Radius', 'spider -elements' ),
578 'type' => Controls_Manager::DIMENSIONS,
579 'size_units' => [ 'px' ],
580 'selectors' => [
581 '{{WRAPPER}} .blog-meta-two' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
582 '{{WRAPPER}} .blog-meta-one' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
583 ],
584 'condition' => [
585 'style' => [ '1', '2', '3', '4', ],
586 'style!' => [ '5' ]
587 ]
588 ]
589 );
590
591 $this->add_control(
592 'hove_blog', [
593 'label' => esc_html__( 'Hover Color', 'spider-elements' ),
594 'type' => Controls_Manager::HEADING,
595 'separator' => 'before',
596 'condition' => [
597 'style' => [ '1', '2', '3', '4', ],
598 'style!' => [ '5' ]
599 ]
600 ]
601
602 );
603
604 $this->add_group_control(
605 \Elementor\Group_Control_Background::get_type(),
606 [
607 'name' => 'hover_background',
608 'types' => [ 'classic', 'gradient' ],
609 'exclude' => [ 'image' ],
610 'selector' => '{{WRAPPER}} .blog-meta-two:hover,
611 {{WRAPPER}} .blog-meta-one:hover',
612 'condition' => [
613 'style' => [ '1', '2', '3', '4', ],
614 'style!' => [ '5' ]
615 ]
616 ]
617 );
618
619 $this->end_controls_section();
620 }
621
622 //============ Start Image Style Control Section ================//
623 public function blog_image_style() {
624 $this->start_controls_section(
625 'blog_image_tab',
626 [
627 'label' => esc_html__( 'Image', 'spider-elements' ),
628 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
629 'condition' => [
630 'style' => [ '1', '2', '3', '4' ]
631 ]
632 ]
633 );
634
635 $this->add_responsive_control(
636 'blog_img_radius',
637 [
638 'label' => esc_html__( 'Border Radius', 'spider-elements' ),
639 'type' => Controls_Manager::DIMENSIONS,
640 'size_units' => [ 'px' ],
641 'selectors' => [
642 '{{WRAPPER}} .blog-meta-two .post-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
643 '{{WRAPPER}} .blog-meta-one .post-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
644 ],
645 ]
646 );
647
648 $this->add_responsive_control(
649 'blog_img_margin',
650 [
651 'label' => esc_html__( 'Margin Bottom', 'spider-elements' ),
652 'description' => esc_html__( 'Spacing between the image', 'spider-elements' ),
653 'type' => Controls_Manager::SLIDER,
654 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
655 'range' => [
656 'px' => [
657 'max' => 250,
658 ],
659 'em' => [
660 'max' => 0,
661 ],
662 ],
663 'selectors' => [
664 '{{WRAPPER}} .blog-meta-two .post-img' => 'margin-bottom: {{SIZE}}{{UNIT}} !important;',
665 '{{WRAPPER}} .blog-meta-one .post-img' => 'margin-bottom: {{SIZE}}{{UNIT}};',
666 ],
667 'condition' => [
668 'style' => [ '1', '2', '3', '4' ],
669 'style!' => [ '5' ]
670 ],
671 ]
672 );
673
674 $this->end_controls_section();
675 }
676
677
678 //============ Start Content Section Control============
679 public function blog_content_style() {
680
681 $this->start_controls_section(
682 'blog_content_tab',
683 [
684 'label' => esc_html__( 'Contents', 'spider-elements' ),
685 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
686 ]
687 );
688
689 $this->start_controls_tabs(
690 'style_blog_title_tabs'
691 );
692
693 //=== blog Normal icon
694 $this->start_controls_tab(
695 'style_blog_title_normal',
696 [
697 'label' => esc_html__( 'Normal', 'spider-elements' ),
698 ]
699 );
700
701 $this->add_control(
702 'blog_title_options', [
703 'label' => esc_html__( 'Title', 'spider-elements' ),
704 'type' => Controls_Manager::HEADING,
705 ]
706 );
707
708 $this->add_group_control(
709 Group_Control_Typography::get_type(),
710 [
711 'name' => 'blog_content_title',
712 'selector' => '{{WRAPPER}} .blog-meta-two .blog-title,
713 {{WRAPPER}} .blog-meta-one .blog-title,
714 {{WRAPPER}} .blog-six-title',
715 ]
716 );
717
718 $this->add_control(
719 'blog_title_color',
720 [
721 'label' => esc_html__( 'Color', 'spider-elements' ),
722 'type' => Controls_Manager::COLOR,
723 'default' => '',
724 'selectors' => [
725 '{{WRAPPER}} .blog-meta-two .blog-title' => 'color: {{VALUE}};',
726 '{{WRAPPER}} .blog-meta-one .blog-title' => 'color: {{VALUE}};',
727 '{{WRAPPER}} .blog-six-title' => 'color: {{VALUE}};',
728 ],
729 ]
730 );
731
732 $this->add_responsive_control(
733 'blog_title_margin',
734 [
735 'label' => esc_html__( 'Margin', 'spider-elements' ),
736 'type' => Controls_Manager::DIMENSIONS,
737 'size_units' => [ 'px' ],
738 'range' => [
739 'px' => [
740 'min' => - 100,
741 'max' => 100,
742 'step' => 5,
743 ],
744 ],
745 'default' => [
746 'unit' => 'px',
747 'size' => 10,
748 ],
749 'selectors' => [
750 '{{WRAPPER}} .blog-meta-two .blog-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
751 '{{WRAPPER}} .blog-meta-one .blog-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
752 ],
753 'condition' => [
754 'style' => [ '1', '2', '3', '4', ],
755 'style!' => [ '5' ]
756 ]
757 ]
758 );
759
760 $this->end_controls_tab(); //End Normal title
761
762 //=== Hover icon====
763 $this->start_controls_tab(
764 'blog_hover_title', [
765 'label' => esc_html__( 'Hover', 'spider-elements' ),
766 ]
767 );
768
769 $this->add_control(
770 'blog_title_hover_heading',
771 [
772 'label' => esc_html__( 'Title', 'spider-elements' ),
773 'type' => Controls_Manager::HEADING,
774 ]
775 );
776
777 $this->add_control(
778 'blog_title_hover_color',
779 [
780 'label' => esc_html__( 'Color', 'spider-elements' ),
781 'type' => Controls_Manager::COLOR,
782 'default' => '',
783 'selectors' => [
784 '{{WRAPPER}} .blog-meta-two .blog-title:hover' => 'color: {{VALUE}};',
785 '{{WRAPPER}} .blog-meta-one .blog-title:hover' => 'color: {{VALUE}};',
786 '{{WRAPPER}} .blog-six-title:hover' => 'color: {{VALUE}};',
787 ],
788 ]
789 );
790
791 $this->end_controls_tab(); // End title hover
792 $this->end_controls_tabs(); // end normal and hover title tabs
793
794
795 //===============Blog Style 2, Description Style......................
796 $this->add_control(
797 'blog_description_options', [
798 'label' => esc_html__( 'Description', 'spider-elements' ),
799 'type' => Controls_Manager::HEADING,
800 'separator' => 'before',
801 'condition' => [
802 'style' => [ '2' ],
803 'style!' => [ '1', '3', '4', '5' ]
804 ],
805 ]
806 );
807
808 $this->add_group_control(
809 \Elementor\Group_Control_Typography::get_type(),
810 [
811 'name' => 'description_typography',
812 'selector' => '{{WRAPPER}} .blog-meta-one p',
813 'condition' => [
814 'style' => [ '2' ],
815 'style!' => [ '1', '3', '4', '5' ]
816 ],
817 ]
818
819 );
820
821 $this->add_control(
822 'blog_description_color',
823 [
824 'label' => esc_html__( 'Text Color', 'spider-elements' ),
825 'type' => Controls_Manager::COLOR,
826 'default' => '',
827 'selectors' => [
828 '{{WRAPPER}} .blog-meta-one p' => 'color: {{VALUE}};',
829 ],
830 'condition' => [
831 'style' => [ '2' ],
832 'style!' => [ '1', '3', '4', '5' ]
833 ],
834 ]
835 );
836
837 // End //
838
839 $this->end_controls_section();
840 }
841
842
843 //===================Start Blog Grid Button Style Controls===============//
844 public function button_style() {
845 $this->start_controls_section(
846 'blog_button_tab',
847 [
848 'label' => esc_html__( 'Button', 'spider-elements' ),
849 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
850 'condition' => [
851 'style' => [ '1', '2', '4', ]
852 ]
853 ]
854 );
855
856 // ===== Button Style Tabs=====//
857 $this->start_controls_tabs(
858 'style_btn_tabs'
859 );
860
861 //==== Normal ====//
862 $this->start_controls_tab(
863 'blog_normal_btn', [
864 'label' => esc_html__( 'Normal', 'spider-elements' ),
865 ]
866 );
867
868 $this->add_group_control(
869 \Elementor\Group_Control_Typography::get_type(),
870 [
871 'name' => 'content_typography',
872 'selector' =>
873 '{{WRAPPER}} .blog-meta-two .continue-btn,
874 {{WRAPPER}} .blog-meta-two .read-more-btn a,
875 {{WRAPPER}} .blog-meta-one .continue-btn',
876 ]
877 );
878
879 $this->add_group_control(
880 \Elementor\Group_Control_Background::get_type(),
881 [
882 'name' => 'btn_background',
883 'types' => [ 'classic', 'gradient' ],
884 'exclude' => [ 'image' ],
885 'selector' => '{{WRAPPER}} .blog-meta-two .continue-btn.btn-seven',
886 'condition' => [
887 'style' => '4'
888 ],
889 ]
890 );
891
892 $this->add_control(
893 'blog_button_color',
894 [
895 'label' => esc_html__( 'Text Color', 'spider-elements' ),
896 'type' => Controls_Manager::COLOR,
897 'default' => '',
898 'selectors' => [
899 '{{WRAPPER}} .blog-meta-two .continue-btn' => 'color: {{VALUE}};',
900 '{{WRAPPER}} .blog-meta-two .read-more-btn a' => 'color: {{VALUE}};',
901 '{{WRAPPER}} .blog-meta-one .continue-btn' => 'color: {{VALUE}};',
902 ],
903 ]
904 );
905
906 $this->add_responsive_control(
907 'blog_btn_padding',
908 [
909 'label' => esc_html__( 'Padding', 'spider-elements' ),
910 'type' => Controls_Manager::DIMENSIONS,
911 'size_units' => [ 'px' ],
912 'range' => [
913 'px' => [
914 'min' => - 100,
915 'max' => 100,
916 'step' => 5,
917 ],
918 ],
919 'default' => [
920 'unit' => 'px',
921 'size' => 10,
922 ],
923 'selectors' => [
924 '{{WRAPPER}} .blog-meta-two .continue-btn.btn-seven' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
925 ],
926 'condition' => [
927 'style' => '4'
928 ],
929 ]
930 );
931
932 $this->add_group_control(
933 \Elementor\Group_Control_Border::get_type(),
934 [
935 'name' => 'button_border_color',
936 'label' => esc_html__( 'Border', 'spider-elements' ),
937 'selector' => '{{WRAPPER}} .blog-meta-two .continue-btn.btn-seven',
938 'condition' => [
939 'style' => '4'
940 ],
941 ]
942 );
943
944 $this->add_responsive_control(
945 'button_border_radius',
946 [
947 'label' => esc_html__( 'Border Radius', 'spider-elements' ),
948 'type' => Controls_Manager::DIMENSIONS,
949 'size_units' => [ 'px' ],
950 'selectors' => [
951 '{{WRAPPER}} .blog-meta-two .continue-btn.btn-seven' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
952 ],
953 'condition' => [
954 'style' => '4'
955 ],
956 ]
957 );
958
959 $this->end_controls_tab();
960
961 //=== Button Hover ====//
962 $this->start_controls_tab(
963 'blog_hover_btn', [
964 'label' => esc_html__( 'Hover', 'spider-elements' ),
965 ]
966 );
967
968 $this->add_group_control(
969 \Elementor\Group_Control_Background::get_type(),
970 [
971 'name' => 'btn_hover_background',
972 'types' => [ 'classic', 'gradient' ],
973 'exclude' => [ 'image' ],
974 'selector' => '{{WRAPPER}} .blog-meta-two .continue-btn.btn-seven:hover',
975 'condition' => [
976 'style' => '4'
977 ],
978 ]
979 );
980
981 $this->add_control(
982 'blog_button_hover_color',
983 [
984 'label' => esc_html__( 'Text Color', 'spider-elements' ),
985 'type' => Controls_Manager::COLOR,
986 'default' => '',
987 'selectors' => [
988 '{{WRAPPER}} .blog-meta-two .continue-btn:hover' => 'color: {{VALUE}};',
989 '{{WRAPPER}} .blog-meta-two .read-more-btn a:hover' => 'color: {{VALUE}};',
990 '{{WRAPPER}} .blog-meta-one .continue-btn:hover' => 'color: {{VALUE}};',
991 ],
992 ]
993 );
994
995 $this->add_control(
996 'button_hover_border_color',
997 [
998 'label' => esc_html__( 'Border Color', 'spider-elements' ),
999 'type' => \Elementor\Controls_Manager::COLOR,
1000 'selectors' => [
1001 '{{WRAPPER}} .blog-meta-two .continue-btn.btn-seven:hover' => 'border-color: {{VALUE}}',
1002 ],
1003 'condition' => [
1004 'style' => '4'
1005 ],
1006 ]
1007 );
1008
1009 $this->end_controls_tab();
1010 $this->end_controls_tabs();
1011 $this->end_controls_section();
1012 }
1013
1014 //==================== Start Meta Style Section ==================//
1015 public function meta_style() {
1016 $this->start_controls_section(
1017 'blog_meta_tab',
1018 [
1019 'label' => esc_html__( 'Meta', 'spider-elements' ),
1020 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
1021 'condition' => [
1022 'style' => [ '1', '2', '3', '4', ]
1023 ]
1024 ]
1025 );
1026
1027 $this->add_control(
1028 'date-heading',
1029 [
1030 'label' => esc_html__( 'Date', 'spider-elements' ),
1031 'type' => Controls_Manager::HEADING,
1032 'condition' => [
1033 'style' => [ '1', '2', '4', '5' ],
1034 'style!' => [ '3' ]
1035 ],
1036 ]
1037 );
1038
1039 $this->add_group_control(
1040 Group_Control_Typography::get_type(),
1041 [
1042 'name' => 'blog_meta_typography',
1043 'selector' => '{{WRAPPER}} .blog-meta-two .date a,
1044 {{WRAPPER}} .blog-meta-one .date a',
1045 'condition' => [
1046 'style' => [ '1', '2', '4' ],
1047 'style!' => [ '3', '5' ]
1048 ],
1049 ]
1050 );
1051
1052 $this->add_control(
1053 'blog_meta_color',
1054 [
1055 'label' => esc_html__( 'Text Color', 'spider-elements' ),
1056 'type' => Controls_Manager::COLOR,
1057 'default' => '',
1058 'selectors' => [
1059 '{{WRAPPER}} .blog-meta-two .date a' => 'color: {{VALUE}};',
1060 '{{WRAPPER}} .blog-meta-one .date a' => 'color: {{VALUE}};',
1061 '{{WRAPPER}} .blog-item .blog-meta .author-info h5, .blog-item .blog-meta .author-info span,
1062 .blog-item .blog-meta :is(.blog-category, .blog-category a, .blog-read)' => 'color: {{VALUE}} !important;',
1063 ],
1064 'condition' => [
1065 'style' => [ '1', '2', '4', '5' ],
1066 'style!' => [ '3' ]
1067 ],
1068 ]
1069 );
1070
1071
1072 //============ Start meta category Style Controls =================//
1073 $this->add_control(
1074 'blog_category_options', [
1075 'label' => esc_html__( 'Category', 'spider-elements' ),
1076 'type' => Controls_Manager::HEADING,
1077 'separator' => 'before',
1078 'condition' => [
1079 'style' => [ '1', '3', '5' ],
1080 'style!' => [ '2', '4' ]
1081 ],
1082 ]
1083 );
1084
1085 $this->start_controls_tabs(
1086 'cat_tabs', [
1087 'condition' => [
1088 'style' => [ '1', '3', '5' ],
1089 'style!' => [ '2', '4' ]
1090 ],
1091 ]
1092 );
1093
1094 $this->start_controls_tab(
1095 'cat_normal_tab',
1096 [
1097 'label' => esc_html__( 'Normal', 'spider-elements' ),
1098 ]
1099 );
1100
1101 $this->add_group_control(
1102 Group_Control_Typography::get_type(),
1103 [
1104 'name' => 'blog_category_typography',
1105 'selector' => '{{WRAPPER}} .blog-meta-one .tags,
1106 {{WRAPPER}} .blog-meta-two .post-img .tags,
1107 {{WRAPPER}} .blog-item .blog-meta .tags',
1108 'condition' => [
1109 'style' => [ '1', '3', '5' ],
1110 'style!' => [ '2', '4' ]
1111 ]
1112 ]
1113 );
1114
1115 $this->add_control(
1116 'blog_category_color',
1117 [
1118 'label' => esc_html__( 'Text Color', 'spider-elements' ),
1119 'type' => Controls_Manager::COLOR,
1120 'default' => '',
1121 'selectors' => [
1122 '{{WRAPPER}} .blog-meta-two .post-img .tags' => 'color: {{VALUE}};',
1123 '{{WRAPPER}} .blog-meta-one .tags' => 'color: {{VALUE}};',
1124 '{{WRAPPER}} .blog-item .blog-meta .tags, .blog-read::before' => 'color: {{VALUE}};',
1125 ],
1126 'condition' => [
1127 'style' => [ '1', '3', '5' ],
1128 'style!' => [ '2', '4' ]
1129 ]
1130 ]
1131 );
1132
1133 $this->add_control(
1134 'first_category_bg',
1135 [
1136 'label' => esc_html__( 'Background', 'spider-elements' ),
1137 'type' => Controls_Manager::COLOR,
1138 'selectors' => [
1139 '{{WRAPPER}} .blog-meta-two .post-img .tags' => 'background: {{VALUE}};',
1140 ],
1141 'condition' => [
1142 'style' => [ '1' ],
1143 'style!' => [ '2', '3', '4', '5' ]
1144 ],
1145 ]
1146 );
1147
1148 $this->end_controls_tab();
1149
1150 $this->start_controls_tab(
1151 'cat_hover_tab',
1152 [
1153 'label' => esc_html__( 'Hover', 'spider-elements' ),
1154 ]
1155 );
1156
1157 $this->add_control(
1158 'category_hover_color',
1159 [
1160 'label' => esc_html__( 'Text Color', 'spider-elements' ),
1161 'type' => Controls_Manager::COLOR,
1162 'default' => '',
1163 'selectors' => [
1164 '{{WRAPPER}} .blog-meta-one .tags:hover' => 'color: {{VALUE}} !important;',
1165 '{{WRAPPER}} .blog-item .blog-meta .tags:hover' => 'color: {{VALUE}};',
1166 '{{WRAPPER}} .blog-meta-two .post-img .tags:hover' => 'color: {{VALUE}};',
1167 ],
1168 'condition' => [
1169 'style' => [ '3', '5', '1' ],
1170 'style!' => [ '2', '4' ]
1171 ]
1172 ]
1173 );
1174
1175 $this->add_control(
1176 'bg_hover_category',
1177 [
1178 'label' => esc_html__( 'Background', 'spider-elements' ),
1179 'type' => Controls_Manager::COLOR,
1180 'selectors' => [
1181 '{{WRAPPER}} .blog-meta-two .post-img .tags:hover' => 'background: {{VALUE}};',
1182 ],
1183 'condition' => [
1184 'style' => [ '1' ],
1185 'style!' => [ '2', '3', '4', '5' ]
1186 ],
1187 ]
1188 );
1189
1190 $this->end_controls_tab();
1191
1192 $this->end_controls_tabs();
1193
1194 //============ End meta category Style Controls =================//
1195
1196 //============ Start meta Author Style Controls =================//
1197 $this->add_control(
1198 'blog_author_options', [
1199 'label' => esc_html__( 'Author Name', 'spider-elements' ),
1200 'type' => Controls_Manager::HEADING,
1201 'separator' => 'before',
1202 'condition' => [
1203 'style' => [ '3', '5' ],
1204 'style!' => [ '1', '2', '4' ]
1205 ],
1206 ]
1207 );
1208
1209 $this->add_group_control(
1210 \Elementor\Group_Control_Typography::get_type(),
1211 [
1212 'name' => 'author_typography',
1213 'selector' => '{{WRAPPER}} .blog-meta-one .author a,
1214 {{WRAPPER}} .blog-item .blog-meta .author-info h5 a',
1215 'condition' => [
1216 'style' => [ '3', '5' ],
1217 'style!' => [ '1', '2', '4' ]
1218 ],
1219 ]
1220 );
1221
1222 $this->add_control(
1223 'author_color',
1224 [
1225 'label' => esc_html__( 'Text Color', 'spider-elements' ),
1226 'type' => \Elementor\Controls_Manager::COLOR,
1227 'selectors' => [
1228 '{{WRAPPER}} .blog-meta-one .author a' => 'color: {{VALUE}}',
1229 '{{WRAPPER}} .blog-item .blog-meta .author-info h5 a' => 'color: {{VALUE}}',
1230 ],
1231 'condition' => [
1232 'style' => [ '3', '5' ],
1233 'style!' => [ '1', '2', '4' ]
1234 ],
1235 ]
1236 );
1237
1238 $this->add_control(
1239 'blog_author_hover_color',
1240 [
1241 'label' => esc_html__( 'Hover Color', 'spider-elements' ),
1242 'type' => Controls_Manager::COLOR,
1243 'default' => '',
1244 'selectors' => [
1245 '{{WRAPPER}} .blog-meta-one .author a:hover' => 'color: {{VALUE}};',
1246 '{{WRAPPER}} .blog-item .blog-meta .author-info h5 a:hover' => 'color: {{VALUE}};',
1247 ],
1248 'condition' => [
1249 'style' => [ '3', '5' ],
1250 'style!' => [ '1', '2', '4' ]
1251 ],
1252 ]
1253 );
1254 //============ End meta Author Style Controls =================//
1255
1256 $this->end_controls_section();
1257 }
1258
1259 //==================== End Meta Style Section ==================//
1260
1261 public function icon_style() {
1262 $this->start_controls_section(
1263 'blog_icon_tab',
1264 [
1265 'label' => esc_html__( 'Icon', 'spider-elements' ),
1266 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
1267 'condition' => [
1268 'style' => [ '5' ],
1269 'style!' => [ '1', '2', '3', '4', ]
1270 ]
1271 ]
1272 );
1273
1274 // Blog icon Normal/hover/ State
1275 $this->start_controls_tabs(
1276 'style_blog_icon_tabs'
1277 );
1278
1279 //=== blog Normal icon
1280 $this->start_controls_tab(
1281 'style_blog_icon_normal',
1282 [
1283 'label' => esc_html__( 'Normal', 'spider-elements' ),
1284 ]
1285 );
1286
1287 $this->add_control(
1288 'blog_icon_color',
1289 [
1290 'label' => esc_html__( 'Color', 'spider-elements' ),
1291 'type' => Controls_Manager::COLOR,
1292 'selectors' => [
1293 '{{WRAPPER}} .slick-arrow' => 'color: {{VALUE}}',
1294 ],
1295 ]
1296 );
1297
1298 $this->add_control(
1299 'blog_icon_bg_color',
1300 [
1301 'label' => esc_html__( 'Background', 'spider-elements' ),
1302 'type' => Controls_Manager::COLOR,
1303 'selectors' => [
1304 '{{WRAPPER}} .slick-arrow' => 'background: {{VALUE}};',
1305
1306 ],
1307 ]
1308 );
1309
1310 $this->end_controls_tab(); //End Normal icon
1311
1312 //=== Hover icon====
1313 $this->start_controls_tab(
1314 'blog_hover_icon', [
1315 'label' => esc_html__( 'Hover', 'spider-elements' ),
1316 ]
1317 );
1318
1319 $this->add_control(
1320 'icon_hover_color', [
1321 'label' => esc_html__( 'Color', 'spider-elements' ),
1322 'type' => Controls_Manager::COLOR,
1323 'selectors' => [
1324 '{{WRAPPER}} .slick-arrow:hover' => 'color: {{VALUE}};',
1325 ],
1326 ]
1327 );
1328
1329 $this->add_control(
1330 'icon_hover_bg_color', [
1331 'label' => esc_html__( 'Background', 'spider-elements' ),
1332 'type' => Controls_Manager::COLOR,
1333 'selectors' => [
1334 '{{WRAPPER}} .slick-arrow:hover' => 'background: {{VALUE}};',
1335 ],
1336 ]
1337 );
1338
1339 $this->add_control(
1340 'icon_border_color',
1341 [
1342 'label' => esc_html__( 'Border Color', 'spider-elements' ),
1343 'type' => Controls_Manager::COLOR,
1344 'selectors' => [
1345 '{{WRAPPER}} .slick-arrow:hover' => 'border-color: {{VALUE}}',
1346 ],
1347 ]
1348 );
1349
1350 $this->end_controls_tab(); // End Active Tab Title
1351 $this->end_controls_tabs(); // End Accordion icon Normal/Active/ State
1352
1353 $this->add_responsive_control(
1354 'blog_icon_size',
1355 [
1356 'label' => esc_html__( 'Icon Size', 'spider-elements' ),
1357 'type' => Controls_Manager::SLIDER,
1358 'size_units' => [ 'px', '%' ],
1359 'range' => [
1360 'px' => [
1361 'min' => 0,
1362 'max' => 100,
1363 'step' => 1,
1364 ],
1365 '%' => [
1366 'min' => 0,
1367 'max' => 100,
1368 ],
1369 ],
1370 'default' => [
1371 'unit' => 'px',
1372 ],
1373 'selectors' => [
1374 '{{WRAPPER}} .slick-arrow ' => 'font-size: {{SIZE}}{{UNIT}};',
1375 ],
1376 'separator' => 'before',
1377 ]
1378 );
1379
1380 $this->add_group_control(
1381 \Elementor\Group_Control_Border::get_type(),
1382 [
1383 'name' => 'blog_icon_border',
1384 'selector' => '{{WRAPPER}} .slick-arrow',
1385 ]
1386 );
1387
1388 $this->add_responsive_control(
1389 'blog_icon_border_radius',
1390 [
1391 'label' => esc_html__( 'Border Radius', 'spider-elements' ),
1392 'type' => Controls_Manager::SLIDER,
1393 'size_units' => [ 'px', '%', 'em' ],
1394 'selectors' => [
1395 '{{WRAPPER}} .slick-arrow' => 'border-radius: {{SIZE}}px;',
1396 ],
1397 ]
1398 );
1399
1400 $this->add_responsive_control(
1401 'blog_icon_padding',
1402 [
1403 'label' => esc_html__( 'Padding', 'spider-elements' ),
1404 'type' => Controls_Manager::DIMENSIONS,
1405 'size_units' => [ 'px', 'em', '%' ],
1406 'selectors' => [
1407 '{{WRAPPER}} .slick-arrow' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1408 ],
1409 ]
1410 );
1411
1412 $this->end_controls_section();
1413 }
1414
1415
1416 protected function render() {
1417 $settings = $this->get_settings_for_display();
1418 extract( $settings ); // Array to variable conversation
1419
1420 $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
1421
1422 // query part
1423 $query['post_status'] = 'publish';
1424 $query['ignore_sticky_posts'] = true;
1425 $query['suppress_filters'] = false;
1426 $query['paged'] = $paged;
1427 if ( $blog_queryby == 'postype' ) {
1428 $query['post_type'] = isset( $blog_posttype ) ? $blog_posttype : [ 'post' ];
1429 } else {
1430 $query['post_type'] = [ 'post' ];
1431 }
1432
1433 $query['orderby'] = $blog_order_by;
1434 if ( ! empty( $blog_order ) ) {
1435 $query['order'] = $blog_order;
1436 }
1437 if ( ! empty( $blog_limit ) ) {
1438 $query['posts_per_page'] = (int) $blog_limit;
1439 }
1440 if ( ! empty( $blog_offset ) ) {
1441 $query['offset'] = (int) $blog_offset;
1442 }
1443
1444 if ( $blog_queryby == 'categories' ) {
1445 if ( is_array( $blog_categories ) && sizeof( $blog_categories ) > 0 ) {
1446 $cate_query = [
1447 [
1448 'taxonomy' => 'category',
1449 'field' => 'term_id',
1450 'terms' => $blog_categories,
1451 ],
1452 'relation' => 'AND',
1453 ];
1454 $query['tax_query'] = $cate_query;
1455 }
1456 }
1457
1458 if ( $blog_queryby == 'posts' ) {
1459 if ( is_array( $blog_post ) && sizeof( $blog_post ) > 0 ) {
1460 $query['post__in'] = $blog_post;
1461 }
1462 }
1463
1464 $post_query = new \WP_Query( $query );
1465
1466 include "templates/blog-grid/blog-{$settings['style']}.php";
1467 }
1468
1469 }