Created
May 19, 2014 04:59
-
-
Save DragorWW/4085ebcb515ecc53544b to your computer and use it in GitHub Desktop.
Add custom tyneMCE style in wordpress
This file contains 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
// TyneMCE options : | |
// - editor style | |
function add_editor_styles() { | |
add_editor_style( 'css/editor-style.css' ); | |
} | |
add_action( 'init', 'add_editor_styles' ); | |
// - add custom style | |
add_filter( 'mce_buttons_2', 'mce_editor_buttons' ); | |
function mce_editor_buttons( $buttons ) { | |
array_unshift( $buttons, 'styleselect' ); | |
return $buttons; | |
} | |
function mce_insert_formats( $init_array ) { | |
// Define the style_formats array | |
$style_formats = array( | |
// Each array child is a format with it's own settings | |
array( | |
'title' => 'Цитата', | |
'block' => 'blockquote', | |
'classes' => 'blue', | |
'wrapper' => true, | |
), | |
array( | |
'title' => 'Цитата с права', | |
'block' => 'blockquote', | |
'classes' => 'blue right', | |
'wrapper' => true, | |
), | |
); | |
// Insert the array, JSON ENCODED, into 'style_formats' | |
$init_array['style_formats'] = json_encode( $style_formats ); | |
return $init_array; | |
} | |
// Attach callback to 'tiny_mce_before_init' | |
add_filter( 'tiny_mce_before_init', 'mce_insert_formats' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment