From c0b51276832e30d20d7c5ae071bf5ab497e40f63 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 8 Sep 2019 02:28:55 +0000 Subject: [PATCH] Upload: Reset the temp upload reference in Plupload when the file is not an image. See #47872. Built from https://develop.svn.wordpress.org/trunk@46081 git-svn-id: http://core.svn.wordpress.org/trunk@45893 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/plupload/handlers.js | 2 +- wp-includes/js/plupload/handlers.min.js | 2 +- wp-includes/js/plupload/wp-plupload.js | 2 +- wp-includes/js/plupload/wp-plupload.min.js | 2 +- wp-includes/version.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-includes/js/plupload/handlers.js b/wp-includes/js/plupload/handlers.js index 37b56631cb..81d91e9f88 100644 --- a/wp-includes/js/plupload/handlers.js +++ b/wp-includes/js/plupload/handlers.js @@ -601,7 +601,7 @@ jQuery( document ).ready( function( $ ) { if ( file.type && file.type.indexOf( 'image/' ) === 0 ) { up.settings.multipart_params._wp_temp_image_ref = file.id; } else { - unset( up.settings.multipart_params._wp_temp_image_ref ); + up.settings.multipart_params._wp_temp_image_ref = ''; } } ); }; diff --git a/wp-includes/js/plupload/handlers.min.js b/wp-includes/js/plupload/handlers.min.js index fd9e4b16eb..42799910e9 100644 --- a/wp-includes/js/plupload/handlers.min.js +++ b/wp-includes/js/plupload/handlers.min.js @@ -1 +1 @@ -function fileQueued(a){jQuery(".media-blank").remove();var b=jQuery("#media-items").children(),c=post_id||0;1==b.length&&b.removeClass("open").find(".slidetoggle").slideUp(200),jQuery('
').attr("id","media-item-"+a.id).addClass("child-of-"+c).append('
0%
',jQuery('
').text(" "+a.name)).appendTo(jQuery("#media-items")),jQuery("#insert-gallery").prop("disabled",!0)}function uploadStart(){try{"undefined"!=typeof topWin.tb_remove&&topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}catch(a){}return!0}function uploadProgress(a,b){var c=jQuery("#media-item-"+b.id);jQuery(".bar",c).width(200*b.loaded/b.size),jQuery(".percent",c).html(b.percent+"%")}function fileUploading(a,b){var c=104857600,d=parseInt(a.settings.max_file_size,10);d>c&&b.size>c&&setTimeout(function(){b.status<3&&0===b.loaded&&(wpFileError(b,pluploadL10n.big_upload_failed.replace("%1$s",'').replace("%2$s","")),a.stop(),a.removeFile(b),a.start())},1e4)}function updateMediaForm(){var a=jQuery("#media-items").children();1==a.length?(a.addClass("open").find(".slidetoggle").show(),jQuery(".insert-gallery").hide()):a.length>1&&(a.removeClass("open"),jQuery(".insert-gallery").show()),a.not(".media-blank").length>0?jQuery(".savebutton").show():jQuery(".savebutton").hide()}function uploadSuccess(a,b){var c=jQuery("#media-item-"+a.id);return"string"==typeof b&&(b=b.replace(/^
(\d+)<\/pre>$/,"$1"),/media-upload-error|error-div/.test(b))?void c.html(b):(c.find(".percent").html(pluploadL10n.crunching),prepareMediaItem(a,b),updateMediaForm(),void(post_id&&c.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)))}function setResize(a){a?window.resize_width&&window.resize_height?uploader.settings.resize={enabled:!0,width:window.resize_width,height:window.resize_height,quality:100}:uploader.settings.multipart_params.image_resize=!0:delete uploader.settings.multipart_params.image_resize}function prepareMediaItem(a,b){var c="undefined"==typeof shortform?1:2,d=jQuery("#media-item-"+a.id);2==c&&shortform>2&&(c=shortform);try{"undefined"!=typeof topWin.tb_remove&&topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}catch(e){}isNaN(b)||!b?(d.append(b),prepareMediaItemInit(a)):d.load("async-upload.php",{attachment_id:b,fetch:c},function(){prepareMediaItemInit(a),updateMediaForm()})}function prepareMediaItemInit(a){var b=jQuery("#media-item-"+a.id);jQuery(".thumbnail",b).clone().attr("class","pinkynail toggle").prependTo(b),jQuery(".filename.original",b).replaceWith(jQuery(".filename.new",b)),jQuery("a.delete",b).click(function(){return jQuery.ajax({url:ajaxurl,type:"post",success:deleteSuccess,error:deleteError,id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}}),!1}),jQuery("a.undo",b).click(function(){return jQuery.ajax({url:ajaxurl,type:"post",id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(){var b,c=jQuery("#media-item-"+a.id);(b=jQuery("#type-of-"+a.id).val())&&jQuery("#"+b+"-counter").text(jQuery("#"+b+"-counter").text()-0+1),post_id&&c.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1),jQuery(".filename .trashnotice",c).remove(),jQuery(".filename .title",c).css("font-weight","normal"),jQuery("a.undo",c).addClass("hidden"),jQuery(".menu_order_input",c).show(),c.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:!1,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}}),!1}),jQuery("#media-item-"+a.id+".startopen").removeClass("startopen").addClass("open").find("slidetoggle").fadeIn()}function wpQueueError(a){jQuery("#media-upload-error").show().html('

'+a+"

")}function wpFileError(a,b){itemAjaxError(a.id,b)}function itemAjaxError(a,b){var c=jQuery("#media-item-"+a),d=c.find(".filename").text(),e=c.data("last-err");e!=a&&c.html('
'+pluploadL10n.dismiss+""+pluploadL10n.error_uploading.replace("%s",jQuery.trim(d))+" "+b+"
").data("last-err",a)}function deleteSuccess(a){var b,c,d;return"-1"==a?itemAjaxError(this.id,"You do not have permission. Has your session expired?"):"0"==a?itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?"):(c=this.id,d=jQuery("#media-item-"+c),(b=jQuery("#type-of-"+c).val())&&jQuery("#"+b+"-counter").text(jQuery("#"+b+"-counter").text()-1),post_id&&d.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1),1==jQuery("form.type-form #media-items").children().length&&jQuery(".hidden","#media-items").length>0&&(jQuery(".toggle").toggle(),jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")),jQuery(".toggle",d).toggle(),jQuery(".slidetoggle",d).slideUp(200).siblings().removeClass("hidden"),d.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:!1,duration:500}).addClass("undo"),jQuery(".filename:empty",d).remove(),jQuery(".filename .title",d).css("font-weight","bold"),jQuery(".filename",d).append(' '+pluploadL10n.deleted+" ").siblings("a.toggle").hide(),jQuery(".filename",d).append(jQuery("a.undo",d).removeClass("hidden")),void jQuery(".menu_order_input",d).hide())}function deleteError(){}function uploadComplete(){jQuery("#insert-gallery").prop("disabled",!1)}function switchUploader(a){a?(deleteUserSetting("uploader"),jQuery(".media-upload-form").removeClass("html-uploader"),"object"==typeof uploader&&uploader.refresh()):(setUserSetting("uploader","1"),jQuery(".media-upload-form").addClass("html-uploader"))}function uploadError(a,b,c,d){var e,f=104857600;switch(b){case plupload.FAILED:wpFileError(a,pluploadL10n.upload_failed);break;case plupload.FILE_EXTENSION_ERROR:wpFileExtensionError(d,a,pluploadL10n.invalid_filetype);break;case plupload.FILE_SIZE_ERROR:uploadSizeError(d,a);break;case plupload.IMAGE_FORMAT_ERROR:wpFileError(a,pluploadL10n.not_an_image);break;case plupload.IMAGE_MEMORY_ERROR:wpFileError(a,pluploadL10n.image_memory_exceeded);break;case plupload.IMAGE_DIMENSIONS_ERROR:wpFileError(a,pluploadL10n.image_dimensions_exceeded);break;case plupload.GENERIC_ERROR:wpQueueError(pluploadL10n.upload_failed);break;case plupload.IO_ERROR:e=parseInt(d.settings.filters.max_file_size,10),e>f&&a.size>f?wpFileError(a,pluploadL10n.big_upload_failed.replace("%1$s",'').replace("%2$s","")):wpQueueError(pluploadL10n.io_error);break;case plupload.HTTP_ERROR:wpQueueError(pluploadL10n.http_error);break;case plupload.INIT_ERROR:jQuery(".media-upload-form").addClass("html-uploader");break;case plupload.SECURITY_ERROR:wpQueueError(pluploadL10n.security_error);break;default:wpFileError(a,pluploadL10n.default_error)}}function uploadSizeError(a,b){var c,d;c=pluploadL10n.file_exceeds_size_limit.replace("%s",b.name),d=jQuery("
").attr({id:"media-item-"+b.id,"class":"media-item error"}).append(jQuery("

").text(c)),jQuery("#media-items").append(d),a.removeFile(b)}function wpFileExtensionError(a,b,c){jQuery("#media-items").append('

'+c+"

"),a.removeFile(b)}var topWin=window.dialogArguments||opener||parent||top,uploader,uploader_init;jQuery(document).ready(function(a){var b,c={};a(".media-upload-form").bind("click.uploader",function(b){var c,d,e=a(b.target);e.is('input[type="radio"]')?(c=e.closest("tr"),c.hasClass("align")?setUserSetting("align",e.val()):c.hasClass("image-size")&&setUserSetting("imgsize",e.val())):e.is("button.button")?(d=b.target.className||"",d=d.match(/url([^ '"]+)/),d&&d[1]&&(setUserSetting("urlbutton",d[1]),e.siblings(".urlfield").val(e.data("link-url")))):e.is("a.dismiss")?e.parents(".media-item").fadeOut(200,function(){a(this).remove()}):e.is(".upload-flash-bypass a")||e.is("a.uploader-html")?(a("#media-items, p.submit, span.big-file-warning").css("display","none"),switchUploader(0),b.preventDefault()):e.is(".upload-html-bypass a")?(a("#media-items, p.submit, span.big-file-warning").css("display",""),switchUploader(1),b.preventDefault()):e.is("a.describe-toggle-on")?(e.parent().addClass("open"),e.siblings(".slidetoggle").fadeIn(250,function(){var b,c,d=a(window).scrollTop(),e=a(window).height(),f=a(this).offset().top,g=a(this).height();e&&f&&g&&(b=f+g,c=d+e,b>c&&(b-c4?(a.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:_wpPluploadSettings.defaults.multipart_params._wpnonce,_wp_temp_image_ref:g.id,_wp_upload_failed_cleanup:!0}}),void wpQueueError(e.message&&500!==e.status?e.message:pluploadL10n.http_error_image)):(f?c[g.id]=++f:c[g.id]=1,void a.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:wpUploaderInit.multipart_params._wpnonce,_wp_temp_image_ref:g.id,_legasy_support:"true"}}).done(function(a){var b;a.success?uploadSuccess(g,a.data.id):(a.data&&a.data.message&&(b=a.data.message),wpQueueError(b||pluploadL10n.http_error_image))}).fail(function(a){return 500===a.status?void b(d,e):void wpQueueError(pluploadL10n.http_error_image)}))):void wpQueueError(e.message||pluploadL10n.default_error)},uploader_init=function(){uploader=new plupload.Uploader(wpUploaderInit),a("#image_resize").bind("change",function(){var b=a(this).prop("checked");setResize(b),b?setUserSetting("upload_resize","1"):deleteUserSetting("upload_resize")}),uploader.bind("Init",function(b){var c=a("#plupload-upload-ui");setResize(getUserSetting("upload_resize",!1)),b.features.dragdrop&&!a(document.body).hasClass("mobile")?(c.addClass("drag-drop"),a("#drag-drop-area").on("dragover.wp-uploader",function(){c.addClass("drag-over")}).on("dragleave.wp-uploader, drop.wp-uploader",function(){c.removeClass("drag-over")})):(c.removeClass("drag-drop"),a("#drag-drop-area").off(".wp-uploader")),"html4"===b.runtime&&a(".upload-flash-bypass").hide()}),uploader.bind("postinit",function(a){a.refresh()}),uploader.init(),uploader.bind("FilesAdded",function(b,c){a("#media-upload-error").empty(),uploadStart(),plupload.each(c,function(a){fileQueued(a)}),b.refresh(),b.start()}),uploader.bind("UploadFile",function(a,b){fileUploading(a,b)}),uploader.bind("UploadProgress",function(a,b){uploadProgress(a,b)}),uploader.bind("Error",function(a,c){var d=c.file&&c.file.type&&0===c.file.type.indexOf("image/"),e=c&&c.status;return 500===e&&d?void b(a,c):(uploadError(c.file,c.code,c.message,a),void a.refresh())}),uploader.bind("FileUploaded",function(a,b,c){uploadSuccess(b,c.response)}),uploader.bind("UploadComplete",function(){uploadComplete()}),uploader.bind("BeforeUpload",function(a,b){b.type&&0===b.type.indexOf("image/")?a.settings.multipart_params._wp_temp_image_ref=b.id:unset(a.settings.multipart_params._wp_temp_image_ref)})},"object"==typeof wpUploaderInit&&uploader_init()}); \ No newline at end of file +function fileQueued(a){jQuery(".media-blank").remove();var b=jQuery("#media-items").children(),c=post_id||0;1==b.length&&b.removeClass("open").find(".slidetoggle").slideUp(200),jQuery('
').attr("id","media-item-"+a.id).addClass("child-of-"+c).append('
0%
',jQuery('
').text(" "+a.name)).appendTo(jQuery("#media-items")),jQuery("#insert-gallery").prop("disabled",!0)}function uploadStart(){try{"undefined"!=typeof topWin.tb_remove&&topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}catch(a){}return!0}function uploadProgress(a,b){var c=jQuery("#media-item-"+b.id);jQuery(".bar",c).width(200*b.loaded/b.size),jQuery(".percent",c).html(b.percent+"%")}function fileUploading(a,b){var c=104857600,d=parseInt(a.settings.max_file_size,10);d>c&&b.size>c&&setTimeout(function(){b.status<3&&0===b.loaded&&(wpFileError(b,pluploadL10n.big_upload_failed.replace("%1$s",'').replace("%2$s","")),a.stop(),a.removeFile(b),a.start())},1e4)}function updateMediaForm(){var a=jQuery("#media-items").children();1==a.length?(a.addClass("open").find(".slidetoggle").show(),jQuery(".insert-gallery").hide()):a.length>1&&(a.removeClass("open"),jQuery(".insert-gallery").show()),a.not(".media-blank").length>0?jQuery(".savebutton").show():jQuery(".savebutton").hide()}function uploadSuccess(a,b){var c=jQuery("#media-item-"+a.id);return"string"==typeof b&&(b=b.replace(/^
(\d+)<\/pre>$/,"$1"),/media-upload-error|error-div/.test(b))?void c.html(b):(c.find(".percent").html(pluploadL10n.crunching),prepareMediaItem(a,b),updateMediaForm(),void(post_id&&c.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)))}function setResize(a){a?window.resize_width&&window.resize_height?uploader.settings.resize={enabled:!0,width:window.resize_width,height:window.resize_height,quality:100}:uploader.settings.multipart_params.image_resize=!0:delete uploader.settings.multipart_params.image_resize}function prepareMediaItem(a,b){var c="undefined"==typeof shortform?1:2,d=jQuery("#media-item-"+a.id);2==c&&shortform>2&&(c=shortform);try{"undefined"!=typeof topWin.tb_remove&&topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}catch(e){}isNaN(b)||!b?(d.append(b),prepareMediaItemInit(a)):d.load("async-upload.php",{attachment_id:b,fetch:c},function(){prepareMediaItemInit(a),updateMediaForm()})}function prepareMediaItemInit(a){var b=jQuery("#media-item-"+a.id);jQuery(".thumbnail",b).clone().attr("class","pinkynail toggle").prependTo(b),jQuery(".filename.original",b).replaceWith(jQuery(".filename.new",b)),jQuery("a.delete",b).click(function(){return jQuery.ajax({url:ajaxurl,type:"post",success:deleteSuccess,error:deleteError,id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}}),!1}),jQuery("a.undo",b).click(function(){return jQuery.ajax({url:ajaxurl,type:"post",id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(){var b,c=jQuery("#media-item-"+a.id);(b=jQuery("#type-of-"+a.id).val())&&jQuery("#"+b+"-counter").text(jQuery("#"+b+"-counter").text()-0+1),post_id&&c.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1),jQuery(".filename .trashnotice",c).remove(),jQuery(".filename .title",c).css("font-weight","normal"),jQuery("a.undo",c).addClass("hidden"),jQuery(".menu_order_input",c).show(),c.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:!1,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}}),!1}),jQuery("#media-item-"+a.id+".startopen").removeClass("startopen").addClass("open").find("slidetoggle").fadeIn()}function wpQueueError(a){jQuery("#media-upload-error").show().html('

'+a+"

")}function wpFileError(a,b){itemAjaxError(a.id,b)}function itemAjaxError(a,b){var c=jQuery("#media-item-"+a),d=c.find(".filename").text(),e=c.data("last-err");e!=a&&c.html('
'+pluploadL10n.dismiss+""+pluploadL10n.error_uploading.replace("%s",jQuery.trim(d))+" "+b+"
").data("last-err",a)}function deleteSuccess(a){var b,c,d;return"-1"==a?itemAjaxError(this.id,"You do not have permission. Has your session expired?"):"0"==a?itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?"):(c=this.id,d=jQuery("#media-item-"+c),(b=jQuery("#type-of-"+c).val())&&jQuery("#"+b+"-counter").text(jQuery("#"+b+"-counter").text()-1),post_id&&d.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1),1==jQuery("form.type-form #media-items").children().length&&jQuery(".hidden","#media-items").length>0&&(jQuery(".toggle").toggle(),jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")),jQuery(".toggle",d).toggle(),jQuery(".slidetoggle",d).slideUp(200).siblings().removeClass("hidden"),d.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:!1,duration:500}).addClass("undo"),jQuery(".filename:empty",d).remove(),jQuery(".filename .title",d).css("font-weight","bold"),jQuery(".filename",d).append(' '+pluploadL10n.deleted+" ").siblings("a.toggle").hide(),jQuery(".filename",d).append(jQuery("a.undo",d).removeClass("hidden")),void jQuery(".menu_order_input",d).hide())}function deleteError(){}function uploadComplete(){jQuery("#insert-gallery").prop("disabled",!1)}function switchUploader(a){a?(deleteUserSetting("uploader"),jQuery(".media-upload-form").removeClass("html-uploader"),"object"==typeof uploader&&uploader.refresh()):(setUserSetting("uploader","1"),jQuery(".media-upload-form").addClass("html-uploader"))}function uploadError(a,b,c,d){var e,f=104857600;switch(b){case plupload.FAILED:wpFileError(a,pluploadL10n.upload_failed);break;case plupload.FILE_EXTENSION_ERROR:wpFileExtensionError(d,a,pluploadL10n.invalid_filetype);break;case plupload.FILE_SIZE_ERROR:uploadSizeError(d,a);break;case plupload.IMAGE_FORMAT_ERROR:wpFileError(a,pluploadL10n.not_an_image);break;case plupload.IMAGE_MEMORY_ERROR:wpFileError(a,pluploadL10n.image_memory_exceeded);break;case plupload.IMAGE_DIMENSIONS_ERROR:wpFileError(a,pluploadL10n.image_dimensions_exceeded);break;case plupload.GENERIC_ERROR:wpQueueError(pluploadL10n.upload_failed);break;case plupload.IO_ERROR:e=parseInt(d.settings.filters.max_file_size,10),e>f&&a.size>f?wpFileError(a,pluploadL10n.big_upload_failed.replace("%1$s",'').replace("%2$s","")):wpQueueError(pluploadL10n.io_error);break;case plupload.HTTP_ERROR:wpQueueError(pluploadL10n.http_error);break;case plupload.INIT_ERROR:jQuery(".media-upload-form").addClass("html-uploader");break;case plupload.SECURITY_ERROR:wpQueueError(pluploadL10n.security_error);break;default:wpFileError(a,pluploadL10n.default_error)}}function uploadSizeError(a,b){var c,d;c=pluploadL10n.file_exceeds_size_limit.replace("%s",b.name),d=jQuery("
").attr({id:"media-item-"+b.id,"class":"media-item error"}).append(jQuery("

").text(c)),jQuery("#media-items").append(d),a.removeFile(b)}function wpFileExtensionError(a,b,c){jQuery("#media-items").append('

'+c+"

"),a.removeFile(b)}var topWin=window.dialogArguments||opener||parent||top,uploader,uploader_init;jQuery(document).ready(function(a){var b,c={};a(".media-upload-form").bind("click.uploader",function(b){var c,d,e=a(b.target);e.is('input[type="radio"]')?(c=e.closest("tr"),c.hasClass("align")?setUserSetting("align",e.val()):c.hasClass("image-size")&&setUserSetting("imgsize",e.val())):e.is("button.button")?(d=b.target.className||"",d=d.match(/url([^ '"]+)/),d&&d[1]&&(setUserSetting("urlbutton",d[1]),e.siblings(".urlfield").val(e.data("link-url")))):e.is("a.dismiss")?e.parents(".media-item").fadeOut(200,function(){a(this).remove()}):e.is(".upload-flash-bypass a")||e.is("a.uploader-html")?(a("#media-items, p.submit, span.big-file-warning").css("display","none"),switchUploader(0),b.preventDefault()):e.is(".upload-html-bypass a")?(a("#media-items, p.submit, span.big-file-warning").css("display",""),switchUploader(1),b.preventDefault()):e.is("a.describe-toggle-on")?(e.parent().addClass("open"),e.siblings(".slidetoggle").fadeIn(250,function(){var b,c,d=a(window).scrollTop(),e=a(window).height(),f=a(this).offset().top,g=a(this).height();e&&f&&g&&(b=f+g,c=d+e,b>c&&(b-c4?(a.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:_wpPluploadSettings.defaults.multipart_params._wpnonce,_wp_temp_image_ref:g.id,_wp_upload_failed_cleanup:!0}}),void wpQueueError(e.message&&500!==e.status?e.message:pluploadL10n.http_error_image)):(f?c[g.id]=++f:c[g.id]=1,void a.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:wpUploaderInit.multipart_params._wpnonce,_wp_temp_image_ref:g.id,_legasy_support:"true"}}).done(function(a){var b;a.success?uploadSuccess(g,a.data.id):(a.data&&a.data.message&&(b=a.data.message),wpQueueError(b||pluploadL10n.http_error_image))}).fail(function(a){return 500===a.status?void b(d,e):void wpQueueError(pluploadL10n.http_error_image)}))):void wpQueueError(e.message||pluploadL10n.default_error)},uploader_init=function(){uploader=new plupload.Uploader(wpUploaderInit),a("#image_resize").bind("change",function(){var b=a(this).prop("checked");setResize(b),b?setUserSetting("upload_resize","1"):deleteUserSetting("upload_resize")}),uploader.bind("Init",function(b){var c=a("#plupload-upload-ui");setResize(getUserSetting("upload_resize",!1)),b.features.dragdrop&&!a(document.body).hasClass("mobile")?(c.addClass("drag-drop"),a("#drag-drop-area").on("dragover.wp-uploader",function(){c.addClass("drag-over")}).on("dragleave.wp-uploader, drop.wp-uploader",function(){c.removeClass("drag-over")})):(c.removeClass("drag-drop"),a("#drag-drop-area").off(".wp-uploader")),"html4"===b.runtime&&a(".upload-flash-bypass").hide()}),uploader.bind("postinit",function(a){a.refresh()}),uploader.init(),uploader.bind("FilesAdded",function(b,c){a("#media-upload-error").empty(),uploadStart(),plupload.each(c,function(a){fileQueued(a)}),b.refresh(),b.start()}),uploader.bind("UploadFile",function(a,b){fileUploading(a,b)}),uploader.bind("UploadProgress",function(a,b){uploadProgress(a,b)}),uploader.bind("Error",function(a,c){var d=c.file&&c.file.type&&0===c.file.type.indexOf("image/"),e=c&&c.status;return 500===e&&d?void b(a,c):(uploadError(c.file,c.code,c.message,a),void a.refresh())}),uploader.bind("FileUploaded",function(a,b,c){uploadSuccess(b,c.response)}),uploader.bind("UploadComplete",function(){uploadComplete()}),uploader.bind("BeforeUpload",function(a,b){b.type&&0===b.type.indexOf("image/")?a.settings.multipart_params._wp_temp_image_ref=b.id:a.settings.multipart_params._wp_temp_image_ref=""})},"object"==typeof wpUploaderInit&&uploader_init()}); \ No newline at end of file diff --git a/wp-includes/js/plupload/wp-plupload.js b/wp-includes/js/plupload/wp-plupload.js index 3200f316ac..7677cc66ea 100644 --- a/wp-includes/js/plupload/wp-plupload.js +++ b/wp-includes/js/plupload/wp-plupload.js @@ -326,7 +326,7 @@ window.wp = window.wp || {}; if ( file.type && file.type.indexOf( 'image/' ) === 0 ) { up.settings.multipart_params._wp_temp_image_ref = file.id; } else { - unset( up.settings.multipart_params._wp_temp_image_ref ); + up.settings.multipart_params._wp_temp_image_ref = ''; } } ); diff --git a/wp-includes/js/plupload/wp-plupload.min.js b/wp-includes/js/plupload/wp-plupload.min.js index f3c18228e6..1a18ba5588 100644 --- a/wp-includes/js/plupload/wp-plupload.min.js +++ b/wp-includes/js/plupload/wp-plupload.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a,b){var c;"undefined"!=typeof _wpPluploadSettings&&(c=function(a){var d,e,f,g,h=this,i={container:"container",browser:"browse_button",dropzone:"drop_element"},j={};if(this.supports={upload:c.browser.supported},this.supported=this.supports.upload,this.supported){this.plupload=b.extend(!0,{multipart_params:{}},c.defaults),this.container=document.body,b.extend(!0,this,a);for(e in this)b.isFunction(this[e])&&(this[e]=b.proxy(this[e],this));for(e in i)this[e]&&(this[e]=b(this[e]).first(),this[e].length?(this[e].prop("id")||this[e].prop("id","__wp-uploader-id-"+c.uuid++),this.plupload[i[e]]=this[e].prop("id")):delete this[e]);(this.browser&&this.browser.length||this.dropzone&&this.dropzone.length)&&(this.uploader=new plupload.Uploader(this.plupload),delete this.plupload,this.param(this.params||{}),delete this.params,d=function(a,c,e){var i;return e&&e.id?(i=j[e.id],i&&i>4?(b.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:_wpPluploadSettings.defaults.multipart_params._wpnonce,_wp_temp_image_ref:e.id,_wp_upload_failed_cleanup:!0}}),void f(a,c,e,"no-retry")):(i?j[e.id]=++i:j[e.id]=1,void b.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:_wpPluploadSettings.defaults.multipart_params._wpnonce,_wp_temp_image_ref:e.id}}).done(function(b){b.success?g(h.uploader,e,b):(b.data&&b.data.message&&(a=b.data.message),f(a,c,e,"no-retry"))}).fail(function(b){return 500===b.status?void d(a,c,e):void f(a,c,e,"no-retry")}))):void f(pluploadL10n.upload_failed,c,e,"no-retry")},f=function(a,b,e,f){var g=e.type&&0===e.type.indexOf("image/"),i=b&&b.status;return"no-retry"!==f&&500===i&&g?void d(a,b,e):(e.attachment&&e.attachment.destroy(),c.errors.unshift({message:a||pluploadL10n.default_error,data:b,file:e}),void h.error(a,b,e))},g=function(a,b,d){var e;_.each(["file","loaded","size","percent"],function(a){b.attachment.unset(a)}),b.attachment.set(_.extend(d.data,{uploading:!1})),wp.media.model.Attachment.get(d.data.id,b.attachment),e=c.queue.all(function(a){return!a.get("uploading")}),e&&c.queue.reset(),h.success(b.attachment)},this.uploader.bind("init",function(a){var d,e,f,g=h.dropzone;if(f=h.supports.dragdrop=a.features.dragdrop&&!c.browser.mobile,g){if(g.toggleClass("supports-drag-drop",!!f),!f)return g.unbind(".wp-uploader");g.bind("dragover.wp-uploader",function(){d&&clearTimeout(d),e||(g.trigger("dropzone:enter").addClass("drag-over"),e=!0)}),g.bind("dragleave.wp-uploader, drop.wp-uploader",function(){d=setTimeout(function(){e=!1,g.trigger("dropzone:leave").removeClass("drag-over")},0)}),h.ready=!0,b(h).trigger("uploader:ready")}}),this.uploader.bind("postinit",function(a){a.refresh(),h.init()}),this.uploader.init(),this.browser?this.browser.on("mouseenter",this.refresh):(this.uploader.disableBrowse(!0),b("#"+this.uploader.id+"_html5_container").hide()),this.uploader.bind("BeforeUpload",function(a,b){b.type&&0===b.type.indexOf("image/")?a.settings.multipart_params._wp_temp_image_ref=b.id:unset(a.settings.multipart_params._wp_temp_image_ref)}),this.uploader.bind("FilesAdded",function(a,b){_.each(b,function(a){var b,d;plupload.FAILED!==a.status&&(b=_.extend({file:a,uploading:!0,date:new Date,filename:a.name,menuOrder:0,uploadedTo:wp.media.model.settings.post.id},_.pick(a,"loaded","size","percent")),d=/(?:jpe?g|png|gif)$/i.exec(a.name),d&&(b.type="image",b.subtype="jpg"===d[0]?"jpeg":d[0]),a.attachment=wp.media.model.Attachment.create(b),c.queue.add(a.attachment),h.added(a.attachment))}),a.refresh(),a.start()}),this.uploader.bind("UploadProgress",function(a,b){b.attachment.set(_.pick(b,"loaded","percent")),h.progress(b.attachment)}),this.uploader.bind("FileUploaded",function(a,b,c){try{c=JSON.parse(c.response)}catch(d){return f(pluploadL10n.default_error,d,b)}return!_.isObject(c)||_.isUndefined(c.success)?f(pluploadL10n.default_error,null,b):c.success?void g(a,b,c):f(c.data&&c.data.message,c.data,b)}),this.uploader.bind("Error",function(a,b){var d,e=pluploadL10n.default_error;for(d in c.errorMap)if(b.code===plupload[d]){e=c.errorMap[d],_.isFunction(e)&&(e=e(b.file,b));break}f(e,b,b.file),a.refresh()}))}},b.extend(c,_wpPluploadSettings),c.uuid=0,c.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,SECURITY_ERROR:pluploadL10n.security_error,FILE_SIZE_ERROR:function(a){return pluploadL10n.file_exceeds_size_limit.replace("%s",a.name)},HTTP_ERROR:function(a){return a.type&&0===a.type.indexOf("image/")?pluploadL10n.http_error_image:pluploadL10n.http_error}},b.extend(c.prototype,{param:function(a,c){return 1===arguments.length&&"string"==typeof a?this.uploader.settings.multipart_params[a]:void(arguments.length>1?this.uploader.settings.multipart_params[a]=c:b.extend(this.uploader.settings.multipart_params,a))},init:function(){},error:function(){},success:function(){},added:function(){},progress:function(){},complete:function(){},refresh:function(){var a,c,d,e;if(this.browser){for(a=this.browser[0];a;){if(a===document.body){c=!0;break}a=a.parentNode}c||(e="wp-uploader-browser-"+this.uploader.id,d=b("#"+e),d.length||(d=b('
').css({position:"fixed",top:"-1000px",left:"-1000px",height:0,width:0}).attr("id","wp-uploader-browser-"+this.uploader.id).appendTo("body")),d.append(this.browser))}this.uploader.refresh()}}),c.queue=new wp.media.model.Attachments([],{query:!1}),c.errors=new Backbone.Collection,a.Uploader=c)}(wp,jQuery); \ No newline at end of file +window.wp=window.wp||{},function(a,b){var c;"undefined"!=typeof _wpPluploadSettings&&(c=function(a){var d,e,f,g,h=this,i={container:"container",browser:"browse_button",dropzone:"drop_element"},j={};if(this.supports={upload:c.browser.supported},this.supported=this.supports.upload,this.supported){this.plupload=b.extend(!0,{multipart_params:{}},c.defaults),this.container=document.body,b.extend(!0,this,a);for(e in this)b.isFunction(this[e])&&(this[e]=b.proxy(this[e],this));for(e in i)this[e]&&(this[e]=b(this[e]).first(),this[e].length?(this[e].prop("id")||this[e].prop("id","__wp-uploader-id-"+c.uuid++),this.plupload[i[e]]=this[e].prop("id")):delete this[e]);(this.browser&&this.browser.length||this.dropzone&&this.dropzone.length)&&(this.uploader=new plupload.Uploader(this.plupload),delete this.plupload,this.param(this.params||{}),delete this.params,d=function(a,c,e){var i;return e&&e.id?(i=j[e.id],i&&i>4?(b.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:_wpPluploadSettings.defaults.multipart_params._wpnonce,_wp_temp_image_ref:e.id,_wp_upload_failed_cleanup:!0}}),void f(a,c,e,"no-retry")):(i?j[e.id]=++i:j[e.id]=1,void b.ajax({type:"post",url:ajaxurl,dataType:"json",data:{action:"media-create-image-subsizes",_wpnonce:_wpPluploadSettings.defaults.multipart_params._wpnonce,_wp_temp_image_ref:e.id}}).done(function(b){b.success?g(h.uploader,e,b):(b.data&&b.data.message&&(a=b.data.message),f(a,c,e,"no-retry"))}).fail(function(b){return 500===b.status?void d(a,c,e):void f(a,c,e,"no-retry")}))):void f(pluploadL10n.upload_failed,c,e,"no-retry")},f=function(a,b,e,f){var g=e.type&&0===e.type.indexOf("image/"),i=b&&b.status;return"no-retry"!==f&&500===i&&g?void d(a,b,e):(e.attachment&&e.attachment.destroy(),c.errors.unshift({message:a||pluploadL10n.default_error,data:b,file:e}),void h.error(a,b,e))},g=function(a,b,d){var e;_.each(["file","loaded","size","percent"],function(a){b.attachment.unset(a)}),b.attachment.set(_.extend(d.data,{uploading:!1})),wp.media.model.Attachment.get(d.data.id,b.attachment),e=c.queue.all(function(a){return!a.get("uploading")}),e&&c.queue.reset(),h.success(b.attachment)},this.uploader.bind("init",function(a){var d,e,f,g=h.dropzone;if(f=h.supports.dragdrop=a.features.dragdrop&&!c.browser.mobile,g){if(g.toggleClass("supports-drag-drop",!!f),!f)return g.unbind(".wp-uploader");g.bind("dragover.wp-uploader",function(){d&&clearTimeout(d),e||(g.trigger("dropzone:enter").addClass("drag-over"),e=!0)}),g.bind("dragleave.wp-uploader, drop.wp-uploader",function(){d=setTimeout(function(){e=!1,g.trigger("dropzone:leave").removeClass("drag-over")},0)}),h.ready=!0,b(h).trigger("uploader:ready")}}),this.uploader.bind("postinit",function(a){a.refresh(),h.init()}),this.uploader.init(),this.browser?this.browser.on("mouseenter",this.refresh):(this.uploader.disableBrowse(!0),b("#"+this.uploader.id+"_html5_container").hide()),this.uploader.bind("BeforeUpload",function(a,b){b.type&&0===b.type.indexOf("image/")?a.settings.multipart_params._wp_temp_image_ref=b.id:a.settings.multipart_params._wp_temp_image_ref=""}),this.uploader.bind("FilesAdded",function(a,b){_.each(b,function(a){var b,d;plupload.FAILED!==a.status&&(b=_.extend({file:a,uploading:!0,date:new Date,filename:a.name,menuOrder:0,uploadedTo:wp.media.model.settings.post.id},_.pick(a,"loaded","size","percent")),d=/(?:jpe?g|png|gif)$/i.exec(a.name),d&&(b.type="image",b.subtype="jpg"===d[0]?"jpeg":d[0]),a.attachment=wp.media.model.Attachment.create(b),c.queue.add(a.attachment),h.added(a.attachment))}),a.refresh(),a.start()}),this.uploader.bind("UploadProgress",function(a,b){b.attachment.set(_.pick(b,"loaded","percent")),h.progress(b.attachment)}),this.uploader.bind("FileUploaded",function(a,b,c){try{c=JSON.parse(c.response)}catch(d){return f(pluploadL10n.default_error,d,b)}return!_.isObject(c)||_.isUndefined(c.success)?f(pluploadL10n.default_error,null,b):c.success?void g(a,b,c):f(c.data&&c.data.message,c.data,b)}),this.uploader.bind("Error",function(a,b){var d,e=pluploadL10n.default_error;for(d in c.errorMap)if(b.code===plupload[d]){e=c.errorMap[d],_.isFunction(e)&&(e=e(b.file,b));break}f(e,b,b.file),a.refresh()}))}},b.extend(c,_wpPluploadSettings),c.uuid=0,c.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,SECURITY_ERROR:pluploadL10n.security_error,FILE_SIZE_ERROR:function(a){return pluploadL10n.file_exceeds_size_limit.replace("%s",a.name)},HTTP_ERROR:function(a){return a.type&&0===a.type.indexOf("image/")?pluploadL10n.http_error_image:pluploadL10n.http_error}},b.extend(c.prototype,{param:function(a,c){return 1===arguments.length&&"string"==typeof a?this.uploader.settings.multipart_params[a]:void(arguments.length>1?this.uploader.settings.multipart_params[a]=c:b.extend(this.uploader.settings.multipart_params,a))},init:function(){},error:function(){},success:function(){},added:function(){},progress:function(){},complete:function(){},refresh:function(){var a,c,d,e;if(this.browser){for(a=this.browser[0];a;){if(a===document.body){c=!0;break}a=a.parentNode}c||(e="wp-uploader-browser-"+this.uploader.id,d=b("#"+e),d.length||(d=b('
').css({position:"fixed",top:"-1000px",left:"-1000px",height:0,width:0}).attr("id","wp-uploader-browser-"+this.uploader.id).appendTo("body")),d.append(this.browser))}this.uploader.refresh()}}),c.queue=new wp.media.model.Attachments([],{query:!1}),c.errors=new Backbone.Collection,a.Uploader=c)}(wp,jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 7647756cf5..9db088a52d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46080'; +$wp_version = '5.3-alpha-46081'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.