/
home
/
rekodeb
/
webmars
/
wp-content
/
plugins
/
calmor-core
/
widgets
/
Upload File
HOME
<?php namespace calmorCore\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Group_Control_Typography; use Elementor\Group_Control_Box_Shadow; use Elementor\Group_Control_Background; use WP_Query; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Text Typing Effect * * Elementor widget for text typing effect. * * @since 1.7.0 */ class calmor_blog extends Widget_Base { public function get_name() { return 'calmor_blog'; } public function get_title() { return esc_html__( 'Calmer Blog', 'calmor-hero' ); } public function get_icon() { return 'eicon-menu-bar'; } public function get_categories() { return [ 'calmor-elements' ]; } protected function _register_controls() { // ---------------------------------------- Hero content ------------------------------ $this->start_controls_section( 'blog_design_style', [ 'label' => __( 'Blog Style', 'calmor-core' ), ] ); $this->add_control( 'select_style', [ 'label' => esc_html__( 'Select Style', 'calmor-core' ), 'type' => Controls_Manager::SELECT, 'label_block' => false, 'options' => [ 'style_1' => 'Style 1 [ slide 2 column ]', 'style_2' => 'Style 2 [Grid 2 column ]', 'style_3' => 'Style 3 [Grid 3 column ]', 'style_4' => 'Style 4 [ slide 3 column ]', ], 'default' => 'style_1' ] ); $this->end_controls_section(); // End Hero content // ---Start Blog Setting $this->start_controls_section( 'Blog_filter', [ 'label' => __( 'Blog Settings', 'calmor-core' ), ] ); $this->add_control( 'all_label', [ 'label' => esc_html__( 'All filter label', 'calmor-core' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => 'See All' ] ); $this->add_control( 'show_count', [ 'label' => esc_html__( 'Show count', 'calmor-core' ), 'type' => Controls_Manager::NUMBER, 'label_block' => true, 'default' => 8 ] ); $this->add_control( 'order', [ 'label' => esc_html__( 'Order', 'calmor-core' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'ASC' => 'ASC', 'DESC' => 'DESC' ], 'default' => 'ASC' ] ); $this->add_control( 'read_more_Text', [ 'label' => esc_html__( 'Button Title', 'calmor-core' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => 'Read More' ] ); $this->end_controls_section(); //---------------- Style Section --------------- // $this->start_controls_section( 'blog_style', [ 'label' => __( 'Blog Title', 'calmor-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_color', [ 'label' => __( 'Title Text Color', 'appart-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .single_blog .blog_bottom h4 a' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'label' => 'Typography', 'name' => 'sec_typography_title', 'selector' => '{{WRAPPER}} .single_blog .blog_bottom h4 a', ] ); $this->end_controls_section(); ///(Style) End The Blog Title Section ///(Style) Strat The Blog Sub Title Section $this->start_controls_section( 'blog_sub_style', [ 'label' => __( 'Blog Date & Author ', 'calmor-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'sub_title_color', [ 'label' => __( 'Text Color', 'calmor-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .date_cetagory' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'label' => 'Typography', 'name' => 'typography_sub_title', 'selector' => '{{WRAPPER}} .date_cetagory', ] ); $this->end_controls_section(); /// End The Blog Sub Title Section ///(Style) Strat The Blog button $this->start_controls_section( 'blog_button_style', [ 'label' => __( 'Blog button', 'calmor-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'blog_button_color', [ 'label' => __( 'Text Color', 'calmor-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .text_btn' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'label' => 'Typography', 'name' => 'typography_button_blog', 'selector' => '{{WRAPPER}} .single_success_story .read_more_btn', ] ); $this->add_control( 'blog_button_hover_color', [ 'label' => __( 'Hover Text Color', 'calmor-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .text_btn:hover' => 'color: {{VALUE}};', ], ] ); $this->end_controls_section(); /// End The Blog button ///(Style) Strat The Blog button $this->start_controls_section( 'blog_cate_style', [ 'label' => __( 'Blog Author', 'calmor-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'blog_author_bg_color', [ 'label' => esc_html__( 'Background Color', 'calmor-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .single_blog .blog_top .author a' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'blog_author_color', [ 'label' => __( 'Text Color', 'calmor-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .single_blog .blog_top .author a' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'label' => 'Typography', 'name' => 'typography_author_blog', 'selector' => '{{WRAPPER}} .single_blog .blog_top .author a', ] ); $this->end_controls_section(); } protected function render() { $this->load_widget_script(); $settings = $this->get_settings(); $animation_imags = isset($settings['feature_animation']) ? $settings['feature_animation'] : ''; $select_style = !empty( $settings['select_style'] ) ? $settings['select_style'] : ''; $blogPost = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => $settings['show_count'], 'order' => $settings['order'], 'post__not_in' => ! empty( $settings['exclude'] ) ? explode( ',', $settings['exclude'] ) : '' ) ); $opt = get_option('calmor_opt'); ?> <?php if($select_style =='style_1'){ ?> <section class="blog"> <div class="container"> <div class="min_blog_area"> <?php if( $blogPost->have_posts() ){ while ( $blogPost->have_posts() ){ $blogPost->the_post(); ?> <div class="single_blog wow fadeInLeft" data-wow-delay="0.3s"> <div class="blog_top"> <?php if( has_post_thumbnail() ){ ?> <?php the_post_thumbnail(); ?> <?php } ?> <span class="author"><a href="">by <?php echo get_the_author(); ?></a></span> </div> <div class="blog_bottom"> <div class="date_cetagory"> <span class="date"><?php echo get_the_date(); ?></span> <span>/</span> <?php $tags = get_the_tags(); if(!empty($tags)): foreach ($tags as $tag){ ?> <span class="cetagory"><?php echo $tag->name; ?>,</span> <?php } endif; ?> </div> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <a href="<?php the_permalink(); ?>" class="text_btn"><?php echo $settings['read_more_Text']; ?> <i class="fa-solid fa-arrow-right"></i></a> </div> </div> <?php } } ?> </div> </div> </section> <?php }elseif($select_style =='style_2'){ ?> <setion class="blog_grid_with_sidebar"> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="min_blog_area_blog_list grid two_col"> <div class="row"> <?php if( $blogPost->have_posts() ){ while ( $blogPost->have_posts() ){ $blogPost->the_post(); ?> <div class="col-xl-6"> <div class="single_blog wow fadeInLeft" data-wow-delay="0.3s"> <div class="blog_top"> <?php if( has_post_thumbnail() ){ ?> <?php the_post_thumbnail(); ?> <?php } ?> <span class="author"><a href="">by <?php echo get_the_author(); ?></a></span> </div> <div class="blog_bottom"> <div class="date_cetagory"> <span class="date"><?php echo get_the_date(); ?></span> <span>/</span> <?php $tags = get_the_tags(); if(!empty($tags)): foreach ($tags as $tag){ ?> <span class="cetagory"><?php echo $tag->name; ?>,</span> <?php } endif; ?> </div> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <a href="<?php the_permalink(); ?>" class="text_btn"><?php echo $settings['read_more_Text']; ?> <i class="fa-solid fa-arrow-right"></i></a> </div> </div> </div> <?php } } ?> </div> </div> </div> </div> </div> </setion> <?php }elseif($select_style =='style_3'){ ?> <setion class="blog_grid_with_sidebar"> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="min_blog_area_blog_list grid two_col"> <div class="row"> <?php if( $blogPost->have_posts() ){ while ( $blogPost->have_posts() ){ $blogPost->the_post(); ?> <div class="col-xl-4"> <div class="single_blog wow fadeInLeft" data-wow-delay="0.3s"> <div class="blog_top"> <?php if( has_post_thumbnail() ){ ?> <?php the_post_thumbnail(); ?> <?php } ?> <span class="author"><a href="">by <?php echo get_the_author(); ?></a></span> </div> <div class="blog_bottom"> <div class="date_cetagory"> <span class="date"><?php echo get_the_date(); ?></span> <span>/</span> <?php $tags = get_the_tags(); if(!empty($tags)): foreach ($tags as $tag){ ?> <span class="cetagory"><?php echo $tag->name; ?>,</span> <?php } endif; ?> </div> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <a href="<?php the_permalink(); ?>" class="text_btn"><?php echo $settings['read_more_Text']; ?> <i class="fa-solid fa-arrow-right"></i></a> </div> </div> </div> <?php } } ?> </div> </div> </div> </div> </div> </setion> <?php }else{ ?> <div class="min_blog_area_col_3"> <?php if( $blogPost->have_posts() ){ while ( $blogPost->have_posts() ){ $blogPost->the_post(); ?> <div class="single_blog wow fadeInLeft" data-wow-delay="0.3s"> <div class="blog_top"> <?php if( has_post_thumbnail() ){ ?> <?php the_post_thumbnail(); ?> <?php } ?> <span class="author"><a href="#">by <?php echo get_the_author(); ?></a></span> </div> <div class="blog_bottom"> <div class="date_cetagory"> <span class="date"><?php echo get_the_date(); ?></span> <span>/</span> <?php $tags = get_the_tags(); if(!empty($tags)): foreach ($tags as $tag){ ?> <span class="cetagory"><?php echo $tag->name; ?></span> <?php } endif; ?> </div> <h4><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words( get_the_title(), 6, false ); ?></a></h4> <a href="<?php the_permalink(); ?>" class="text_btn">Read more <i class="fa-solid fa-arrow-right"></i></a> </div> </div> <?php } } ?> </div> <?php } } public function load_widget_script(){ if( \Elementor\Plugin::$instance->editor->is_edit_mode() === true ) { ?> <script> ( function( $ ){ $('.min_blog_area').slick({ autoplay: true, infinite: true, slidesToShow: 2, slidesToScroll: 1, dots: true, arrows: false, speed: 300, responsive: [ { breakpoint: 992, settings: { slidesToShow: 1, } } ] }); $('.min_blog_area_col_3').slick({ autoplay: true, infinite: true, slidesToShow: 3, slidesToScroll: 1, dots: true, arrows: false, speed: 300, responsive: [ { breakpoint: 1400, settings: { slidesToShow: 2, } }, { breakpoint: 992, settings: { slidesToShow: 1, } } ] }); // end Slider Script })(jQuery); </script> <?php } } }