Add/clear theme info cache (#50803)

* Add function to clear system status theme info cache to tool page

* Add clear cache tooltip to the template override section

* Add changefile(s) from automation for the following project(s): woocommerce

* Remove extra td

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Roy Ho 2024-08-21 06:21:14 -07:00 committed by GitHub
parent 5690850e47
commit 944d9233ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 13 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
Add function to clear system status theme info cache

View File

@ -1060,6 +1060,12 @@ if ( 0 < $mu_plugins_count ) :
</mark>
<a href="https://woocommerce.com/document/fix-outdated-templates-woocommerce/" target="_blank">
<?php esc_html_e( 'Learn how to update', 'woocommerce' ); ?>
</a> |
<mark class="info">
<span class="dashicons dashicons-info"></span>
</mark>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-status&tab=tools' ) ); ?>">
<?php esc_html_e( 'Clear system status theme info cache', 'woocommerce' ); ?>
</a>
</td>
</tr>

View File

@ -176,6 +176,15 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
__( 'This tool will empty the template cache.', 'woocommerce' )
),
),
'clear_system_status_theme_info_cache' => array(
'name' => __( 'Clear system status theme info cache', 'woocommerce' ),
'button' => __( 'Clear', 'woocommerce' ),
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
__( 'This tool will empty the system status theme info cache.', 'woocommerce' )
),
),
'install_pages' => array(
'name' => __( 'Create default WooCommerce pages', 'woocommerce' ),
'button' => __( 'Create pages', 'woocommerce' ),
@ -567,6 +576,11 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
}
break;
case 'clear_system_status_theme_info_cache':
wc_clear_system_status_theme_info_cache();
$message = __( 'System status theme info cache cleared.', 'woocommerce' );
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' );

View File

@ -456,6 +456,15 @@ function wc_clear_template_cache() {
}
}
/**
* Clear the system status theme info cache.
*
* @since 9.4.0
*/
function wc_clear_system_status_theme_info_cache() {
delete_transient( 'wc_system_status_theme_info' );
}
/**
* Get Base Currency Code.
*