Created
October 12, 2018 09:30
-
-
Save Bobz-zg/5d1e6a6cfa4d465ed5f6f8ca09adc88f to your computer and use it in GitHub Desktop.
Quickly unhook WooCommerce template parts
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
<?php | |
/** | |
* Remove variouse template parts in WooCommerce | |
*/ | |
add_filter( 'wc_get_template', function( $located, $template_name, $args, $template_path, $default_path ) { | |
$remove = [ | |
'sale-flash.php', | |
'meta.php', | |
'share.php', | |
'up-sells.php', | |
'quantity-input.php', | |
'simple.php', | |
'tabs.php', | |
'related.php', | |
'variable.php', | |
'variation-add-to-cart-button.php', | |
'add-to-cart.php', | |
'rating.php' | |
]; | |
/** | |
* Add any additional condition here | |
* eg: in_array( basename($located), $remove ) || ! current_user_can('manage_options') | |
*/ | |
if ( in_array( basename($located), $remove ) ) | |
$located = false; | |
return $located; | |
}, 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment