Changeset 21814 for trunk/wp-admin/includes/ajax-actions.php
- Timestamp:
- 09/11/2012 04:55:58 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r21682 r21814 1612 1612 1613 1613 if ( ! current_user_can( 'upload_files' ) ) 1614 wp_ die( -1);1614 wp_send_json_error(); 1615 1615 1616 1616 if ( isset( $_REQUEST['post_id'] ) ) { 1617 1617 $post_id = $_REQUEST['post_id']; 1618 1618 if ( ! current_user_can( 'edit_post', $post_id ) ) 1619 wp_ die( -1);1619 wp_send_json_error(); 1620 1620 } else { 1621 1621 $post_id = null; … … 1627 1627 1628 1628 if ( is_wp_error( $attachment_id ) ) { 1629 echo json_encode( array( 1630 'type' => 'error', 1631 'data' => array( 1632 'message' => $attachment_id->get_error_message(), 1633 'filename' => $_FILES['async-upload']['name'], 1634 ), 1629 wp_send_json_error( array( 1630 'message' => $attachment_id->get_error_message(), 1631 'filename' => $_FILES['async-upload']['name'], 1635 1632 ) ); 1636 wp_die();1637 1633 } 1638 1634 … … 1645 1641 } 1646 1642 1647 $post = get_post( $attachment_id ); 1648 1649 echo json_encode( array( 1650 'type' => 'success', 1651 'data' => array( 1652 'id' => $attachment_id, 1653 'title' => esc_attr( $post->post_title ), 1654 'filename' => esc_html( basename( $post->guid ) ), 1655 'url' => wp_get_attachment_url( $attachment_id ), 1656 'meta' => wp_get_attachment_metadata( $attachment_id ), 1657 ), 1658 ) ); 1659 wp_die(); 1643 if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) 1644 wp_send_json_error(); 1645 1646 wp_send_json_success( $attachment ); 1660 1647 } 1661 1648
Note: See TracChangeset
for help on using the changeset viewer.