Changeset 30354 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 11/16/2014 05:46:35 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r30333 r30354 1834 1834 check_ajax_referer( 'media-form' ); 1835 1835 1836 if ( ! current_user_can( 'upload_files' ) ) 1837 wp_die(); 1836 if ( ! current_user_can( 'upload_files' ) ) { 1837 wp_send_json_error( array( 1838 'message' => __( "You don't have permission to upload files." ), 1839 'filename' => $_FILES['async-upload']['name'], 1840 ) ); 1841 } 1838 1842 1839 1843 if ( isset( $_REQUEST['post_id'] ) ) { 1840 1844 $post_id = $_REQUEST['post_id']; 1841 if ( ! current_user_can( 'edit_post', $post_id ) ) 1842 wp_die(); 1845 if ( ! current_user_can( 'edit_post', $post_id ) ) { 1846 wp_send_json_error( array( 1847 'message' => __( "You don't have permission to attach files to this post." ), 1848 'filename' => $_FILES['async-upload']['name'], 1849 ) ); 1850 } 1843 1851 } else { 1844 1852 $post_id = null; … … 1851 1859 $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false ); 1852 1860 if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { 1853 echo wp_json_encode( array( 1854 'success' => false, 1855 'data' => array( 1856 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), 1857 'filename' => $_FILES['async-upload']['name'], 1858 ) 1861 wp_send_json_error( array( 1862 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), 1863 'filename' => $_FILES['async-upload']['name'], 1859 1864 ) ); 1860 1861 wp_die();1862 1865 } 1863 1866 } … … 1866 1869 1867 1870 if ( is_wp_error( $attachment_id ) ) { 1868 echo wp_json_encode( array( 1869 'success' => false, 1870 'data' => array( 1871 'message' => $attachment_id->get_error_message(), 1872 'filename' => $_FILES['async-upload']['name'], 1873 ) 1871 wp_send_json_error( array( 1872 'message' => $attachment_id->get_error_message(), 1873 'filename' => $_FILES['async-upload']['name'], 1874 1874 ) ); 1875 1876 wp_die();1877 1875 } 1878 1876 … … 1888 1886 wp_die(); 1889 1887 1890 echo wp_json_encode( array( 1891 'success' => true, 1892 'data' => $attachment, 1893 ) ); 1894 1895 wp_die(); 1888 wp_send_json_success( $attachment ); 1896 1889 } 1897 1890
Note: See TracChangeset
for help on using the changeset viewer.