Skip to content

Instantly share code, notes, and snippets.

Created September 22, 2016 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/459d62df1ac1cf3b2565756177c68d63 to your computer and use it in GitHub Desktop.
Save anonymous/459d62df1ac1cf3b2565756177c68d63 to your computer and use it in GitHub Desktop.
<?php
// Ab hier kopieren
/*
* Callback Funktion für den MCE-Editor
*/
function ah_mce_before_init_insert_formats( $init_array ) {
// Define the style_formats array
$style_formats = array(
/*
* Each array child is a format with it's own settings
* Notice that each array has title, block, classes, and wrapper arguments
* Title is the label which will be visible in Formats menu
* Block defines whether it is a span, div, selector, or inline style
* Classes allows you to define CSS classes
* Wrapper whether or not to add a new block-level element around any selected elements
*/
array(
'title' => 'Blauer Button',
'block' => 'span',
'classes' => 'blue-button',
'wrapper' => true,
),
array(
'title' => 'Roter Button',
'block' => 'span',
'classes' => 'red-button',
'wrapper' => true,
),
array(
'title' => 'Grüner Button',
'block' => 'span',
'classes' => 'green-button',
'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', 'ah_mce_before_init_insert_formats' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment