Advertisement
rejuancse

crowfunding-tab

Nov 7th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.03 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) exit; # Exit if accessed directly
  4.  
  5. class Themeum_Product_crowdfunding_tab {
  6.  
  7.     public function get_name(){
  8.         return 'themeum-crowdfuning-tab';
  9.     }
  10.     public function get_icon() {
  11.         return 'wppb-font-trash';
  12.     }
  13.     public function get_category_name(){
  14.         return __( 'Patrios Widgets', 'patrios-core' );
  15.     }
  16.     public function get_title(){
  17.         return __( 'Crowdfunding Tab', 'patrios-core' );
  18.     }
  19.    
  20.     # headline Settings Fields
  21.     public function get_settings() {
  22.  
  23.         $settings = array(
  24.  
  25.             # General
  26.             'product_cats' => array(
  27.                 'type'      => 'select',
  28.                 'title'     => __('Select Category', 'patrios-core'),
  29.                 'values'    => crowdfunding_all_category_list('product_cat'),
  30.                 'std'       => 'allpost',
  31.                 'multiple'  => true,
  32.             ),
  33.             'btn_name' => array(
  34.                 'type'      => 'text',
  35.                 'title'     => __('Button Text','patrios-core'),
  36.                 'std'       => 'See All Projects',
  37.             ),
  38.             'btn_url' => array(
  39.                 'type'      => 'text',
  40.                 'title'     => __('Button URL','patrios-core'),
  41.                 'std'       => '#',
  42.             ),
  43.  
  44.             # Style
  45.             'title_color' => array(
  46.                 'type'      => 'color2',
  47.                 'title'     => __('Color','patrios-core'),
  48.                 'tab'       => 'style',
  49.                 'clip'      => true,
  50.                 'selector'  => '{{SELECTOR}} .themeum-campaign-post .entry-title a'
  51.             ),
  52.             'border_radius' => array(
  53.                 'type'      => 'dimension',
  54.                 'title'     => 'Border Radius',
  55.                 'std'       => array(
  56.                         'md'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  57.                         'sm'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  58.                         'xs'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  59.                         ),
  60.                 'unit'          => array( 'px', '%' ),
  61.                 'responsive'    => true,
  62.                 'tab'           => 'style',
  63.                 'selector'      => '{{SELECTOR}} .themeum-campaign-post { border-radius: {{data.border_radius}}; }'
  64.             ),
  65.            
  66.             'title_fontstyle' => array(
  67.                 'type'      => 'typography',
  68.                 'title'     => __('Typography','patrios-core'),
  69.                 'std'   => array(
  70.                     'fontFamily'    => '',
  71.                     'fontSize'      => array( 'md'=>'28px', 'sm'=>'', 'xs'=>'' ),
  72.                     'lineHeight'    => array( 'md'=>'', 'sm'=>'', 'xs'=>'' ),
  73.                     'fontWeight'    => '700',
  74.                     'textTransform' => '',
  75.                     'fontStyle'     => '',
  76.                     'letterSpacing' => array( 'md'=>'', 'sm'=>'', 'xs'=>'' ),
  77.                 ),
  78.                 'selector'  => '{{SELECTOR}} .themeum-campaign-post .entry-title a',
  79.                 'tab'       => 'style',
  80.             ),
  81.  
  82.  
  83.  
  84.            
  85.         );
  86.  
  87.         return $settings;
  88.     }
  89.  
  90.     # Title Render HTML
  91.     public function render($data = null){
  92.         $settings       = $data['settings'];
  93.  
  94.         $product_cat    = isset($settings['product_cat']) ? $settings['product_cat'] : array();
  95.         $button_name        = $settings['btn_name'];
  96.         $btn_url        = isset($settings['btn_url']) ? $settings['btn_url'] : array();
  97.  
  98.         $arg = array(
  99.             'post_type'     => 'product',
  100.             'post_status'   => 'publish',
  101.         );
  102.  
  103.         if( $product_cat ){
  104.             $cat_data = array();
  105.             $cat_data['relation'] = 'AND';
  106.             $cat_data[] = array(
  107.                         'taxonomy' => 'product_type',
  108.                         'field'    => 'slug',
  109.                         'terms'    => 'crowdfunding',
  110.                     );
  111.             if( $product_cat != 'allpost' ){
  112.                 $cat_data[] = array(
  113.                         'taxonomy'  => 'product_cat',
  114.                         'field'     => 'slug',
  115.                         'terms'     => $product_cat
  116.                     );
  117.             }
  118.             $arg['tax_query'] = $cat_data;
  119.         }
  120.         $category = array();
  121.         $data = new \WP_Query( $arg );
  122.         $reasult = get_terms('product_cat'); ob_start();  ?>
  123.  
  124.         <div class="row">
  125.  
  126.             <div class="col-12">
  127.                 <ul class="nav themeum-tab-navigation justify-content-center">
  128.                     <?php
  129.                     $i = 1;
  130.                     foreach ( $reasult as $value ) {
  131.                         if($i <= 20) {
  132.                                
  133.                                 $category[] = $value->slug;
  134.                                 if( $i == 1 ){ ?>
  135.                                     <li class="nav-item">
  136.                                         <a class="nav-link active" href="#<?php echo $value->slug;?>" data-toggle="pill"><?php echo $value->name;?></a>
  137.                                     </li>
  138.                                 <?php }else{ ?>
  139.                                     <li class="nav-item">
  140.                                         <a class="nav-link" href="#<?php echo $value->slug;?>" data-toggle="pill" ><?php echo $value->name;?></a>
  141.                                     </li>
  142.                                 <?php }
  143.                             }
  144.                             $i++;
  145.                         }
  146.                     ?>
  147.                 </ul>
  148.             </div><!--/.col-12-->
  149.  
  150.             <div class="col-12">
  151.                 <div class="tab-content" id="pills-tabContent">
  152.                
  153.                     <?php
  154.                     $i=1;
  155.                     foreach ($category as $value) {
  156.                         if( $i == 1){ ?>
  157.                         <div class="tab-pane fade show active" id="<?php echo $value;?>">
  158.                         <?php }else{?>
  159.                         <div class="tab-pane fade" id="<?php echo $value;?>">
  160.                         <?php } $i++; ?>  
  161.  
  162.                             <?php
  163.                             # Query Build
  164.                             $args = array(
  165.                                     'post_type'         => 'product',
  166.                                     'post_status'       => 'publish',
  167.                                     'product_cat'       => $value ,
  168.                                     'posts_per_page'    => 4,
  169.                                 );
  170.  
  171.                             $data = new \WP_Query( $args ); ?>
  172.  
  173.                             <?php if( function_exists( 'wpneo_crowdfunding_price' ) ){ ?>
  174.  
  175.                                 <div class="row">
  176.                                     <?php
  177.  
  178.                                     $count = 0;
  179.                                     if ( $data->have_posts() ) :
  180.                                     while ( $data->have_posts() ) : $data->the_post();
  181.  
  182.                                         # Campaign Love Button meta-data.
  183.                                         $active = '';
  184.                                         if ( is_user_logged_in() ) {
  185.                                             $campaign_id = get_user_meta( get_current_user_id() , 'loved_campaign_ids', true);
  186.                                             if( $campaign_id ){
  187.                                                 $campaign_id = json_decode( $campaign_id, true );
  188.                                                 if (in_array( get_the_ID() , $campaign_id )){
  189.                                                     $active = 'active';
  190.                                                 }
  191.                                             }
  192.                                         }
  193.                                         # End.
  194.                                         ?>
  195.  
  196.                                        
  197.                                         <?php if($count == 0 ) { ?>
  198.                                             <div class="col-lg-4 single-cam-img">
  199.                                                 <div class="themeum-tab-inners">
  200.                                                     <div class="themeum-tab-category">
  201.                                                         <?php if ( has_post_thumbnail() ){ ?>
  202.                                                         <div class="themeum-campaign-img">
  203.                                                             <a class="review-item-image"  href="<?php the_permalink(); ?>"><?php the_post_thumbnail('patrios-campaign', array('class' => 'img-fluid')); ?></a>
  204.                                                         </div>
  205.                                                         <?php } ?>
  206.                                                         <div class="thm-content text-left">
  207.                                                             <div class="themeum-campaign-post-content clearfix">
  208.                                                                 <h3 class="entry-title-main"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  209.                                                                 </h3>
  210.                                                             </div>
  211.                                                             <div class="progressbar-content-wrapper">
  212.                                                                 <div class="thm-progress-bar">
  213.                                                                     <div class="lead">
  214.                                                                         <span class="thm-Price-amount"><?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_fund_raised_by_campaign()); ?></span>
  215.                                                                         <span class="thm-raise-sp">
  216.                                                                             <?php _e('Raised','patrios-core'); ?>
  217.                                                                             <?php _e(' from','patrios-core'); ?>
  218.                                                                         </span>
  219.                                                                         <span class="thm-Price-amount">
  220.                                                                             <?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_goal_by_campaign(get_the_ID())); ?>
  221.                                                                         </span>
  222.                                                                         <span class="thm-raise-sp">
  223.                                                                             <?php _e('Goal','patrios-core'); ?>
  224.                                                                         </span>
  225.                                                                     </div>
  226.                                                                     <div class="progress">
  227.                                                                         <?php $css_width = WPNEOCF()->getFundRaisedPercent(); if( $css_width >= 100 ){ $css_width = 100; } ?>
  228.                                                                         <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>
  229.                                                                     </div>
  230.                                                                 </div>
  231.                                                             </div>
  232.                                                         </div>
  233.                                                     </div>
  234.                                                 </div>
  235.                                             </div><!--col-lg-4-->
  236.                                         <?php } else { ?>
  237.                                                
  238.                                                 <?php if ($count == 1): ?>
  239.                                                     <div class="col-lg-8">
  240.                                                     <div class="themeum-tab-inner patrios-cam-list align-items-center">
  241.                                                 <?php endif; ?>
  242.  
  243.                                                 <div class="campain-list-wrap">
  244.                                                     <div class="patrios-img-wrap">
  245.                                                         <?php if ( has_post_thumbnail() ){ ?>
  246.                                                             <div class="themeum-campaign-img">
  247.                                                                 <a class="review-item-image single"  href="<?php the_permalink(); ?>">
  248.                                                                     <?php the_post_thumbnail('patrios-portfo', array('class' => 'img-fluid')); ?>
  249.                                                                 </a>
  250.                                                             </div>
  251.                                                         <?php } ?>
  252.                                                     </div><!--/.col-sm-6-->
  253.  
  254.                                                     <div class="patrios-content-wrap">
  255.                                                         <div class="thm-tab-content text-left">
  256.                                                             <div class="themeum-campaign-tab-post">
  257.                                                                 <div class="themeum-campaign-post-content clearfix">
  258.                                                                     <span class="entry-category"><?php echo get_the_term_list( get_the_ID(), 'product_cat', ' ', ', ', ' ' ); ?></span>
  259.                                                                     <h3 class="entry-title">
  260.                                                                         <a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a>
  261.                                                                     </h3>
  262.                                                                 </div>
  263.                                                                 <div class="progressbar-content-wrapper">
  264.                                                                     <div class="thm-progress-bar">
  265.                                                                         <div class="lead">
  266.                                                                             <span class="thm-Price-amount">
  267.                                                                             <?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_fund_raised_by_campaign()); ?>
  268.                                                                             </span>
  269.                                                                             <span class="thm-raise-sp">
  270.                                                                                 <?php _e('Raised','patrios-core'); ?>
  271.                                                                                 <?php _e('from','patrios-core'); ?>
  272.                                                                             </span>
  273.                                                                             <div class="thm-meta-desc">
  274.                                                                                 <span class="thm-Price-amount">
  275.                                                                                     <?php echo wpneo_crowdfunding_price(wpneo_crowdfunding_get_total_goal_by_campaign(get_the_ID())); ?>
  276.                                                                                 </span>
  277.                                                                                 <span class="thm-raise-sp">
  278.                                                                                     <?php _e('Goal','patrios-core'); ?>
  279.                                                                                 </span>
  280.                                                                             </div>
  281.                                                                         </div>
  282.                                                                         <div class="progress">
  283.                                                                             <?php $css_width = WPNEOCF()->getFundRaisedPercent(); if( $css_width >= 100 ){ $css_width = 100; } ?>
  284.                                                                             <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>
  285.                                                                         </div>
  286.                                                                     </div>
  287.                                                                 </div>
  288.                                                             </div>
  289.                                                         </div>
  290.                                                     </div><!--/.col-sm-6-->
  291.  
  292.                                                     <div class="patrios-love-sign">
  293.                                                         <a href="#" class="thm-love-btn <?php echo $active; ?>" data-campaign="<?php echo get_the_ID(); ?>" data-user="<?php echo get_current_user_id(); ?>">
  294.                                                             <?php echo ($active)  ? '<i class="fa fa-heart"></i>' : '<i class="fa fa-heart-o"></i>'; ?>
  295.                                                         </a>
  296.                                                     </div>
  297.                                                 </div>
  298.                                                 <?php
  299.                                                 if ( $count == 4 || ( $count <= 4 && ( ( $data->post_count - 1 ) == $count ) ) ): ?>
  300.                                                     <div class="view-campaign">
  301.                                                         <?php if ($settings['btn_url']) { ?>
  302.                                                             <a href="<?php echo $settings['btn_url']; ?>">
  303.                                                                 <?php echo $button_name; ?>
  304.                                                             </a>
  305.                                                         <?php } ?>
  306.                                                     </div>
  307.  
  308.                                                     </div><!--.themeum-tab-inner-->
  309.                                                     </div><!--.col-lg-8-->
  310.                                                 <?php endif; ?>
  311.  
  312.  
  313.                                         <?php } ?>
  314.                                            
  315.                                         <?php $count++; ?>
  316.                                     <?php
  317.                                     endwhile;
  318.                                     wp_reset_query();
  319.                                     endif;  ?> 
  320.                                 </div><!--/.col-lg-8-->
  321.  
  322.                             <?php } ?>
  323.  
  324.                     </div> <!--/.tab-pane-->
  325.                     <?php } ?>                                    
  326.                 </div><!--/.tab-content-->
  327.             </div> <!--/.col-12-->
  328.        
  329.         </div><!--/.row-->
  330.  
  331.         <?php
  332.         $output = ob_get_contents();
  333.         ob_end_clean();
  334.         wp_reset_postdata();
  335.         return $output; ?>
  336.  
  337.     <?php }
  338.  
  339. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement