Changeset 20179 for trunk/wp-admin/includes/ajax-actions.php
- Timestamp:
- 03/15/2012 04:14:05 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r20072 r20179 1545 1545 } 1546 1546 1547 function wp_ajax_upload_attachment() { 1548 check_ajax_referer( 'media-form' ); 1549 1550 if ( ! current_user_can( 'upload_files' ) ) 1551 wp_die( -1 ); 1552 1553 if ( isset( $_REQUEST['post_id'] ) ) { 1554 $post_id = $_REQUEST['post_id']; 1555 if ( ! current_user_can( 'edit_post', $post_id ) ) 1556 wp_die( -1 ); 1557 } else { 1558 $post_id = null; 1559 } 1560 1561 $post_data = is_array( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array(); 1562 1563 $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data ); 1564 1565 if ( is_wp_error( $attachment_id ) ) { 1566 echo json_encode( array( 1567 'type' => 'error', 1568 'data' => array( 1569 'message' => $attachment_id->get_error_message(), 1570 'filename' => $_FILES['async-upload']['name'], 1571 ), 1572 ) ); 1573 wp_die(); 1574 } 1575 1576 $post = get_post( $attachment_id ); 1577 1578 echo json_encode( array( 1579 'type' => 'success', 1580 'data' => array( 1581 'id' => $attachment_id, 1582 'title' => esc_attr( $post->post_title ), 1583 'filename' => esc_html( basename( $post->guid ) ), 1584 'url' => wp_get_attachment_url( $attachment_id ), 1585 'meta' => wp_get_attachment_metadata( $attachment_id ), 1586 ), 1587 ) ); 1588 wp_die(); 1589 } 1590 1547 1591 function wp_ajax_image_editor() { 1548 1592 $attachment_id = intval($_POST['postid']);
Note: See TracChangeset
for help on using the changeset viewer.