- wp_send_json_error( array(
- 'message' => __( "You don't have permission to upload files." ),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode( array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => __( "You don't have permission to upload files." ),
+ 'filename' => $_FILES['async-upload']['name'],
+ )
}
if ( isset( $_REQUEST['post_id'] ) ) {
$post_id = $_REQUEST['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) ) {
}
if ( isset( $_REQUEST['post_id'] ) ) {
$post_id = $_REQUEST['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) ) {
- wp_send_json_error( array(
- 'message' => __( "You don't have permission to attach files to this post." ),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode( array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => __( "You don't have permission to attach files to this post." ),
+ 'filename' => $_FILES['async-upload']['name'],
+ )
if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false );
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false );
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
- wp_send_json_error( array(
- 'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode( array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
+ 'filename' => $_FILES['async-upload']['name'],
+ )
}
}
$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
if ( is_wp_error( $attachment_id ) ) {
}
}
$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
if ( is_wp_error( $attachment_id ) ) {
- wp_send_json_error( array(
- 'message' => $attachment_id->get_error_message(),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode( array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => $attachment_id->get_error_message(),
+ 'filename' => $_FILES['async-upload']['name'],
+ )