WordPress.org

Make WordPress Core

Changeset 18484


Ignore:
Timestamp:
07/29/2011 07:21:21 PM (10 years ago)
Author:
azaozz
Message:

Add SWFUpload back for plugins that queue it directly, fix some escaping in media.php, see #18206

Location:
trunk
Files:
12 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/media.dev.css

    r18406 r18484  
    169169}
    170170
     171#media-upload #media-items:empty {
     172    border: 0 none;
     173}
     174
    171175#media-upload .media-item {
    172176    border-bottom-width: 1px;
  • trunk/wp-admin/includes/media.php

    r18483 r18484  
    14391439
    14401440    $upload_action_url = admin_url('async-upload.php');
    1441 
    14421441    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    14431442
    1444     $upload_size_unit = $max_upload_size =  wp_max_upload_size();
     1443    $upload_size_unit = $max_upload_size = wp_max_upload_size();
    14451444    $sizes = array( 'KB', 'MB', 'GB' );
    1446     for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ )
     1445
     1446    for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
    14471447        $upload_size_unit /= 1024;
     1448    }
     1449
    14481450    if ( $u < 0 ) {
    14491451        $upload_size_unit = 0;
     
    14541456?>
    14551457</script>
     1458
    14561459<div id="media-upload-notice">
    14571460<?php if (isset($errors['upload_notice']) ) { ?>
     
    14591462<?php } ?>
    14601463</div>
     1464
    14611465<div id="media-upload-error">
    14621466<?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?>
     
    14841488        "short" => "1",
    14851489);
     1490
    14861491$post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params'
    14871492$p = array();
    1488 foreach ( $post_params as $param => $val )
     1493
     1494foreach ( $post_params as $param => $val ) {
     1495    $val = esc_js( $val );
    14891496    $p[] = "\t\t'$param' : '$val'";
     1497}
     1498
    14901499$post_params_str = implode( ", \n", $p );
    14911500
     
    14931502<script type="text/javascript">
    14941503//<![CDATA[
    1495 var resize_height = <?php echo get_option('large_size_h'); ?>,
    1496     resize_width = <?php echo get_option('large_size_w'); ?>;
     1504var resize_height = <?php echo get_option('large_size_h', 1024); ?>,
     1505    resize_width = <?php echo get_option('large_size_w', 1024); ?>;
    14971506
    14981507jQuery(document).ready(function($) {
     
    15031512        drop_element: 'media-upload',
    15041513        file_data_name: 'async-upload',
    1505         max_file_size: '<?php echo $max_upload_size / 1024; ?>kb',
    1506         url: '<?php echo esc_attr( $upload_action_url ); ?>',
    1507         flash_swf_url: '<?php echo includes_url('js/plupload/plupload.flash.swf'); ?>',
    1508         silverlight_xap_url: '<?php echo includes_url('js/plupload/plupload.silverlight.xap'); ?>',
     1514        max_file_size: '<?php echo round( (int) $max_upload_size / 1024 ); ?>kb',
     1515        url: '<?php echo esc_js( $upload_action_url ); ?>',
     1516        flash_swf_url: '<?php echo esc_js( includes_url('js/plupload/plupload.flash.swf') ); ?>',
     1517        silverlight_xap_url: '<?php echo esc_js( includes_url('js/plupload/plupload.silverlight.xap') ); ?>',
    15091518        filters: [
    1510             {title: '<?php _e( 'Allowed Files' ); ?>', extensions: '<?php echo apply_filters('upload_file_glob', '*'); ?>'}
     1519            {title: '<?php echo esc_js( __( 'Allowed Files' ) ); ?>', extensions: '<?php echo esc_js( apply_filters('uploader_allowed_extensions', '*') ); ?>'}
    15111520        ],
    15121521        multipart: true,
     
    15891598</div>
    15901599
    1591 <p class="media-upload-size"><?php printf( __( 'Maximum upload file size: %d%s' ), $upload_size_unit, $sizes[$u] ); ?></p>
     1600<p class="media-upload-size"><?php printf( __( 'Maximum upload file size: %d%s' ), esc_html($upload_size_unit), esc_html($sizes[$u]) ); ?></p>
    15921601<p class="howto"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p>
    15931602
     
    16341643//]]>
    16351644</script>
    1636 <div id="media-items">
    1637 <?php
     1645<div id="media-items"><?php
     1646
    16381647if ( $id ) {
    16391648    if ( !is_wp_error($id) ) {
     
    16411650        echo get_media_items( $id, $errors );
    16421651    } else {
    1643         echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div>';
     1652        echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div></div>';
    16441653        exit;
    16451654    }
    16461655}
    1647 ?>
    1648 </div>
     1656?></div>
     1657
    16491658<p class="savebutton ml-submit">
    16501659<?php submit_button( __( 'Save all changes' ), 'button', 'save', false ); ?>
  • trunk/wp-includes/js/plupload/handlers.dev.js

    r18482 r18484  
    3434}
    3535
    36 function uploadProgress(fileObj, bytesDone, bytesTotal) {
    37     // Lengthen the progress bar
     36function uploadProgress(fileObj, bytesDone, bytesTotal) { // Lengthen the progress bar
    3837    var w = jQuery('#media-items').width() - 2, item = jQuery('#media-item-' + fileObj.id);
     38
    3939    jQuery('.bar', item).width( w * bytesDone / bytesTotal );
    4040    jQuery('.percent', item).html( Math.ceil(bytesDone / bytesTotal * 100) + '%' );
     
    210210// file-specific message
    211211function wpFileError(fileObj, message) {
    212     var item = jQuery('#media-item-' + fileObj.id);
    213     var filename = jQuery('.filename', item).text();
     212    var item = jQuery('#media-item-' + fileObj.id), filename = jQuery('.filename', item).text();
    214213
    215214    item.html('<div class="error-div">'
     
    222221
    223222function itemAjaxError(id, html) {
    224     var item = jQuery('#media-item-' + id);
    225     var filename = jQuery('.filename', item).text();
     223    var item = jQuery('#media-item-' + id), filename = jQuery('.filename', item).text();
    226224
    227225    item.html('<div class="error-div">'
     
    270268}
    271269
    272 
     270// SWFUpload?
    273271function uploadComplete(fileObj) {
    274272    // If no more uploads queued, enable the submit button
    275273    if ( swfu.getStats().files_queued == 0 ) {
    276         jQuery('#cancel-upload').attr('disabled', 'disabled');
    277         jQuery('#insert-gallery').attr('disabled', '');
    278     }
    279 }
    280 
    281 
    282 // wp-specific error handlers
    283 
    284 // generic message
    285 function wpQueueError(message) {
    286     jQuery('#media-upload-error').show().text(message);
    287 }
    288 
    289 // file-specific message
    290 function wpFileError(fileObj, message) {
    291     var item = jQuery('#media-item-' + fileObj.id);
    292     var filename = jQuery('.filename', item).text();
    293 
    294     item.html('<div class="error-div">'
    295                 + '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>'
    296                 + '<strong>' + pluploadL10n.error_uploading.replace('%s', filename) + '</strong><br />'
    297                 + message
    298                 + '</div>');
    299     item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
     274        jQuery('#cancel-upload').prop('disabled', true);
     275        jQuery('#insert-gallery').prop('disabled', false);
     276    }
    300277}
    301278
    302279function switchUploader(s) {
    303280    var p = document.getElementById('flash-upload-ui'), h = document.getElementById('html-upload-ui');
     281
    304282    if ( s ) {
    305283        p.style.display = 'block';
     
    313291function dndHelper(s) {
    314292    var d = document.getElementById('dnd-helper');
     293
    315294    if ( s ) {
    316295        d.style.display = 'block';
     
    320299}
    321300
     301// SWFUpload?
    322302function swfuploadPreLoad() {
    323303    if ( !uploaderMode ) {
     
    328308}
    329309
     310// SWFUpload?
    330311function swfuploadLoadFailed() {
    331312    switchUploader(0);
  • trunk/wp-includes/js/plupload/handlers.js

    r18482 r18484  
    1 var topWin=window.dialogArguments||opener||parent||top;function fileDialogStart(){jQuery("#media-upload-error").empty()}
    2 function fileQueued(a){jQuery(".media-blank").remove();jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0&&(jQuery(".describe-toggle-on").show(),jQuery(".describe-toggle-off").hide(),jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden"));jQuery("#media-items").append('<div id="media-item-'+a.id+'" class="media-item child-of-'+post_id+'"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> '+
    3 a.name+"</div></div>");jQuery(".progress","#media-item-"+a.id).show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(){try{typeof topWin.tb_remove!="undefined"&&topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}catch(a){}return!0}
    4 function uploadProgress(a,b,c){var d=jQuery("#media-items").width()-2,a=jQuery("#media-item-"+a.id);jQuery(".bar",a).width(d*b/c);jQuery(".percent",a).html(Math.ceil(b/c*100)+"%");b==c&&jQuery(".bar",a).html('<strong class="crunching">'+pluploadL10n.crunching+"</strong>")}
    5 function updateMediaForm(){var a=jQuery("form.type-form #media-items").children(),b=jQuery("#media-items").children();a.length==1&&jQuery(".slidetoggle",a).slideDown(500).siblings().addClass("hidden").filter(".toggle").toggle();b.not(".media-blank").length>0?jQuery(".savebutton").show():jQuery(".savebutton").hide();b.length>1?jQuery(".insert-gallery").show():jQuery(".insert-gallery").hide()}
    6 function uploadSuccess(a,b){b.match("media-upload-error")?jQuery("#media-item-"+a.id).html(b):(prepareMediaItem(a,b),updateMediaForm(),jQuery("#media-item-"+a.id).hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1))}
    7 function setResize(a){jQuery("#image_resize").prop("checked",a);a?(uploader.settings.resize={width:resize_width,height:resize_height,quality:100},uploader.settings.multipart_params.image_resize=!0):(uploader.settings.resize={},uploader.settings.multipart_params.image_resize=null)}
    8 function prepareMediaItem(a,b){var c=typeof shortform=="undefined"?1:2,d=jQuery("#media-item-"+a.id);jQuery(".bar",d).remove();jQuery(".progress",d).hide();try{typeof topWin.tb_remove!="undefined"&&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()})}
    9 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.toggle",b).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var a=jQuery(window).height(),b=jQuery(this).offset().top,e=jQuery(this).height(),f;a&&b&&e&&(f=b+e,f>a&&e+48<a?window.scrollBy(0,f-a+13):f>a&&window.scrollTo(0,b-36))});jQuery(this).siblings(".toggle").andSelf().toggle();
    10 jQuery(this).siblings("a.toggle").focus();return!1});jQuery("a.delete",b).click(function(){jQuery.ajax({url:"admin-ajax.php",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=/,"")}});return!1});jQuery("a.undo",b).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,
    11 "")},success:function(){var b=jQuery("#media-item-"+a.id);(type=jQuery("#type-of-"+a.id).val())&&jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1);b.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1);jQuery(".filename .trashnotice",b).remove();jQuery(".filename .title",b).css("font-weight","normal");jQuery("a.undo",b).addClass("hidden");jQuery("a.describe-toggle-on, .menu_order_input",b).show();b.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},
    12 {queue:!1,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}});return!1});jQuery("#media-item-"+a.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function cancelUpload(){uploader.stop();jQuery.each(uploader.files,function(a,b){b.status==plupload.STOPPED&&jQuery("#media-item-"+b.id).remove()})}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}
    13 function wpFileError(a,b){var c=jQuery("#media-item-"+a.id),d=jQuery(".filename",c).text();c.html('<div class="error-div"><a class="dismiss" href="#">'+pluploadL10n.dismiss+"</a><strong>"+pluploadL10n.error_uploading.replace("%s",d)+"</strong><br />"+b+"</div>");c.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}
    14 function itemAjaxError(a,b){var c=jQuery("#media-item-"+a),d=jQuery(".filename",c).text();c.html('<div class="error-div"><a class="dismiss" href="#">'+pluploadL10n.dismiss+"</a><strong>"+pluploadL10n.error_uploading.replace("%s",d)+"</strong><br />"+b+"</div>");c.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}
    15 function deleteSuccess(a){if(a=="-1")return itemAjaxError(this.id,"You do not have permission. Has your session expired?");if(a=="0")return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?");var a=this.id,b=jQuery("#media-item-"+a);(type=jQuery("#type-of-"+a).val())&&jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1);b.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1);jQuery("form.type-form #media-items").children().length==
    16 1&&jQuery(".hidden","#media-items").length>0&&(jQuery(".toggle").toggle(),jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden"));jQuery(".toggle",b).toggle();jQuery(".slidetoggle",b).slideUp(200).siblings().removeClass("hidden");b.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:!1,duration:500}).addClass("undo");jQuery(".filename:empty",b).remove();jQuery(".filename .title",b).css("font-weight","bold");jQuery(".filename",b).append('<span class="trashnotice"> '+
    17 pluploadL10n.deleted+" </span>").siblings("a.toggle").hide();jQuery(".filename",b).append(jQuery("a.undo",b).removeClass("hidden"));jQuery(".menu_order_input",b).hide()}function deleteError(){}function uploadComplete(){swfu.getStats().files_queued==0&&(jQuery("#cancel-upload").attr("disabled","disabled"),jQuery("#insert-gallery").attr("disabled",""))}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}
    18 function wpFileError(a,b){var c=jQuery("#media-item-"+a.id),d=jQuery(".filename",c).text();c.html('<div class="error-div"><a class="dismiss" href="#">'+pluploadL10n.dismiss+"</a><strong>"+pluploadL10n.error_uploading.replace("%s",d)+"</strong><br />"+b+"</div>");c.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}
    19 function switchUploader(a){var b=document.getElementById("flash-upload-ui"),c=document.getElementById("html-upload-ui");a?(b.style.display="block",c.style.display="none"):(b.style.display="none",c.style.display="block")}function dndHelper(a){document.getElementById("dnd-helper").style.display=a?"block":"none"}function swfuploadPreLoad(){uploaderMode?switchUploader(0):switchUploader(1)}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}
    20 function uploadError(a,b){switch(b){case plupload.FAILED:wpFileError(a,pluploadL10n.upload_failed);break;case plupload.FILE_EXTENSION_ERROR:wpFileError(a,pluploadL10n.invalid_filetype);break;case plupload.FILE_SIZE_ERROR:wpFileError(a,pluploadL10n.upload_limit_exceeded);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);
    21 break;case plupload.GENERIC_ERROR:wpQueueError(pluploadL10n.upload_failed);break;case plupload.IO_ERROR:wpQueueError(pluploadL10n.io_error);break;case plupload.HTTP_ERROR:wpQueueError(pluploadL10n.http_error);break;case plupload.INIT_ERROR:switchUploader(0);jQuery(".upload-html-bypass").hide();break;case plupload.SECURITY_ERROR:wpQueueError(pluploadL10n.security_error);break;default:wpFileError(a,pluploadL10n.default_error)}}
    22 jQuery(document).ready(function(a){a('input[type="radio"]',"#media-items").live("click",function(){var b=a(this).closest("tr");a(b).hasClass("align")?setUserSetting("align",a(this).val()):a(b).hasClass("image-size")&&setUserSetting("imgsize",a(this).val())});a("button.button","#media-items").live("click",function(){var b=this.className||"";if((b=b.match(/url([^ '"]+)/))&&b[1])setUserSetting("urlbutton",b[1]),a(this).siblings(".urlfield").val(a(this).attr("title"))})});
     1var topWin=window.dialogArguments||opener||parent||top;function fileDialogStart(){jQuery("#media-upload-error").empty()}function fileQueued(a){jQuery(".media-blank").remove();if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('<div id="media-item-'+a.id+'" class="media-item child-of-'+post_id+'"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> '+a.name+"</div></div>");jQuery(".progress","#media-item-"+a.id).show();jQuery("#insert-gallery").prop("disabled",true);jQuery("#cancel-upload").prop("disabled",false)}function uploadStart(a){try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}}catch(b){}return true}function uploadProgress(e,b,d){var a=jQuery("#media-items").width()-2,c=jQuery("#media-item-"+e.id);jQuery(".bar",c).width(a*b/d);jQuery(".percent",c).html(Math.ceil(b/d*100)+"%");if(b==d){jQuery(".bar",c).html('<strong class="crunching">'+pluploadL10n.crunching+"</strong>")}}function updateMediaForm(){var b=jQuery("form.type-form #media-items").children(),a=jQuery("#media-items").children();if(b.length==1){jQuery(".slidetoggle",b).slideDown(500).siblings().addClass("hidden").filter(".toggle").toggle()}if(a.not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(a.length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(b,a){if(a.match("media-upload-error")){jQuery("#media-item-"+b.id).html(a);return}prepareMediaItem(b,a);updateMediaForm();if(jQuery("#media-item-"+b.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function setResize(a){jQuery("#image_resize").prop("checked",a);if(a){uploader.settings.resize={width:resize_width,height:resize_height,quality:100};uploader.settings.multipart_params.image_resize=true}else{uploader.settings.resize={};uploader.settings.multipart_params.image_resize=null}}function prepareMediaItem(c,a){var d=(typeof shortform=="undefined")?1:2,b=jQuery("#media-item-"+c.id);jQuery(".bar",b).remove();jQuery(".progress",b).hide();try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}}catch(g){}if(isNaN(a)||!a){b.append(a);prepareMediaItemInit(c)}else{b.load("async-upload.php",{attachment_id:a,fetch:d},function(){prepareMediaItemInit(c);updateMediaForm()})}}function prepareMediaItemInit(b){var a=jQuery("#media-item-"+b.id);jQuery(".thumbnail",a).clone().attr("class","pinkynail toggle").prependTo(a);jQuery(".filename.original",a).replaceWith(jQuery(".filename.new",a));jQuery("a.toggle",a).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var d=jQuery(window).height(),e=jQuery(this).offset().top,f=jQuery(this).height(),c;if(d&&e&&f){c=e+f;if(c>d&&(f+48)<d){window.scrollBy(0,c-d+13)}else{if(c>d){window.scrollTo(0,e-36)}}}});jQuery(this).siblings(".toggle").andSelf().toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("a.delete",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("a.undo",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(d,e){var c=jQuery("#media-item-"+b.id);if(type=jQuery("#type-of-"+b.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1)}if(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("a.describe-toggle-on, .menu_order_input",c).show();c.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:false,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}});return false});jQuery("#media-item-"+b.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function cancelUpload(){uploader.stop();jQuery.each(uploader.files,function(b,a){if(a.status==plupload.STOPPED){jQuery("#media-item-"+a.id).remove()}})}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}function wpFileError(d,c){var b=jQuery("#media-item-"+d.id),a=jQuery(".filename",b).text();b.html('<div class="error-div"><a class="dismiss" href="#">'+pluploadL10n.dismiss+"</a><strong>"+pluploadL10n.error_uploading.replace("%s",a)+"</strong><br />"+c+"</div>");b.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function itemAjaxError(d,b){var c=jQuery("#media-item-"+d),a=jQuery(".filename",c).text();c.html('<div class="error-div"><a class="dismiss" href="#">'+pluploadL10n.dismiss+"</a><strong>"+pluploadL10n.error_uploading.replace("%s",a)+"</strong><br />"+b+"</div>");c.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function deleteSuccess(b,d){if(b=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(b=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var c=this.id,a=jQuery("#media-item-"+c);if(type=jQuery("#type-of-"+c).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(a.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery(".toggle",a).toggle();jQuery(".slidetoggle",a).slideUp(200).siblings().removeClass("hidden");a.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:false,duration:500}).addClass("undo");jQuery(".filename:empty",a).remove();jQuery(".filename .title",a).css("font-weight","bold");jQuery(".filename",a).append('<span class="trashnotice"> '+pluploadL10n.deleted+" </span>").siblings("a.toggle").hide();jQuery(".filename",a).append(jQuery("a.undo",a).removeClass("hidden"));jQuery(".menu_order_input",a).hide();return}function deleteError(c,b,a){}function uploadComplete(a){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").prop("disabled",true);jQuery("#insert-gallery").prop("disabled",false)}}function switchUploader(b){var c=document.getElementById("flash-upload-ui"),a=document.getElementById("html-upload-ui");if(b){c.style.display="block";a.style.display="none"}else{c.style.display="none";a.style.display="block"}}function dndHelper(a){var b=document.getElementById("dnd-helper");if(a){b.style.display="block"}else{b.style.display="none"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(b,c,a){switch(c){case plupload.FAILED:wpFileError(b,pluploadL10n.upload_failed);break;case plupload.FILE_EXTENSION_ERROR:wpFileError(b,pluploadL10n.invalid_filetype);break;case plupload.FILE_SIZE_ERROR:wpFileError(b,pluploadL10n.upload_limit_exceeded);break;case plupload.IMAGE_FORMAT_ERROR:wpFileError(b,pluploadL10n.not_an_image);break;case plupload.IMAGE_MEMORY_ERROR:wpFileError(b,pluploadL10n.image_memory_exceeded);break;case plupload.IMAGE_DIMENSIONS_ERROR:wpFileError(b,pluploadL10n.image_dimensions_exceeded);break;case plupload.GENERIC_ERROR:wpQueueError(pluploadL10n.upload_failed);break;case plupload.IO_ERROR:wpQueueError(pluploadL10n.io_error);break;case plupload.HTTP_ERROR:wpQueueError(pluploadL10n.http_error);break;case plupload.INIT_ERROR:switchUploader(0);jQuery(".upload-html-bypass").hide();break;case plupload.SECURITY_ERROR:wpQueueError(pluploadL10n.security_error);break;default:wpFileError(b,pluploadL10n.default_error)}}jQuery(document).ready(function(a){a('input[type="radio"]',"#media-items").live("click",function(){var b=a(this).closest("tr");if(a(b).hasClass("align")){setUserSetting("align",a(this).val())}else{if(a(b).hasClass("image-size")){setUserSetting("imgsize",a(this).val())}}});a("button.button","#media-items").live("click",function(){var b=this.className||"";b=b.match(/url([^ '"]+)/);if(b&&b[1]){setUserSetting("urlbutton",b[1]);a(this).siblings(".urlfield").val(a(this).attr("title"))}})});
  • trunk/wp-includes/script-loader.php

    r18482 r18484  
    199199    $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8-20110113');
    200200
     201    $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", false, '2.2');
     202
     203    // common bits for both uploaders
     204    $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
     205   
     206    if ( empty($max_upload_size) )
     207        $max_upload_size = __('not configured');
     208   
     209    // error messagoe for both plupload and swfupload
     210    $uploader_l10n = array(
     211        'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
     212        'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
     213        'zero_byte_file' => __('This file is empty. Please try another.'),
     214        'invalid_filetype' => __('This file type is not allowed. Please try another.'),
     215        'not_an_image' => __('This file is not an image. Please try another.'),
     216        'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
     217        'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
     218        'default_error' => __('An error occurred in the upload. Please try again later.'),
     219        'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
     220        'upload_limit_exceeded' => __('You may only upload 1 file.'),
     221        'http_error' => __('HTTP error.'),
     222        'upload_failed' => __('Upload failed.'),
     223        'io_error' => __('IO error.'),
     224        'security_error' => __('Security error.'),
     225        'file_cancelled' => __('File canceled.'),
     226        'upload_stopped' => __('Upload stopped.'),
     227        'dismiss' => __('Dismiss'),
     228        'crunching' => __('Crunching&hellip;'),
     229        'deleted' => __('moved to the trash.'),
     230        'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error')
     231    );
    201232
    202233    $scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.js', false, '1.4.3.2');
     
    207238    $scripts->add( 'plupload-html4', '/wp-includes/js/plupload/plupload.html4.js', array('plupload'), '1.4.3.2');
    208239
    209     // TODO: find out if we can use the plupload.full.js (it does load browserplus)
    210     $scripts->add( 'plupload-full', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-gears', 'plupload-html4'), '1.4.3.2');
    211 
    212     $scripts->add( 'plupload-handlers', '/wp-includes/js/plupload/handlers.js', array('plupload-full', 'jquery'), '1.4.3.2');
    213    
    214     // TODO: find out if we really need this debug clause with plupload
    215     /*if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
     240    // TODO: find out if we can use the plupload.full.js, it loads browserplus init JS from Yahoo
     241    $scripts->add( 'plupload-full', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1.4.3.2');
     242
     243    $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-full', 'jquery'), '1.4.3.2');
     244    $scripts->add_script_data( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
     245
     246    // keep 'swfupload' for back-compat.
     247    $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2201-20110113');
     248    $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a');
     249    $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
     250    $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
     251
     252    if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
    216253        // queue all SWFUpload scripts that are used by default
    217254        $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
    218255    } else {
    219         $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201');
    220     }*/
    221 
    222     $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
    223     if ( empty($max_upload_size) )
    224         $max_upload_size = __('not configured');
    225 
    226     $scripts->add_script_data( 'plupload-handlers', 'pluploadL10n', array(
    227             'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
    228             'zero_byte_file' => __('This file is empty. Please try another.'),
    229             'invalid_filetype' => __('This file type is not allowed. Please try another.'),
    230             'not_an_image' => __('This file is not an image. Please try another.'),
    231             'image_memory_exceeded' => __('Memery exceeded. Please try another smaller file.'),
    232             'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
    233             'default_error' => __('An error occurred in the upload. Please try again later.'),
    234             'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
    235             'upload_limit_exceeded' => __('You may only upload 1 file.'),
    236             'http_error' => __('HTTP error.'),
    237             'upload_failed' => __('Upload failed.'),
    238             'io_error' => __('IO error.'),
    239             'security_error' => __('Security error.'),
    240             'file_cancelled' => __('File canceled.'),
    241             'upload_stopped' => __('Upload stopped.'),
    242             'dismiss' => __('Dismiss'),
    243             'crunching' => __('Crunching&hellip;'),
    244             'deleted' => __('moved to the trash.'),
    245             'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error'),
    246     ) );
     256        $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201a');
     257    }
     258
     259    $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524');
     260    $scripts->add_script_data( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
    247261
    248262    $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102');
Note: See TracChangeset for help on using the changeset viewer.