Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 17f8d5a

Browse files
committed
add clear template cache tool
1 parent bd5fe42 commit 17f8d5a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ public function get_tools() {
167167
__( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce-rest-api' )
168168
),
169169
),
170+
'clear_template_cache' => array(
171+
'name' => __( 'Clear template cache', 'woocommerce-rest-api' ),
172+
'button' => __( 'Clear', 'woocommerce-rest-api' ),
173+
'desc' => sprintf(
174+
'<strong class="red">%1$s</strong> %2$s',
175+
__( 'Note:', 'woocommerce-rest-api' ),
176+
__( 'This tool will empty the template cache.', 'woocommerce-rest-api' )
177+
),
178+
),
170179
'install_pages' => array(
171180
'name' => __( 'Create default WooCommerce pages', 'woocommerce-rest-api' ),
172181
'button' => __( 'Create pages', 'woocommerce-rest-api' ),
@@ -206,6 +215,10 @@ public function get_tools() {
206215
unset( $tools['regenerate_thumbnails'] );
207216
}
208217

218+
if ( ! function_exists( 'wc_clear_template_cache' ) ) {
219+
unset( $tools['clear_template_cache'] );
220+
}
221+
209222
return apply_filters( 'woocommerce_debug_tools', $tools );
210223
}
211224

@@ -538,6 +551,11 @@ public function execute_tool( $tool ) {
538551
$message = __( 'Database upgrade routine has been scheduled to run in the background.', 'woocommerce-rest-api' );
539552
break;
540553

554+
case 'clear_template_cache':
555+
wc_clear_template_cache();
556+
$message = __( 'Template cache cleared.', 'woocommerce-rest-api' );
557+
break;
558+
541559
default:
542560
$tools = $this->get_tools();
543561
if ( isset( $tools[ $tool ]['callback'] ) ) {

0 commit comments

Comments
 (0)