Skip to content

Instantly share code, notes, and snippets.

@sejas
Created February 9, 2016 20:51
Show Gist options
  • Save sejas/e8a8ebdd64f6863b7876 to your computer and use it in GitHub Desktop.
Save sejas/e8a8ebdd64f6863b7876 to your computer and use it in GitHub Desktop.
Add new tabs with the content of Advanced Custom Fields.
<?php
/**
* Add new tabs with the content of Advanced Custom Fields.
*/
add_filter( 'woocommerce_product_tabs', 'bau_woo_remove_product_tabs', 98 );
function bau_woo_remove_product_tabs( $tabs ) {
// Define, the meta_key of the
$bautabs = array(
'alergenos' => array(
'title' => __('Alérgenos'),
)
,'preparacion' => array(
'title' => __('Preparación')
)
);
foreach ($bautabs as $bau_meta_key => $bauTab) {
$tabContent = get_post_meta( get_the_ID(), $bau_meta_key, true );
if ($tabContent && "" != $tabContent && null != $tabContent) {
$tabs[$bau_meta_key] = array(
'title' => $bauTab['title'],
'priority' => (isset($bauTab['priority']))?$bauTab['priority']:21,
'tabContent' => $tabContent,
'callback' => function ($tabName,$tab)
{
echo wpautop($tab['tabContent']);
},
);
}
}
return $tabs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment