Last active
March 11, 2020 15:13
-
-
Save vanaf1979/697ec59c272c14821981cce3660cd999 to your computer and use it in GitHub Desktop.
Snippet #009 Custom Gutenberg font sizes https://since1979.dev/wp-snippet-002-changing-the-gutenberg-font-sizes/
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 | |
/** | |
* 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