Advertisement
rejuancse

category-list

Sep 28th, 2018
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.57 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) exit; # Exit if accessed directly
  4.  
  5. class Themeum_Product_category_List {
  6.  
  7.     public function get_name(){
  8.         return 'themeum-product-category';
  9.     }
  10.     public function get_icon() {
  11.         return 'wppb-font-trash';
  12.     }
  13.     public function get_category_name(){
  14.         return __( 'Backnow Widgets', 'themeum-core' );
  15.     }
  16.     public function get_title(){
  17.         return __( 'Product Category List', 'themeum-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', 'themeum-core'),
  29.                 'values'    => crowdfunding_all_category_list('product_cat'),
  30.                 'std'       => 'allpost',
  31.                 'multiple'  => true,
  32.             ),
  33.             'number' => array(
  34.                 'type'      => 'slider',
  35.                 'title'     => __('Number Width','wp-pagebuilder'),
  36.                 'range'     => array(
  37.                             'min'   => 0,
  38.                             'max'   => 32,
  39.                             'step'  => 1,
  40.                     ),
  41.                 'std' => '10',
  42.             ),
  43.             'number_column' => array(
  44.                 'type'      => 'select',
  45.                 'title'     => __('Select Column', 'themeum-core'),
  46.                 'values'    => array(
  47.                             '1' => __( 'One Column', 'themeum-core' ),
  48.                             '2' => __( 'Two Column', 'themeum-core' ),
  49.                             '3' => __( 'Three Column', 'themeum-core' ),
  50.                             '4' => __( 'Four Column', 'themeum-core' ),
  51.                             '5' => __( 'Five Column', 'themeum-core' ),
  52.                             '6' => __( 'Six Column', 'themeum-core' ),
  53.                     ),
  54.                 'std'       => '5',
  55.             ),
  56.  
  57.             # Style
  58.             'title_text_padding' => array(
  59.                 'type'      => 'dimension',
  60.                 'title'     => 'Padding',
  61.                 'std'       => array(
  62.                         'md'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  63.                         'sm'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  64.                         'xs'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  65.                         ),
  66.                 'unit'          => array( 'px','em','%' ),
  67.                 'responsive'    => true,
  68.                 'tab'           => 'style',
  69.                 'selector'      => '{{SELECTOR}} .themeum-campaign-wrapper a.camp-title { padding: {{data.title_text_padding}}; }'
  70.             ),
  71.  
  72.             'border_radius' => array(
  73.                 'type'      => 'dimension',
  74.                 'title'     => 'Border Radius',
  75.                 'std'       => array(
  76.                         'md'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  77.                         'sm'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  78.                         'xs'    => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
  79.                         ),
  80.                 'unit'          => array( 'px', '%' ),
  81.                 'responsive'    => true,
  82.                 'tab'           => 'style',
  83.                 'selector'      => '{{SELECTOR}} .themeum-campaign-wrapper { border-radius: {{data.border_radius}}; }'
  84.             ),
  85.            
  86.             'title_fontstyle' => array(
  87.                 'type'      => 'typography',
  88.                 'title'     => __('Typography','themeum-core'),
  89.                 'std'   => array(
  90.                     'fontFamily'    => '',
  91.                     'fontSize'      => array( 'md'=>'28px', 'sm'=>'', 'xs'=>'' ),
  92.                     'lineHeight'    => array( 'md'=>'', 'sm'=>'', 'xs'=>'' ),
  93.                     'fontWeight'    => '700',
  94.                     'textTransform' => '',
  95.                     'fontStyle'     => '',
  96.                     'letterSpacing' => array( 'md'=>'', 'sm'=>'', 'xs'=>'' ),
  97.                 ),
  98.                 'selector'  => '{{SELECTOR}} .themeum-campaign-item .camp-title',
  99.                 'tab'       => 'style',
  100.             ),
  101.  
  102.             'align'     => array(
  103.                 'type'          => 'alignment',
  104.                 'title'         => __('Alignment','themeum-core'),
  105.                 'responsive'    => true,
  106.                 'tab'           => 'style',
  107.                 'selector'      => '{{SELECTOR}} .themeum-campaign-wrapper .camp-title { text-align: {{data.align}}; }'
  108.             ),
  109.  
  110.  
  111.            
  112.         );
  113.  
  114.         return $settings;
  115.     }
  116.  
  117.     # Title Render HTML
  118.     public function render($data = null){
  119.         $settings       = $data['settings'];
  120.         $number         = $settings['number'];
  121.         $number_column  = $settings['number_column'];
  122.         $product_cat    = isset($settings["product_cats"]) ? $settings["product_cats"] : array();
  123.         $column_width   = 100 / $number_column;
  124.         $count          = 1;
  125.         $output = '';
  126.  
  127.         $output .= '<div class="clearfix themeum-campains">';
  128.             if( function_exists('get_woocommerce_term_meta') ){
  129.             foreach ($product_cat as $value) {
  130.                 if( term_exists($value) ){
  131.                     if( $count <= $number ){
  132.  
  133.                         $count++;
  134.                         $term           = get_term_by('slug', $value , 'product_cat');
  135.                         $thumbnail_id   = get_term_meta( $term->term_id, 'thumbnail_id', true );
  136.                         $image          = wp_get_attachment_url( $thumbnail_id );
  137.                         $ico            = get_option('product_cat_custom_order_'.$term->term_taxonomy_id);
  138.                         $subitle        = get_option('product_cat_subtitle_custom_order_'.$term->term_taxonomy_id);
  139.                         $color          = get_option('product_cat_color_custom_order_'.$term->term_taxonomy_id);
  140.                         $colsor         = backnowhex2rgba($color, 0.9);
  141.                         $styles         = 'width: '.esc_attr($column_width).'%;';
  142.  
  143.                         $output .= '<div class="themeum-campaign-item" style="'.esc_attr($styles).'">';
  144.                             $output .= '<div class="themeum-campaign-wrapper" style="background-color: rgba('.$colsor.')">';
  145.                                 $output .= '<div class="themeum-campaign-box">';
  146.                                    
  147.                                     if( $ico != 'Select' ) {
  148.                                         $output .= '<a class="themeum-campaign-icon" href="'.get_term_link($term->term_id).'">';
  149.                                             $output .= '<i class="back-'.$ico.'"></i>';
  150.                                         $output .= '</a>';
  151.                                     } else {
  152.                                         if ($image) {
  153.                                             $output .= '<a class="themeum-campaign-img" href="<?php echo get_term_link($term->term_id); ?>">';
  154.                                                 $output .= '<img src="'.$image.'" alt="'.$term->name.'">';
  155.                                             $output .= '</a>';
  156.                                         }
  157.                                     }
  158.                                     if ($term->name) {
  159.                                         $output .= '<h3><a class="camp-title" href="'.get_term_link($term->term_id).'">'.$term->name.'</a></h3>';
  160.                                     }
  161.                                 $output .= '</div>';
  162.                             $output .= '</div>';
  163.                         $output .= '</div>';
  164.                     }
  165.                 }
  166.             }
  167.         }
  168.         $output .= '</div>';
  169.  
  170.         return $output;
  171.  
  172.     }
  173.  
  174.  
  175.  
  176.  
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement