Skip to content

Instantly share code, notes, and snippets.

@mcmullengreg
Last active August 29, 2015 14:21
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 mcmullengreg/fca018f231e1d6fa5584 to your computer and use it in GitHub Desktop.
Save mcmullengreg/fca018f231e1d6fa5584 to your computer and use it in GitHub Desktop.
Editor Mods for OL Reversed
// For CKEditor
// you will just add an object style to the StylesSet Object
CKEDITOR.stylesSet.add('cs_styles', [
// Object Styles
{
name : 'OL Reversed',
element : 'ol',
attributes : {
'reversed' : 'reversed'
}
}
]);
// For TinyMCE (not within wordpress)
// Adjust your initialize call accordingly
tinymce.init({
style_formats: [
{
title: 'Reverse OL',
selector: 'ol',
attributes: {
'reversed':'reversed',
},
},
]
)};
/*
This code goes in your functions.php
Check your themes functions file as they may already be using this.
*/
// Add Formats Dropdown Menu To MCE
add_filter( 'mce_buttons', 'mce_style_button' );
if ( ! function_exists( 'mce_style_button' ) ) {
function mce_style_button( $buttons ) {
array_push( $buttons, 'styleselect' );
return $buttons;
}
}
// Adds styles to the dropdown
add_filter( 'tiny_mce_before_init', 'mce_before_init' );
function mce_before_init( $settings ) {
$style_formats = array(
array(
'title' => 'Reverse OL',
'attributes' => array(
'reversed' => 'reversed',
),
'selector' => 'ol',
),
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment