<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[40476] trunk/src: Editor: Provide API for the editor to be dynamically instantiated via JS.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/40476">40476</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/40476","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-04-19 02:37:29 +0000 (Wed, 19 Apr 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: Provide API for the editor to be dynamically instantiated via JS. First run.

See: <a href="https://core.trac.wordpress.org/ticket/35760">#35760</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminjseditorjs">trunk/src/wp-admin/js/editor.js</a></li>
<li><a href="#trunksrcwpincludesclasswpeditorphp">trunk/src/wp-includes/class-wp-editor.php</a></li>
<li><a href="#trunksrcwpincludescsseditorcss">trunk/src/wp-includes/css/editor.css</a></li>
<li><a href="#trunksrcwpincludesgeneraltemplatephp">trunk/src/wp-includes/general-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php      2017-04-18 17:05:28 UTC (rev 40475)
+++ trunk/src/wp-admin/includes/ajax-actions.php        2017-04-19 02:37:29 UTC (rev 40476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1497,7 +1497,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        require(ABSPATH . WPINC . '/class-wp-editor.php');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! class_exists( '_WP_Editors', false ) ) {
+               require( ABSPATH . WPINC . '/class-wp-editor.php' );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $results = _WP_Editors::wp_link_query( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! isset( $results ) )
</span></span></pre></div>
<a id="trunksrcwpadminjseditorjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/editor.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/editor.js   2017-04-18 17:05:28 UTC (rev 40475)
+++ trunk/src/wp-admin/js/editor.js     2017-04-19 02:37:29 UTC (rev 40476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,5 +1,8 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+window.wp = window.wp || {};
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-( function( $ ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+( function( $, wp ) {
+       wp.editor = wp.editor || {};
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @summary Utility functions for the editor.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -484,10 +487,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        } );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                window.wp = window.wp || {};
-               window.wp.editor = window.wp.editor || {};
-               window.wp.editor.autop = wpautop;
-               window.wp.editor.removep = pre_wpautop;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp.editor.autop = wpautop;
+               wp.editor.removep = pre_wpautop;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                exports = {
</span><span class="cx" style="display: block; padding: 0 10px">                        go: switchEditor,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -505,4 +506,143 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * Expose the switch editors to be used globally.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        window.switchEditors = new SwitchEditors();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}( window.jQuery ));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Initialize TinyMCE and/or Quicktags. For use with wp_enqueue_editor() (PHP).
+        *
+        * Intended for use with an existing textarea that will become the Text editor tab.
+        * The editor width will be the width of the textarea container, height will be adjustable.
+        *
+        * Settings for both TinyMCE and Quicktags can be passed on initialization, and are "filtered"
+        * with custom jQuery events on the document element, wp-before-tinymce-init and wp-before-quicktags-init.
+        *
+        * @since 4.8
+        *
+        * @param {string} id The HTML id of the textarea that is used for the editor.
+        *                    Has to be jQuery compliant. No brackets, special chars, etc.
+        * @param {object} settings Example:
+        * settings = {
+        *    // See https://www.tinymce.com/docs/configure/integration-and-setup/.
+        *    // Alternatively set to `true` to use the defaults.
+        *    tinymce: {
+        *        setup: function( editor ) {
+        *            console.log( 'Editor initialized', editor );
+        *        }
+        *    }
+        *
+        *    // Alternatively set to `true` to use the defaults.
+        *        quicktags: {
+        *        buttons: 'strong,em,link'
+        *    }
+        * }
+        */
+       wp.editor.initialize = function( id, settings ) {
+               var init;
+               var defaults;
+
+               if ( ! $ || ! id || ! wp.editor.getDefaultSettings ) {
+                       return;
+               }
+
+               defaults = wp.editor.getDefaultSettings();
+
+               // Initialize TinyMCE by default
+               if ( ! settings ) {
+                       settings = {
+                               tinymce: true
+                       };
+               }
+
+               // Add wrap and the Visual|Text tabs.
+               if ( settings.tinymce && settings.quicktags ) {
+                       var $textarea = $( '#' + id );
+                       var $wrap = $( '<div>' ).attr( {
+                                       'class': 'wp-core-ui wp-editor-wrap tmce-active',
+                                       id: 'wp-' + id + '-wrap'
+                               } );
+                       var $editorContainer = $( '<div class="wp-editor-container">' );
+                       var $button = $( '<button>' ).attr( {
+                                       type: 'button',
+                                       'data-wp-editor-id': id
+                               } );
+
+                       $wrap.append(
+                               $( '<div class="wp-editor-tools">' )
+                                       .append( $( '<div class="wp-editor-tabs">' )
+                                               .append( $button.clone().attr({
+                                                       id: id + '-tmce',
+                                                       'class': 'wp-switch-editor switch-tmce'
+                                               }).text( window.tinymce.translate( 'Visual' ) ) )
+                                               .append( $button.attr({
+                                                       id: id + '-html',
+                                                       'class': 'wp-switch-editor switch-html'
+                                               }).text( window.tinymce.translate( 'Text' ) ) )
+                                       ).append( $editorContainer )
+                       );
+
+                       $textarea.after( $wrap );
+                       $editorContainer.append( $textarea );
+               }
+
+               if ( window.tinymce && settings.tinymce ) {
+                       if ( typeof settings.tinymce !== 'object' ) {
+                               settings.tinymce = {};
+                       }
+
+                       init = $.extend( {}, defaults.tinymce, settings.tinymce );
+                       init.selector = '#' + id;
+
+                       $( document ).trigger( 'wp-before-tinymce-init', init );
+                       window.tinymce.init( init );
+
+                       if ( ! window.wpActiveEditor ) {
+                               window.wpActiveEditor = id;
+                       }
+               }
+
+               if ( window.quicktags && settings.quicktags ) {
+                       if ( typeof settings.quicktags !== 'object' ) {
+                               settings.quicktags = {};
+                       }
+
+                       init = $.extend( {}, defaults.quicktags, settings.quicktags );
+                       init.id = id;
+
+                       $( document ).trigger( 'wp-before-quicktags-init', init );
+                       window.quicktags( init );
+
+                       if ( ! window.wpActiveEditor ) {
+                               window.wpActiveEditor = init.id;
+                       }
+               }
+       };
+
+       /**
+        * Get the editor content.
+        *
+        * Intended for use with editors that were initialized with wp.editor.initialize().
+        *
+        * @since 4.8
+        *
+        * @param {string} id The HTML id of the editor textarea.
+        * @return The editor content.
+        */
+       wp.editor.getContent = function( id ) {
+               var editor;
+
+               if ( ! $ || ! id ) {
+                       return;
+               }
+
+               if ( window.tinymce ) {
+                       editor = window.tinymce.get( id );
+
+                       if ( editor && ! editor.isHidden() ) {
+                               editor.save();
+                       }
+               }
+
+               return $( '#' + id ).val();
+       };
+
+}( window.jQuery, window.wp ));
</ins></span></pre></div>
<a id="trunksrcwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-editor.php 2017-04-18 17:05:28 UTC (rev 40475)
+++ trunk/src/wp-includes/class-wp-editor.php   2017-04-19 02:37:29 UTC (rev 40476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,6 +27,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        private static $drag_drop_upload = false;
</span><span class="cx" style="display: block; padding: 0 10px">        private static $old_dfw_compat = false;
</span><span class="cx" style="display: block; padding: 0 10px">        private static $translation;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        private static $tinymce_scripts_printed = false;
+       private static $link_dialog_printed = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        private function __construct() {}
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -350,22 +352,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( self::$this_tinymce ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( empty( self::$first_init ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                self::$baseurl = includes_url( 'js/tinymce' );
-
-                               $mce_locale = get_user_locale();
-                               self::$mce_locale = $mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1
-
-                               /** This filter is documented in wp-admin/includes/media.php */
-                               $no_captions = (bool) apply_filters( 'disable_captions', '' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $baseurl = self::get_baseurl();
+                               $mce_locale = self::get_mce_locale();
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $ext_plugins = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $shortcut_labels = array();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                foreach ( self::get_translation() as $name => $value ) {
-                                       if ( is_array( $value ) ) {
-                                               $shortcut_labels[$name] = $value[1];
-                                       }
-                               }
-
</del><span class="cx" style="display: block; padding: 0 10px">                                 if ( $set['teeny'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -376,7 +366,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                         * @param array  $plugins   An array of teenyMCE plugins.
</span><span class="cx" style="display: block; padding: 0 10px">                                         * @param string $editor_id Unique editor identifier, e.g. 'content'.
</span><span class="cx" style="display: block; padding: 0 10px">                                         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        self::$plugins = $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 } else {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -521,65 +511,23 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                self::$plugins = $plugins;
</span><span class="cx" style="display: block; padding: 0 10px">                                self::$ext_plugins = $ext_plugins;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                self::$first_init = array(
-                                       'theme' => 'modern',
-                                       'skin' => 'lightgray',
-                                       'language' => self::$mce_locale,
-                                       'formats' => '{' .
-                                               'alignleft: [' .
-                                                       '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' .
-                                                       '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' .
-                                               '],' .
-                                               'aligncenter: [' .
-                                                       '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' .
-                                                       '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' .
-                                               '],' .
-                                               'alignright: [' .
-                                                       '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' .
-                                                       '{selector: "img,table,dl.wp-caption", classes: "alignright"}' .
-                                               '],' .
-                                               'strikethrough: {inline: "del"}' .
-                                       '}',
-                                       'relative_urls' => false,
-                                       'remove_script_host' => false,
-                                       'convert_urls' => false,
-                                       'browser_spellcheck' => true,
-                                       'fix_list_elements' => true,
-                                       'entities' => '38,amp,60,lt,62,gt',
-                                       'entity_encoding' => 'raw',
-                                       'keep_styles' => false,
-                                       'cache_suffix' => 'wp-mce-' . $tinymce_version,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $settings = self::default_settings();
+                               $settings['plugins'] = implode( ',', $plugins );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        // Limit the preview styles in the menu/toolbar
-                                       'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',
-
-                                       'end_container_on_empty_block' => true,
-                                       'wpeditimage_disable_captions' => $no_captions,
-                                       'wpeditimage_html5_captions' => current_theme_supports( 'html5', 'caption' ),
-                                       'plugins' => implode( ',', $plugins ),
-                                       'wp_lang_attr' => get_bloginfo( 'language' ),
-                                       'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ),
-                               );
-
</del><span class="cx" style="display: block; padding: 0 10px">                                 if ( ! empty( $mce_external_plugins ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        self::$first_init['external_plugins'] = wp_json_encode( $mce_external_plugins );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $settings['external_plugins'] = wp_json_encode( $mce_external_plugins );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $suffix = SCRIPT_DEBUG ? '' : '.min';
-                               $version = 'ver=' . get_bloginfo( 'version' );
-                               $dashicons = includes_url( "css/dashicons$suffix.css?$version" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         /** This filter is documented in wp-admin/includes/media.php */
+                               if ( apply_filters( 'disable_captions', '' ) ) {
+                                       $settings['wpeditimage_disable_captions'] = true;
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // WordPress default stylesheet and dashicons
-                               $mce_css = array(
-                                       $dashicons,
-                                       self::$baseurl . '/skins/wordpress/wp-content.css?' . $version
-                               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $mce_css = $settings['content_css'];
+                               $editor_styles = get_editor_stylesheets();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $editor_styles = get_editor_stylesheets();
</del><span class="cx" style="display: block; padding: 0 10px">                                 if ( ! empty( $editor_styles ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        foreach ( $editor_styles as $style ) {
-                                               $mce_css[] = $style;
-                                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $mce_css .= ',' . implode( ',', $editor_styles );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -589,10 +537,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                 *
</span><span class="cx" style="display: block; padding: 0 10px">                                 * @param string $stylesheets Comma-delimited list of stylesheets.
</span><span class="cx" style="display: block; padding: 0 10px">                                 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $mce_css = trim( apply_filters( 'mce_css', implode( ',', $mce_css ) ), ' ,' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                if ( ! empty($mce_css) )
-                                       self::$first_init['content_css'] = $mce_css;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( ! empty( $mce_css ) ) {
+                                       $settings['content_css'] = $mce_css;
+                               } else {
+                                       unset( $settings['content_css'] );
+                               }
+
+                               self::$first_init = $settings;
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $set['teeny'] ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -690,21 +643,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( !empty($set['tinymce']['body_class']) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( ! empty( $set['tinymce']['body_class'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $body_class .= ' ' . $set['tinymce']['body_class'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                unset($set['tinymce']['body_class']);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         unset( $set['tinymce']['body_class'] );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $mceInit = array (
</span><span class="cx" style="display: block; padding: 0 10px">                                'selector' => "#$editor_id",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'resize' => 'vertical',
-                               'menubar' => false,
</del><span class="cx" style="display: block; padding: 0 10px">                                 'wpautop' => (bool) $set['wpautop'],
</span><span class="cx" style="display: block; padding: 0 10px">                                'indent' => ! $set['wpautop'],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'toolbar1' => implode($mce_buttons, ','),
-                               'toolbar2' => implode($mce_buttons_2, ','),
-                               'toolbar3' => implode($mce_buttons_3, ','),
-                               'toolbar4' => implode($mce_buttons_4, ','),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'toolbar1' => implode( ',', $mce_buttons ),
+                               'toolbar2' => implode( ',', $mce_buttons_2 ),
+                               'toolbar3' => implode( ',', $mce_buttons_3 ),
+                               'toolbar4' => implode( ',', $mce_buttons_4 ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'tabfocus_elements' => $set['tabfocus_elements'],
</span><span class="cx" style="display: block; padding: 0 10px">                                'body_class' => $body_class
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -762,19 +713,23 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $init
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        private static function _parse_init($init) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private static function _parse_init( $init ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $options = '';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                foreach ( $init as $k => $v ) {
-                       if ( is_bool($v) ) {
-                               $val = $v ? 'true' : 'false';
-                               $options .= $k . ':' . $val . ',';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         foreach ( $init as $key => $value ) {
+                       if ( is_bool( $value ) ) {
+                               $val = $value ? 'true' : 'false';
+                               $options .= $key . ':' . $val . ',';
</ins><span class="cx" style="display: block; padding: 0 10px">                                 continue;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } elseif ( !empty($v) && is_string($v) && ( ('{' == $v{0} && '}' == $v{strlen($v) - 1}) || ('[' == $v{0} && ']' == $v{strlen($v) - 1}) || preg_match('/^\(?function ?\(/', $v) ) ) {
-                               $options .= $k . ':' . $v . ',';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } elseif ( ! empty( $value ) && is_string( $value ) && (
+                               ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) ||
+                               ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) ||
+                               preg_match( '/^\(?function ?\(/', $value ) ) ) {
+
+                               $options .= $key . ':' . $value . ',';
</ins><span class="cx" style="display: block; padding: 0 10px">                                 continue;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $options .= $k . ':"' . $v . '",';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $options .= $key . ':"' . $value . '",';
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return '{' . trim( $options, ' ,' ) . '}';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -784,28 +739,31 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @static
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public static function enqueue_scripts() {
-               if ( self::$has_tinymce )
-                       wp_enqueue_script('editor');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function enqueue_scripts( $default_scripts = false ) {
+               if ( $default_scripts || self::$has_tinymce ) {
+                       wp_enqueue_script( 'editor' );
+               }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( self::$has_quicktags ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( $default_scripts || self::$has_quicktags ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_enqueue_script( 'quicktags' );
</span><span class="cx" style="display: block; padding: 0 10px">                        wp_enqueue_style( 'buttons' );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) {
-                       wp_enqueue_script('wplink');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( $default_scripts || in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) {
+                       wp_enqueue_script( 'wplink' );
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp_enqueue_script( 'jquery-ui-autocomplete' );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( self::$old_dfw_compat ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        wp_enqueue_script('wp-fullscreen-stub');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_enqueue_script( 'wp-fullscreen-stub' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( self::$has_medialib ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        add_thickbox();
</span><span class="cx" style="display: block; padding: 0 10px">                        wp_enqueue_script( 'media-upload' );
</span><span class="cx" style="display: block; padding: 0 10px">                        wp_enqueue_script( 'wp-embed' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                } elseif ( $default_scripts ) {
+                       wp_enqueue_script( 'media-upload' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -817,11 +775,198 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 *                       and Quicktags are being loaded.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                do_action( 'wp_enqueue_editor', array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'tinymce'   => self::$has_tinymce,
-                       'quicktags' => self::$has_quicktags,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'tinymce'   => ( $default_scripts || self::$has_tinymce ),
+                       'quicktags' => ( $default_scripts || self::$has_quicktags ),
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Enqueue all editor scripts.
+        * For use when the editor is going to be initialized after page load.
+        *
+        * @since 4.8.0
+        */
+       public static function enqueue_default_editor() {
+               // We are past the point where scripts can be enqueued properly.
+               if ( did_action( 'wp_enqueue_editor' ) ) {
+                       return;
+               }
+
+               self::enqueue_scripts( true );
+
+               // Also add wp-includes/css/editor.css
+               wp_enqueue_style( 'editor-buttons' );
+
+               if ( is_admin() ) {
+                       add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 );
+               } else {
+                       add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 );
+               }
+       }
+
+       /**
+        * Print (output) all editor scripts and default settings.
+        * For use when the editor is going to be initialized after page load.
+        *
+        * @since 4.8.0
+        *
+        */
+       public static function print_default_editor_scripts() {
+               $settings = self::default_settings();
+
+               $settings['toolbar1'] = 'bold,italic,bullist,numlist,link';
+               $settings['wpautop'] = false;
+               $settings['indent'] = true;
+               $settings['elementpath'] = false;
+
+               // In production all plugins are loaded (they are in wp-editor.js.gz)
+               // but only these will be initialized by default.
+               $settings['plugins'] = implode( ',', array(
+                       'charmap',
+                       'colorpicker',
+                       'hr',
+                       'lists',
+       //              'media',
+                       'paste',
+                       'tabfocus',
+                       'textcolor',
+                       'fullscreen',
+                       'wordpress',
+                       'wpautoresize',
+                       'wpeditimage',
+                       'wpemoji',
+                       'wpgallery',
+                       'wplink',
+       //              'wpdialogs',
+                       'wptextpattern',
+       //              'wpview',
+               ) );
+
+               $settings = self::_parse_init( $settings );
+
+               $suffix = SCRIPT_DEBUG ? '' : '.min';
+               $baseurl = self::get_baseurl();
+
+               ?>
+               <script type="text/javascript">
+               window.wp = window.wp || {};
+               window.wp.editor = window.wp.editor || {};
+               window.wp.editor.getDefaultSettings = function() {
+                       return {
+                               tinymce: <?php echo $settings; ?>,
+                               quicktags: {
+                                       buttons: 'strong,em,link,ul,ol,li,code'
+                               }
+                       };
+               };
+
+               var tinyMCEPreInit = {
+                       baseURL: "<?php echo $baseurl; ?>",
+                       suffix: "<?php echo $suffix; ?>",
+                       mceInit: {},
+                       qtInit: {},
+                       load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
+               };
+               </script>
+               <?php
+
+               self::print_tinymce_scripts();
+
+               /**
+                * Fires when the editor scripts are loaded for later initialization,
+                * after all scripts and settings are printed.
+                *
+                * @since 4.8.0
+                */
+               do_action( 'print_default_editor_scripts' );
+
+               self::wp_link_dialog();
+       }
+
+       public static function get_mce_locale() {
+               if ( empty( self::$mce_locale ) ) {
+                       $mce_locale = get_user_locale();
+                       self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1
+               }
+
+               return self::$mce_locale;
+       }
+
+       public static function get_baseurl() {
+               if ( empty( self::$baseurl ) ) {
+                       self::$baseurl = includes_url( 'js/tinymce' );
+               }
+
+               return self::$baseurl;
+       }
+
+       /**
+        * Returns the default TinyMCE settings.
+        * Doesn't include plugins, buttons, editor selector.
+        *
+        * @return array
+        */
+       private static function default_settings() {
+               global $tinymce_version;
+
+               $shortcut_labels = array();
+
+               foreach ( self::get_translation() as $name => $value ) {
+                       if ( is_array( $value ) ) {
+                               $shortcut_labels[$name] = $value[1];
+                       }
+               }
+
+               $settings = array(
+                       'theme' => 'modern',
+                       'skin' => 'lightgray',
+                       'language' => self::get_mce_locale(),
+                       'formats' => '{' .
+                               'alignleft: [' .
+                                       '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' .
+                                       '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' .
+                               '],' .
+                               'aligncenter: [' .
+                                       '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' .
+                                       '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' .
+                               '],' .
+                               'alignright: [' .
+                                       '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' .
+                                       '{selector: "img,table,dl.wp-caption", classes: "alignright"}' .
+                               '],' .
+                               'strikethrough: {inline: "del"}' .
+                       '}',
+                       'relative_urls' => false,
+                       'remove_script_host' => false,
+                       'convert_urls' => false,
+                       'browser_spellcheck' => true,
+                       'fix_list_elements' => true,
+                       'entities' => '38,amp,60,lt,62,gt',
+                       'entity_encoding' => 'raw',
+                       'keep_styles' => false,
+                       'cache_suffix' => 'wp-mce-' . $tinymce_version,
+                       'resize' => 'vertical',
+                       'menubar' => false,
+
+                       // Limit the preview styles in the menu/toolbar
+                       'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',
+
+                       'end_container_on_empty_block' => true,
+                       'wpeditimage_html5_captions' => true,
+                       'wp_lang_attr' => get_bloginfo( 'language' ),
+                       'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ),
+               );
+
+               $suffix = SCRIPT_DEBUG ? '' : '.min';
+               $version = 'ver=' . get_bloginfo( 'version' );
+
+               // Default stylesheets
+               $settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' .
+                       includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" );
+
+               return $settings;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         private static function get_translation() {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( empty( self::$translation ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        self::$translation = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1028,11 +1173,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        /* translators: word count */
</span><span class="cx" style="display: block; padding: 0 10px">                        'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . __( 'If you&#8217;re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ),
-                       'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => __( 'Rich Text Area. Press Alt-Shift-H for help.' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' =>
+                               __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" .
+                               __( 'If you&#8217;re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ),
+                       'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' =>
+                               __( 'Rich Text Area. Press Alt-Shift-H for help.' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'You have unsaved changes are you sure you want to navigate away?' => __( 'The changes you made will be lost if you navigate away from this page.' ),
-                       'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser&#8217;s edit menu instead.' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'You have unsaved changes are you sure you want to navigate away?' =>
+                               __( 'The changes you made will be lost if you navigate away from this page.' ),
+                       'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' =>
+                               __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser&#8217;s edit menu instead.' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // TinyMCE menus
</span><span class="cx" style="display: block; padding: 0 10px">                        'Insert' => _x( 'Insert', 'TinyMCE menu' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1055,6 +1205,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog
</span><span class="cx" style="display: block; padding: 0 10px">                        'Apply'  => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog
</span><span class="cx" style="display: block; padding: 0 10px">                        'Link options'  => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'Visual' => __( 'Visual' ), // Editor switch tab label
+                       'Text' => __( 'Text' ), // Editor switch tab label
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Shortcuts help modal
</span><span class="cx" style="display: block; padding: 0 10px">                        'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1098,8 +1250,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n().
-        * Can be used directly (_WP_Editors::wp_mce_translation()) by passing the same locale as set in the TinyMCE init object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(),
+        * or as JS snippet that should run after tinymce.js is loaded.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @static
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $mce_locale The locale used for the editor.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1108,11 +1260,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function wp_mce_translation( $mce_locale = '', $json_only = false ) {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! $mce_locale ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $mce_locale = self::$mce_locale;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $mce_locale = self::get_mce_locale();
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $mce_translation = self::get_translation();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">                 foreach ( $mce_translation as $name => $value ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( is_array( $value ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $mce_translation[$name] = $value[0];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1150,55 +1302,79 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return wp_json_encode( $mce_translation );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $baseurl = self::$baseurl ? self::$baseurl : includes_url( 'js/tinymce' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $baseurl = self::get_baseurl();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" .
</span><span class="cx" style="display: block; padding: 0 10px">                        "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n";
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Print (output) the main TinyMCE scripts.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 4.8
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @static
</span><span class="cx" style="display: block; padding: 0 10px">         * @global string $tinymce_version
</span><span class="cx" style="display: block; padding: 0 10px">         * @global bool   $concatenate_scripts
</span><span class="cx" style="display: block; padding: 0 10px">         * @global bool   $compress_scripts
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public static function editor_js() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function print_tinymce_scripts() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 global $tinymce_version, $concatenate_scripts, $compress_scripts;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /**
-                * Filters "tiny_mce_version" is deprecated
-                *
-                * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
-                * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
-                * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
-                */
-               $version = 'ver=' . $tinymce_version;
-               $tmce_on = !empty(self::$mce_settings);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( self::$tinymce_scripts_printed ) {
+                       return;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! isset($concatenate_scripts) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         self::$tinymce_scripts_printed = true;
+
+               if ( ! isset( $concatenate_scripts ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         script_concat_settings();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $version = 'ver=' . $tinymce_version;
+               $baseurl = self::get_baseurl();
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING'])
</span><span class="cx" style="display: block; padding: 0 10px">                        && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)
+               $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min';
+
+               if ( $compressed ) {
+                       echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;$version'></script>\n";
+               } else {
+                       echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n";
+                       echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n";
+               }
+
+               echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n";
+       }
+
+       /**
+        * Print (output) the TinyMCE configuration and initialization scripts.
+        *
+        * @static
+        */
+       public static function editor_js() {
+               $tmce_on = ! empty( self::$mce_settings );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $mceInit = $qtInit = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( $tmce_on ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        foreach ( self::$mce_settings as $editor_id => $init ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $options = self::_parse_init( $init );
</span><span class="cx" style="display: block; padding: 0 10px">                                $mceInit .= "'$editor_id':{$options},";
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $mceInit = '{' . trim($mceInit, ',') . '}';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $mceInit = '{' . trim( $mceInit, ',' ) . '}';
</ins><span class="cx" style="display: block; padding: 0 10px">                 } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $mceInit = '{}';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( !empty(self::$qt_settings) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! empty( self::$qt_settings ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         foreach ( self::$qt_settings as $editor_id => $init ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $options = self::_parse_init( $init );
</span><span class="cx" style="display: block; padding: 0 10px">                                $qtInit .= "'$editor_id':{$options},";
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $qtInit = '{' . trim($qtInit, ',') . '}';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $qtInit = '{' . trim( $qtInit, ',' ) . '}';
</ins><span class="cx" style="display: block; padding: 0 10px">                 } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $qtInit = '{}';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1210,6 +1386,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $suffix = SCRIPT_DEBUG ? '' : '.min';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $baseurl = self::get_baseurl();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Fires immediately before the TinyMCE settings are printed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1223,7 +1400,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                <script type="text/javascript">
</span><span class="cx" style="display: block; padding: 0 10px">                tinyMCEPreInit = {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        baseURL: "<?php echo self::$baseurl; ?>",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 baseURL: "<?php echo $baseurl; ?>",
</ins><span class="cx" style="display: block; padding: 0 10px">                         suffix: "<?php echo $suffix; ?>",
</span><span class="cx" style="display: block; padding: 0 10px">                        <?php
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1240,20 +1417,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                </script>
</span><span class="cx" style="display: block; padding: 0 10px">                <?php
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $baseurl = self::$baseurl;
-               // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)
-               $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min';
-
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( $tmce_on ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( $compressed ) {
-                               echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;$version'></script>\n";
-                       } else {
-                               echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n";
-                               echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n";
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::print_tinymce_scripts();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n";
-
</del><span class="cx" style="display: block; padding: 0 10px">                         if ( self::$ext_plugins ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                // Load the old-format English strings to prevent unsightly labels in old style popups
</span><span class="cx" style="display: block; padding: 0 10px">                                echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1434,6 +1600,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @static
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function wp_link_dialog() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Run once
+               if ( self::$link_dialog_printed ) {
+                       return;
+               }
+
+               self::$link_dialog_printed = true;
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // display: none is required here, see #WP27605
</span><span class="cx" style="display: block; padding: 0 10px">                ?>
</span><span class="cx" style="display: block; padding: 0 10px">                <div id="wp-link-backdrop" style="display: none"></div>
</span></span></pre></div>
<a id="trunksrcwpincludescsseditorcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/css/editor.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/css/editor.css      2017-04-18 17:05:28 UTC (rev 40475)
+++ trunk/src/wp-includes/css/editor.css        2017-04-19 02:37:29 UTC (rev 40476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -608,16 +608,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /* Menubar */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.mce-menubar {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div.mce-menubar {
</ins><span class="cx" style="display: block; padding: 0 10px">         border-color: #e5e5e5;
</span><span class="cx" style="display: block; padding: 0 10px">        background: #fff;
</span><span class="cx" style="display: block; padding: 0 10px">        border-width: 0px 0px 1px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.mce-menubar .mce-menubtn {
-       margin: 2px;
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> .mce-menubar .mce-menubtn:hover,
</span><span class="cx" style="display: block; padding: 0 10px"> .mce-menubar .mce-menubtn.mce-active,
</span><span class="cx" style="display: block; padding: 0 10px"> .mce-menubar .mce-menubtn:focus {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1091,6 +1087,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> .wp-editor-container {
</span><span class="cx" style="display: block; padding: 0 10px">        clear: both;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        border: 1px solid #e5e5e5;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> .wp-editor-area {
</span></span></pre></div>
<a id="trunksrcwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/general-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/general-template.php        2017-04-18 17:05:28 UTC (rev 40475)
+++ trunk/src/wp-includes/general-template.php  2017-04-19 02:37:29 UTC (rev 40476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3057,6 +3057,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Outputs the editor scripts, stylesheets, and default settings.
+ *
+ * The editor can be initialized when needed after page load.
+ * See wp.editor.initialize() in wp-admin/js/editor.js for initialization options.
+ *
+ * @uses _WP_Editors
+ * @since 4.8.0
+ */
+function wp_enqueue_editor() {
+       if ( ! class_exists( '_WP_Editors', false ) ) {
+               require( ABSPATH . WPINC . '/class-wp-editor.php' );
+       }
+
+       _WP_Editors::enqueue_default_editor();
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Retrieves the contents of the search WordPress query variable.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * The search query string is passed through esc_attr() to ensure that it is safe
</span></span></pre>
</div>
</div>

</body>
</html>