-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoocommerce-tab-manager-template.php
82 lines (72 loc) · 2.66 KB
/
woocommerce-tab-manager-template.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
<?php
/**
* WooCommerce Tab Manager
*
* This source file is subject to the GNU General Public License v3.0
* that is bundled with this package in the file license.txt.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/gpl-3.0.html
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@skyverge.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade WooCommerce Tab Manager to newer
* versions in the future. If you wish to customize WooCommerce Tab Manager for your
* needs please refer to http://docs.woocommerce.com/document/tab-manager/
*
* @author SkyVerge
* @copyright Copyright (c) 2012-2023, SkyVerge, Inc. (info@skyverge.com)
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
*/
/**
* WooCommerce Tab Manager Template Functions
*
* Functions used in the template files to output content - in most cases
* hooked in via the template actions. All functions are pluggable.
*/
defined( 'ABSPATH' ) or exit;
if ( ! function_exists( 'woocommerce_tab_manager_tab_content' ) ) {
/**
* Renders the product/global tab content.
*
* Templates are loaded in the following order:
*
* 1. theme / woocommerce / single-product / tabs / content-{tab-name-slug}.php
* 2. theme / woocommerce / single-product / tabs / content.php
* 3. woocommerce-tab-manager / templates / single-product / tabs / content.php
*
* $tab structure:
* Array(
* 'title' => (string) Tab title,
* 'priority' => (string) Tab priority,
* 'callback' => (mixed) callback function,
* 'id' => (int) tab post identifier,
* )
*
* @since 1.0.5
*
* @global \WC_Tab_Manager wc_tab_manager()
* @global \WC_Product $product
*
* @param string $key tab key, this is the sanitized tab title with possibly a numerical suffix to avoid key clashes
* @param null|array $tab tab data
*/
function woocommerce_tab_manager_tab_content( $key, $tab ) {
global $product;
if ( $product && ( $tab = wc_tab_manager()->get_product_tab( $product->get_id(), $tab['id'], true ) ) ) {
// first look for a template specific for this tab
$template_name = "single-product/tabs/content-{$tab['name']}.php";
$located = locate_template( [
trailingslashit( WC()->template_path() ) . $template_name,
$template_name
] );
// if not found, fallback to the general template
if ( ! $located ) {
$template_name = 'single-product/tabs/content.php';
}
wc_tab_manager()->load_template( $template_name, [ 'tab' => $tab ] );
}
}
}