Skip to content

Instantly share code, notes, and snippets.

@jonschr
Created March 8, 2022 18:00
Show Gist options
  • Select an option

  • Save jonschr/b7802d145c34000063ce36cbd7bfcbbb to your computer and use it in GitHub Desktop.

Select an option

Save jonschr/b7802d145c34000063ce36cbd7bfcbbb to your computer and use it in GitHub Desktop.
// get the palette from the theme defaults, as defined in theme.json
$color_palette = [];
if ( class_exists( 'WP_Theme_JSON_Resolver' ) ) {
$settings = WP_Theme_JSON_Resolver::get_theme_data()->get_settings();
if ( isset( $settings['color']['palette']['theme'] ) ) {
$color_palette = $settings['color']['palette']['theme'];
}
}
// do stuff with $color_palette
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment