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_crowdfunding_Donate extends Widget_Base {
- public function get_name() {
- return 'donate-product-grid';
- }
- public function get_title() {
- return __( 'Crowdfunding Donate', 'themeum-core' );
- }
- 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', 'themeum-core' )
- ]
- );
- $this->add_control(
- 'product_number',
- [
- 'label' => __( 'Number of Products', 'themeum-core' ),
- 'type' => Controls_Manager::NUMBER,
- 'label_block' => true,
- 'default' => 6
- ]
- );
- $this->add_control(
- 'product_column',
- [
- 'label' => __( 'Number of Column', 'themeum-core' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 4,
- 'options' => [
- '12' => __( 'One Column', 'themeum-core' ),
- '6' => __( 'Two Column', 'themeum-core' ),
- '4' => __( 'Three Column', 'themeum-core' ),
- '3' => __( 'Four Column', 'themeum-core' ),
- ],
- ]
- );
- $this->add_control(
- 'product_cat',
- [
- 'label' => __( 'Product Category', 'themeum-core' ),
- 'type' => Controls_Manager::SELECT,
- 'options' => crowdfunding_all_category_list( 'product_cat' ),
- 'multiple' => true,
- 'default' => 'allpost',
- ]
- );
- $this->add_control(
- 'product_pagination',
- [
- 'label' => __( 'Post Pagination', 'themeum-core' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => 'No',
- 'label_on' => __( 'Yes', 'themeum-core' ),
- 'label_off' => __( 'No', 'themeum-core' ),
- 'selectors' => [
- '{{WRAPPER}} iframe' => 'pointer-events: none;',
- ],
- ]
- );
- $this->add_control(
- 'product_filter',
- [
- 'label' => __( 'Product Show', 'themeum-core' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 'latest',
- 'options' => [
- 'popular' => __( 'Popular(By View)', 'themeum-core' ),
- 'latest' => __( 'Latest', 'themeum-core' ),
- 'recommended' => __( 'Recommended Pick', 'themeum-core' ),
- ],
- ]
- );
- $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}} .themeum-campaign-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}} .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', '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}} .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'];
- $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;
- }
- $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(); ?>
- <!-- single item start -->
- <div class="col-md-4 col-sm-4 col-xs-12">
- <div class="rc-causes-item causes-style-two">
- <div class="rc-thumb">
- <?php if ( has_post_thumbnail() ){ ?>
- <a class="img-responsive" href="<?php the_permalink(); ?>">
- <?php the_post_thumbnail('backnow-medium', array('class' => 'img-fluid')); ?>
- </a>
- <?php } ?>
- <div class="donate-btn">
- <?php $baker_list = WPNEOCF()->getCustomersByProduct(); ?>
- <a href="#"><i class="fa fa-heart"></i><?php echo count($baker_list); ?> <?php esc_html_e('Donators', 'backnow')?></a>
- </div>
- </div>
- <div class="rc-causes-info">
- <div class="causes-progress" data-sr="enter">
- <?php $css_width = WPNEOCF()->getFundRaisedPercent(); if( $css_width >= 100 ){ $css_width = 100; } ?>
- <div class="progress-bar left-anim" role="progressbar" style="width: <?php echo $css_width; ?>%;">
- <span><?php echo $css_width; ?>%</span>
- </div>
- </div>
- <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
- <p> <?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_fund_raised_by_campaign()); ?> <span class="theme__text">donated of</span>
- <br><?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_goal_by_campaign(get_the_ID())); ?> <span class="theme__text">goal</span></p>
- </div>
- <div class="rc-donate-btn">
- <a href="#">Donate Now</a>
- <a href="<?php the_permalink(); ?>"><?php esc_html_e('More Details', 'backnow'); ?></a>
- </div>
- </div>
- </div>
- <!-- END single item start -->
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- <?php endif; ?>
- </div>
- <?php } ?>
- <?php }
- protected function _content_template() { }
- }
- Plugin::instance()->widgets_manager->register_widget_type( new Themeum_Widget_crowdfunding_Donate() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement