Make WordPress Core

Changeset 41443


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

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.0 branch.

Location:
branches/4.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

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

    r29649 r41443  
    129129
    130130            if ( head || body.indexOf( '<script' ) !== -1 ) {
     131                if ( body.indexOf( '[' ) !== -1 && body.indexOf( ']' ) !== -1 ) {
     132                    var shortcodesRegExp = new RegExp( '\\[\\/?(?:' + window.mceViewL10n.shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
     133                    // Escape tags inside shortcode previews.
     134                    body = body.replace( shortcodesRegExp, function( match ) {
     135                        return match.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
     136                    } );
     137                }
     138
    131139                this.getNodes( function ( editor, node, content ) {
    132140                    var dom = editor.dom,
  • branches/4.0/src/wp-includes/script-loader.php

    r29689 r41443  
    703703    ) );
    704704
     705    wp_localize_script( 'mce-view', 'mceViewL10n', array(
     706        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     707    ) );
    705708}
    706709
Note: See TracChangeset for help on using the changeset viewer.