Skip to content

add clear template cache tool #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ public function get_tools() {
__( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce-rest-api' )
),
),
'clear_template_cache' => array(
'name' => __( 'Clear template cache', 'woocommerce-rest-api' ),
'button' => __( 'Clear', 'woocommerce-rest-api' ),
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce-rest-api' ),
__( 'This tool will empty the template cache.', 'woocommerce-rest-api' )
),
),
'install_pages' => array(
'name' => __( 'Create default WooCommerce pages', 'woocommerce-rest-api' ),
'button' => __( 'Create pages', 'woocommerce-rest-api' ),
Expand Down Expand Up @@ -215,6 +224,10 @@ public function get_tools() {
unset( $tools['regenerate_thumbnails'] );
}

if ( ! function_exists( 'wc_clear_template_cache' ) ) {
unset( $tools['clear_template_cache'] );
}

return apply_filters( 'woocommerce_debug_tools', $tools );
}

Expand Down Expand Up @@ -547,6 +560,16 @@ public function execute_tool( $tool ) {
$message = __( 'Database upgrade routine has been scheduled to run in the background.', 'woocommerce-rest-api' );
break;

case 'clear_template_cache':
if ( function_exists( 'wc_clear_template_cache' ) ) {
wc_clear_template_cache();
$message = __( 'Template cache cleared.', 'woocommerce-rest-api' );
} else {
$message = __( 'The active version of WooCommerce does not support template cache clearing.', 'woocommerce-rest-api' );
$ran = false;
}
break;

case 'verify_db_tables':
if ( ! method_exists( 'WC_Install', 'verify_base_tables' ) ) {
$message = __( 'You need WooCommerce 4.2 or newer to run this tool.', 'woocommerce-rest-api' );
Expand Down