Make WordPress Core

Changeset 41437


Ignore:
Timestamp:
09/19/2017 12:40:14 PM (9 years ago)
Author:
ocean90
Message:

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.6 branch.

Location:
branches/4.6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/js/mce-view.js

    r38158 r41437  
    156156                                instance;
    157157
    158                         text = tinymce.DOM.decode( text );
    159 
    160158                        if ( ! force ) {
    161159                                instance = this.getInstance( text );
    … …  
    423421                                var $viewNode;
    424422
    425                                 if ( ! this.loader && $( node ).text() !== this.text ) {
     423                                if ( ! this.loader && $( node ).text() !== tinymce.DOM.decode( this.text ) ) {
    426424                                        editor.dom.setAttrib( node, 'data-wpview-marker', null );
    427425                                        return;
    … …  
    486484                setIframes: function( head, body, callback, rendered ) {
    487485                        var self = this;
     486
     487                        if ( body.indexOf( '[' ) !== -1 && body.indexOf( ']' ) !== -1 ) {
     488                                var shortcodesRegExp = new RegExp( '\\[\\/?(?:' + window.mceViewL10n.shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
     489                                // Escape tags inside shortcode previews.
     490                                body = body.replace( shortcodesRegExp, function( match ) {
     491                                        return match.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
     492                                } );
     493                        }
    488494
    489495                        this.getNodes( function( editor, node ) {
  • branches/4.6/src/wp-includes/script-loader.php

    r38487 r41437  
    915915                'blog_id' => get_current_blog_id(),
    916916        ) );
     917
     918        wp_localize_script( 'mce-view', 'mceViewL10n', array(
     919                'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     920        ) );
    917921}
    918922
Note: See TracChangeset for help on using the changeset viewer.