<!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>[18799] trunk: Fix enqueueing of the right scripts when more than one instance of the editor, fix inserting images in full screen mode, see #17144</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, #logmsg > ol { margin-left: 0; 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">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/18799">18799</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2011-09-28 07:26:34 +0000 (Wed, 28 Sep 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix enqueueing of the right scripts when more than one instance of the editor, fix inserting images in full screen mode, see <a href="http://core.trac.wordpress.org/ticket/17144">#17144</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjsmediauploaddevjs">trunk/wp-admin/js/media-upload.dev.js</a></li>
<li><a href="#trunkwpadminjsmediauploadjs">trunk/wp-admin/js/media-upload.js</a></li>
<li><a href="#trunkwpincludesclasswpeditorphp">trunk/wp-includes/class-wp-editor.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjsmediauploaddevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/media-upload.dev.js (18798 => 18799)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/media-upload.dev.js        2011-09-28 06:08:56 UTC (rev 18798)
+++ trunk/wp-admin/js/media-upload.dev.js        2011-09-28 07:26:34 UTC (rev 18799)
</span><span class="lines">@@ -12,11 +12,13 @@
</span><span class="cx">                 } else if ( !qt ) {
</span><span class="cx">                         return false;
</span><span class="cx">                 }
</span><del>-        } 
</del><ins>+        } else {
+                if ( mce &amp;&amp; tinymce.activeEditor &amp;&amp; (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
+                        ed = tinymce.activeEditor;
+                else
+                        ed = tinymce.get(wpActiveEditor);
+        }
</ins><span class="cx"> 
</span><del>-        if ( !ed &amp;&amp; mce &amp;&amp; wpActiveEditor )
-                ed = tinymce.get(wpActiveEditor);
-
</del><span class="cx">         if ( ed &amp;&amp; !ed.isHidden() ) {
</span><span class="cx">                 // restore caret position on IE
</span><span class="cx">                 if ( tinymce.isIE &amp;&amp; ed.windowManager.insertimagebookmark )
</span></span></pre></div>
<a id="trunkwpadminjsmediauploadjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/media-upload.js (18798 => 18799)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/media-upload.js        2011-09-28 06:08:56 UTC (rev 18798)
+++ trunk/wp-admin/js/media-upload.js        2011-09-28 07:26:34 UTC (rev 18799)
</span><span class="lines">@@ -1 +1 @@
</span><del>-var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!=&quot;undefined&quot;,f=typeof(QTags)!=&quot;undefined&quot;;if(!wpActiveEditor){if(a&amp;&amp;tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}if(!b&amp;&amp;a&amp;&amp;wpActiveEditor){b=tinymce.get(wpActiveEditor)}if(b&amp;&amp;!b.isHidden()){if(tinymce.isIE&amp;&amp;b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf(&quot;[caption&quot;)===0){if(b.plugins.wpeditimage){c=b.plugins.wpeditimage._do_shcode(c)}}else{if(c.indexOf(&quot;[gallery&quot;)===0){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf(&quot;[embed&quot;)===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand(&quot;mceInsertContent&quot;,false,c)}else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_
 position;(function(a){tb_position=function(){var f=a(&quot;#TB_window&quot;),e=a(window).width(),d=a(window).height(),c=(720&lt;e)?720:e,b=0;if(a(&quot;body.admin-bar&quot;).length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a(&quot;#TB_iframeContent&quot;).width(c-50).height(d-75-b);f.css({&quot;margin-left&quot;:&quot;-&quot;+parseInt(((c-50)/2),10)+&quot;px&quot;});if(typeof document.body.style.maxWidth!=&quot;undefined&quot;){f.css({top:20+b+&quot;px&quot;,&quot;margin-top&quot;:&quot;0&quot;})}}return a(&quot;a.thickbox&quot;).each(function(){var g=a(this).attr(&quot;href&quot;);if(!g){return}g=g.replace(/&amp;width=[0-9]+/g,&quot;&quot;);g=g.replace(/&amp;height=[0-9]+/g,&quot;&quot;);a(this).attr(&quot;href&quot;,g+&quot;&amp;width=&quot;+(c-80)+&quot;&amp;height=&quot;+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b(&quot;a.thickbox&quot;).click(function(){var c;if(typeof(tinymce)!=&quot;undefined&quot;&amp;&amp;tinymce.is
 IE&amp;&amp;(c=tinymce.get(wpActiveEditor))&amp;&amp;!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);
</del><span class="cx">\ No newline at end of file
</span><ins>+var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!=&quot;undefined&quot;,f=typeof(QTags)!=&quot;undefined&quot;;if(!wpActiveEditor){if(a&amp;&amp;tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}else{if(a&amp;&amp;tinymce.activeEditor&amp;&amp;(tinymce.activeEditor.id==&quot;mce_fullscreen&quot;||tinymce.activeEditor.id==&quot;wp_mce_fullscreen&quot;)){b=tinymce.activeEditor}else{b=tinymce.get(wpActiveEditor)}}if(b&amp;&amp;!b.isHidden()){if(tinymce.isIE&amp;&amp;b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf(&quot;[caption&quot;)===0){if(b.plugins.wpeditimage){c=b.plugins.wpeditimage._do_shcode(c)}}else{if(c.indexOf(&quot;[gallery&quot;)===0){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf(&quot;[embed&quot;)===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand(&quot;mceInser
 tContent&quot;,false,c)}else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_position;(function(a){tb_position=function(){var f=a(&quot;#TB_window&quot;),e=a(window).width(),d=a(window).height(),c=(720&lt;e)?720:e,b=0;if(a(&quot;body.admin-bar&quot;).length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a(&quot;#TB_iframeContent&quot;).width(c-50).height(d-75-b);f.css({&quot;margin-left&quot;:&quot;-&quot;+parseInt(((c-50)/2),10)+&quot;px&quot;});if(typeof document.body.style.maxWidth!=&quot;undefined&quot;){f.css({top:20+b+&quot;px&quot;,&quot;margin-top&quot;:&quot;0&quot;})}}return a(&quot;a.thickbox&quot;).each(function(){var g=a(this).attr(&quot;href&quot;);if(!g){return}g=g.replace(/&amp;width=[0-9]+/g,&quot;&quot;);g=g.replace(/&amp;height=[0-9]+/g,&quot;&quot;);a(this).attr(&quot;href&quot;,g+&quot;&amp;width=&quot;+(c-80)+&quot;&amp;height=&quot;+(d-85-b))})};a(window).resize(function(){tb_positi
 on()});a(document).ready(function(b){b(&quot;a.thickbox&quot;).click(function(){var c;if(typeof(tinymce)!=&quot;undefined&quot;&amp;&amp;tinymce.isIE&amp;&amp;(c=tinymce.get(wpActiveEditor))&amp;&amp;!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-editor.php (18798 => 18799)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-editor.php        2011-09-28 06:08:56 UTC (rev 18798)
+++ trunk/wp-includes/class-wp-editor.php        2011-09-28 07:26:34 UTC (rev 18799)
</span><span class="lines">@@ -25,6 +25,9 @@
</span><span class="cx">         var $first_init;
</span><span class="cx">         var $this_tinymce = false;
</span><span class="cx">         var $this_quicktags = false;
</span><ins>+        var $has_tinymce = false;
+        var $has_quicktags = false;
+        var $has_medialib = false;
</ins><span class="cx"> 
</span><span class="cx">         function __construct() {
</span><span class="cx">                 $this-&gt;can_richedit = user_can_richedit();
</span><span class="lines">@@ -67,6 +70,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;this_quicktags &amp;&amp; $this-&gt;this_tinymce ) {
</span><span class="cx">                         $switch_class = 'html-active';
</span><ins>+                        $this-&gt;has_tinymce = $this-&gt;has_quicktags = true;
</ins><span class="cx"> 
</span><span class="cx">                         if ( 'html' == $this-&gt;default_editor ) {
</span><span class="cx">                                 add_filter('the_editor_content', 'wp_htmledit_pre');
</span><span class="lines">@@ -77,6 +81,12 @@
</span><span class="cx"> 
</span><span class="cx">                         $buttons .= '&lt;a id=&quot;' . $editor_id . '-html&quot; class=&quot;hide-if-no-js wp-switch-editor switch-html&quot; onclick=&quot;switchEditors.go(this);return false;&quot;&gt;' . __('HTML') . &quot;&lt;/a&gt;\n&quot;;
</span><span class="cx">                         $buttons .= '&lt;a id=&quot;' . $editor_id . '-tmce&quot; class=&quot;hide-if-no-js wp-switch-editor switch-tmce&quot; onclick=&quot;switchEditors.go(this);return false;&quot;&gt;' . __('Visual') . &quot;&lt;/a&gt;\n&quot;;
</span><ins>+                } else {
+                        if ( $this-&gt;this_tinymce )
+                                $this-&gt;has_tinymce = true;
+
+                        if ( $this-&gt;this_quicktags )
+                                $this-&gt;has_quicktags = true;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 echo '&lt;div id=&quot;wp-' . $editor_id . '-wrap&quot; class=&quot;wp-editor-wrap ' . $switch_class . '&quot;&gt;';
</span><span class="lines">@@ -89,6 +99,8 @@
</span><span class="cx">                         echo $buttons;
</span><span class="cx"> 
</span><span class="cx">                         if ( $set['media_buttons'] ) {
</span><ins>+                                $this-&gt;has_medialib = true;
+
</ins><span class="cx">                                 if ( !function_exists('media_buttons') )
</span><span class="cx">                                         include(ABSPATH . 'wp-admin/includes/media.php');
</span><span class="cx"> 
</span><span class="lines">@@ -442,10 +454,10 @@
</span><span class="cx">                 wp_enqueue_script('word-count');
</span><span class="cx">                 wp_enqueue_style('editor-buttons');
</span><span class="cx"> 
</span><del>-                if ( $this-&gt;this_tinymce )
</del><ins>+                if ( $this-&gt;has_tinymce )
</ins><span class="cx">                         wp_enqueue_script('editor');
</span><span class="cx"> 
</span><del>-                if ( $this-&gt;this_quicktags )
</del><ins>+                if ( $this-&gt;has_quicktags )
</ins><span class="cx">                         wp_enqueue_script('quicktags');
</span><span class="cx"> 
</span><span class="cx">                 if ( in_array('wplink', $this-&gt;plugins, true) || in_array('link', $this-&gt;qt_buttons, true) ) {
</span><span class="lines">@@ -457,8 +469,10 @@
</span><span class="cx">                 if ( in_array('wpfullscreen', $this-&gt;plugins, true) || in_array('fullscreen', $this-&gt;qt_buttons, true) )
</span><span class="cx">                         wp_enqueue_script('wp-fullscreen');
</span><span class="cx"> 
</span><del>-                add_thickbox();
-                wp_enqueue_script('media-upload');
</del><ins>+                if ( $this-&gt;has_medialib ) {
+                        add_thickbox();
+                        wp_enqueue_script('media-upload');
+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function editor_js() {
</span><span class="lines">@@ -800,4 +814,3 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (18798 => 18799)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2011-09-28 06:08:56 UTC (rev 18798)
+++ trunk/wp-includes/script-loader.php        2011-09-28 07:26:34 UTC (rev 18799)
</span><span class="lines">@@ -276,7 +276,7 @@
</span><span class="cx"> 
</span><span class="cx">         $scripts-&gt;add( 'word-count', &quot;/wp-admin/js/word-count$suffix.js&quot;, array( 'jquery' ), '20110515', 1 );
</span><span class="cx"> 
</span><del>-        $scripts-&gt;add( 'media-upload', &quot;/wp-admin/js/media-upload$suffix.js&quot;, array( 'thickbox' ), '20110922', 1 );
</del><ins>+        $scripts-&gt;add( 'media-upload', &quot;/wp-admin/js/media-upload$suffix.js&quot;, array( 'thickbox' ), '20110927', 1 );
</ins><span class="cx"> 
</span><span class="cx">         if ( is_admin() ) {
</span><span class="cx">                 $scripts-&gt;add( 'ajaxcat', &quot;/wp-admin/js/cat$suffix.js&quot;, array( 'wp-lists' ), '20090102' );
</span></span></pre>
</div>
</div>

</body>
</html>