• I’m very pleased with the new function that does enable the user to use the visual & text editor for the text widget.

    I want to filter the settings which are used within the TinyMCE editor of the new text widget. For the TinyMCE editor which is used within the post/page editor I can use the filter before_wp_tiny_mce.

    When switching from Visual editor to Text editor WordPress formats HTML I added the following key extended_valid_elements with the value span[*], div[*], meta[*] to the settings of the TinyMCE editor.

    add_filter( 'tiny_mce_before_init', function( $settings ) {
        $settings['extended_valid_elements'] = 'span[*], div[*], meta[*]';
        return $settings;
    } );

    otherwise <span>test</span> will become test after switching from the text editor to the visual editor.

    Is there a filter to add the settings used in the TinyMCE editor which is used in the new text widget?

    Note: The option in the WordPress user profile to disable the visual editor doesn’t work for the widget text editor.

    • This topic was modified 7 years, 5 months ago by basvandijkk.
Viewing 1 replies (of 1 total)
  • Hi @basvandijkk!

    The before_wp_tiny_mce filter doesn’t work for the widget TinyMCE instance because this new instance is JS based.

    Since WordPress 3.3 there has been the wp_editor() PHP function for instantiating an editor for the initial page load, but there was no facility for instantiating editors afterward, such as when adding a new Text widget to a sidebar. So in #35760 a new JS API was introduced for dynamically instantiating WP editors on the page: wp.editor.initialize(). This JS API is used for the new TinyMCE-powered Text widget

    Addition of TinyMCE to the Text Widget

    You will need to use the wp-before-tinymce-init jQuery event for editor settings.
    ??

    • This reply was modified 7 years, 5 months ago by natalia_c. Reason: Added the link to the ticket in the quoted text
Viewing 1 replies (of 1 total)
  • The topic ‘TinyMCE define valid HTML for the updated text widget’ is closed to new replies.