<!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>[18516] trunk: Fix send_to_editor() and Insert/Upload buttons URLs, 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/18516">18516</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2011-08-06 01:35:02 +0000 (Sat, 06 Aug 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix send_to_editor() and Insert/Upload buttons URLs, see <a href="http://core.trac.wordpress.org/ticket/17144">#17144</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<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="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (18515 => 18516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2011-08-05 20:54:08 UTC (rev 18515)
+++ trunk/wp-admin/includes/media.php        2011-08-06 01:35:02 UTC (rev 18516)
</span><span class="lines">@@ -403,7 +403,7 @@
</span><span class="cx"> function get_upload_iframe_src($type) {
</span><span class="cx">         global $post_ID, $temp_ID;
</span><span class="cx">         $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
</span><del>-        $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
</del><ins>+        $upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, admin_url('media-upload.php') );
</ins><span class="cx"> 
</span><span class="cx">         if ( 'media' != $type )
</span><span class="cx">                 $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
</span></span></pre></div>
<a id="trunkwpadminjsmediauploaddevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/media-upload.dev.js (18515 => 18516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/media-upload.dev.js        2011-08-05 20:54:08 UTC (rev 18515)
+++ trunk/wp-admin/js/media-upload.dev.js        2011-08-06 01:35:02 UTC (rev 18516)
</span><span class="lines">@@ -1,9 +1,23 @@
</span><span class="cx"> // send html to the post editor
</span><del>-/*
</del><ins>+
+var wpActiveEditor;
+
</ins><span class="cx"> function send_to_editor(h) {
</span><span class="cx">         var ed;
</span><span class="cx"> 
</span><del>-        if ( typeof tinyMCE != 'undefined' &amp;&amp; ( ed = tinyMCE.activeEditor ) &amp;&amp; !ed.isHidden() ) {
</del><ins>+        if ( !wpActiveEditor ) {
+                if ( typeof(tinymce) != 'undefined' &amp;&amp; tinymce.activeEditor ) {
+                        ed = tinymce.activeEditor;
+                        wpActiveEditor = ed.id;
+                } else {
+                        return false;
+                }
+        } 
+
+        if ( !ed &amp;&amp; typeof(tinymce) != 'undefined' &amp;&amp; wpActiveEditor )
+                ed = tinymce.get(wpActiveEditor);
+
+        if ( ed &amp;&amp; !ed.isHidden() ) {
</ins><span class="cx">                 // restore caret position on IE
</span><span class="cx">                 if ( tinymce.isIE &amp;&amp; ed.windowManager.insertimagebookmark )
</span><span class="cx">                         ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
</span><span class="lines">@@ -20,16 +34,14 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 ed.execCommand('mceInsertContent', false, h);
</span><del>-
-        } else if ( typeof edInsertContent == 'function' ) {
-                edInsertContent(edCanvas, h);
</del><ins>+        } else if ( typeof(QTags) != 'undefined' ) {
+                QTags.insertContent(h);
</ins><span class="cx">         } else {
</span><del>-                jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
</del><ins>+                document.getElementById(wpActiveEditor).value += h;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         tb_remove();
</span><span class="cx"> }
</span><del>-*/
</del><span class="cx"> 
</span><span class="cx"> // thickbox settings
</span><span class="cx"> var tb_position;
</span><span class="lines">@@ -64,7 +76,7 @@
</span><span class="cx">                 $('a.thickbox').click(function(){
</span><span class="cx">                         var ed;
</span><span class="cx"> 
</span><del>-                        if ( typeof tinyMCE != 'undefined' &amp;&amp; tinymce.isIE &amp;&amp; ( ed = tinyMCE.activeEditor ) &amp;&amp; !ed.isHidden() ) {
</del><ins>+                        if ( typeof(tinymce) != 'undefined' &amp;&amp; tinymce.isIE &amp;&amp; ( ed = tinymce.get(wpActiveEditor) ) &amp;&amp; !ed.isHidden() ) {
</ins><span class="cx">                                 ed.focus();
</span><span class="cx">                                 ed.windowManager.insertimagebookmark = ed.selection.getBookmark();
</span><span class="cx">                         }
</span></span></pre></div>
<a id="trunkwpadminjsmediauploadjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/media-upload.js (18515 => 18516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/media-upload.js        2011-08-05 20:54:08 UTC (rev 18515)
+++ trunk/wp-admin/js/media-upload.js        2011-08-06 01:35:02 UTC (rev 18516)
</span><span class="lines">@@ -1 +1 @@
</span><del>-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;&a
 mp;&amp;tinymce.isIE&amp;&amp;(c=tinyMCE.activeEditor)&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(b){var a;if(!wpActiveEditor){if(typeof(tinymce)!=&quot;undefined&quot;&amp;&amp;tinymce.activeEditor){a=tinymce.activeEditor;wpActiveEditor=a.id}else{return false}}if(!a&amp;&amp;typeof(tinymce)!=&quot;undefined&quot;&amp;&amp;wpActiveEditor){a=tinymce.get(wpActiveEditor)}if(a&amp;&amp;!a.isHidden()){if(tinymce.isIE&amp;&amp;a.windowManager.insertimagebookmark){a.selection.moveToBookmark(a.windowManager.insertimagebookmark)}if(b.indexOf(&quot;[caption&quot;)===0){if(a.plugins.wpeditimage){b=a.plugins.wpeditimage._do_shcode(b)}}else{if(b.indexOf(&quot;[gallery&quot;)===0){if(a.plugins.wpgallery){b=a.plugins.wpgallery._do_gallery(b)}}else{if(b.indexOf(&quot;[embed&quot;)===0){if(a.plugins.wordpress){b=a.plugins.wordpress._setEmbed(b)}}}}a.execCommand(&quot;mceInsertContent&quot;,false,b)}else{if(typeof(QTags)!=&quot;undefined&quot;){QTags.insertContent(b)}else{document.getElementById(wpActiveEditor).value+=b}}tb_remove()}v
 ar 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;tiny
 mce.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 (18515 => 18516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-editor.php        2011-08-05 20:54:08 UTC (rev 18515)
+++ trunk/wp-includes/class-wp-editor.php        2011-08-06 01:35:02 UTC (rev 18516)
</span><span class="lines">@@ -429,6 +429,7 @@
</span><span class="cx">                         wp_enqueue_script('wp-fullscreen');
</span><span class="cx"> 
</span><span class="cx">                 add_thickbox();
</span><ins>+                wp_enqueue_script('media-upload');
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function editor_js() {
</span><span class="lines">@@ -525,54 +526,23 @@
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         if ( mce )
</span><del>-                                                try{tinymce.init(init);}catch(e){}
</del><ins>+                                                try { tinymce.init(init); } catch(e){}
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         if ( typeof(QTags) == 'function' ) {
</span><span class="cx">                                 for ( qt in tinyMCEPreInit.qtInit ) {
</span><del>-                                        try{quicktags(tinyMCEPreInit.qtInit[qt]);}catch(e){}
</del><ins>+                                        try { quicktags( tinyMCEPreInit.qtInit[qt] ); } catch(e){}
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 })();
</span><span class="cx"> 
</span><span class="cx">                 var wpActiveEditor;
</span><span class="cx"> 
</span><del>-                jQuery('.wp-editor-wrap').click(function(e){
</del><ins>+                jQuery('.wp-editor-wrap').mousedown(function(e){
</ins><span class="cx">                     wpActiveEditor = this.id.slice(3, -5);
</span><span class="cx">                 });
</span><span class="cx"> 
</span><del>-                function send_to_editor(h) {
-                        var ed;
-
-                        if ( typeof(tinymce) != 'undefined' &amp;&amp; wpActiveEditor )
-                                ed = tinymce.get(wpActiveEditor);
-
-                        if ( ed &amp;&amp; !ed.isHidden() ) {
-                                // restore caret position on IE
-                                if ( tinymce.isIE &amp;&amp; ed.windowManager.insertimagebookmark )
-                                        ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
-
-                                if ( h.indexOf('[caption') === 0 ) {
-                                        if ( ed.plugins.wpeditimage )
-                                                h = ed.plugins.wpeditimage._do_shcode(h);
-                                } else if ( h.indexOf('[gallery') === 0 ) {
-                                        if ( ed.plugins.wpgallery )
-                                                h = ed.plugins.wpgallery._do_gallery(h);
-                                } else if ( h.indexOf('[embed') === 0 ) {
-                                        if ( ed.plugins.wordpress )
-                                                h = ed.plugins.wordpress._setEmbed(h);
-                                }
-
-                                ed.execCommand('mceInsertContent', false, h);
-                        } else if ( typeof quicktags != 'undefined' ) {
-                                QTags.insertContent(wpActiveEditor, h);
-                        } else {
-                                jQuery('#'+wpActiveEditor).val( jQuery('#'+wpActiveEditor).val() + h );
-                        }
-
-                        tb_remove();
-                }
</del><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;ext_plugins )
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (18515 => 18516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2011-08-05 20:54:08 UTC (rev 18515)
+++ trunk/wp-includes/script-loader.php        2011-08-06 01:35:02 UTC (rev 18516)
</span><span class="lines">@@ -249,7 +249,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' ), '20110425', 1 );
</del><ins>+        $scripts-&gt;add( 'media-upload', &quot;/wp-admin/js/media-upload$suffix.js&quot;, array( 'thickbox' ), '20110805', 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>