Adding a Filter for Saved Content

Editus allows you to add Javascript codes to filter the content being saved. Here is an example JQuery code. Beside filtering, you can technically do other operations you want here.

        // the following lines insert filter1() function to the Editus filter list
	if (lasso_editor.filterArray) {
	} else {
		lasso_editor.filterArray = [filter1];
	function filter1(html){
                // replace all the occurences of dog with doll
		html = html.replace('dog', 'doll'); 
		return html;

Note that this code will still run even if you set “Disable Post Saving” option to on. So using this mechanism, you can replace the default save operation with whatever operation you may need to do.

Of course this Javascript code needs to be loaded. Here is sample PHP code to do so. Note you need to set CODE_LOCATION to the location of your Javascript file.

add_action('wp_enqueue_scripts', my_editus_save_filter);

function my_editus_save_filter(){
	wp_enqueue_script('my_editus_save_filter', CODE_LOCATION."/my_editus_save_filter.js", array(), '1.0', true);

Here is another trick that would be useful. By default, Editus preserves shortcodes that are not part of Aesop Story Engine. So Editus will always recover the shortcodes after editing and saving operations. If you want to add your own processing for certain shortcodes, you can use the following filter to add to the list of shortcodes that will NOT be preserved by Editus. That way you can write filter codes that will modify shortcodes before saving in the way you want.

add_filter( 'lasso_wrap_shortcode_exceptions',   'my_shortcode_exceptions' );

function my_shotcode_exceptions( $exception_arr ) {
	array_push($exception_arr, "my_shortcode");
    return $exception_arr;