Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active April 1, 2020 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanaf1979/42fb1608e37b3faefd2b29c07807ac23 to your computer and use it in GitHub Desktop.
Save vanaf1979/42fb1608e37b3faefd2b29c07807ac23 to your computer and use it in GitHub Desktop.
Snippet #011 Custom Gutenberg gradient colors. https://since1979.dev/snippet-011-custom-gutenberg-gradient-colors/
<?php
/**
* theme_custom_gradients.
*
* Add custom gradients to the Gutenberg editor.
*
* @see https://since1979.dev/snippet-011-custom-gutenberg-gradient-colors/
*
* @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
*/
function theme_custom_gradients()
{
add_theme_support('editor-gradient-presets', array(
array(
'name' => __('Light blue to white', 'your-textdomain'),
'gradient' => 'linear-gradient(180deg, rgba(0,101,155,0.5) 0%, rgba(255,255,255,1) 100%)',
'slug' => 'light-blue-to-white'
),
array(
'name' => __('Blue to white', 'your-textdomain'),
'gradient' => 'linear-gradient(180deg, rgba(0,101,155,1) 0%, rgba(255,255,255,1) 100%)',
'slug' => 'blue-to-white'
),
array(
'name' => __('Dark blue to white', 'your-textdomain'),
'gradient' => 'linear-gradient(180deg,rgba(29,39,53,1) 0%,rgba(255,255,255,1) 100%)',
'slug' => 'dark-blue-to-white',
),
array(
'name' => __('Blue to dark blue', 'your-textdomain'),
'gradient' => 'linear-gradient(180deg, rgba(0,101,155,1) 0%, rgba(29,39,53,1) 100%)',
'slug' => 'blue-to-dark-blue'
),
array(
'name' => __('Light blue to black', 'your-textdomain'),
'gradient' => 'linear-gradient(180deg, rgba(0,101,155,0.5) 0%, rgba(0,0,0,1) 100%)',
'slug' => 'light-blue-to-black'
),
array(
'name' => __('Blue to block', 'your-textdomain'),
'gradient' => 'linear-gradient(180deg,rgba(0,101,155,1) 0%,rgba(0,0,0,1) 100%)',
'slug' => 'blue-to-black',
),
));
}
/**
* 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', 'theme_custom_gradients');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment