[wp-hackers] No filter of code on switch from html to visual editor, how?

Frank Bueltge frank at bueltge.de
Wed Jan 25 11:50:32 UTC 2012

Hello at all,
if I include code inside the html-tab and I switch to the visual mode
of the Editor on post/page, then format WP the code to a block, remove
all breaks and leave lines, see the screenshots at this post on WPSE.
I think this easier to understand as my bad english.

My tests for an solution.
I have test this to stop WP for this with the follow test plugin, also
readable in this https://gist.github.com/1663554

add_filter( 'tiny_mce_before_init', 'fb_tinymce', 9 );

function fb_tinymce( $init ) {

    $init['fix_list_elements'] = FALSE;
    $init['wpautop'] = FALSE;
    $init['remove_linebreaks'] = FALSE;
    $init['apply_source_formatting'] = TRUE;
    $init['extended_valid_elements'] .= ',pre[*],code[*]';

    return $init;

Alternative is it maybe possible to change the process viua jquery, an
script which add a process on the tab change of the editor, but not
very fine. Basically an add on for editor.js

Maybe an other reader has an solution for this topic.
THANKS for replies.

More information about the wp-hackers mailing list