Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active March 11, 2020 15:13
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/697ec59c272c14821981cce3660cd999 to your computer and use it in GitHub Desktop.
Save vanaf1979/697ec59c272c14821981cce3660cd999 to your computer and use it in GitHub Desktop.
<?php
/**
* set_editor_font_sizes.
*
* Add theme support for editor-font-sizes,
* and set font-sizes for the gutenberg editor.
*
* @see https://since1979.dev/wp-snippet-002-changing-the-gutenberg-font-sizes/
*
* @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 set_editor_font_sizes()
{
add_theme_support('editor-font-sizes', array(
array(
'name' => __('Small', 'your-textdomain'),
'size' => 12,
'slug' => 'small'
),
array(
'name' => __('Medium', 'your-textdomain'),
'size' => 16,
'slug' => 'medium'
),
array(
'name' => __('Large', 'your-textdomain'),
'size' => 24,
'slug' => 'large'
),
array(
'name' => __('Bonkers', 'your-textdomain'),
'size' => 40,
'slug' => 'bonkers'
)
));
}
/**
* Hook: after_setup_theme.
*
* @uses after_setup_theme https://developer.wordpress.org/reference/hooks/after_setup_theme/
* @uses add_action() https://developer.wordpress.org/reference/functions/add_action/
*/
add_action('after_setup_theme', 'set_editor_font_sizes');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment