From c8f3451522c0b8fa15d91436efaf1801da8eb42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Mon, 19 Sep 2022 17:36:29 +0200 Subject: [PATCH] Skeleton for filtering theme.json for classic themes at all layers --- .../hook-theme-json-for-classic-themes.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/compat/wordpress-6.1/hook-theme-json-for-classic-themes.php diff --git a/lib/compat/wordpress-6.1/hook-theme-json-for-classic-themes.php b/lib/compat/wordpress-6.1/hook-theme-json-for-classic-themes.php new file mode 100644 index 0000000000000..a5813c8881acd --- /dev/null +++ b/lib/compat/wordpress-6.1/hook-theme-json-for-classic-themes.php @@ -0,0 +1,46 @@ + 2, + 'settings' => array( /* we should maintain the presets by core */ ), + 'styles' => array( /* clear this? add only the base-layout-styles? */ ), + ); + $theme_json_data->update_with( $new_data ); + } + return $theme_json_data; +} +add_filter( 'theme_json_default', 'theme_json_default_filter_for_classic_themes'); + +function theme_json_blocks_filter_for_classic_themes( $theme_json_data ) { + if ( theme_json_current_theme_has_support() ) { + $new_data = array( + 'version' => 2, + 'settings' => array(), + 'styles' => array( /* add button styles for classic here */ ), + ); + $theme_json_data->update_with( $new_data ); + } + return $theme_json_data; +} +add_filter( 'theme_json_blocks', 'theme_json_blocks_filter_for_classic_themes' ); + +function theme_json_reset_for_classic_themes( $theme_json_data ) { + if ( theme_json_current_theme_has_support() ) { + $new_data = array( + 'version' => 2, + 'settings' => array(), + 'styles' => array(), + ); + $theme_json_data->update_with( $new_data ); + } + + return $theme_json_data; +} +add_filter( 'theme_json_theme', 'theme_json_reset_for_classic_themes' ); +add_filter( 'theme_json_user', 'theme_json_reset_for_classic_themes' );