From 944d9233ed95d467b0beb1cceb2511525a901795 Mon Sep 17 00:00:00 2001 From: Roy Ho Date: Wed, 21 Aug 2024 06:21:14 -0700 Subject: [PATCH] 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 --- .../50803-add-clear-theme-info-cache | 4 ++ .../views/html-admin-page-status-report.php | 6 +++ ...rest-system-status-tools-v2-controller.php | 40 +++++++++++++------ .../includes/wc-core-functions.php | 9 +++++ 4 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 plugins/woocommerce/changelog/50803-add-clear-theme-info-cache diff --git a/plugins/woocommerce/changelog/50803-add-clear-theme-info-cache b/plugins/woocommerce/changelog/50803-add-clear-theme-info-cache new file mode 100644 index 00000000000..01c35c74631 --- /dev/null +++ b/plugins/woocommerce/changelog/50803-add-clear-theme-info-cache @@ -0,0 +1,4 @@ +Significance: patch +Type: add + +Add function to clear system status theme info cache \ No newline at end of file diff --git a/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php b/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php index 1630d059b2c..76a0418a68f 100644 --- a/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php +++ b/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php @@ -1060,6 +1060,12 @@ if ( 0 < $mu_plugins_count ) : + | + + + + + diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php index d9c8ad8d9fe..822b2a651f1 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php @@ -123,42 +123,42 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller { */ public function get_tools() { $tools = array( - 'clear_transients' => array( + 'clear_transients' => array( 'name' => __( 'WooCommerce transients', 'woocommerce' ), 'button' => __( 'Clear transients', 'woocommerce' ), 'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ), ), - 'clear_expired_transients' => array( + 'clear_expired_transients' => array( 'name' => __( 'Expired transients', 'woocommerce' ), 'button' => __( 'Clear transients', 'woocommerce' ), 'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ), ), - 'delete_orphaned_variations' => array( + 'delete_orphaned_variations' => array( 'name' => __( 'Orphaned variations', 'woocommerce' ), 'button' => __( 'Delete orphaned variations', 'woocommerce' ), 'desc' => __( 'This tool will delete all variations which have no parent.', 'woocommerce' ), ), - 'clear_expired_download_permissions' => array( + 'clear_expired_download_permissions' => array( 'name' => __( 'Used-up download permissions', 'woocommerce' ), 'button' => __( 'Clean up download permissions', 'woocommerce' ), 'desc' => __( 'This tool will delete expired download permissions and permissions with 0 remaining downloads.', 'woocommerce' ), ), - 'regenerate_product_lookup_tables' => array( + 'regenerate_product_lookup_tables' => array( 'name' => __( 'Product lookup tables', 'woocommerce' ), 'button' => __( 'Regenerate', 'woocommerce' ), 'desc' => __( 'This tool will regenerate product lookup table data. This process may take a while.', 'woocommerce' ), ), - 'recount_terms' => array( + 'recount_terms' => array( 'name' => __( 'Term counts', 'woocommerce' ), 'button' => __( 'Recount terms', 'woocommerce' ), 'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ), ), - 'reset_roles' => array( + 'reset_roles' => array( 'name' => __( 'Capabilities', 'woocommerce' ), 'button' => __( 'Reset capabilities', 'woocommerce' ), 'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ), ), - 'clear_sessions' => array( + 'clear_sessions' => array( 'name' => __( 'Clear customer sessions', 'woocommerce' ), 'button' => __( 'Clear', 'woocommerce' ), 'desc' => sprintf( @@ -167,7 +167,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller { __( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce' ) ), ), - 'clear_template_cache' => array( + 'clear_template_cache' => array( 'name' => __( 'Clear template cache', 'woocommerce' ), 'button' => __( 'Clear', 'woocommerce' ), 'desc' => sprintf( @@ -176,7 +176,16 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller { __( 'This tool will empty the template cache.', 'woocommerce' ) ), ), - 'install_pages' => array( + 'clear_system_status_theme_info_cache' => array( + 'name' => __( 'Clear system status theme info cache', 'woocommerce' ), + 'button' => __( 'Clear', 'woocommerce' ), + 'desc' => sprintf( + '%1$s %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' ), 'desc' => sprintf( @@ -185,7 +194,7 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller { __( 'This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce' ) ), ), - 'delete_taxes' => array( + 'delete_taxes' => array( 'name' => __( 'Delete WooCommerce tax rates', 'woocommerce' ), 'button' => __( 'Delete tax rates', 'woocommerce' ), 'desc' => sprintf( @@ -194,12 +203,12 @@ class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller { __( 'This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce' ) ), ), - 'regenerate_thumbnails' => array( + 'regenerate_thumbnails' => array( 'name' => __( 'Regenerate shop thumbnails', 'woocommerce' ), 'button' => __( 'Regenerate', 'woocommerce' ), 'desc' => __( 'This will regenerate all shop thumbnails to match your theme and/or image settings.', 'woocommerce' ), ), - 'db_update_routine' => array( + 'db_update_routine' => array( 'name' => __( 'Update database', 'woocommerce' ), 'button' => __( 'Update database', 'woocommerce' ), 'desc' => sprintf( @@ -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' ); diff --git a/plugins/woocommerce/includes/wc-core-functions.php b/plugins/woocommerce/includes/wc-core-functions.php index 764e32cb4d3..2af8724638b 100644 --- a/plugins/woocommerce/includes/wc-core-functions.php +++ b/plugins/woocommerce/includes/wc-core-functions.php @@ -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. *