Created
August 30, 2017 13:51
-
-
Save cr0ybot/18f1eeaa7215f8072f29c024d7082563 to your computer and use it in GitHub Desktop.
Add style formats to WordPress editor dropdown
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
function my_mce_before_init_insert_formats( $init_array ) { | |
$style_formats = array( | |
array( | |
'title' => 'Headline', | |
'block' => 'h2', | |
'classes' => 'headline', | |
'wrapper' => false, | |
), | |
array( | |
'title' => 'Blockquote', | |
'block' => 'blockquote', | |
'classes' => '', | |
'wrapper' => false | |
), | |
array( | |
'title' => 'Button link', | |
'selector' => 'a', | |
'classes' => 'button', | |
'wrapper' => false | |
), | |
array( | |
'title' => 'CTA Button link', | |
'selector' => 'a', | |
'classes' => 'cta', | |
'wrapper' => false | |
) | |
); | |
// Insert the array, JSON ENCODED, into 'style_formats' | |
$init_array['style_formats'] = json_encode( $style_formats ); | |
return $init_array; | |
} | |
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment