Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.