Skip to content

Instantly share code, notes, and snippets.

@Ravenna
Created August 17, 2016 21:10
Show Gist options
  • Select an option

  • Save Ravenna/20347fb4d5e321ab70cdc3b1d06c8039 to your computer and use it in GitHub Desktop.

Select an option

Save Ravenna/20347fb4d5e321ab70cdc3b1d06c8039 to your computer and use it in GitHub Desktop.
// CUSTOMIZE TinyMCE
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter('mce_buttons_2', 'my_mce_buttons_2');
function my_theme_add_editor_styles() {
add_editor_style( '/assets/css/custom-editor-style.css' );
}
add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );
function my_mce_before_init_insert_formats( $init_array ) {
$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => 'Blue Text',
'block' => 'span',
'classes' => 'blue',
'wrapper' => true,
),
array(
'title' => 'Leader Title',
'block' => 'p',
'classes' => 'lead',
'wrapper' => false,
),
array(
'title' => 'h2.5',
'block' => 'h1',
'classes' => 'h2-5',
'wrapper' => false,
),
);
$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