Skip to content

Instantly share code, notes, and snippets.

@phlbnks
Created December 7, 2016 11:45
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 phlbnks/03d8c012411e3b43805e4a83a98c9e2a to your computer and use it in GitHub Desktop.
Save phlbnks/03d8c012411e3b43805e4a83a98c9e2a to your computer and use it in GitHub Desktop.
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