Hat tip to Felix Arntz for introducing us to this simple trick.
When using Gutenberg, in order to ensure that users of your theme stick to the color foundation you provide them, use `add_theme_support( ‘disable-custom-colors’ )`.
— Felix Arntz (@felixarntz) March 10, 2018
I first learned about this from Felix’s tweet, but have since confirmed it via the official Gutenberg documentation on wordpress.org.
“By default, the color palette offered to blocks, allows the user to select a custom color different from the editor or theme default colors. Themes can disable this feature using:”
add_theme_support( 'disable-custom-colors' );
Simply add this line to the
functions.php of your theme to prevent clients from going rogue on your predetermined color scheme.
This flag will make sure users are only able to choose colors from the
editor-color-palette the theme provided or from the editor default colors if the theme did not provide one.
Speaking of the editor-color-palette…