Fix send_to_editor() and Insert/Upload buttons URLs, see #17144

git-svn-id: http://svn.automattic.com/wordpress/trunk@18516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-08-06 01:35:02 +00:00
parent 902cbda424
commit d012143326
5 changed files with 27 additions and 45 deletions

View File

@ -403,7 +403,7 @@ function _media_button($title, $icon, $type, $id) {
function get_upload_iframe_src($type) {
global $post_ID, $temp_ID;
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
$upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
$upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, admin_url('media-upload.php') );
if ( 'media' != $type )
$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);

View File

@ -1,9 +1,23 @@
// send html to the post editor
/*
var wpActiveEditor;
function send_to_editor(h) {
var ed;
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
if ( !wpActiveEditor ) {
if ( typeof(tinymce) != 'undefined' && tinymce.activeEditor ) {
ed = tinymce.activeEditor;
wpActiveEditor = ed.id;
} else {
return false;
}
}
if ( !ed && typeof(tinymce) != 'undefined' && wpActiveEditor )
ed = tinymce.get(wpActiveEditor);
if ( ed && !ed.isHidden() ) {
// restore caret position on IE
if ( tinymce.isIE && ed.windowManager.insertimagebookmark )
ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
@ -20,16 +34,14 @@ function send_to_editor(h) {
}
ed.execCommand('mceInsertContent', false, h);
} else if ( typeof edInsertContent == 'function' ) {
edInsertContent(edCanvas, h);
} else if ( typeof(QTags) != 'undefined' ) {
QTags.insertContent(h);
} else {
jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
document.getElementById(wpActiveEditor).value += h;
}
tb_remove();
}
*/
// thickbox settings
var tb_position;
@ -64,7 +76,7 @@ var tb_position;
$('a.thickbox').click(function(){
var ed;
if ( typeof tinyMCE != 'undefined' && tinymce.isIE && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
if ( typeof(tinymce) != 'undefined' && tinymce.isIE && ( ed = tinymce.get(wpActiveEditor) ) && !ed.isHidden() ) {
ed.focus();
ed.windowManager.insertimagebookmark = ed.selection.getBookmark();
}

View File

@ -1 +1 @@
var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b("a.thickbox").click(function(){var c;if(typeof tinyMCE!="undefined"&&tinymce.isIE&&(c=tinyMCE.activeEditor)&&!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);
var wpActiveEditor;function send_to_editor(b){var a;if(!wpActiveEditor){if(typeof(tinymce)!="undefined"&&tinymce.activeEditor){a=tinymce.activeEditor;wpActiveEditor=a.id}else{return false}}if(!a&&typeof(tinymce)!="undefined"&&wpActiveEditor){a=tinymce.get(wpActiveEditor)}if(a&&!a.isHidden()){if(tinymce.isIE&&a.windowManager.insertimagebookmark){a.selection.moveToBookmark(a.windowManager.insertimagebookmark)}if(b.indexOf("[caption")===0){if(a.plugins.wpeditimage){b=a.plugins.wpeditimage._do_shcode(b)}}else{if(b.indexOf("[gallery")===0){if(a.plugins.wpgallery){b=a.plugins.wpgallery._do_gallery(b)}}else{if(b.indexOf("[embed")===0){if(a.plugins.wordpress){b=a.plugins.wordpress._setEmbed(b)}}}}a.execCommand("mceInsertContent",false,b)}else{if(typeof(QTags)!="undefined"){QTags.insertContent(b)}else{document.getElementById(wpActiveEditor).value+=b}}tb_remove()}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b("a.thickbox").click(function(){var c;if(typeof(tinymce)!="undefined"&&tinymce.isIE&&(c=tinymce.get(wpActiveEditor))&&!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);

View File

@ -429,6 +429,7 @@ class WP_Editor {
wp_enqueue_script('wp-fullscreen');
add_thickbox();
wp_enqueue_script('media-upload');
}
function editor_js() {
@ -525,54 +526,23 @@ class WP_Editor {
}
if ( mce )
try{tinymce.init(init);}catch(e){}
try { tinymce.init(init); } catch(e){}
}
}
if ( typeof(QTags) == 'function' ) {
for ( qt in tinyMCEPreInit.qtInit ) {
try{quicktags(tinyMCEPreInit.qtInit[qt]);}catch(e){}
try { quicktags( tinyMCEPreInit.qtInit[qt] ); } catch(e){}
}
}
})();
var wpActiveEditor;
jQuery('.wp-editor-wrap').click(function(e){
jQuery('.wp-editor-wrap').mousedown(function(e){
wpActiveEditor = this.id.slice(3, -5);
});
function send_to_editor(h) {
var ed;
if ( typeof(tinymce) != 'undefined' && wpActiveEditor )
ed = tinymce.get(wpActiveEditor);
if ( ed && !ed.isHidden() ) {
// restore caret position on IE
if ( tinymce.isIE && 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();
}
<?php
if ( $this->ext_plugins )

View File

@ -249,7 +249,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110515', 1 );
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110425', 1 );
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110805', 1 );
if ( is_admin() ) {
$scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );