Skip to content

Instantly share code, notes, and snippets.

@elseloop
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save elseloop/9fd515da010a57bee113 to your computer and use it in GitHub Desktop.

Select an option

Save elseloop/9fd515da010a57bee113 to your computer and use it in GitHub Desktop.
Example added WYSIWYG styles in WP
/**
* 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