From c856d5adf3e759775e3a1f107d4b01c9c534c9d3 Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:36:16 -0800 Subject: [PATCH 1/2] Add core update hook to clear global styles --- wp-test-56970.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wp-test-56970.php b/wp-test-56970.php index e68f274..953429f 100644 --- a/wp-test-56970.php +++ b/wp-test-56970.php @@ -48,3 +48,16 @@ function wp_test_56970_transient_global_styles_stylesheet( $value, $transient ) return false; } + +add_action( '_core_updated_successfully', '_delete_global_styles_stylesheet_transient' ); +if ( ! function_exists( '_delete_global_styles_stylesheet_transient' ) ) { + /** + * Deletes the global styles stylesheet transient. + * + * @since 6.1.2 + */ + function _delete_global_styles_stylesheet_transient() { + $transient_name = 'global_styles_' . get_stylesheet(); + delete_site_transient( "transient_{$transient_name}" ); + } +} From a9b590d2789b5fc9cb7613419dd2819bb2b2d19e Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 9 Dec 2022 16:27:57 -0800 Subject: [PATCH 2/2] Rename function to avoid chance of core collision --- wp-test-56970.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/wp-test-56970.php b/wp-test-56970.php index 953429f..cb04b2a 100644 --- a/wp-test-56970.php +++ b/wp-test-56970.php @@ -49,15 +49,9 @@ function wp_test_56970_transient_global_styles_stylesheet( $value, $transient ) return false; } -add_action( '_core_updated_successfully', '_delete_global_styles_stylesheet_transient' ); -if ( ! function_exists( '_delete_global_styles_stylesheet_transient' ) ) { - /** - * Deletes the global styles stylesheet transient. - * - * @since 6.1.2 - */ - function _delete_global_styles_stylesheet_transient() { - $transient_name = 'global_styles_' . get_stylesheet(); - delete_site_transient( "transient_{$transient_name}" ); - } +// Hook to delete the global styles stylesheet transient after core update. +add_action( '_core_updated_successfully', 'wp_test_56970_delete_global_styles_stylesheet_transient' ); +function wp_test_56970_delete_global_styles_stylesheet_transient() { + $transient_name = 'global_styles_' . get_stylesheet(); + delete_site_transient( "transient_{$transient_name}" ); }