Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Elementor;
- if ( ! defined( 'ABSPATH' ) ) exit; # Exit if accessed directly
- class Themeum_Widget_Post_Slider extends Widget_Base {
- public function get_name() {
- return 'newskit-post-slider';
- }
- public function get_title() {
- return __( 'Themeum Post Slider', 'themeum-core' );
- }
- public function get_icon() {
- return 'eicon-gallery-grid';
- }
- public function get_categories() {
- return [ 'themeum-elementor' ];
- }
- protected function _register_controls() {
- $this->start_controls_section(
- 'woo_product',
- [
- 'label' => __( 'Post Element', 'themeum-core' )
- ]
- );
- $this->add_control(
- 'post_number',
- [
- 'label' => __( 'Number of Posts', 'themeum-core' ),
- 'type' => Controls_Manager::NUMBER,
- 'label_block' => true,
- 'default' => __( '9', 'themeum-core' ),
- ]
- );
- $this->add_control(
- 'post_cat',
- [
- 'label' => __( 'Product Category', 'themeum-core' ),
- 'type' => Controls_Manager::SELECT,
- 'options' => themeum_cat_list( 'category' ),
- 'multiple' => true,
- 'default' => 'allpost'
- ]
- );
- $this->add_control(
- 'post_order_by',
- [
- 'label' => __( 'Order', 'themeum-core' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 'DESC',
- 'options' => [
- 'DESC' => __( 'Descending', 'themeum-core' ),
- 'ASC' => __( 'Ascending', 'themeum-core' ),
- ],
- ]
- );
- $this->add_control(
- 'textlimit',
- [
- 'label' => __( 'Text Limit Of Content', 'themeum-core' ),
- 'type' => Controls_Manager::NUMBER,
- 'label_block' => true,
- 'default' => 280,
- ]
- );
- $this->end_controls_section();
- # Title Section
- $this->start_controls_section(
- 'section_title_style',
- [
- 'label' => __( 'Title', 'themeum-core' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'border_radius',
- [
- 'label' => __( 'Border Radius', 'themeum-core' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', '%' ],
- 'selectors' => [
- '{{WRAPPER}} .blog-post-item-col .newskit-index-post' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
- $this->add_control(
- 'title_color',
- [
- 'label' => __( 'Title Color', 'themeum-core' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .newskit-post .content-item-title a' => 'color: {{VALUE}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
- 'selector' => '{{WRAPPER}} .newskit-post .content-item-title a',
- ]
- );
- $this->end_controls_section();
- # Title Section End
- #Pagination Section
- $this->start_controls_section(
- 'section_pagination_style',
- [
- 'label' => __( 'Pagination', 'themeum-core' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_responsive_control(
- 'post_align',
- [
- 'label' => __( 'Alignment', 'themeum-core' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'themeum-core' ),
- 'icon' => 'fa fa-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'themeum-core' ),
- 'icon' => 'fa fa-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'themeum-core' ),
- 'icon' => 'fa fa-align-right',
- ],
- 'justify' => [
- 'title' => __( 'Justified', 'themeum-core' ),
- 'icon' => 'fa fa-align-justify',
- ],
- ],
- 'default' => 'center',
- 'selectors' => [
- '{{WRAPPER}} .themeum-pagination' => 'text-align: {{VALUE}}; display: inline-block; width: 100%;',
- ],
- ]
- );
- $this->end_controls_section();
- #Subtitle Section
- $this->start_controls_section(
- 'section_price_style',
- [
- 'label' => __( 'Subtitle', 'themeum-core' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'content_color',
- [
- 'label' => __( 'Content Color', 'themeum-core' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_2,
- ],
- 'selectors' => [
- '{{WRAPPER}} .newskit-post .entry-summary' => 'color: {{VALUE}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography2',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_2,
- 'selector' => '{{WRAPPER}} .newskit-post .entry-summary',
- ]
- );
- } # function _register_controls end
- protected function render( ) {
- $settings = $this->get_settings();
- $post_number = $settings['post_number'];
- $post_cat = $settings['post_cat'];
- $post_order_by = $settings['post_order_by'];
- $textlimit = $settings['textlimit'];
- $page_numb = max( 1, get_query_var('paged') );
- # Query Build
- $arg = array(
- 'post_type' => 'post',
- 'post_status' => 'publish',
- );
- if( $post_order_by ){
- $arg['order'] = $post_order_by;
- }
- if( $page_numb ){
- $arg['paged'] = $page_numb;
- }
- if( $post_number ){
- $arg['posts_per_page'] = $post_number;
- }
- if( $post_cat ){
- if( $post_cat != 'allpost' ){
- $cat_data = array();
- $cat_data['relation'] = 'AND';
- $cat_data[] = array(
- 'taxonomy' => 'category',
- 'field' => 'slug',
- 'terms' => $post_cat
- );
- $arg['tax_query'] = $cat_data;
- }
- }
- $data = new \WP_Query( $arg );
- ?>
- <div class="container-fluid healine-wrapper slider-post-cont-wrap">
- <?php
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $args = array(
- 'post_type' => 'post',
- 'paged' => $paged
- );
- $index = 1;
- ?>
- <div class="themeum-post-slider" >
- <?php
- if ( $data->have_posts() ) :
- while ( $data->have_posts() ) : $data->the_post();
- ?>
- <div class="thm-slider-wrap">
- <div class="section-img">
- <?php if ( has_post_thumbnail()) { ?>
- <a class="item-image" href="<?php get_permalink(); ?>">
- <?php echo get_the_post_thumbnail(get_the_ID(), 'newskit-slider', array('class' => 'img-responsive')); ?>
- </a>
- <?php } ?>
- <!-- add js file: $('.prettySocial').prettySocial(); -->
- <!-- CSS file add:
- .thm-slider-wrap .section-img {
- width: 50%;
- float: left;
- overflow: hidden;
- position: relative;
- }
- .thm-slider-wrap:hover .post-share-social{
- opacity: 1;
- visibility: visible;
- }
- -->
- <div class="article-image-wrap">
- <div class="post-share-social">
- <span class="share-button"><i class="fa fa-share-square-o"></i></span>
- <div class="post-share-social-others">
- <a href="#" data-type="facebook" class="fa fa-facebook prettySocial"></a>
- <a href="#" data-type="twitter" class="fa fa-twitter prettySocial"></a>
- <a href="#" data-type="googleplus" class="fa fa-google-plus prettySocial"></a>
- </div>
- </div>
- </div>
- </div>
- <div class="total-content">
- <?php if ( get_theme_mod( 'blog_category', true ) ): ?>
- <ul class="blog-post-cat">
- <?php if ( get_theme_mod( 'blog_category', true ) ): ?>
- <li class="meta-category"><?php printf(esc_html__('%s', 'themeum-core'), get_the_category_list(' ')); ?></li>
- <?php endif; ?>
- </ul>
- <?php endif; ?>
- <div class="blog-date-wrapper">
- <span><time datetime="<?php echo get_the_date('Y-m-d') ?>"><?php echo get_the_date(); ?></time></span>
- </div>
- <h2><a href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a></h2>
- <?php
- if ( $textlimit ) {
- if (get_theme_mod( 'blog_intro_text_en', true )) {
- echo newskit_excerpt_max_charlength($textlimit);
- }
- } else {
- the_content();
- }
- ?>
- </div>
- </div>
- <?php
- endwhile;
- endif;?>
- </div>
- <?php wp_reset_postdata();
- ?>
- </div><!-- row (inner) -->
- <?php }
- protected function _content_template() { }
- }
- Plugin::instance()->widgets_manager->register_widget_type( new Themeum_Widget_Post_Slider() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement