SHOW:
|
|
- or go back to the newest paste.
1 | // Modify/Remove Tabs | |
2 | add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); | |
3 | ||
4 | function woo_remove_product_tabs( $tabs ) { | |
5 | unset( $tabs['description'] ); | |
6 | unset( $tabs['reviews'] ); | |
7 | unset( $tabs['additional_information'] ); | |
8 | ||
9 | return $tabs; | |
10 | } | |
11 | ||
12 | ||
13 | // Add new tabs | |
14 | add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' ); | |
15 | ||
16 | function woo_new_product_tab( $tabs ) { | |
17 | ||
18 | // Adds the new tabs | |
19 | $tabs['desc'] = array( | |
20 | 'title' => __( 'Description', 'woocommerce' ), | |
21 | 'priority' => 50, | |
22 | 'callback' => 'woo_new_product_tab_description' | |
23 | ); | |
24 | ||
25 | $tabs['ingredients'] = array( | |
26 | 'title' => __( 'Ingredients', 'woocommerce' ), | |
27 | 'priority' => 51, | |
28 | 'callback' => 'woo_new_product_tab_ingredients' | |
29 | ); | |
30 | ||
31 | $tabs['tips'] = array( | |
32 | 'title' => __( 'Tips', 'woocommerce' ), | |
33 | 'priority' => 52, | |
34 | 'callback' => 'woo_new_product_tab_tips' | |
35 | ); | |
36 | ||
37 | return $tabs; | |
38 | } | |
39 | ||
40 | function woo_new_product_tab_description( $tab_nicename, $tab_data ){ | |
41 | global $product; | |
42 | ||
43 | // The new tab content | |
44 | echo '<div class="wc-tab--title"><div class="wc-section--title"><span>' . $tab_data['title'] . '</span></div></div>'; | |
45 | echo '<div class="wc-section--content">' . wpautop($product->post->post_content) . '</div>'; | |
46 | } | |
47 | ||
48 | function woo_new_product_tab_ingredients( $tab_nicename, $tab_data ){ | |
49 | global $product; | |
50 | $tab_content = get_post_meta($product->post->ID, 'product_ingredients', true); | |
51 | ||
52 | // The new tab content | |
53 | echo '<div class="wc-tab--title"><div class="wc-section--title"><span>' . $tab_data['title'] . '</span></div></div>'; | |
54 | echo '<div class="wc-section--content">' . wpautop($tab_content) . '</div>'; | |
55 | } | |
56 | ||
57 | function woo_new_product_tab_tips( $tab_nicename, $tab_data ){ | |
58 | global $product; | |
59 | $tab_content = get_post_meta($product->post->ID, 'product_tips', true); | |
60 | ||
61 | // The new tab content | |
62 | echo '<div class="wc-tab--title"><div class="wc-section--title"><span>' . $tab_data['title'] . '</span></div></div>'; | |
63 | echo '<div class="wc-section--content">' . wpautop($tab_content) . '</div>'; | |
64 | } |