Exemplo n.º 1
0
function tpvc_vc_getCategoryChilds($param = 'slug', $parent_id, $pos, $array, $level, &$dropdown)
{
    for ($i = $pos; $i < count($array); $i++) {
        if ($array[$i]->category_parent == $parent_id) {
            if ($param == 'slug') {
                $data = array(str_repeat("- ", $level) . $array[$i]->name => $array[$i]->slug);
            } else {
                $data = array(str_repeat("- ", $level) . $array[$i]->name => $array[$i]->term_id);
            }
            $dropdown = array_merge($dropdown, $data);
            tpvc_vc_getCategoryChilds($param, $array[$i]->term_id, $i, $array, $level + 1, $dropdown);
        }
    }
}
function tpvc_wc_cat_categories_vcmap()
{
    if (!class_exists('woocommerce')) {
        return;
    }
    $args = array('type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'product_cat', 'pad_counts' => false);
    $categories = get_categories($args);
    $product_categories_dropdown = array();
    tpvc_vc_getCategoryChilds('id', 0, 0, $categories, 0, $product_categories_dropdown);
    $product_categories_dropdown_begin = array(__('[All Categories]', 'tokopress') => '', __('[Top Level Only]', 'tokopress') => 'top');
    $product_categories_dropdown = array_merge($product_categories_dropdown_begin, $product_categories_dropdown);
    vc_map(array('name' => __('WooCommerce - Product Categories', 'tokopress'), 'base' => 'tokopress_product_categories', 'class' => '', 'icon' => 'woocommerce_icon', 'category' => 'Tokopress - Marketica', 'params' => array(array('type' => 'textfield', 'heading' => __('Title', 'tokopress'), 'param_name' => 'tpvc_wc_cat_title', 'value' => __('Product Categories', 'tokopress')), array('type' => 'colorpicker', 'heading' => __('Title Color', 'tokopress'), 'param_name' => 'tpvc_wc_cat_title_color'), array('type' => 'colorpicker', 'heading' => __('Title Background Color', 'tokopress'), 'param_name' => 'tpvc_wc_cat_title_bg'), array('type' => 'iconpicker', 'heading' => __('Title Icon', 'tokopress'), 'param_name' => 'tpvc_wc_cat_title_icon', 'settings' => array('emptyIcon' => false, 'iconsPerPage' => 100), 'dependency' => array('element' => 'type', 'value' => 'fontawesome')), array('type' => 'colorpicker', 'heading' => __('Title Icon Color', 'tokopress'), 'param_name' => 'tpvc_wc_cat_title_icon_color'), array('type' => 'checkbox', 'heading' => __('Hide Title', 'tokopress'), 'param_name' => 'tpvc_wc_cat_hide_title', 'value' => array(__('Hide Title', 'tokopress') => 'hide')), array('type' => 'dropdown', 'heading' => __('Parent Category', 'tokopress'), 'value' => $product_categories_dropdown, 'param_name' => 'parent', 'description' => __('Useful to show subcategories', 'tokopress')), array('type' => 'textfield', 'heading' => __('Numbers', 'tokopress'), 'description' => __('How many categories to show', 'tokopress'), 'param_name' => 'tpvc_wc_cat_numbers', 'value' => "8"), array('type' => 'dropdown', 'heading' => __('Columns', 'tokopress'), 'description' => __('How many columns per row', 'tokopress'), 'param_name' => 'tpvc_wc_cat_columns', 'value' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4'), 'std' => '3'), array('type' => 'dropdown', 'heading' => __('Order By', 'tokopress'), 'param_name' => 'tpvc_wc_cat_orderby', 'value' => array(__('None', 'tokopress') => 'none', __('Name', 'tokopress') => 'name', __('Count', 'tokopress') => 'count', __('Slug', 'tokopress') => 'slug', __('ID', 'tokopress') => 'id'), 'std' => 'none'), array('type' => 'dropdown', 'heading' => __('Order Type', 'tokopress'), 'param_name' => 'tpvc_wc_cat_order', 'value' => array('Ascending' => 'asc', 'Descending' => 'desc'), 'std' => 'asc'), array('type' => 'textfield', 'heading' => __('Extra Class', 'tokopress'), 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'tokopress'), 'param_name' => 'tpvc_wc_cat_class', 'value' => ''))));
}