Add custom editor font sizes to your site after the block library styles using wp_inline_style.
<?php | |
add_action( 'enqueue_block_assets', 'rgc_editor_font_sizes', 15 ); | |
/** | |
* Add custom font sizes to the site using wp_inline_style, attached to the wp-block-library stylesheet. | |
* Editor font sizes must be defined in your theme. | |
*/ | |
function rgc_editor_font_sizes() { | |
list( $font_sizes, ) = (array) get_theme_support( 'editor-font-sizes' ); | |
if ( ! $font_sizes ) { | |
return; | |
} | |
$css = ''; | |
foreach ( $font_sizes as $size ) { | |
$css .= sprintf( '.has-%s-font-size {font-size: %spx;}', $size['slug'], $size['size'] ); | |
} | |
wp_add_inline_style( 'wp-block-library', $css ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment