Support » Alpha/Beta/RC » tiny_mce_before_init ignores filters after switching between editor modes

  • Resolved k3davis

    (@k3davis)


    I’m inserting an argument into the visual editor using tiny_mce_before_init and it works as expected in 3.4.2 and lower, and on initial load of the editor in 3.5 beta 1. However when I switch to the “Text” tab and then back to the visual editor, it appears to be initializing again while ignoring that filter.

    Should not functions applied using tiny_mce_before_init hold on every instance of the visual editor, not just the intial page load? The current behavior in this respect is inconsistent with 3.4.2, which I believe is correct.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    Lead Plugin Wrangler

    What’s the argument?

    TinyMCE got updated for 3.5, so it may be an issue with that code changing. Hard to say at this point without seeing your code.

    This particular use:

    /**
    	 * Set visual editor as "read only"
    	 *
    	 * @return  array Array of arguments to send to editor
    	 */
    	function cf_visedit_readonly() {
    		// suppress php warning in core when editor is read only
    		error_reporting(0);
    		return $args['readonly'] = 1;
    	}
    
    add_filter( 'tiny_mce_before_init', 'cf_visedit_readonly' );

    From my “Code Freeze” plugin:

    http://wordpress.org/extend/plugins/code-freeze/

    This is still an issue in beta 3.

    To clarify the behavior: The initial load of the Visual editor with this filter in place works. After switching to “text” editor and back again, the tinymce editor is loaded (not the wordpress version, but the actual standard tinymce buttons). So the argument is honored on the first load and apparently ignored (or something else is going wrong) on subsequent clicks on the Visual tab.

    Moderator Andrew Ozz

    (@azaozz)

    WordPress Dev

    @k3davis when switching Visual -> Text and back TinyMCE is not initialized again, only hidden/shown. The actual editor instance is always available.

    If the user was using the Text editor, it’s shown first and TinyMCE is initialized if/when the user switches to the Visual tab for the first time.

    Also all TinyMCE init settings are passed from PHP to JS in the tinyMCEPreInit object and then used to initialize it. So adding something with ‘tiny_mce_before_init’ would add it to tinyMCEPreInit.

    If you’re seeing the standard buttons in TinyMCE, that means there is something that messes with the initialization or there is bad code/error in tinyMCEPreInit.

    Moderator Andrew Nacin

    (@nacin)

    Lead Developer

    No replies since, marking as resolved.

    This is still a problem, but I understood Andrew’s answer to say that the issue is with TinyMCE, not with WordPress. So in that sense I would call it resolved… 🙂

    Thanks all for your great work.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘tiny_mce_before_init ignores filters after switching between editor modes’ is closed to new replies.