Make WordPress Core

Ticket #22446: 22446.upload.diff

File 22446.upload.diff, 1.9 KB (added by koopersmith, 12 years ago)
  • wp-admin/includes/ajax-actions.php

     
    15851585        check_ajax_referer( 'media-form' );
    15861586
    15871587        if ( ! current_user_can( 'upload_files' ) )
    1588                 wp_send_json_error();
     1588                wp_die();
    15891589
    15901590        if ( isset( $_REQUEST['post_id'] ) ) {
    15911591                $post_id = $_REQUEST['post_id'];
    15921592                if ( ! current_user_can( 'edit_post', $post_id ) )
    1593                         wp_send_json_error();
     1593                        wp_die();
    15941594        } else {
    15951595                $post_id = null;
    15961596        }
     
    16011601        if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
    16021602                $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false );
    16031603                if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
    1604                         wp_send_json_error( array(
     1604                        echo json_encode( array(
     1605                                'success'  => false,
    16051606                                'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
    16061607                                'filename' => $_FILES['async-upload']['name'],
    16071608                        ) );
     1609
     1610                        wp_die();
    16081611                }
    16091612        }
    16101613
    16111614        $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
    16121615
    16131616        if ( is_wp_error( $attachment_id ) ) {
    1614                 wp_send_json_error( array(
     1617                echo json_encode( array(
     1618                        'success'  => false,
    16151619                        'message'  => $attachment_id->get_error_message(),
    16161620                        'filename' => $_FILES['async-upload']['name'],
    16171621                ) );
     1622
     1623                wp_die();
    16181624        }
    16191625
    16201626        if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
     
    16261632        }
    16271633
    16281634        if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
    1629                 wp_send_json_error();
     1635                wp_die();
    16301636
    1631         wp_send_json_success( $attachment );
     1637        echo json_encode( array(
     1638                'success' => true,
     1639                'data'    => $attachment,
     1640        ) );
     1641
     1642        wp_die();
    16321643}
    16331644
    16341645function wp_ajax_image_editor() {