From 463e050b25e84ab53fcab73451e884dc41b69439 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 19 Sep 2019 01:26:55 +0000 Subject: [PATCH] Uploads: add helper functions for setting, getting, and deleting the temp upload reference used to the attachment_id when retrying to make image sub-sizes. See #47872. Built from https://develop.svn.wordpress.org/trunk@46174 git-svn-id: http://core.svn.wordpress.org/trunk@45986 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 21 ++++---- wp-admin/includes/file.php | 57 ++++++++++++++++++++++ wp-admin/includes/media.php | 27 +++++----- wp-includes/js/plupload/handlers.js | 8 +-- wp-includes/js/plupload/handlers.min.js | 2 +- wp-includes/js/plupload/wp-plupload.js | 8 +-- wp-includes/js/plupload/wp-plupload.min.js | 2 +- wp-includes/version.php | 2 +- 8 files changed, 88 insertions(+), 39 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 759f011b09..8d10ff731d 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -2422,21 +2422,18 @@ function wp_ajax_media_create_image_subsizes() { wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to upload files.' ) ) ); } - // Using Plupload `file.id` as ref. - if ( ! empty( $_POST['_wp_temp_image_ref'] ) ) { - $image_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $_POST['_wp_temp_image_ref'] ); + if ( ! empty( $_POST['_wp_temp_upload_ref'] ) ) { + // Uploading of images usually fails while creating the sub-sizes, either because of a timeout or out of memory. + // At this point the file has been uploaded and an attachment post created, but because of the PHP fatal error + // the cliend doesn't know the attachment ID yet. + // To be able to find the new attachment_id in these cases we temporarily store an upload reference sent by the client + // in the original upload request. It is used to save a transient with the attachment_id as value. + // That reference currently is Plupload's `file.id` but can be any sufficiently random alpha-numeric string. + $attachment_id = _wp_get_upload_ref_attachment_id( $_POST['_wp_temp_upload_ref'] ); } else { wp_send_json_error( array( 'message' => __( 'Invalid file reference.' ) ) ); } - // Uploading of images usually fails while creating the sub-sizes, either because of a timeout or out of memory. - // At this point the file has been uploaded and an attachment post created, but because of the PHP fatal error - // the cliend doesn't know the attachment ID yet. - // To be able to find the new attachment_id in these cases we temporarily store an upload reference sent by the client - // in the original upload request. It is used to save a transient with the attachment_id as value. - // That reference currently is Plupload's `file.id` but can be any sufficiently random alpha-numeric string. - $attachment_id = get_transient( '_wp_temp_image_ref:' . $image_ref ); - if ( empty( $attachment_id ) ) { wp_send_json_error( array( 'message' => __( 'Upload failed. Please reload and try again.' ) ) ); } @@ -2481,7 +2478,7 @@ function wp_ajax_media_create_image_subsizes() { } // At this point the image has been uploaded successfully. - delete_transient( '_wp_temp_image_ref:' . $image_ref ); + _wp_clear_upload_ref( $_POST['_wp_temp_upload_ref'] ); wp_send_json_success( $response ); } diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 4f04c62fbe..9d5244202e 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -978,6 +978,63 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) { return _wp_handle_upload( $file, $overrides, $time, $action ); } +/** + * Temporarily stores the client upload reference in a transient. + * + * @since 5.3.0 + * @access private + * + * @param string $upload_ref The upload reference sent by the client. + * @param int $attachment_id Attachment post ID. + * @return bool Whether the transient was set. + */ +function _wp_set_upload_ref( $upload_ref, $attachment_id ) { + $upload_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $upload_ref ); + + if ( ! empty( $upload_ref ) ) { + return set_transient( '_wp_temp_image_ref:' . $upload_ref, $attachment_id, HOUR_IN_SECONDS ); + } + + return false; +} + +/** + * Get attachment post ID from an upload reference. + * + * @since 5.3.0 + * @access private + * + * @param string $upload_ref The upload reference sent by the client. + * @return int The attachemtn post ID. Zero if the upload reference has expired or doesn't exist. + */ +function _wp_get_upload_ref_attachment_id( $upload_ref ) { + $upload_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $upload_ref ); + + if ( ! empty( $upload_ref ) ) { + return (int) get_transient( '_wp_temp_image_ref:' . $upload_ref ); + } + + return 0; +} + +/** + * Remove the transient that stores a temporary upload reference. + * + * @since 5.3.0 + * @access private + * + * @param string $upload_ref The upload reference sent by the client. + * @return bool Whether the transient was removed. + */ +function _wp_clear_upload_ref( $upload_ref ) { + $upload_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $upload_ref ); + + if ( ! empty( $upload_ref ) ) { + return delete_transient( '_wp_temp_image_ref:' . $upload_ref ); + } + + return false; +} /** * Downloads a URL to a local temporary file using the WordPress HTTP API. diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 2efe0830b5..9cab599662 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -308,13 +308,13 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid $ext = pathinfo( $name, PATHINFO_EXTENSION ); $name = wp_basename( $name, ".$ext" ); - $url = $file['url']; - $type = $file['type']; - $file = $file['file']; - $title = sanitize_text_field( $name ); - $content = ''; - $excerpt = ''; - $image_ref = false; + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = sanitize_text_field( $name ); + $content = ''; + $excerpt = ''; + $_ref = false; if ( preg_match( '#^audio#', $type ) ) { $meta = wp_read_audio_metadata( $file ); @@ -376,11 +376,6 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid // Use image exif/iptc data for title and caption defaults if possible. } elseif ( 0 === strpos( $type, 'image/' ) ) { - // Image file reference passed by the uploader. - if ( ! empty( $_POST['_wp_temp_image_ref'] ) ) { - $image_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $_POST['_wp_temp_image_ref'] ); - } - $image_meta = wp_read_image_metadata( $file ); if ( $image_meta ) { @@ -415,8 +410,8 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid if ( ! is_wp_error( $attachment_id ) ) { // If an image, keep the upload reference until all image sub-sizes are created. - if ( $image_ref ) { - set_transient( '_wp_temp_image_ref:' . $image_ref, $attachment_id, HOUR_IN_SECONDS ); + if ( ! empty( $_POST['_wp_temp_upload_ref'] ) && wp_attachment_is_image( $attachment_id ) ) { + $_ref = _wp_set_upload_ref( $_POST['_wp_temp_upload_ref'], $attachment_id ); } // The image sub-sizes are created during wp_generate_attachment_metadata(). @@ -425,8 +420,8 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid // At this point the image is uploaded successfully even if there were specific errors or some sub-sizes were not created. // The transient is not needed any more. - if ( $image_ref ) { - delete_transient( '_wp_temp_image_ref:' . $image_ref ); + if ( $_ref ) { + _wp_clear_upload_ref( $_POST['_wp_temp_upload_ref'] ); } } diff --git a/wp-includes/js/plupload/handlers.js b/wp-includes/js/plupload/handlers.js index 81d91e9f88..f225c49970 100644 --- a/wp-includes/js/plupload/handlers.js +++ b/wp-includes/js/plupload/handlers.js @@ -450,7 +450,7 @@ jQuery( document ).ready( function( $ ) { data: { action: 'media-create-image-subsizes', _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce, - _wp_temp_image_ref: file.id, + _wp_temp_upload_ref: file.id, _wp_upload_failed_cleanup: true, } }); @@ -478,7 +478,7 @@ jQuery( document ).ready( function( $ ) { data: { action: 'media-create-image-subsizes', _wpnonce: wpUploaderInit.multipart_params._wpnonce, - _wp_temp_image_ref: file.id, + _wp_temp_upload_ref: file.id, _legasy_support: 'true', } }).done( function( response ) { @@ -599,9 +599,9 @@ jQuery( document ).ready( function( $ ) { */ uploader.bind( 'BeforeUpload', function( up, file ) { if ( file.type && file.type.indexOf( 'image/' ) === 0 ) { - up.settings.multipart_params._wp_temp_image_ref = file.id; + up.settings.multipart_params._wp_temp_upload_ref = file.id; } else { - up.settings.multipart_params._wp_temp_image_ref = ''; + up.settings.multipart_params._wp_temp_upload_ref = ''; } } ); }; diff --git a/wp-includes/js/plupload/handlers.min.js b/wp-includes/js/plupload/handlers.min.js index 42799910e9..0b65ec4254 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: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_upload_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_upload_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_upload_ref=b.id:a.settings.multipart_params._wp_temp_upload_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 7677cc66ea..67e44226e6 100644 --- a/wp-includes/js/plupload/wp-plupload.js +++ b/wp-includes/js/plupload/wp-plupload.js @@ -138,7 +138,7 @@ window.wp = window.wp || {}; data: { action: 'media-create-image-subsizes', _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce, - _wp_temp_image_ref: file.id, + _wp_temp_upload_ref: file.id, _wp_upload_failed_cleanup: true, } }); @@ -161,7 +161,7 @@ window.wp = window.wp || {}; data: { action: 'media-create-image-subsizes', _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce, - _wp_temp_image_ref: file.id, // Used to find the new attachment_id. + _wp_temp_upload_ref: file.id, // Used to find the new attachment_id. } }).done( function( response ) { if ( response.success ) { @@ -324,9 +324,9 @@ window.wp = window.wp || {}; */ this.uploader.bind( 'BeforeUpload', function( up, file ) { if ( file.type && file.type.indexOf( 'image/' ) === 0 ) { - up.settings.multipart_params._wp_temp_image_ref = file.id; + up.settings.multipart_params._wp_temp_upload_ref = file.id; } else { - up.settings.multipart_params._wp_temp_image_ref = ''; + up.settings.multipart_params._wp_temp_upload_ref = ''; } } ); diff --git a/wp-includes/js/plupload/wp-plupload.min.js b/wp-includes/js/plupload/wp-plupload.min.js index 1a18ba5588..35bc3bac58 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: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_upload_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_upload_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_upload_ref=b.id:a.settings.multipart_params._wp_temp_upload_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 31ad9804b5..ef62ff64d9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46173'; +$wp_version = '5.3-alpha-46174'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.