-
Adding Custom Font Sizes to TinyMCE editor
// Enable font size & font family selects in the editor if ( ! function_exists( ‘wpex_mce_buttons’ ) ) { function wpex_mce_buttons( $buttons ) { array_unshift( $buttons, ‘fontselect’ ); // Add Font Select array_unshift( $buttons, ‘fontsizeselect’ ); // Add Font Size Select return $buttons; } } add_filter( ‘mce_buttons_2’, ‘wpex_mce_buttons’ ); https://www.wpexplorer.com/wordpress-tinymce-tweaks/
-
Add select field to TinyMCE to change line height
function add_style_select_button($buttons) { array_unshift($buttons, ‘styleselect’); return $buttons; } add_filter(‘mce_buttons_2’, ‘add_style_select_button’); function my_mce_before_init_insert_formats( $init_array ) { $style_formats = array( // These are the custom styles array( ‘title’ => ‘line 2’, ‘block’ => ‘span’, ‘classes’ => ‘line20’, ‘wrapper’ => true, ), array( ‘title’ => ‘line 3’, ‘inline’ => ‘span’, ‘classes’ => ‘line30’, ‘wrapper’ => true, ), ); // Insert the array, JSON ENCODED, into ‘style_formats’ $init_array[‘style_formats’] = json_encode( $style_formats ); return $init_array; } // Attach callback to ‘tiny_mce_before_init’ add_filter( ‘tiny_mce_before_init’, ‘my_mce_before_init_insert_formats’ ); css /* custom css */ .line20 { line-height: 2em; } .line30 { line-height: 3em; }