WordPress.org

Make WordPress Core

Changeset 41439 for branches/4.4


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

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.4 branch.

Location:
branches/4.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

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

    r35341 r41439  
    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.4/src/wp-includes/script-loader.php

    r37372 r41439  
    813813    ) );
    814814
     815    wp_localize_script( 'mce-view', 'mceViewL10n', array(
     816        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     817    ) );
    815818}
    816819
Note: See TracChangeset for help on using the changeset viewer.