function hocwp_tab_content_bootstrap($args = array()) { $class = hocwp_get_value_by_key($args, 'class'); hocwp_add_string_with_space_before($class, 'product-tabs'); $tabs = hocwp_get_value_by_key($args, 'tabs'); $callback = hocwp_get_value_by_key($args, 'callback'); if (!hocwp_callback_exists($callback)) { return; } ?> <div class="<?php echo $class; ?> "> <?php if (hocwp_array_has_value($tabs)) { ?> <ul class="nav nav-tabs" data-tabs="tabs"> <?php $count = 0; foreach ($tabs as $tab) { $href = hocwp_get_value_by_key($tab, 'href'); if (empty($href)) { continue; } $text = hocwp_get_value_by_key($tab, 'text'); $class = 'tab-item'; if (0 === $count) { hocwp_add_string_with_space_before($class, 'active'); } $custom_link = hocwp_get_value_by_key($tab, 'custom_link'); $data_toggle = 'tab'; if (!empty($custom_link)) { $href = $custom_link; $data_toggle = ''; } else { $href = '#' . $href; } ?> <li class="<?php echo $class; ?> "> <a href="<?php echo $href; ?> " data-toggle="<?php echo $data_toggle; ?> "><?php echo $text; ?> </a> </li> <?php $count++; } ?> </ul> <?php } ?> <?php $after_nav_tabs = hocwp_get_value_by_key($args, 'after_nav_tabs'); if (!empty($after_nav_tabs)) { echo '<div class="after-nav-tabs">'; hocwp_the_custom_content($after_nav_tabs); echo '</div>'; } ?> <div class="tab-content"> <?php call_user_func($callback, $args); ?> </div> </div> <?php }
function hocwp_setup_theme_woocommerce_product_tabs_callback($key, $tab) { $content = hocwp_get_post_meta($key, get_the_ID()); $content = trim($content); $title = hocwp_get_value_by_key($tab, 'title'); if (empty($content)) { $slug = hocwp_sanitize_html_class($key); $hocwp_product_tab = hocwp_get_post_by_slug($slug, 'hocwp_product_tab'); if (!hocwp_is_post($hocwp_product_tab)) { $hocwp_product_tab = hocwp_get_post_by_column('post_title', $title); } if (hocwp_is_post($hocwp_product_tab)) { $content = $hocwp_product_tab->post_content; $content = trim($content); } } if (!empty($content)) { if (!empty($title)) { echo hocwp_wrap_tag($title, 'h2', 'tab-title'); } echo '<div class="hocwp-product-info">'; $embed = new WP_Embed(); $content = $embed->run_shortcode($content); $content = $embed->autoembed($content); hocwp_the_custom_content($content); echo '</div>'; } }