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_category_List {
- public function get_name(){
- return 'themeum-product-category';
- }
- public function get_icon() {
- return 'wppb-font-trash';
- }
- public function get_category_name(){
- return __( 'Backnow Widgets', 'themeum-core' );
- }
- public function get_title(){
- return __( 'Product Category List', 'themeum-core' );
- }
- # headline Settings Fields
- public function get_settings() {
- $settings = array(
- # General
- 'product_cats' => array(
- 'type' => 'select',
- 'title' => __('Select Category', 'themeum-core'),
- 'values' => crowdfunding_all_category_list('product_cat'),
- 'std' => 'allpost',
- 'multiple' => true,
- ),
- 'number' => array(
- 'type' => 'slider',
- 'title' => __('Number Width','wp-pagebuilder'),
- 'range' => array(
- 'min' => 0,
- 'max' => 32,
- 'step' => 1,
- ),
- 'std' => '10',
- ),
- 'number_column' => array(
- 'type' => 'select',
- 'title' => __('Select Column', 'themeum-core'),
- 'values' => array(
- '1' => __( 'One Column', 'themeum-core' ),
- '2' => __( 'Two Column', 'themeum-core' ),
- '3' => __( 'Three Column', 'themeum-core' ),
- '4' => __( 'Four Column', 'themeum-core' ),
- '5' => __( 'Five Column', 'themeum-core' ),
- '6' => __( 'Six Column', 'themeum-core' ),
- ),
- 'std' => '5',
- ),
- # Style
- 'title_text_padding' => array(
- 'type' => 'dimension',
- 'title' => 'Padding',
- 'std' => array(
- 'md' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
- 'sm' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
- 'xs' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' ),
- ),
- 'unit' => array( 'px','em','%' ),
- 'responsive' => true,
- 'tab' => 'style',
- 'selector' => '{{SELECTOR}} .themeum-campaign-wrapper a.camp-title { padding: {{data.title_text_padding}}; }'
- ),
- '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-wrapper { border-radius: {{data.border_radius}}; }'
- ),
- 'title_fontstyle' => array(
- 'type' => 'typography',
- 'title' => __('Typography','themeum-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-item .camp-title',
- 'tab' => 'style',
- ),
- 'align' => array(
- 'type' => 'alignment',
- 'title' => __('Alignment','themeum-core'),
- 'responsive' => true,
- 'tab' => 'style',
- 'selector' => '{{SELECTOR}} .themeum-campaign-wrapper .camp-title { text-align: {{data.align}}; }'
- ),
- );
- return $settings;
- }
- # Title Render HTML
- public function render($data = null){
- $settings = $data['settings'];
- $number = $settings['number'];
- $number_column = $settings['number_column'];
- $product_cat = isset($settings["product_cats"]) ? $settings["product_cats"] : array();
- $column_width = 100 / $number_column;
- $count = 1;
- $output = '';
- $output .= '<div class="clearfix themeum-campains">';
- if( function_exists('get_woocommerce_term_meta') ){
- foreach ($product_cat as $value) {
- if( term_exists($value) ){
- if( $count <= $number ){
- $count++;
- $term = get_term_by('slug', $value , 'product_cat');
- $thumbnail_id = get_term_meta( $term->term_id, 'thumbnail_id', true );
- $image = wp_get_attachment_url( $thumbnail_id );
- $ico = get_option('product_cat_custom_order_'.$term->term_taxonomy_id);
- $subitle = get_option('product_cat_subtitle_custom_order_'.$term->term_taxonomy_id);
- $color = get_option('product_cat_color_custom_order_'.$term->term_taxonomy_id);
- $colsor = backnowhex2rgba($color, 0.9);
- $styles = 'width: '.esc_attr($column_width).'%;';
- $output .= '<div class="themeum-campaign-item" style="'.esc_attr($styles).'">';
- $output .= '<div class="themeum-campaign-wrapper" style="background-color: rgba('.$colsor.')">';
- $output .= '<div class="themeum-campaign-box">';
- if( $ico != 'Select' ) {
- $output .= '<a class="themeum-campaign-icon" href="'.get_term_link($term->term_id).'">';
- $output .= '<i class="back-'.$ico.'"></i>';
- $output .= '</a>';
- } else {
- if ($image) {
- $output .= '<a class="themeum-campaign-img" href="<?php echo get_term_link($term->term_id); ?>">';
- $output .= '<img src="'.$image.'" alt="'.$term->name.'">';
- $output .= '</a>';
- }
- }
- if ($term->name) {
- $output .= '<h3><a class="camp-title" href="'.get_term_link($term->term_id).'">'.$term->name.'</a></h3>';
- }
- $output .= '</div>';
- $output .= '</div>';
- $output .= '</div>';
- }
- }
- }
- }
- $output .= '</div>';
- return $output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement