Skip to content

Commit

Permalink
Move _gutenberg_clean_theme_json_caches
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed May 9, 2023
1 parent e171681 commit a987667
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
7 changes: 0 additions & 7 deletions lib/compat/wordpress-6.2/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
* @package gutenberg
*/

/**
* When backporting to core, the existing filters hooked to WP_Theme_JSON_Resolver::clean_cached_data()
* need to be removed.
*/
add_action( 'start_previewing_theme', '_gutenberg_clean_theme_json_caches' );
add_action( 'switch_theme', '_gutenberg_clean_theme_json_caches' );

/**
* This is a temporary fix to ensure that the block editor styles are enqueued
* in the order the iframe expects.
Expand Down
14 changes: 0 additions & 14 deletions lib/compat/wordpress-6.2/get-global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ function wp_theme_has_theme_json_clean_cache() {
}
}

/**
* Private function to clean the caches used by gutenberg_get_global_settings method.
*
* @access private
*/
function _gutenberg_clean_theme_json_caches() {
wp_cache_delete( 'wp_theme_has_theme_json', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_stylesheet', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_settings_custom', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_settings_theme', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_custom_css', 'theme_json' );
WP_Theme_JSON_Resolver_Gutenberg::clean_cached_data();
}

/**
* Tell the cache mechanisms not to persist theme.json data across requests.
* The data stored under this cache group:
Expand Down
16 changes: 16 additions & 0 deletions lib/global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,19 @@ function ( $item ) {
}
}
}

/**
* Private function to clean the caches used by gutenberg_get_global_settings method.
*
* @access private
*/
function _gutenberg_clean_theme_json_caches() {
wp_cache_delete( 'wp_theme_has_theme_json', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_stylesheet', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_settings_custom', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_settings_theme', 'theme_json' );
wp_cache_delete( 'gutenberg_get_global_custom_css', 'theme_json' );
WP_Theme_JSON_Resolver_Gutenberg::clean_cached_data();
}
add_action( 'start_previewing_theme', '_gutenberg_clean_theme_json_caches' );
add_action( 'switch_theme', '_gutenberg_clean_theme_json_caches' );

0 comments on commit a987667

Please sign in to comment.