Skip to content

Instantly share code, notes, and snippets.

@philJohnson
Last active September 30, 2015 04:08
Show Gist options
  • Save philJohnson/8438e857dbc06265fe11 to your computer and use it in GitHub Desktop.
Save philJohnson/8438e857dbc06265fe11 to your computer and use it in GitHub Desktop.
Tiny MCE advanced formats
function my_mce_css() {
return get_bloginfo('template_url').'/css/editor-style.css';
}
add_filter( 'mce_css', 'my_mce_css' );
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
function my_mce_before_init_insert_formats( $settings ) {
$style_formats = array(
array(
'title' => 'Lead Paragraph',
'selector' => 'p',
'classes' => 'lead_paragraph'
),
array(
'title' => 'Red',
'inline' => 'span',
'classes' => 'red'
),
array(
'title' => 'Button',
'selector' => 'a',
'classes' => 'button'
),
array(
'title' => 'Red Button',
'selector' => 'a',
'classes' => 'button red'
),
array(
'title' => '2 Columns',
'block' => 'div',
'wrapper' => true,
'classes' => 'columns'
),
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment