Last active
January 9, 2020 14:49
-
-
Save vanaf1979/fc6a6e6e31b3c1f0c5bd7c6eb6008a65 to your computer and use it in GitHub Desktop.
Add WordPress theme support for editor-color-palette, and set colours for the gutenberg colour pallete.
This file contains 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
<?php | |
/** | |
* change_gutenberg_color_palette. | |
* | |
* Add theme support for editor-color-palette, | |
* and set colours for the gutenberg colour pallete. | |
* | |
* @see https://since1979.dev/wp-snippet-002-changing-the-gutenberg-color-palette/ | |
* | |
* @uses add_theme_support() https://developer.wordpress.org/reference/functions/add_theme_support/ | |
* @uses __() https://developer.wordpress.org/reference/functions/__/ | |
* @uses array() https://www.php.net/manual/en/function.array.php | |
* | |
* @return void | |
*/ | |
function change_gutenberg_color_palette() { | |
add_theme_support( 'editor-color-palette', array( | |
array( | |
'name' => __('Blackish', 'your-textdomain'), | |
'slug' => 'blackish', | |
'color' => '#323232', | |
), | |
array( | |
'name' => __('Whiteish', 'your-textdomain'), | |
'slug' => 'white', | |
'color' => '#eeeeee', | |
), | |
array( | |
'name' => __('White', 'your-textdomain'), | |
'slug' => 'white', | |
'color' => '#ffffff', | |
), | |
array( | |
'name' => __('Dark blue', 'your-textdomain'), | |
'slug' => 'dark-blue', | |
'color' => '#1d2735', | |
), | |
array( | |
'name' => __('Blue', 'your-textdomain'), | |
'slug' => 'blue', | |
'color' => '#00659b', | |
), | |
array( | |
'name' => __('Light blue', 'your-textdomain'), | |
'slug' => 'light-blue', | |
'color' => '#4999ca', | |
), | |
)); | |
} | |
/** | |
* Hook: after_setup_theme. | |
* | |
* @uses add_action() https://developer.wordpress.org/reference/functions/add_action/ | |
* @uses after_setup_theme https://developer.wordpress.org/reference/hooks/after_setup_theme/ | |
*/ | |
add_action( 'after_setup_theme' , 'change_gutenberg_color_palette' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment