WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] tiny_mce_before_init ignores filters after switching between editor modes (7 posts)

  1. k3davis
    Member
    Posted 1 year ago #

    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.

  2. 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.

  3. k3davis
    Member
    Posted 1 year ago #

    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/

  4. k3davis
    Member
    Posted 1 year ago #

    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.

  5. Andrew Ozz
    WordPress Dev
    Posted 1 year ago #

    @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.

  6. Andrew Nacin
    Lead Developer
    Posted 1 year ago #

    No replies since, marking as resolved.

  7. k3davis
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic