Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Created April 8, 2024 00:17
Show Gist options
  • Save marklchaves/9f0aa613662e6c6a69a1fd43cd81055c to your computer and use it in GitHub Desktop.
Save marklchaves/9f0aa613662e6c6a69a1fd43cd81055c to your computer and use it in GitHub Desktop.
Add Font Family and Custom Font Size Options to TinyMCE
<?php // Ignore this first line when copying to your child theme's functions.php file.
// Turn on font size & font family selects in the classic editor.
add_filter( 'mce_buttons_2', function( $buttons ) {
array_unshift( $buttons, 'fontselect' );
array_unshift( $buttons, 'fontsizeselect' );
return $buttons;
} );
/**
* You can add the PHP code snippet to your child theme's functions.php file
* or with third-party plugins such as My Custom Functions and Code Snippets.
*
* Learn more:
* - https://docs.wppopupmaker.com/article/552-getting-started-with-custom-php
*/
<?php // Ignore this first line when copying to your child theme's functions.php file.
// Customize the classic editor font size dropdown.
add_filter( 'tiny_mce_before_init', function( $init_array ) {
$init_array['fontsize_formats'] = "9px 10px 12px 13px 14px 16px 18px 21px 24px 28px 32px 36px";
return $init_array;
} );
/**
* You can add the PHP code snippet to your child theme's functions.php file
* or with third-party plugins such as My Custom Functions and Code Snippets.
*
* Learn more:
* - https://docs.wppopupmaker.com/article/552-getting-started-with-custom-php
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment