<!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>[32899] trunk/src: Update the TinyMCE initialization:</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/32899">32899</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/32899","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>2015-06-21 22:00:42 +0000 (Sun, 21 Jun 2015)</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'>Update the TinyMCE initialization:
- Replace `wp_htmledit_pre()` and `wp_richedit_pre()` with `format_for_editor()`.
- Replace the `'htmledit_pre'` and `'richedit_pre'` filters with `'format_for_editor'`.
- Do not run the post content through `wpautop()` in PHP when the visual editor is default. Run the textarea content through the JS wpautop on initializing TinyMCE.
- Simplify both editors initialization.
- Improve setting of `wpActiveEditor` in Quicktags.
- Improve editor.js, use `tinymce.$` when possible.
See <a href="https://core.trac.wordpress.org/ticket/32425">#32425</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsseditcss">trunk/src/wp-admin/css/edit.css</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="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesdeprecatedphp">trunk/src/wp-includes/deprecated.php</a></li>
<li><a href="#trunksrcwpincludesformattingphp">trunk/src/wp-includes/formatting.php</a></li>
<li><a href="#trunksrcwpincludesjsquicktagsjs">trunk/src/wp-includes/js/quicktags.js</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswordpresspluginjs">trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsseditcss"></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/css/edit.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/edit.css   2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-admin/css/edit.css     2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -425,6 +425,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">        visibility: visible !important;
</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">+.mce-fullscreen #wp-content-wrap .mce-tinymce .mce-wp-dfw {
+       display: none;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .post-php.mce-fullscreen #wpadminbar,
</span><span class="cx" style="display: block; padding: 0 10px"> .mce-fullscreen #wp-content-wrap .mce-wp-dfw {
</span><span class="cx" style="display: block; padding: 0 10px">        display: none;
</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   2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-admin/js/editor.js     2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,38 +1,29 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* global tinymce, tinyMCEPreInit, QTags, setUserSetting */
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-window.switchEditors = {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+( function( $ ) {
+       function SwitchEditors() {
+               var tinymce, $$,
+                       exports = {};
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        switchto: function( el ) {
-               var aid = el.id,
-                       l = aid.length,
-                       id = aid.substr( 0, l - 5 ),
-                       mode = aid.substr( l - 4 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         function init() {
+                       if ( ! tinymce && window.tinymce ) {
+                               tinymce = window.tinymce;
+                               $$ = tinymce.$;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                this.go( id, mode );
-       },
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $$( document ).on( 'click', function( event ) {
+                                       var id, mode,
+                                               target = $$( event.target );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // mode can be 'html', 'tmce', or 'toggle'; 'html' is used for the 'Text' editor tab.
-       go: function( id, mode ) {
-               var t = this, ed, wrap_id, txtarea_el, iframe, editorHeight, toolbarHeight,
-                       DOM = tinymce.DOM; //DOMUtils outside the editor iframe
-
-               id = id || 'content';
-               mode = mode || 'toggle';
-
-               ed = tinymce.get( id );
-               wrap_id = 'wp-' + id + '-wrap';
-               txtarea_el = DOM.get( id );
-
-               if ( 'toggle' === mode ) {
-                       if ( ed && ! ed.isHidden() ) {
-                               mode = 'html';
-                       } else {
-                               mode = 'tmce';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 if ( target.hasClass( 'wp-switch-editor' ) ) {
+                                               id = target.attr( 'data-wp-editor-id' );
+                                               mode = target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html';
+                                               switchEditor( id, mode );
+                                       }
+                               });
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                function getToolbarHeight() {
-                       var node = DOM.select( '.mce-toolbar-grp', ed.getContainer() )[0],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         function getToolbarHeight( editor ) {
+                       var node = $$( '.mce-toolbar-grp', editor.getContainer() )[0],
</ins><span class="cx" style="display: block; padding: 0 10px">                                 height = node && node.clientHeight;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( height && height > 10 && height < 200 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,283 +33,332 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return 30;
</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 ( 'tmce' === mode || 'tinymce' === mode ) {
-                       if ( ed && ! ed.isHidden() ) {
-                               return false;
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         function switchEditor( id, mode ) {
+                       id = id || 'content';
+                       mode = mode || 'toggle';
</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 ( typeof( QTags ) !== 'undefined' ) {
-                               QTags.closeAllTags( id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 var editorHeight, toolbarHeight, iframe,
+                               editor = tinymce.get( id ),
+                               wrap = $$( '#wp-' + id + '-wrap' ),
+                               $textarea = $$( '#' + id ),
+                               textarea = $textarea[0];
+
+                       if ( 'toggle' === mode ) {
+                               if ( editor && ! editor.isHidden() ) {
+                                       mode = 'html';
+                               } else {
+                                       mode = 'tmce';
+                               }
</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">-                        editorHeight = txtarea_el ? parseInt( txtarea_el.style.height, 10 ) : 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( 'tmce' === mode || 'tinymce' === mode ) {
+                               if ( editor && ! editor.isHidden() ) {
+                                       return false;
+                               }
</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 ( tinyMCEPreInit.mceInit[ id ] && tinyMCEPreInit.mceInit[ id ].wpautop ) {
-                               txtarea_el.value = t.wpautop( txtarea_el.value );
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( typeof( window.QTags ) !== 'undefined' ) {
+                                       window.QTags.closeAllTags( id );
+                               }
</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 ( ed ) {
-                               ed.show();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         editorHeight = parseInt( textarea.style.height, 10 ) || 0;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // No point resizing the iframe in iOS
-                               if ( ! tinymce.Env.iOS && editorHeight ) {
-                                       toolbarHeight = getToolbarHeight();
-                                       editorHeight = editorHeight - toolbarHeight + 14;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( editor ) {
+                                       editor.show();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        // height cannot be under 50 or over 5000
-                                       if ( editorHeight > 50 && editorHeight < 5000 ) {
-                                               ed.theme.resizeTo( null, editorHeight );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 // No point resizing the iframe in iOS
+                                       if ( ! tinymce.Env.iOS && editorHeight ) {
+                                               toolbarHeight = getToolbarHeight( editor );
+                                               editorHeight = editorHeight - toolbarHeight + 14;
+
+                                               // height cannot be under 50 or over 5000
+                                               if ( editorHeight > 50 && editorHeight < 5000 ) {
+                                                       editor.theme.resizeTo( null, editorHeight );
+                                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                                         }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                } else {
+                                       tinymce.init( window.tinyMCEPreInit.mceInit[id] );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } else {
-                               tinymce.init( tinyMCEPreInit.mceInit[id] );
-                       }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        DOM.removeClass( wrap_id, 'html-active' );
-                       DOM.addClass( wrap_id, 'tmce-active' );
-                       DOM.setAttrib( txtarea_el, 'aria-hidden', true );
-                       setUserSetting( 'editor', 'tinymce' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         wrap.removeClass( 'html-active' ).addClass( 'tmce-active' );
+                               $textarea.attr( 'aria-hidden', true );
+                               window.setUserSetting( 'editor', 'tinymce' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                } else if ( 'html' === mode ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } else if ( 'html' === mode ) {
+                               if ( editor && editor.isHidden() ) {
+                                       return false;
+                               }
</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 ( ed && ed.isHidden() ) {
-                               return false;
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( editor ) {
+                                       if ( ! tinymce.Env.iOS ) {
+                                               iframe = editor.iframeElement;
+                                               editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0;
</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 ( ed ) {
-                               if ( ! tinymce.Env.iOS ) {
-                                       iframe = DOM.get( id + '_ifr' );
-                                       editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         if ( editorHeight ) {
+                                                       toolbarHeight = getToolbarHeight( editor );
+                                                       editorHeight = editorHeight + toolbarHeight - 14;
</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 ( editorHeight ) {
-                                               toolbarHeight = getToolbarHeight();
-                                               editorHeight = editorHeight + toolbarHeight - 14;
-
-                                               // height cannot be under 50 or over 5000
-                                               if ( editorHeight > 50 && editorHeight < 5000 ) {
-                                                       txtarea_el.style.height = editorHeight + 'px';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                                 // height cannot be under 50 or over 5000
+                                                       if ( editorHeight > 50 && editorHeight < 5000 ) {
+                                                               textarea.style.height = editorHeight + 'px';
+                                                       }
</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">-                                }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                ed.hide();
-                       } else {
-                               // The TinyMCE instance doesn't exist, run the content through 'pre_wpautop()' and show the textarea
-                               if ( tinyMCEPreInit.mceInit[ id ] && tinyMCEPreInit.mceInit[ id ].wpautop ) {
-                                       txtarea_el.value = t.pre_wpautop( txtarea_el.value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 editor.hide();
+                               } else {
+                                       // The TinyMCE instance doesn't exist, show the textarea
+                                       $textarea.css({ 'display': '', 'visibility': '' });
</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">-                                DOM.setStyles( txtarea_el, {'display': '', 'visibility': ''} );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         wrap.removeClass( 'tmce-active' ).addClass( 'html-active' );
+                               $textarea.attr( 'aria-hidden', false );
+                               window.setUserSetting( 'editor', 'html' );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-                       DOM.removeClass( wrap_id, 'tmce-active' );
-                       DOM.addClass( wrap_id, 'html-active' );
-                       DOM.setAttrib( txtarea_el, 'aria-hidden', false );
-                       setUserSetting( 'editor', 'html' );
</del><span class="cx" style="display: block; padding: 0 10px">                 }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return false;
-       },
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        _wp_Nop: function( content ) {
-               var blocklist1, blocklist2,
-                       preserve_linebreaks = false,
-                       preserve_br = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Replace paragraphs with double line breaks
+               function removep( html ) {
+                       var blocklist = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset',
+                               blocklist1 = blocklist + '|div|p',
+                               blocklist2 = blocklist + '|pre',
+                               preserve_linebreaks = false,
+                               preserve_br = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Protect pre|script tags
-               if ( content.indexOf( '<pre' ) !== -1 || content.indexOf( '<script' ) !== -1 ) {
-                       preserve_linebreaks = true;
-                       content = content.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) {
-                               a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>' );
-                               a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>' );
-                               return a.replace( /\r?\n/g, '<wp-line-break>' );
-                       });
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( ! html ) {
+                               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">-                // keep <br> tags inside captions and remove line breaks
-               if ( content.indexOf( '[caption' ) !== -1 ) {
-                       preserve_br = true;
-                       content = content.replace( /\[caption[\s\S]+?\[\/caption\]/g, function( a ) {
-                               return a.replace( /<br([^>]*)>/g, '<wp-temp-br$1>' ).replace( /[\r\n\t]+/, '' );
-                       });
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Protect pre|script tags
+                       if ( html.indexOf( '<pre' ) !== -1 || html.indexOf( '<script' ) !== -1 ) {
+                               preserve_linebreaks = true;
+                               html = html.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) {
+                                       a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>' );
+                                       a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>' );
+                                       return a.replace( /\r?\n/g, '<wp-line-break>' );
+                               });
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Pretty it up for the source editor
-               blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset';
-               content = content.replace( new RegExp( '\\s*</(' + blocklist1 + ')>\\s*', 'g' ), '</$1>\n' );
-               content = content.replace( new RegExp( '\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g' ), '\n<$1>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // keep <br> tags inside captions and remove line breaks
+                       if ( html.indexOf( '[caption' ) !== -1 ) {
+                               preserve_br = true;
+                               html = html.replace( /\[caption[\s\S]+?\[\/caption\]/g, function( a ) {
+                                       return a.replace( /<br([^>]*)>/g, '<wp-temp-br$1>' ).replace( /[\r\n\t]+/, '' );
+                               });
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Mark </p> if it has any attributes.
-               content = content.replace( /(<p [^>]+>.*?)<\/p>/g, '$1</p#>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Pretty it up for the source editor
+                       html = html.replace( new RegExp( '\\s*</(' + blocklist1 + ')>\\s*', 'g' ), '</$1>\n' );
+                       html = html.replace( new RegExp( '\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g' ), '\n<$1>' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Separate <div> containing <p>
-               content = content.replace( /<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Mark </p> if it has any attributes.
+                       html = html.replace( /(<p [^>]+>.*?)<\/p>/g, '$1</p#>' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Remove <p> and <br />
-               content = content.replace( /\s*<p>/gi, '' );
-               content = content.replace( /\s*<\/p>\s*/gi, '\n\n' );
-               content = content.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
-               content = content.replace( /\s*<br ?\/?>\s*/gi, '\n' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Separate <div> containing <p>
+                       html = html.replace( /<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Fix some block element newline issues
-               content = content.replace( /\s*<div/g, '\n<div' );
-               content = content.replace( /<\/div>\s*/g, '</div>\n' );
-               content = content.replace( /\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n' );
-               content = content.replace( /caption\]\n\n+\[caption/g, 'caption]\n\n[caption' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Remove <p> and <br />
+                       html = html.replace( /\s*<p>/gi, '' );
+                       html = html.replace( /\s*<\/p>\s*/gi, '\n\n' );
+                       html = html.replace( /\n[\s\u00a0]+\n/g, '\n\n' );
+                       html = html.replace( /\s*<br ?\/?>\s*/gi, '\n' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                blocklist2 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset';
-               content = content.replace( new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g' ), '\n<$1>' );
-               content = content.replace( new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g' ), '</$1>\n' );
-               content = content.replace( /<li([^>]*)>/g, '\t<li$1>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Fix some block element newline issues
+                       html = html.replace( /\s*<div/g, '\n<div' );
+                       html = html.replace( /<\/div>\s*/g, '</div>\n' );
+                       html = html.replace( /\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n' );
+                       html = html.replace( /caption\]\n\n+\[caption/g, 'caption]\n\n[caption' );
</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 ( content.indexOf( '<option' ) !== -1 ) {
-                       content = content.replace( /\s*<option/g, '\n<option' );
-                       content = content.replace( /\s*<\/select>/g, '\n</select>' );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 html = html.replace( new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g' ), '\n<$1>' );
+                       html = html.replace( new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g' ), '</$1>\n' );
+                       html = html.replace( /<li([^>]*)>/g, '\t<li$1>' );
</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 ( content.indexOf( '<hr' ) !== -1 ) {
-                       content = content.replace( /\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n' );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( html.indexOf( '<option' ) !== -1 ) {
+                               html = html.replace( /\s*<option/g, '\n<option' );
+                               html = html.replace( /\s*<\/select>/g, '\n</select>' );
+                       }
</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 ( content.indexOf( '<object' ) !== -1 ) {
-                       content = content.replace( /<object[\s\S]+?<\/object>/g, function( a ) {
-                               return a.replace( /[\r\n]+/g, '' );
-                       });
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( html.indexOf( '<hr' ) !== -1 ) {
+                               html = html.replace( /\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n' );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Unmark special paragraph closing tags
-               content = content.replace( /<\/p#>/g, '</p>\n' );
-               content = content.replace( /\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( html.indexOf( '<object' ) !== -1 ) {
+                               html = html.replace( /<object[\s\S]+?<\/object>/g, function( a ) {
+                                       return a.replace( /[\r\n]+/g, '' );
+                               });
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Trim whitespace
-               content = content.replace( /^\s+/, '' );
-               content = content.replace( /[\s\u00a0]+$/, '' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Unmark special paragraph closing tags
+                       html = html.replace( /<\/p#>/g, '</p>\n' );
+                       html = html.replace( /\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // put back the line breaks in pre|script
-               if ( preserve_linebreaks ) {
-                       content = content.replace( /<wp-line-break>/g, '\n' );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Trim whitespace
+                       html = html.replace( /^\s+/, '' );
+                       html = html.replace( /[\s\u00a0]+$/, '' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // and the <br> tags in captions
-               if ( preserve_br ) {
-                       content = content.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // put back the line breaks in pre|script
+                       if ( preserve_linebreaks ) {
+                               html = html.replace( /<wp-line-break>/g, '\n' );
+                       }
+
+                       // and the <br> tags in captions
+                       if ( preserve_br ) {
+                               html = html.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' );
+                       }
+
+                       return html;
</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">-                return content;
-       },
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Similar to `wpautop()` in formatting.php
+               function autop( text ) {
+                       var preserve_linebreaks = false,
+                               preserve_br = false,
+                               blocklist = 'table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre' +
+                                       '|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section' +
+                                       '|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        _wp_Autop: function(pee) {
-               var preserve_linebreaks = false,
-                       preserve_br = false,
-                       blocklist = 'table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre' +
-                               '|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section' +
-                               '|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Normalize line breaks
+                       text = text.replace( /\r\n|\r/g, '\n' );
</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 ( pee.indexOf( '<object' ) !== -1 ) {
-                       pee = pee.replace( /<object[\s\S]+?<\/object>/g, function( a ) {
-                               return a.replace( /[\r\n]+/g, '' );
-                       });
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( text.indexOf( '\n' ) === -1 ) {
+                               return text;
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                pee = pee.replace( /<[^<>]+>/g, function( a ){
-                       return a.replace( /[\r\n]+/g, ' ' );
-               });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( text.indexOf( '<object' ) !== -1 ) {
+                               text = text.replace( /<object[\s\S]+?<\/object>/g, function( a ) {
+                                       return a.replace( /\n+/g, '' );
+                               });
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Protect pre|script tags
-               if ( pee.indexOf( '<pre' ) !== -1 || pee.indexOf( '<script' ) !== -1 ) {
-                       preserve_linebreaks = true;
-                       pee = pee.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) {
-                               return a.replace( /(\r\n|\n)/g, '<wp-line-break>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 text = text.replace( /<[^<>]+>/g, function( a ) {
+                               return a.replace( /[\n\t ]+/g, ' ' );
</ins><span class="cx" style="display: block; padding: 0 10px">                         });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // keep <br> tags inside captions and convert line breaks
-               if ( pee.indexOf( '[caption' ) !== -1 ) {
-                       preserve_br = true;
-                       pee = pee.replace( /\[caption[\s\S]+?\[\/caption\]/g, function( a ) {
-                               // keep existing <br>
-                               a = a.replace( /<br([^>]*)>/g, '<wp-temp-br$1>' );
-                               // no line breaks inside HTML tags
-                               a = a.replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( b ) {
-                                       return b.replace( /[\r\n\t]+/, ' ' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Protect pre|script tags
+                       if ( text.indexOf( '<pre' ) !== -1 || text.indexOf( '<script' ) !== -1 ) {
+                               preserve_linebreaks = true;
+                               text = text.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) {
+                                       return a.replace( /\n/g, '<wp-line-break>' );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // convert remaining line breaks to <br>
-                               return a.replace( /\s*\n\s*/g, '<wp-temp-br />' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 }
+
+                       // keep <br> tags inside captions and convert line breaks
+                       if ( text.indexOf( '[caption' ) !== -1 ) {
+                               preserve_br = true;
+                               text = text.replace( /\[caption[\s\S]+?\[\/caption\]/g, function( a ) {
+                                       // keep existing <br>
+                                       a = a.replace( /<br([^>]*)>/g, '<wp-temp-br$1>' );
+                                       // no line breaks inside HTML tags
+                                       a = a.replace( /<[^<>]+>/g, function( b ) {
+                                               return b.replace( /[\n\t ]+/, ' ' );
+                                       });
+                                       // convert remaining line breaks to <br>
+                                       return a.replace( /\s*\n\s*/g, '<wp-temp-br />' );
+                               });
+                       }
+
+                       text = text + '\n\n';
+                       text = text.replace( /<br \/>\s*<br \/>/gi, '\n\n' );
+                       text = text.replace( new RegExp( '(<(?:' + blocklist + ')(?: [^>]*)?>)', 'gi' ), '\n$1' );
+                       text = text.replace( new RegExp( '(</(?:' + blocklist + ')>)', 'gi' ), '$1\n\n' );
+                       text = text.replace( /<hr( [^>]*)?>/gi, '<hr$1>\n\n' ); // hr is self closing block element
+                       text = text.replace( /\s*<option/gi, '<option' ); // No <p> or <br> around <option>
+                       text = text.replace( /<\/option>\s*/gi, '</option>' );
+                       text = text.replace( /\n\s*\n+/g, '\n\n' );
+                       text = text.replace( /([\s\S]+?)\n\n/g, '<p>$1</p>\n' );
+                       text = text.replace( /<p>\s*?<\/p>/gi, '');
+                       text = text.replace( new RegExp( '<p>\\s*(</?(?:' + blocklist + ')(?: [^>]*)?>)\\s*</p>', 'gi' ), '$1' );
+                       text = text.replace( /<p>(<li.+?)<\/p>/gi, '$1');
+                       text = text.replace( /<p>\s*<blockquote([^>]*)>/gi, '<blockquote$1><p>');
+                       text = text.replace( /<\/blockquote>\s*<\/p>/gi, '</p></blockquote>');
+                       text = text.replace( new RegExp( '<p>\\s*(</?(?:' + blocklist + ')(?: [^>]*)?>)', 'gi' ), '$1' );
+                       text = text.replace( new RegExp( '(</?(?:' + blocklist + ')(?: [^>]*)?>)\\s*</p>', 'gi' ), '$1' );
+                       text = text.replace( /\s*\n/gi, '<br />\n');
+                       text = text.replace( new RegExp( '(</?(?:' + blocklist + ')[^>]*>)\\s*<br />', 'gi' ), '$1' );
+                       text = text.replace( /<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi, '$1' );
+                       text = text.replace( /(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi, '[caption$1[/caption]' );
+
+                       text = text.replace( /(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g, function( a, b, c ) {
+                               if ( c.match( /<p( [^>]*)?>/ ) ) {
+                                       return a;
+                               }
+
+                               return b + '<p>' + c + '</p>';
</ins><span class="cx" style="display: block; padding: 0 10px">                         });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                pee = pee + '\n\n';
-               pee = pee.replace( /<br \/>\s*<br \/>/gi, '\n\n' );
-               pee = pee.replace( new RegExp( '(<(?:' + blocklist + ')(?: [^>]*)?>)', 'gi' ), '\n$1' );
-               pee = pee.replace( new RegExp( '(</(?:' + blocklist + ')>)', 'gi' ), '$1\n\n' );
-               pee = pee.replace( /<hr( [^>]*)?>/gi, '<hr$1>\n\n' ); // hr is self closing block element
-               pee = pee.replace( /\s*<option/gi, '<option' ); // No <p> or <br> around <option>
-               pee = pee.replace( /<\/option>\s*/gi, '</option>' );
-               pee = pee.replace( /\r\n|\r/g, '\n' );
-               pee = pee.replace( /\n\s*\n+/g, '\n\n' );
-               pee = pee.replace( /([\s\S]+?)\n\n/g, '<p>$1</p>\n' );
-               pee = pee.replace( /<p>\s*?<\/p>/gi, '');
-               pee = pee.replace( new RegExp( '<p>\\s*(</?(?:' + blocklist + ')(?: [^>]*)?>)\\s*</p>', 'gi' ), '$1' );
-               pee = pee.replace( /<p>(<li.+?)<\/p>/gi, '$1');
-               pee = pee.replace( /<p>\s*<blockquote([^>]*)>/gi, '<blockquote$1><p>');
-               pee = pee.replace( /<\/blockquote>\s*<\/p>/gi, '</p></blockquote>');
-               pee = pee.replace( new RegExp( '<p>\\s*(</?(?:' + blocklist + ')(?: [^>]*)?>)', 'gi' ), '$1' );
-               pee = pee.replace( new RegExp( '(</?(?:' + blocklist + ')(?: [^>]*)?>)\\s*</p>', 'gi' ), '$1' );
-               pee = pee.replace( /\s*\n/gi, '<br />\n');
-               pee = pee.replace( new RegExp( '(</?(?:' + blocklist + ')[^>]*>)\\s*<br />', 'gi' ), '$1' );
-               pee = pee.replace( /<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi, '$1' );
-               pee = pee.replace( /(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi, '[caption$1[/caption]' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // put back the line breaks in pre|script
+                       if ( preserve_linebreaks ) {
+                               text = text.replace( /<wp-line-break>/g, '\n' );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                pee = pee.replace( /(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g, function( a, b, c ) {
-                       if ( c.match( /<p( [^>]*)?>/ ) ) {
-                               return a;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( preserve_br ) {
+                               text = text.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' );
</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">-                        return b + '<p>' + c + '</p>';
-               });
-
-               // put back the line breaks in pre|script
-               if ( preserve_linebreaks ) {
-                       pee = pee.replace( /<wp-line-break>/g, '\n' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 return text;
</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">-                if ( preserve_br ) {
-                       pee = pee.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Add old events
+               function pre_wpautop( html ) {
+                       var obj = { o: exports, data: html, unfiltered: html };
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return pee;
-       },
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( $ ) {
+                               $( 'body' ).trigger( 'beforePreWpautop', [ obj ] );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        pre_wpautop: function( content ) {
-               var t = this, o = { o: t, data: content, unfiltered: content },
-                       q = typeof( jQuery ) !== 'undefined';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 obj.data = removep( obj.data );
</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 ( q ) {
-                       jQuery( 'body' ).trigger( 'beforePreWpautop', [ o ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( $ ) {
+                               $( 'body' ).trigger( 'afterPreWpautop', [ obj ] );
+                       }
+
+                       return obj.data;
</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">-                o.data = t._wp_Nop( o.data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         function wpautop( text ) {
+                       var obj = { o: exports, data: text, unfiltered: text };
</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 ( q ) {
-                       jQuery('body').trigger('afterPreWpautop', [ o ] );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( $ ) {
+                               $( 'body' ).trigger( 'beforeWpautop', [ obj ] );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return o.data;
-       },
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 obj.data = autop( obj.data );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wpautop: function( pee ) {
-               var t = this, o = { o: t, data: pee, unfiltered: pee },
-                       q = typeof( jQuery ) !== 'undefined';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( $ ) {
+                               $( 'body' ).trigger( 'afterWpautop', [ obj ] );
+                       }
</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 ( q ) {
-                       jQuery( 'body' ).trigger('beforeWpautop', [ o ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 return obj.data;
</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">-                o.data = t._wp_Autop( o.data );
-
-               if ( q ) {
-                       jQuery( 'body' ).trigger('afterWpautop', [ o ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( $ ) {
+                       $( document ).ready( init );
+               } else if ( document.addEventListener ) {
+                       document.addEventListener( 'DOMContentLoaded', init, false );
+                       window.addEventListener( 'load', init, false );
+               } else if ( window.attachEvent ) {
+                       window.attachEvent( 'onload', init );
+                       document.attachEvent( 'onreadystatechange', function() {
+                               if ( 'complete' === document.readyState ) {
+                                       init();
+                               }
+                       } );
</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">-                return o.data;
</del><ins style="background-color: #dfd; 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;
+
+               exports = {
+                       go: switchEditor,
+                       wpautop: wpautop,
+                       pre_wpautop: pre_wpautop,
+                       _wp_Autop: autop,
+                       _wp_Nop: removep
+               };
+
+               return exports;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</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">+
+       window.switchEditors = new SwitchEditors();
+}( window.jQuery ));
</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 2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/class-wp-editor.php   2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,71 +143,74 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $settings See the _parse_settings() method for description.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function editor( $content, $editor_id, $settings = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 $set = self::parse_settings( $editor_id, $settings );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $switch_class = 'html-active';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $default_editor = 'html';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $toolbar = $buttons = $autocomplete = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $editor_id_attr = esc_attr( $editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $set['drag_drop_upload'] ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        self::$drag_drop_upload = true;
</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( $set['editor_height'] ) )
-                       $height = ' style="height: ' . $set['editor_height'] . 'px"';
-               else
-                       $height = ' rows="' . $set['textarea_rows'] . '"';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! empty( $set['editor_height'] ) ) {
+                       $height = ' style="height: ' . (int) $set['editor_height'] . 'px"';
+               } else {
+                       $height = ' rows="' . (int) $set['textarea_rows'] . '"';
+               }
</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 ( !current_user_can( 'upload_files' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! current_user_can( 'upload_files' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $set['media_buttons'] = false;
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! self::$this_quicktags && self::$this_tinymce ) {
-                       $switch_class = 'tmce-active';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( self::$this_tinymce ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $autocomplete = ' autocomplete="off"';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                } elseif ( self::$this_quicktags && self::$this_tinymce ) {
-                       $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor();
-                       $autocomplete = ' autocomplete="off"';
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // 'html' is used for the "Text" editor tab.
-                       if ( 'html' === $default_editor ) {
-                               add_filter('the_editor_content', 'wp_htmledit_pre');
-                               $switch_class = 'html-active';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( self::$this_quicktags ) {
+                               $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor();
+                               // 'html' is used for the "Text" editor tab.
+                               if ( 'html' !== $default_editor ) {
+                                       $default_editor = 'tinymce';
+                               }
+
+                               $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' .
+                                       ' data-wp-editor-id="' . $editor_id_attr . '">' . __('Visual') . "</button>\n";
+                               $buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' .
+                                       ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">                         } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                add_filter('the_editor_content', 'wp_richedit_pre');
-                               $switch_class = 'tmce-active';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $default_editor = 'tinymce';
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-                       $buttons .= '<button type="button" id="' . $editor_id . '-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">' . __('Visual') . "</button>\n";
-                       $buttons .= '<button type="button" id="' . $editor_id . '-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n";
</del><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">+                $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $set['_content_editor_dfw'] ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $wrap_class .= ' has-dfw';
</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">-                echo '<div id="wp-' . $editor_id . '-wrap" class="' . $wrap_class . '">';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( self::$editor_buttons_css ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        wp_print_styles('editor-buttons');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_print_styles( 'editor-buttons' );
</ins><span class="cx" style="display: block; padding: 0 10px">                         self::$editor_buttons_css = false;
</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($set['editor_css']) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! empty( $set['editor_css'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         echo $set['editor_css'] . "\n";
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( !empty($buttons) || $set['media_buttons'] ) {
-                       echo '<div id="wp-' . $editor_id . '-editor-tools" class="wp-editor-tools hide-if-no-js">';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! empty( $buttons ) || $set['media_buttons'] ) {
+                       echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $set['media_buttons'] ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                self::$has_medialib = true;
</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 ( !function_exists('media_buttons') )
-                                       include(ABSPATH . 'wp-admin/includes/media.php');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( ! function_exists( 'media_buttons' ) )
+                                       include( ABSPATH . 'wp-admin/includes/media.php' );
</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 '<div id="wp-' . $editor_id . '-media-buttons" class="wp-media-buttons">';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">';
</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 after the default media button(s) are displayed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -224,6 +227,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        echo "</div>\n";
</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">+                $quicktags_toolbar = '';
+
+               if ( self::$this_quicktags ) {
+                       if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && $GLOBALS['current_screen']->base === 'post' ) {
+                               $toolbar_id = 'ed_toolbar';
+                       } else {
+                               $toolbar_id = 'qt_' . $editor_id_attr . '_toolbar';
+                       }
+
+                       $quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar"></div>';
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Filter the HTML markup output that displays the editor.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -231,9 +246,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param string $output Editor's HTML markup.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container">' .
-                       '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . $set['textarea_name'] . '" ' .
-                       'id="' . $editor_id . '">%s</textarea></div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' .
+                       $quicktags_toolbar .
+                       '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' .
+                       'id="' . $editor_id_attr . '">%s</textarea></div>' );
</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">                 * Filter the default editor content.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,12 +258,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param string $content Default editor 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">-                $content = apply_filters( 'the_editor_content', $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $content = apply_filters( 'the_editor_content', $content, $default_editor );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Back-compat for the `htmledit_pre` and `richedit_pre` filters
+               if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) {
+                       // TODO: needs _deprecated_filter(), use _deprecated_function() as substitute for now
+                       _deprecated_function( 'add_filter( htmledit_pre )', '4.3.0', 'add_filter( format_for_editor )' );
+                       $content = apply_filters( 'htmledit_pre', $content );
+               } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) {
+                       _deprecated_function( 'add_filter( richedit_pre )', '4.3.0', 'add_filter( format_for_editor )' );
+                       $content = apply_filters( 'richedit_pre', $content );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 printf( $the_editor, $content );
</span><span class="cx" style="display: block; padding: 0 10px">                echo "\n</div>\n\n";
</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::editor_settings($editor_id, $set);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         self::editor_settings( $editor_id, $set );
</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">@@ -478,21 +504,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'theme' => 'modern',
</span><span class="cx" style="display: block; padding: 0 10px">                                        'skin' => 'lightgray',
</span><span class="cx" style="display: block; padding: 0 10px">                                        'language' => self::$mce_locale,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        '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'}
-                                       }",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 '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"}' .
+                                       '}',
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'relative_urls' => false,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'remove_script_host' => false,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'convert_urls' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -650,8 +676,8 @@
</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="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( $first_run )
-                               $mceInit = array_merge( self::$first_init, $mceInit );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Merge with the first part of the init array
+                       $mceInit = array_merge( self::$first_init, $mceInit );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( is_array( $set['tinymce'] ) )
</span><span class="cx" style="display: block; padding: 0 10px">                                $mceInit = array_merge( $mceInit, $set['tinymce'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -662,7 +688,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                         * before tinyMCE.init. Setting "valid_elements", "invalid_elements"
</span><span class="cx" style="display: block; padding: 0 10px">                         * and "extended_valid_elements" can be done through this filter. Best
</span><span class="cx" style="display: block; padding: 0 10px">                         * is to use the default cleanup by not specifying valid_elements,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                         * as TinyMCE contains full set of XHTML 1.0.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                  * as TinyMCE checks against the full set of HTML 5.0 elements and attributes.
</ins><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="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1182,55 +1208,30 @@
</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">                ( function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        var init, edId, qtId, firstInit, wrapper;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 var init, id, $wrap;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( typeof tinymce !== 'undefined' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                for ( edId in tinyMCEPreInit.mceInit ) {
-                                       if ( firstInit ) {
-                                               init = tinyMCEPreInit.mceInit[edId] = tinymce.extend( {}, firstInit, tinyMCEPreInit.mceInit[edId] );
-                                       } else {
-                                               init = firstInit = tinyMCEPreInit.mceInit[edId];
-                                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         for ( id in tinyMCEPreInit.mceInit ) {
+                                       init = tinyMCEPreInit.mceInit[id];
+                                       $wrap = tinymce.$( '#wp-' + id + '-wrap' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        wrapper = tinymce.DOM.select( '#wp-' + edId + '-wrap' )[0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) {
+                                               tinymce.init( init );
</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 ( ( tinymce.DOM.hasClass( wrapper, 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( edId ) ) &&
-                                               ! init.wp_skip_init ) {
-
-                                               try {
-                                                       tinymce.init( init );
-
-                                                       if ( ! window.wpActiveEditor ) {
-                                                               window.wpActiveEditor = edId;
-                                                       }
-                                               } catch(e){}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         if ( ! window.wpActiveEditor ) {
+                                                       window.wpActiveEditor = id;
+                                               }
</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="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( typeof quicktags !== 'undefined' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                for ( qtId in tinyMCEPreInit.qtInit ) {
-                                       try {
-                                               quicktags( tinyMCEPreInit.qtInit[qtId] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         for ( id in tinyMCEPreInit.qtInit ) {
+                                       quicktags( tinyMCEPreInit.qtInit[id] );
</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 ( ! window.wpActiveEditor ) {
-                                                       window.wpActiveEditor = qtId;
-                                               }
-                                       } catch(e){};
-                               }
-                       }
-
-                       if ( typeof jQuery !== 'undefined' ) {
-                               jQuery('.wp-editor-wrap').on( 'click.wp-editor', function() {
-                                       if ( this.id ) {
-                                               window.wpActiveEditor = this.id.slice( 3, -5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 if ( ! window.wpActiveEditor ) {
+                                               window.wpActiveEditor = id;
</ins><span class="cx" style="display: block; padding: 0 10px">                                         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                });
-                       } else {
-                               for ( qtId in tinyMCEPreInit.qtInit ) {
-                                       document.getElementById( 'wp-' + qtId + '-wrap' ).onclick = function() {
-                                               window.wpActiveEditor = this.id.slice( 3, -5 );
-                                       }
</del><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></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      2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/css/editor.css        2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -286,7 +286,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .mce-path-item,
</span><span class="cx" style="display: block; padding: 0 10px"> .mce-path .mce-divider {
</span><span class="cx" style="display: block; padding: 0 10px">        font-size: 12px;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        line-height: 18px;
</del><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-toolbar .mce-btn,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1059,6 +1058,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        position: relative;
</span><span class="cx" style="display: block; padding: 0 10px">        border-bottom: 1px solid #dedede;
</span><span class="cx" style="display: block; padding: 0 10px">        background: #f5f5f5;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        min-height: 30px;
</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"> .has-dfw .quicktags-toolbar {
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></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/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/default-filters.php   2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -203,6 +203,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Prepare the content for the Visual or Text editor
+add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Actions
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_head',             '_wp_render_title_tag',            1     );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_head',             'wp_enqueue_scripts',              1     );
</span></span></pre></div>
<a id="trunksrcwpincludesdeprecatedphp"></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/deprecated.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/deprecated.php      2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/deprecated.php        2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3491,3 +3491,75 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Formats text for the rich text editor.
+ *
+ * The filter 'richedit_pre' is applied here. If $text is empty the filter will
+ * be applied to an empty string.
+ *
+ * @since 2.0.0
+ * @deprecated 4.3.0
+ *
+ * @param string $text The text to be formatted.
+ * @return string The formatted text after filter is applied.
+ */
+function wp_richedit_pre($text) {
+       _deprecated_function( __FUNCTION__, '4.3', 'format_for_editor()' );
+
+       if ( empty( $text ) ) {
+               /**
+                * Filter text returned for the rich text editor.
+                *
+                * This filter is first evaluated, and the value returned, if an empty string
+                * is passed to wp_richedit_pre(). If an empty string is passed, it results
+                * in a break tag and line feed.
+                *
+                * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
+                * return after being formatted.
+                *
+                * @since 2.0.0
+                * @deprecated 4.3.0
+                *
+                * @param string $output Text for the rich text editor.
+                */
+               return apply_filters( 'richedit_pre', '' );
+       }
+
+       $output = convert_chars($text);
+       $output = wpautop($output);
+       $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
+
+       /** This filter is documented in wp-includes/deprecated.php */
+       return apply_filters( 'richedit_pre', $output );
+}
+
+/**
+ * Formats text for the HTML editor.
+ *
+ * Unless $output is empty it will pass through htmlspecialchars before the
+ * 'htmledit_pre' filter is applied.
+ *
+ * @since 2.5.0
+ * @deprecated 4.3.0
+ *
+ * @param string $output The text to be formatted.
+ * @return string Formatted text after filter applied.
+ */
+function wp_htmledit_pre($output) {
+       _deprecated_function( __FUNCTION__, '4.3', 'format_for_editor()' );
+
+       if ( !empty($output) )
+               $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
+
+       /**
+        * Filter the text before it is formatted for the HTML editor.
+        *
+        * @since 2.5.0
+        * @deprecated 4.3.0
+        *
+        * @param string $output The HTML-formatted text.
+        */
+       return apply_filters( 'htmledit_pre', $output );
+}
+
</ins></span></pre></div>
<a id="trunksrcwpincludesformattingphp"></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/formatting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/formatting.php      2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/formatting.php        2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3062,66 +3062,35 @@
</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">- * Formats text for the rich text editor.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Formats text for the 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">- * The filter 'richedit_pre' is applied here. If $text is empty the filter will
- * be applied to an empty string.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Generally the browsers treat everything inside a textarea as text, but
+ * it is still a good idea to HTML entity encode `<`, `>` and `&` in the content.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 2.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The filter 'format_for_editor' is applied here. If $text is empty the filter will
+ * be applied to an empty string. 
</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.3.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px">  * @param string $text The text to be formatted.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string The formatted text after filter is applied.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string The formatted text after filter is applied. <?
</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 wp_richedit_pre( $text ) {
-       if ( empty( $text ) ) {
-               /**
-                * Filter text returned for the rich text editor.
-                *
-                * This filter is first evaluated, and the value returned, if an empty string
-                * is passed to wp_richedit_pre(). If an empty string is passed, it results
-                * in a break tag and line feed.
-                *
-                * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
-                * return after being formatted.
-                *
-                * @since 2.0.0
-                *
-                * @param string $output Text for the rich text editor.
-                */
-               return apply_filters( 'richedit_pre', '' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function format_for_editor( $text, $default_editor = null ) {
+       // Back-compat: check if any characters need encoding.
+       if ( ! empty( $text ) && ( false !== strpos( $text, '<' ) || false !== strpos( $text, '>' ) ||
+               preg_match( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', $text ) ) ) {
+
+               $text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
</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">-        $output = convert_chars($text);
-       $output = wpautop($output);
-       $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
-
-       /** This filter is documented in wp-includes/formatting.php */
-       return apply_filters( 'richedit_pre', $output );
-}
-
-/**
- * Formats text for the HTML editor.
- *
- * Unless $output is empty it will pass through htmlspecialchars before the
- * 'htmledit_pre' filter is applied.
- *
- * @since 2.5.0
- *
- * @param string $output The text to be formatted.
- * @return string Formatted text after filter applied.
- */
-function wp_htmledit_pre( $output ) {
-       if ( !empty($output) )
-               $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
-
</del><span class="cx" style="display: block; padding: 0 10px">         /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Filter the text before it is formatted for the HTML editor.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Filter the text after it is formatted for the 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">-         * @since 2.5.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.3.0
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param string $output The HTML-formatted text.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @param string $text The formatted text.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        return apply_filters( 'htmledit_pre', $output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return apply_filters( 'format_for_editor', $text, $default_editor );
</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></pre></div>
<a id="trunksrcwpincludesjsquicktagsjs"></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/js/quicktags.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/quicktags.js     2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/js/quicktags.js       2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,7 +163,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        id = settings.id,
</span><span class="cx" style="display: block; padding: 0 10px">                        canvas = document.getElementById(id),
</span><span class="cx" style="display: block; padding: 0 10px">                        name = 'qt_' + id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        tb, onclick, toolbar_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 tb, onclick, toolbar_id, wrap, setActiveEditor;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( !id || !canvas ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -182,13 +182,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        toolbar_id = name + '_toolbar';
</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">-                tb = document.createElement('div');
-               tb.id = toolbar_id;
-               tb.className = 'quicktags-toolbar';
-               tb.onclick = function() {
-                       window.wpActiveEditor = id;
-               };
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         tb = document.getElementById( toolbar_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( ! tb ) {
+                       tb = document.createElement('div');
+                       tb.id = toolbar_id;
+                       tb.className = 'quicktags-toolbar';
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 canvas.parentNode.insertBefore(tb, canvas);
</span><span class="cx" style="display: block; padding: 0 10px">                t.toolbar = tb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -214,10 +215,24 @@
</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">+                setActiveEditor = function() {
+                       window.wpActiveEditor = id;
+               };
+
+               wrap = document.getElementById( 'wp-' + id + '-wrap' );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( tb.addEventListener ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        tb.addEventListener('click', onclick, false);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 tb.addEventListener( 'click', onclick, false );
+                       
+                       if ( wrap ) {
+                               wrap.addEventListener( 'click', setActiveEditor, false );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                 } else if ( tb.attachEvent ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        tb.attachEvent('onclick', onclick);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 tb.attachEvent( 'onclick', onclick );
+
+                       if ( wrap ) {
+                               wrap.attachEvent( 'onclick', setActiveEditor );
+                       }
</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">                t.getButton = function(id) {
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswordpresspluginjs"></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/js/tinymce/plugins/wordpress/plugin.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js      2015-06-21 19:34:03 UTC (rev 32898)
+++ trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js        2015-06-21 22:00:42 UTC (rev 32899)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,16 +1,19 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* global tinymce, getUserSetting, setUserSetting */
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* global getUserSetting, setUserSetting */
+( function( tinymce ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Set the minimum value for the modals z-index higher than #wpadminbar (100000)
</span><span class="cx" style="display: block; padding: 0 10px"> tinymce.ui.FloatPanel.zIndex = 100100;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> tinymce.PluginManager.add( 'wordpress', function( editor ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        var DOM = tinymce.DOM,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var wpAdvButton, style,
+               DOM = tinymce.DOM,
</ins><span class="cx" style="display: block; padding: 0 10px">                 each = tinymce.each,
</span><span class="cx" style="display: block; padding: 0 10px">                __ = editor.editorManager.i18n.translate,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wpAdvButton, style;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $ = window.jQuery,
+               wp = window.wp,
+               hasWpautop = ( wp && wp.editor && wp.editor.autop && editor.getParam( 'wpautop', 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">-        if ( typeof window.jQuery !== 'undefined' ) {
-               window.jQuery( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $ ) {
+               $( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
</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">        function toggleToolbars( state ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,26 +91,34 @@
</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">        // Replace Read More/Next Page tags with images
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        editor.on( 'BeforeSetContent', function( e ) {
-               var title;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.on( 'BeforeSetContent', function( event ) {
+               var title,
+                       paragraph = tinymce.Env.webkit ? '<p><br /></p>' : '<p></p>';
</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 ( e.content ) {
-                       if ( e.content.indexOf( '<!--more' ) !== -1 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( event.content ) {
+                       if ( event.content.indexOf( '<!--more' ) !== -1 ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 title = __( 'Read more...' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         event.content = event.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="more" data-wp-more-text="' + moretext + '" ' +
</span><span class="cx" style="display: block; padding: 0 10px">                                                'class="wp-more-tag mce-wp-more" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />';
</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">-                        if ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( event.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 title = __( 'Page break' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                e.content = e.content.replace( /<!--nextpage-->/g,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         event.content = event.content.replace( /<!--nextpage-->/g,
</ins><span class="cx" style="display: block; padding: 0 10px">                                         '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" ' +
</span><span class="cx" style="display: block; padding: 0 10px">                                                'title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       // Remove spaces from empty paragraphs.
+                       event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF|\s)+<\/p>/gi, paragraph );
+
+                       if ( event.load && event.format !== 'raw' && hasWpautop ) {
+                               event.content = wp.editor.autop( event.content );
+                       }
</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">@@ -201,7 +212,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">        editor.addCommand( 'WP_Medialib', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( wp && wp.media && wp.media.editor ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp.media.editor.open( editor.id );
</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">@@ -234,7 +245,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Menubar
</span><span class="cx" style="display: block; padding: 0 10px">        // Insert->Add Media
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp && wp.media && wp.media.editor ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 editor.addMenuItem( 'add_media', {
</span><span class="cx" style="display: block; padding: 0 10px">                        text: 'Add Media',
</span><span class="cx" style="display: block; padding: 0 10px">                        icon: 'wp-media-library',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -288,7 +299,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        doc = editor.getDoc(),
</span><span class="cx" style="display: block; padding: 0 10px">                        dom = editor.dom;
</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 ( tinymce.Env.iOS ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( env.iOS ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         dom.addClass( doc.documentElement, 'ios' );
</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">@@ -318,23 +329,22 @@
</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">                // Remove invalid parent paragraphs when inserting HTML
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // TODO: still needed?
-               editor.on( 'BeforeSetContent', function( e ) {
-                       if ( e.content ) {
-                               e.content = e.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi, '<$1$2>');
-                               e.content = e.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         editor.on( 'BeforeSetContent', function( event ) {
+                       if ( event.content ) {
+                               event.content = event.content.replace( /<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' )
+                                       .replace( /<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)>\s*<\/p>/gi, '</$1>' );
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( typeof window.jQuery !== 'undefined' ) {
-                       window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( $ ) {
+                       $( document ).triggerHandler( 'tinymce-editor-init', [editor] );
</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 ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                if ( typeof window.jQuery !== 'undefined' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( $ ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         // Trigger the jQuery handlers.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        window.jQuery( document ).trigger( new window.jQuery.Event( event ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $( document ).trigger( new $.Event( event ) );
</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">@@ -362,30 +372,21 @@
</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">-        editor.on( 'SaveContent', function( e ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.on( 'SaveContent', function( event ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 // If editor is hidden, we just want the textarea's value to be saved
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! editor.inline && editor.isHidden() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        e.content = e.element.value;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 event.content = event.element.value;
</ins><span class="cx" style="display: block; padding: 0 10px">                         return;
</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">                // Keep empty paragraphs :(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                e.content = e.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p>&nbsp;</p>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         event.content = event.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p>&nbsp;</p>' );
</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 ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) {
-                       e.content = window.switchEditors.pre_wpautop( e.content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( hasWpautop ) {
+                       event.content = wp.editor.removep( event.content );
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // Remove spaces from empty paragraphs.
-       editor.on( 'BeforeSetContent', function( event ) {
-               var paragraph = tinymce.Env.webkit ? '<p><br /></p>' : '<p></p>';
-
-               if ( event.content ) {
-                       event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF|\s)+<\/p>/gi, paragraph );
-               }
-       });
-
</del><span class="cx" style="display: block; padding: 0 10px">         editor.on( 'preInit', function() {
</span><span class="cx" style="display: block; padding: 0 10px">                // Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty
</span><span class="cx" style="display: block; padding: 0 10px">                editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -394,6 +395,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        editor.settings.height = 300;
</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">+                // Start hidden when the Text editor is set to load first.
+               if ( tinymce.$( '#wp-' + editor.id + '-wrap' ).hasClass( 'html-active' ) ) {
+                       editor.hide();
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 each( {
</span><span class="cx" style="display: block; padding: 0 10px">                        c: 'JustifyCenter',
</span><span class="cx" style="display: block; padding: 0 10px">                        r: 'JustifyRight',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -415,7 +421,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">                editor.addShortcut( 'meta+s', '', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( typeof wp !== 'undefined' && wp.autosave ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( wp && wp.autosave ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 wp.autosave.server.triggerSave();
</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">@@ -737,3 +743,5 @@
</span><span class="cx" style="display: block; padding: 0 10px">                _getEmbed: noop
</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">+
+}( window.tinymce ));
</ins></span></pre>
</div>
</div>

</body>
</html>