Changeset 22845
- Timestamp:
- 11/26/2012 08:12:50 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r22843 r22845 1586 1586 1587 1587 if ( ! current_user_can( 'upload_files' ) ) 1588 wp_ send_json_error();1588 wp_die(); 1589 1589 1590 1590 if ( isset( $_REQUEST['post_id'] ) ) { 1591 1591 $post_id = $_REQUEST['post_id']; 1592 1592 if ( ! current_user_can( 'edit_post', $post_id ) ) 1593 wp_ send_json_error();1593 wp_die(); 1594 1594 } else { 1595 1595 $post_id = null; … … 1602 1602 $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false ); 1603 1603 if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { 1604 wp_send_json_error( array( 1604 echo json_encode( array( 1605 'success' => false, 1605 1606 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), 1606 1607 'filename' => $_FILES['async-upload']['name'], 1607 1608 ) ); 1609 1610 wp_die(); 1608 1611 } 1609 1612 } … … 1612 1615 1613 1616 if ( is_wp_error( $attachment_id ) ) { 1614 wp_send_json_error( array( 1617 echo json_encode( array( 1618 'success' => false, 1615 1619 'message' => $attachment_id->get_error_message(), 1616 1620 'filename' => $_FILES['async-upload']['name'], 1617 1621 ) ); 1622 1623 wp_die(); 1618 1624 } 1619 1625 … … 1627 1633 1628 1634 if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) 1629 wp_send_json_error(); 1630 1631 wp_send_json_success( $attachment ); 1635 wp_die(); 1636 1637 echo json_encode( array( 1638 'success' => true, 1639 'data' => $attachment, 1640 ) ); 1641 1642 wp_die(); 1632 1643 } 1633 1644
Note: See TracChangeset
for help on using the changeset viewer.