Last active
August 29, 2015 14:00
-
-
Save elseloop/9fd515da010a57bee113 to your computer and use it in GitHub Desktop.
Example added WYSIWYG styles in WP
This file contains hidden or 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
| /** | |
| * Add Styles dropdown to visual editor | |
| */ | |
| function themename_mce_styles_drop( $buttons ) { | |
| array_unshift( $buttons, 'styleselect' ); | |
| return $buttons; | |
| } | |
| add_filter( 'mce_buttons_2', 'themename_mce_styles_drop' ); | |
| /** | |
| * Add Styles to live in the dropdown added above to the visual editor | |
| */ | |
| function themename_mce_styles_init( $settings ) { | |
| $style_formats = array( | |
| array( | |
| 'title' => 'Citation', | |
| 'inline' => 'div', | |
| 'classes' => 'cite', | |
| 'wrapper' => true | |
| ), | |
| array( | |
| 'title' => 'Citation Source Title', | |
| 'inline' => 'span', | |
| 'classes' => 'cite-title' | |
| ), | |
| array( | |
| 'title' => 'Client Name', | |
| 'inline' => 'span', | |
| 'classes' => 'cite-company' | |
| ), | |
| array( | |
| 'title' => 'Contact Info', | |
| 'inline' => 'div', | |
| 'classes' => 'contact-info', | |
| 'wrapper' => true | |
| ) | |
| ); | |
| $settings['style_formats'] = json_encode( $style_formats ); | |
| return $settings; | |
| } | |
| add_filter( 'tiny_mce_before_init', 'themename_mce_styles_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment