Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created January 14, 2013 08:09
Show Gist options
  • Select an option

  • Save gicolek/4528554 to your computer and use it in GitHub Desktop.

Select an option

Save gicolek/4528554 to your computer and use it in GitHub Desktop.
TinyMCE filter adding buttons
<?php
/**
* Filter TinyMCE styleselect dropdown
*
* @link http://codex.wordpress.org/TinyMCE_Custom_Styles
* @param array $init_array
* @return type
* @hook tiny_mce_before_init
*/
function wp_light_mce_before_init_insert_formats($init_array) {
21$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => 'Header Block',
'selector' => 'p',
'classes' => 'header-block-pri fonts-hiQ',
),
array(
'title' => 'Header Block 2',
'selector' => 'p',
'classes' => 'header-block-sec',
),
array(
'title' => 'Red Title span',
'selector' => 'span',
'block' => 'span',
'classes' => 'clr-strong',
),
array(
'title' => 'Paragraph break',
'selector' => 'span',
'classes' => 'paragraph-break',
),
array(
'title' => 'P larger',
'block' => 'p',
'classes' => 'txt-larger',
),
array(
'title' => 'Big list',
'selector' => 'ul',
'classes' => 'big-list clr-light',
),
array(
'title' => 'Heading Blue',
'selector' => 'h2',
'classes' => 'txt-large clr-light',
),
array(
'title' => 'Column Header',
'selector' => 'h2',
'classes' => 'col-header',
),
);
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
add_filter( 'tiny_mce_before_init', 'wp_light_mce_before_init_insert_formats' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment