Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined( 'ABSPATH' ) ) exit; # Exit if accessed directly
- class Themeum_Product_crowdfunding_tab {
- public function get_name(){
- return 'themeum-crowdfuning-tab';
- }
- public function get_icon() {
- return 'wppb-font-trash';
- }
- public function get_category_name(){
- return __( 'Patrios Widgets', 'patrios-core' );
- }
- public function get_title(){
- return __( 'Crowdfunding Tab', 'patrios-core' );
- }
- # headline Settings Fields
- public function get_settings() {
- $settings = array(
- # General
- 'product_cats' => array(
- 'type' => 'select',
- 'title' => __('Select Category', 'patrios-core'),
- 'values' => crowdfunding_all_category_list('product_cat'),
- 'std' => 'allpost',
- 'multiple' => true,
- ),
- 'btn_name' => array(
- 'type' => 'text',
- 'title' => __('Button Text','patrios-core'),
- 'std' => 'See All Projects',
- ),
- 'btn_url' => array(
- 'type' => 'text',
- 'title' => __('Button URL','patrios-core'),
- 'std' => '#',
- ),
- # Style
- 'title_color' => array(
- 'type' => 'color2',
- 'title' => __('Color','patrios-core'),
- 'tab' => 'style',
- 'clip' => true,
- 'selector' => '{{SELECTOR}} .themeum-campaign-post .entry-title a'
- ),
- 'border_radius' => array(
- 'type' => 'dimension',
- 'title' => 'Border Radius',
- 'std' => array(
- 'md' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
- 'sm' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
- 'xs' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
- ),
- 'unit' => array( 'px', '%' ),
- 'responsive' => true,
- 'tab' => 'style',
- 'selector' => '{{SELECTOR}} .themeum-campaign-post { border-radius: {{data.border_radius}}; }'
- ),
- 'title_fontstyle' => array(
- 'type' => 'typography',
- 'title' => __('Typography','patrios-core'),
- 'std' => array(
- 'fontFamily' => '',
- 'fontSize' => array( 'md'=>'28px', 'sm'=>'', 'xs'=>'' ),
- 'lineHeight' => array( 'md'=>'', 'sm'=>'', 'xs'=>'' ),
- 'fontWeight' => '700',
- 'textTransform' => '',
- 'fontStyle' => '',
- 'letterSpacing' => array( 'md'=>'', 'sm'=>'', 'xs'=>'' ),
- ),
- 'selector' => '{{SELECTOR}} .themeum-campaign-post .entry-title a',
- 'tab' => 'style',
- ),
- );
- return $settings;
- }
- # Title Render HTML
- public function render($data = null){
- $settings = $data['settings'];
- $product_cat = isset($settings['product_cat']) ? $settings['product_cat'] : array();
- $button_name = $settings['btn_name'];
- $btn_url = isset($settings['btn_url']) ? $settings['btn_url'] : array();
- $arg = array(
- 'post_type' => 'product',
- 'post_status' => 'publish',
- );
- 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;
- }
- $category = array();
- $data = new \WP_Query( $arg );
- $reasult = get_terms('product_cat'); ob_start(); ?>
- <div class="row">
- <div class="col-12">
- <ul class="nav themeum-tab-navigation justify-content-center">
- <?php
- $i = 1;
- foreach ( $reasult as $value ) {
- if($i <= 20) {
- $category[] = $value->slug;
- if( $i == 1 ){ ?>
- <li class="nav-item">
- <a class="nav-link active" href="#<?php echo $value->slug;?>" data-toggle="pill"><?php echo $value->name;?></a>
- </li>
- <?php }else{ ?>
- <li class="nav-item">
- <a class="nav-link" href="#<?php echo $value->slug;?>" data-toggle="pill" ><?php echo $value->name;?></a>
- </li>
- <?php }
- }
- $i++;
- }
- ?>
- </ul>
- </div><!--/.col-12-->
- <div class="col-12">
- <div class="tab-content" id="pills-tabContent">
- <?php
- $i=1;
- foreach ($category as $value) {
- if( $i == 1){ ?>
- <div class="tab-pane fade show active" id="<?php echo $value;?>">
- <?php }else{?>
- <div class="tab-pane fade" id="<?php echo $value;?>">
- <?php } $i++; ?>
- <?php
- # Query Build
- $args = array(
- 'post_type' => 'product',
- 'post_status' => 'publish',
- 'product_cat' => $value ,
- 'posts_per_page' => 4,
- );
- $data = new \WP_Query( $args ); ?>
- <?php if( function_exists( 'wpneo_crowdfunding_price' ) ){ ?>
- <div class="row">
- <?php
- $count = 0;
- if ( $data->have_posts() ) :
- while ( $data->have_posts() ) : $data->the_post();
- # Campaign Love Button meta-data.
- $active = '';
- if ( is_user_logged_in() ) {
- $campaign_id = get_user_meta( get_current_user_id() , 'loved_campaign_ids', true);
- if( $campaign_id ){
- $campaign_id = json_decode( $campaign_id, true );
- if (in_array( get_the_ID() , $campaign_id )){
- $active = 'active';
- }
- }
- }
- # End.
- ?>
- <?php if($count == 0 ) { ?>
- <div class="col-lg-4 single-cam-img">
- <div class="themeum-tab-inners">
- <div class="themeum-tab-category">
- <?php if ( has_post_thumbnail() ){ ?>
- <div class="themeum-campaign-img">
- <a class="review-item-image" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('patrios-campaign', array('class' => 'img-fluid')); ?></a>
- </div>
- <?php } ?>
- <div class="thm-content text-left">
- <div class="themeum-campaign-post-content clearfix">
- <h3 class="entry-title-main"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
- </h3>
- </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>
- <span class="thm-raise-sp">
- <?php _e('Raised','patrios-core'); ?>
- <?php _e(' from','patrios-core'); ?>
- </span>
- <span class="thm-Price-amount">
- <?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_goal_by_campaign(get_the_ID())); ?>
- </span>
- <span class="thm-raise-sp">
- <?php _e('Goal','patrios-core'); ?>
- </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>
- </div>
- </div>
- </div>
- </div><!--col-lg-4-->
- <?php } else { ?>
- <?php if ($count == 1): ?>
- <div class="col-lg-8">
- <div class="themeum-tab-inner patrios-cam-list align-items-center">
- <?php endif; ?>
- <div class="campain-list-wrap">
- <div class="patrios-img-wrap">
- <?php if ( has_post_thumbnail() ){ ?>
- <div class="themeum-campaign-img">
- <a class="review-item-image single" href="<?php the_permalink(); ?>">
- <?php the_post_thumbnail('patrios-portfo', array('class' => 'img-fluid')); ?>
- </a>
- </div>
- <?php } ?>
- </div><!--/.col-sm-6-->
- <div class="patrios-content-wrap">
- <div class="thm-tab-content text-left">
- <div class="themeum-campaign-tab-post">
- <div class="themeum-campaign-post-content clearfix">
- <span class="entry-category"><?php echo get_the_term_list( get_the_ID(), 'product_cat', ' ', ', ', ' ' ); ?></span>
- <h3 class="entry-title">
- <a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a>
- </h3>
- </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>
- <span class="thm-raise-sp">
- <?php _e('Raised','patrios-core'); ?>
- <?php _e('from','patrios-core'); ?>
- </span>
- <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>
- <span class="thm-raise-sp">
- <?php _e('Goal','patrios-core'); ?>
- </span>
- </div>
- </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>
- </div>
- </div>
- </div><!--/.col-sm-6-->
- <div class="patrios-love-sign">
- <a href="#" class="thm-love-btn <?php echo $active; ?>" data-campaign="<?php echo get_the_ID(); ?>" data-user="<?php echo get_current_user_id(); ?>">
- <?php echo ($active) ? '<i class="fa fa-heart"></i>' : '<i class="fa fa-heart-o"></i>'; ?>
- </a>
- </div>
- </div>
- <?php
- if ( $count == 4 || ( $count <= 4 && ( ( $data->post_count - 1 ) == $count ) ) ): ?>
- <div class="view-campaign">
- <?php if ($settings['btn_url']) { ?>
- <a href="<?php echo $settings['btn_url']; ?>">
- <?php echo $button_name; ?>
- </a>
- <?php } ?>
- </div>
- </div><!--.themeum-tab-inner-->
- </div><!--.col-lg-8-->
- <?php endif; ?>
- <?php } ?>
- <?php $count++; ?>
- <?php
- endwhile;
- wp_reset_query();
- endif; ?>
- </div><!--/.col-lg-8-->
- <?php } ?>
- </div> <!--/.tab-pane-->
- <?php } ?>
- </div><!--/.tab-content-->
- </div> <!--/.col-12-->
- </div><!--/.row-->
- <?php
- $output = ob_get_contents();
- ob_end_clean();
- wp_reset_postdata();
- return $output; ?>
- <?php }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement