Created
November 11, 2023 17:30
-
-
Save nextab/ca7a4adff87a0b92d6cdc1b0a41c81a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Remove bloated inline core color styles. | |
| * | |
| * @param \WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. | |
| * | |
| * @return \WP_Theme_JSON_Data | |
| */ | |
| add_filter( | |
| 'wp_theme_json_data_default', | |
| function( $theme_json ) { | |
| $data = $theme_json->get_data(); | |
| // If you want to debug, use echo '<!-- nxt debug --><pre>'; print_r($theme_json); echo '</pre>'; | |
| // Remove default color palette. | |
| $data['settings']['color']['palette']['default'] = []; | |
| // Remove default duotone. | |
| $data['settings']['color']['duotone']['default'] = []; | |
| // Remove default gradients. | |
| $data['settings']['color']['gradients']['default'] = []; | |
| // Remove shadow presets. | |
| $data['settings']['shadow']['presets']['default'] = []; | |
| // Note: With this method, you can only overwrite "settings", not "styles" or other sub fields of the array, e.g. $data['styles']['elements']['button']['color'] = []; | |
| // Update the theme data. | |
| $theme_json->update_with( $data ); | |
| return $theme_json; | |
| } | |
| ); | |
| #endregion Clean Up WordPress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment