Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make TinyMCE compatible with Garlic.js in Wordpress
/**
* Add Garlic.js compatability to TinyMCE on front-end
*
* @param array $settings TinyMCE settings array.
* @return array Modified TinyMCE settings array.
*/
function mytheme_tinymce_garlicjs_compat( $settings ) {
if ( ! is_admin() ) {
$settings['setup'] = "function(editor) {
editor.on('change keyup', function(e){
editor.save(); // updates this instance's textarea
jQuery(editor.getElement()).trigger('change'); // for garlic to detect change
});
}";
}
return $settings;
}
add_filter( 'tiny_mce_before_init', 'mytheme_tinymce_garlicjs_compat' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.