Making WordPress.org


Ignore:
Timestamp:
10/19/2017 12:06:14 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: Remove the upload form after a successful upload.

Make Upload_Handler::process_upload() return WP_Error on failure.

Fixes #2386.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r6025 r6045  
    4646            }
    4747
     48            $upload_result = false;
     49
    4850            if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'wporg-plugins-upload' ) && 'upload' === $_POST['action'] ) :
    4951                if ( UPLOAD_ERR_OK === $_FILES['zip_file']['error'] ) :
    50                     $uploader = new Upload_Handler;
    51                     $message  = $uploader->process_upload();
     52                    $uploader      = new Upload_Handler;
     53                    $upload_result = $uploader->process_upload();
     54
     55                    if ( is_wp_error( $upload_result ) ) {
     56                        $message = $upload_result->get_error_message();
     57                    } else {
     58                        $message = $upload_result;
     59                    }
    5260                else :
    5361                    $message = __( 'Error in file upload.', 'wporg-plugins' );
     
    119127            <?php endif; // wp_verify_nonce() && 'upload' === $_POST['action'] ?>
    120128
    121             <?php if ( ! $submitted_counts->total ) : ?>
     129            <?php if ( ! $upload_result && ! $submitted_counts->total || is_wp_error( $upload_result ) ) : ?>
    122130
    123131                <form id="upload_form" class="plugin-upload-form" enctype="multipart/form-data" method="POST" action="">
Note: See TracChangeset for help on using the changeset viewer.