Skip to content

Instantly share code, notes, and snippets.

@nmyers
Created March 6, 2018 11:11
Show Gist options
  • Save nmyers/f37865afe8e4f58e1a278d6b6e1ec85a to your computer and use it in GitHub Desktop.
Save nmyers/f37865afe8e4f58e1a278d6b6e1ec85a to your computer and use it in GitHub Desktop.
Custom tinymce editor wordpress #wp
function custom_tiny_mce( $settings ) {
$settings['toolbar1'] = 'styleselect,bold,italic,bullist,blockquote,hr,alignleft,aligncenter,link,unlink';
$style_formats = array(
array(
'title' => 'Content Block',
'block' => 'span',
'classes' => 'content-block',
'wrapper' => true,
),
array(
'title' => 'Blue Button',
'block' => 'span',
'classes' => 'blue-button',
'wrapper' => true,
),
array(
'title' => 'Red Button',
'block' => 'span',
'classes' => 'red-button',
'wrapper' => true,
),
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}
add_filter( 'tiny_mce_before_init', '\W\custom_tiny_mce' );
function add_editor_styles() {
add_editor_style( get_template_directory_uri() . '/css/editor-style.css' );
}
add_action( 'init', '\W\add_editor_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment