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_Product_Grid extends Widget_Base {
- public function get_name() {
- return 'backer-product-grid';
- }
- public function get_title() {
- return __( 'Themeum Crowdfunding Grid', 'backer' );
- }
- public function get_icon() {
- return 'eicon-inner-section';
- }
- public function get_categories() {
- return [ 'themeum-elementor' ];
- }
- protected function _register_controls() {
- $this->start_controls_section(
- 'product_element',
- [
- 'label' => __( 'Product Element', 'backer' )
- ]
- );
- $this->add_control(
- 'product_number',
- [
- 'label' => __( 'Number of Products', 'backer' ),
- 'type' => Controls_Manager::NUMBER,
- 'label_block' => true,
- 'default' => 6
- ]
- );
- $this->add_control(
- 'product_column',
- [
- 'label' => __( 'Number of Column', 'backer' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 4,
- 'options' => [
- '12' => __( 'One Column', 'backer' ),
- '6' => __( 'Two Column', 'backer' ),
- '4' => __( 'Three Column', 'backer' ),
- '3' => __( 'Four Column', 'backer' ),
- ],
- ]
- );
- $this->add_control(
- 'product_cat',
- [
- 'label' => __( 'Product Category', 'backer' ),
- 'type' => Controls_Manager::SELECT,
- 'options' => crowdfunding_all_category_list( 'product_cat' ),
- 'multiple' => true,
- 'default' => 'allpost',
- ]
- );
- $this->add_control(
- 'textlimit',
- [
- 'label' => __( 'Text Limit Of Content', 'backer' ),
- 'type' => Controls_Manager::NUMBER,
- 'label_block' => true,
- 'default' => 280,
- ]
- );
- $this->add_control(
- 'product_pagination',
- [
- 'label' => __( 'Post Pagination', 'backer' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => 'No',
- 'label_on' => __( 'Yes', 'backer' ),
- 'label_off' => __( 'No', 'backer' ),
- 'selectors' => [
- '{{WRAPPER}} iframe' => 'pointer-events: none;',
- ],
- ]
- );
- $this->add_control(
- 'product_filter',
- [
- 'label' => __( 'Product Show', 'backer' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 'latest',
- 'options' => [
- 'popular' => __( 'Popular(By View)', 'backer' ),
- 'latest' => __( 'Latest', 'backer' ),
- 'recommended' => __( 'Recommended Pick', 'backer' ),
- ],
- ]
- );
- $this->end_controls_section();
- # Title Section
- $this->start_controls_section(
- 'section_title_style',
- [
- 'label' => __( 'Title', 'backer' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'border_radius',
- [
- 'label' => __( 'Border Radius', 'backer' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', '%' ],
- 'selectors' => [
- '{{WRAPPER}} .themeum-campaign-post' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
- $this->add_control(
- 'title_color',
- [
- 'label' => __( 'Title Color', 'backer' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .themeum-campaign-post .entry-title a' => 'color: {{VALUE}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
- 'selector' => '{{WRAPPER}} .themeum-campaign-post .entry-title a',
- ]
- );
- $this->end_controls_section();
- # Title Section End
- #Pagination Section
- $this->start_controls_section(
- 'section_pagination_style',
- [
- 'label' => __( 'Pagination', 'backer' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_responsive_control(
- 'post_align',
- [
- 'label' => __( 'Alignment', 'backer' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'backer' ),
- 'icon' => 'fa fa-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'backer' ),
- 'icon' => 'fa fa-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'backer' ),
- 'icon' => 'fa fa-align-right',
- ],
- 'justify' => [
- 'title' => __( 'Justified', 'backer' ),
- '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', 'backer' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'content_color',
- [
- 'label' => __( 'Content Color', 'backer' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_2,
- ],
- 'selectors' => [
- '{{WRAPPER}} .themeum-campaign-post > p' => 'color: {{VALUE}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography2',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_2,
- 'selector' => '{{WRAPPER}} .themeum-campaign-post > p',
- ]
- );
- } # function _register_controls end
- protected function render( ) {
- $settings = $this->get_settings();
- $product_number = $settings['product_number'];
- $product_column = $settings['product_column'];
- $product_cat = $settings['product_cat'];
- $product_pagination = $settings['product_pagination'];
- $textlimit = $settings['textlimit'];
- $product_filter = $settings['product_filter'];
- $page_numb = max( 1, get_query_var('paged') );
- $arg = array(
- 'post_type' => 'product',
- 'post_status' => 'publish',
- );
- if( $page_numb ){
- $arg['paged'] = $page_numb;
- }
- if( $product_number ){
- $arg['posts_per_page'] = $product_number;
- }
- switch( $product_filter ){
- case 'popular':
- $arg['order'] = 'DESC';
- $arg['orderby'] = 'meta_value_num';
- $arg['meta_key'] = '_post_views_count';
- break;
- case 'recommended':
- $arg['order'] = 'ASC';
- $arg['meta_query'] = array(
- array(
- 'key' => 'themeum_handpick',
- 'value' => 1,
- 'compare' => '=',
- )
- );
- break;
- default:
- # code...
- break;
- }
- if( $product_cat ){
- $cat_data = array();
- $cat_data['relation'] = 'AND';
- $cat_data[] = array(
- 'taxonomy' => 'product_type',
- 'field' => 'slug',
- 'terms' => 'crowdfunding',
- );
- if( $product_cat != 'allpost' ){
- $cat_data[] = array(
- 'taxonomy' => 'product_cat',
- 'field' => 'slug',
- 'terms' => $product_cat
- );
- }
- $arg['tax_query'] = $cat_data;
- }
- // echo '<pre>';
- // print_r( $arg );
- // echo '</pre>';
- $data = new \WP_Query( $arg );
- ?>
- <?php if( function_exists( 'wpneo_crowdfunding_price' ) ){ ?>
- <div class="row">
- <?php if ( $data->have_posts() ) : ?>
- <?php while ( $data->have_posts() ) : $data->the_post(); ?>
- <div class="col-12 col-sm-12 col-md-6 col-lg-<?php echo $product_column; ?>"><?php /*echo get_post_meta( get_the_ID(),'_nf_duration_end',true );*/ ?>
- <div class="themeum-campaign-post">
- <?php if ( has_post_thumbnail() ){ ?>
- <div class="themeum-campaign-img">
- <a class="review-item-image" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('backer-portfo', array('class' => 'img-fluid')); ?></a>
- </div>
- <?php } ?>
- <div class="themeum-campaign-post-content clearfix">
- <h3 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
- <span class="entry-author"><?php _e('by','backer'); ?> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php echo get_the_author_meta('display_name'); ?></a></span>
- <span class="entry-category"><?php echo get_the_term_list( get_the_ID(), 'product_cat', 'in ', ', ' ); ?></span>
- <p><?php echo backer_excerpt_max_charlength( $textlimit ); ?></p>
- </div>
- <div class="progressbar-content-wrapper">
- <div class="thm-progress-bar">
- <div class="lead"><span class="thm-Price-amount"><?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_fund_raised_by_campaign()); ?></span> <?php _e('Raised','backer'); ?> <span class="percentag pull-right"><?php echo WPNEOCF()->getFundRaisedPercentFormat(); ?></span></div>
- <div class="progress">
- <?php $css_width = WPNEOCF()->getFundRaisedPercent(); if( $css_width >= 100 ){ $css_width = 100; } ?>
- <div class="progress-bar progress-bar-primary six-sec-ease-in-out" role="progressbar" data-valuetransitiongoal="<?php echo $css_width; ?>" style="width: <?php echo $css_width; ?>%;"></div>
- </div>
- </div>
- <div class="thm-funding-goal">
- <div class="thm-meta-desc"><span class="thm-Price-amount"><?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_goal_by_campaign(get_the_ID())); ?> </span><?php _e('Goal','backer'); ?></div>
- <?php
- $wpneo_campaign_end_method = get_post_meta(get_the_ID(), 'wpneo_campaign_end_method', true);
- if ($wpneo_campaign_end_method != 'never_end'){ ?>
- <div class="thm-meta-name pull-right"><?php echo WPNEOCF()->dateRemaining(); ?> <?php _e('Days to Go','backer'); ?></div>
- <?php } ?>
- </div>
- </div>
- <div class="themeum-campaign-location">
- <span class="location"><i class="fa fa-map-marker"></i> <?php echo wpneo_crowdfunding_get_campaigns_location(); ?></span>
- </div>
- </div>
- </div>
- <?php endwhile; ?>
- <div class="col-12">
- <?php
- if( $product_pagination == 'yes' ){
- $max_page = $data->max_num_pages;
- echo backer_pagination( $page_numb, $max_page );
- }
- ?>
- </div>
- <?php wp_reset_query(); ?>
- <?php endif; ?>
- </div>
- <?php } ?>
- <?php }
- protected function _content_template() { }
- }
- Plugin::instance()->widgets_manager->register_widget_type( new Themeum_Widget_Product_Grid() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement