Created
December 7, 2016 11:45
-
-
Save phlbnks/03d8c012411e3b43805e4a83a98c9e2a to your computer and use it in GitHub Desktop.
Make TinyMCE compatible with Garlic.js in Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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