Make WordPress Core

Changeset 41440 for branches/4.3


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

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.3 branch.

Location:
branches/4.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3

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

    r33484 r41440  
    156156                instance;
    157157
    158             text = tinymce.DOM.decode( text );
    159 
    160158            if ( ! force ) {
    161159                instance = this.getInstance( text );
     
    425423                    $viewNode;
    426424
    427                 if ( ! this.loader && $( node ).text() !== this.text ) {
     425                if ( ! this.loader && $( node ).text() !== tinymce.DOM.decode( this.text ) ) {
    428426                    editor.dom.setAttrib( node, 'data-wpview-marker', null );
    429427                    return;
     
    496494            var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
    497495                self = this;
     496
     497            if ( body.indexOf( '[' ) !== -1 && body.indexOf( ']' ) !== -1 ) {
     498                var shortcodesRegExp = new RegExp( '\\[\\/?(?:' + window.mceViewL10n.shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
     499                // Escape tags inside shortcode previews.
     500                body = body.replace( shortcodesRegExp, function( match ) {
     501                    return match.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
     502                } );
     503            }
    498504
    499505            this.getNodes( function( editor, node, contentNode ) {
  • branches/4.3/src/wp-includes/script-loader.php

    r37374 r41440  
    792792    ) );
    793793
     794    wp_localize_script( 'mce-view', 'mceViewL10n', array(
     795        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     796    ) );
    794797}
    795798
Note: See TracChangeset for help on using the changeset viewer.