Created
June 16, 2015 23:15
-
-
Save tamarazuk/c8d68c988b78849be3e6 to your computer and use it in GitHub Desktop.
WooCommerce Tab Manager - Conditionally hide tab
This file contains hidden or 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
<?php | |
function wc_tab_manager_product_tabs_hide_books_tab( $tabs ) { | |
global $product; | |
// + check if we are on the product page before removing the tab so that the | |
// tab still displays in the admin | |
// + change some_condition() to a function/variable which returns true if the | |
// product should be displayed | |
// + "unique-tab-name" is uniquely generated by Tab Manager and can be found by | |
// inspecting the source on a product page and finding the HTML which outputs | |
// the tab. It will look like: | |
// <a href="#tab-unique-tab-name">Your tab name here</a> | |
if ( $product && ! some_condition( $product ) ) { | |
// remove tab with name "unique-tab-name" | |
unset( $tabs['unique-tab-name'] ); | |
} | |
return $tabs; | |
} | |
add_filter( 'wc_tab_manager_product_tabs', 'wc_tab_manager_product_tabs_hide_books_tab' ); | |
function some_condition( $product ) { | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment