Make WordPress Core

Changeset 41436 for branches/4.7


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

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.7 branch.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

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

    r40482 r41436  
    156156                instance;
    157157
    158             text = tinymce.DOM.decode( text );
    159 
    160158            if ( text.indexOf( '[' ) !== -1 && text.indexOf( ']' ) !== -1 ) {
    161159                // Looks like a shortcode? Remove any line breaks from inside of shortcodes
     
    431429                var $viewNode;
    432430
    433                 if ( ! this.loader && $( node ).text() !== this.text ) {
     431                if ( ! this.loader && $( node ).text() !== tinymce.DOM.decode( this.text ) ) {
    434432                    editor.dom.setAttrib( node, 'data-wpview-marker', null );
    435433                    return;
     
    494492        setIframes: function( head, body, callback, rendered ) {
    495493            var self = this;
     494
     495            if ( body.indexOf( '[' ) !== -1 && body.indexOf( ']' ) !== -1 ) {
     496                var shortcodesRegExp = new RegExp( '\\[\\/?(?:' + window.mceViewL10n.shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
     497                // Escape tags inside shortcode previews.
     498                body = body.replace( shortcodesRegExp, function( match ) {
     499                    return match.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
     500                } );
     501            }
    496502
    497503            this.getNodes( function( editor, node ) {
  • branches/4.7/src/wp-includes/script-loader.php

    r39697 r41436  
    939939        'blog_id' => get_current_blog_id(),
    940940    ) );
     941
     942    wp_localize_script( 'mce-view', 'mceViewL10n', array(
     943        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     944    ) );
    941945}
    942946
Note: See TracChangeset for help on using the changeset viewer.