WordPress.org

Make WordPress Core

Ticket #6243: degrade-swfupload-when-lighty-before-150.diff

File degrade-swfupload-when-lighty-before-150.diff, 4.0 KB (added by nbachiyski, 10 years ago)
  • wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js

     
    3636        SWFUpload.gracefulDegradation.swfUploadLoaded = function () {
    3737                var swfupload_container_id, swfupload_container, degraded_container_id, degraded_container, user_swfUploadLoaded_handler;
    3838                try {
     39                        if (uploadDegradeOptions.is_lighttpd_before_150) throw "Lighttpd versions earlier than 1.5.0 aren't supported!";
    3940                        swfupload_element_id = this.getSetting("swfupload_element_id");
    4041                        degraded_element_id = this.getSetting("degraded_element_id");
    4142                       
  • wp-includes/js/swfupload/handlers.js

     
    1 function uploadLoaded() {
    2         jQuery("#html-upload-ui").remove();
    3         jQuery("#flash-upload-ui").show();
    4 }
    5 
    61function fileDialogStart() {
    72        jQuery("#media-upload-error").empty();
    83}
  • wp-includes/functions.php

     
    17081708                        trigger_error( printf( __("%1$s is <strong>deprecated</strong> since version %2$s with no alternative available."), $file, $version ) );
    17091709        }
    17101710}
     1711
     1712/**
     1713 * is_lighttpd_before_150() - Is the server running earlier than 1.5.0 version of lighttpd
     1714 *
     1715 * @return bool Whether the server is running lighttpd < 1.5.0
     1716 */
     1717function is_lighttpd_before_150() {
     1718        $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
     1719        $server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
     1720        return  'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
     1721}
    17111722?>
  • wp-includes/script-loader.php

     
    8383                $this->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1');
    8484                $this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2');
    8585                $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
     86                $this->localize( 'swfupload-degrade', 'uploadDegradeOptions', array(
     87                        'is_lighttpd_before_150' => is_lighttpd_before_150(),
     88                ) );
    8689                $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
    8790                $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080301');
    8891                // these error messages came from the sample swfupload js, they might need changing.
  • wp-admin/includes/media.php

     
    804804                        file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
    805805                        swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available
    806806                        degraded_element_id : "html-upload-ui",   // when swfupload is unavailable
    807                         swfupload_loaded_handler : uploadLoaded,
    808807                        file_dialog_start_handler : fileDialogStart,
    809808                        file_queued_handler : fileQueued,
    810809                        upload_start_handler : uploadStart,
     
    834833        </p>
    835834        <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
    836835        <br class="clear" />
     836        <?php if ( is_lighttpd_before_150() ): ?>
     837        <p><?php _e('If you want to use all capabilties of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
     838        <?php endif;?>
    837839</div>
    838840<?php
    839841}