Is it possible to pass the value of a customizer field value into a functions.php variable?
I want to provide a language option for custom WooCommerce tabs. Currently the headings for the tabs are hardcoded into functions.php. After removing the default tabs I add the following:
add_filter( 'woocommerce_product_tabs', 'downloads_tab' );
if ( ! function_exists ( 'downloads_tab' ) ) {
function downloads_tab( $tabs ) {
// ensure ACF is available
if ( !function_exists( 'have_rows' ) )
return;
if ( get_field('downloads') ) {
$tabs['downloads_tab'] = array(
'title' => __( 'Downloads', 'woocommerce' ),
'priority' => 60,
'callback' => 'woo_downloads_tab_content'
);
}
return $tabs;
}
}
In customizer.php (theme is based on UnderStrap) I have:
// Product Downloads Tab Setting
$wp_customize->add_setting( 'product-downloads-tab', array( 'default' => '' ) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'product-downloads-tab', array( 'label' => __( 'Product "Downloads" tab text', 'theme-name' ), 'section' => 'language-options', 'settings' => 'product-downloads-tab', ) ) );
Can I use the value of whatever is entered here instead of hardcoding the tab title in functions.php?
My workaround is to override the function in the child theme's functions.php, but I'd rather give the client the ability to set the title of the tab.