/var/www/html/wp-content/plugins/dream-team/admin/cat-custom-settings.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php 
add_action
('product_cat_add_form_fields''dreamteam_taxonomy_cat_product_description'101);
add_action('product_cat_edit_form_fields''dreamteam_taxonomy_cat_product_description'101);

function 
dreamteam_taxonomy_cat_product_description($term null) {
    
$args = array(
        
'title' => __('Porudct Description''dream-team'),
        
'setting_key' => 'cat_product_description'
    
);
    include 
DREAMTEAM_CORE_PLUGIN_PATH 'admin/templates/cat-field-static-block.php';
}

add_action('product_cat_add_form_fields''dreamteam_taxonomy_cat_product_review'101);
add_action('product_cat_edit_form_fields''dreamteam_taxonomy_cat_product_review'101);

function 
dreamteam_taxonomy_cat_product_review($term null) {
    
$args = array(
        
'title' => __('Porudct Review''dream-team'),
        
'setting_key' => 'cat_product_review'
    
);
    include 
DREAMTEAM_CORE_PLUGIN_PATH 'admin/templates/cat-field-static-block.php';
}

add_action('created_term''dreamteam_save_taxonomy_custom_fields'103);
add_action('edit_term''dreamteam_save_taxonomy_custom_fields'103);

function 
dreamteam_save_taxonomy_custom_fields($term_id$tt_id ''$taxonomy '') {
    if (
'product_cat' == $taxonomy) {
        if (isset(
$_POST['cat_product_description'])) {
            
update_term_meta($term_id'cat_product_description'$_POST['cat_product_description']);
        }

        if (isset(
$_POST['cat_product_review'])) {
            
update_term_meta($term_id'cat_product_review'$_POST['cat_product_review']);
        }
    }
}


add_action('init''dreamteam_cat_custom_fields_init'10);

function 
dreamteam_cat_custom_fields_init() {
    
add_filter('woocommerce_product_tabs''dreamteam_custom_tabs_single_product'999);
}

function 
dreamteam_custom_tabs_single_product($tabs) {
    global 
$product$post;
    
// Description tab - shows product content.
    
if ( !$post->post_content ) {
        
$tabs['description'] = array(
            
'title'    => __'Description''dreamteam' ),
            
'priority' => 10,
            
'callback' => 'dreamteam_product_description_default_tab',
        );
    }

    return 
$tabs;
}

function 
dreamteam_product_description_default_tab() {
    global 
$post$nasa_opt;
    
$catId null;
    
$terms get_the_terms$post->ID'product_cat' );
    foreach (
$terms as $term) {
        
$catId $term->term_id;
        break;
    }

    if ((int) 
$catId 0) {
        
$block get_term_meta($catId'cat_product_description'true);
        
        if (
$block === '-1') {
            return;
        }
        
        if (
$block) {
            
$do_content elessi_get_block($block);
            echo 
apply_filters'the_content'$do_content );
        }
    }
}

add_action('woocommerce_after_single_product''dreamteam_product_review_block'10);

function 
dreamteam_product_review_block() {
    global 
$post;
    
$catId null;
    
$terms get_the_terms$post->ID'product_cat' );
    foreach (
$terms as $term) {
        
$catId $term->term_id;
        break;
    }

    if ((int) 
$catId 0) {
        
$block get_term_meta($catId'cat_product_review'true);
        
        if (
$block === '-1') {
            return;
        }
        
        if (
$block) {
            
$do_content elessi_get_block($block);
            
?>
            <div class="row">
                <div class="large-12">
                    <?php echo apply_filters'the_content'$do_content ); ?>
                </div>
            </div>
            <?php
        
}
    }
}