0
votes

I've come across multiple solutions that all use filters and hooks to prevent tinymce from stripping certain elements from within the post editor 'visual' editor.

I have a plugin that allows the user to place custom <span></span> tags into a new post, but when the user switches over to the 'visual' tab, tinymce then deletes the span tags they have placed.

I have one function here that is from 2009, which doesn't seem to work.

function my_change_mce_options( $init ) {
    // Command separated string of extended elements
   $ext = 'span[id|name|class|style]';

    // Add to extended_valid_elements if it alreay exists
    if ( isset( $init['extended_valid_elements'] ) ) {
        $init['extended_valid_elements'] .= ',' . $ext;
    } else {
        $init['extended_valid_elements'] = $ext;
    }

    // Super important: return $init!
    return $init;
}

add_filter('tiny_mce_before_init', 'my_change_mce_options');

I tried adding that to my plugins core files, but does not work. Apparently the newer version of tinymce doesn't do this, but WordPress 3.7.1 is still using an older version for stability reasons I guess.

Any ideas?

1
Still need help on this one. - EHerman

1 Answers

1
votes

Upgrade to Version 4, its confirmed that the bug doesn't exist in that one.