Created
June 8, 2017 08:00
-
-
Save dn7734/43d6f9f10d0f26fbfbc0f599f0703d7f to your computer and use it in GitHub Desktop.
ACF + woocomerce tab + qtranslate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* woocommerce tab Дополнительные возможности*/ | |
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab_plus' ); | |
function woo_new_product_tab_plus( $tabs ) { | |
$title = 'title'; | |
// Adds the new tab | |
if (qtranxf_getLanguage() == 'ua') { | |
// run code here if the current language is ua | |
$title = 'Додаткові можливості'; | |
} elseif (qtranxf_getLanguage() == 'ru') { | |
// run code here if the current language is ru | |
$title = 'Дополнительные возможности'; | |
} | |
$tabs['tab_plus'] = array( | |
'title' => __( $title, 'woocommerce' ), | |
'priority' => 50, | |
'callback' => 'woo_new_product_tab_plus_content' | |
); | |
return $tabs; | |
} | |
function woo_new_product_tab_plus_content() { | |
// The new tab content | |
$tab_plus_content = ''; | |
$tab_plus_content = get_field('tab_plus_content'); | |
echo $tab_plus_content; | |
} | |
/* woocommerce tab Характеристики*/ | |
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab_ch' ); | |
function woo_new_product_tab_ch( $tabs ) { | |
$title = 'title'; | |
// Adds the new tab | |
if (qtranxf_getLanguage() == 'ua') { | |
// run code here if the current language is ua | |
$title = 'Характеристики'; | |
} elseif (qtranxf_getLanguage() == 'ru') { | |
// run code here if the current language is ru | |
$title = 'Характеристики'; | |
} | |
$tabs['tab_ch'] = array( | |
'title' => __( $title, 'woocommerce' ), | |
'priority' => 60, | |
'callback' => 'woo_new_product_tab_ch_content' | |
); | |
return $tabs; | |
} | |
function woo_new_product_tab_ch_content() { | |
// The new tab content | |
$tab_ch_content = ''; | |
$tab_ch_content = get_field('tab_ch_content'); | |
echo $tab_ch_content; | |
if( get_field('tab_ch_content_file') ): ?> | |
<?php $tab_ch_content_file_name = get_field('tab_ch_content_file_name'); ?> | |
<a class="btn btn-primary" href="<?php the_field('tab_ch_content_file'); ?>" ><?php echo $tab_ch_content_file_name; ?></a> | |
<?php endif; | |
} | |
// ACF to work with qTranslate | |
add_filter('acf/format_value_for_api', 'theme_format_value_for_api'); | |
function theme_format_value_for_api($value) { | |
return is_string($value) ? __($value) : $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment