Make WordPress Core

Ticket #39108: 39108.patch

File 39108.patch, 1.2 KB (added by Junaidkbr, 6 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    27592759                wp_send_json_error();
    27602760        }
    27612761
    2762         $changes = $_REQUEST['changes'];
    2763         $post    = get_post( $id, ARRAY_A );
     2762        $changes        = $_REQUEST['changes'];
     2763        $post           = get_post( $id, ARRAY_A );
     2764        $json_data      = array();
    27642765
    27652766        if ( 'attachment' != $post['post_type'] ) {
    27662767                wp_send_json_error();
     
    27712772        }
    27722773
    27732774        if ( isset( $changes['title'] ) ) {
    2774                 $post['post_title'] = $changes['title'];
     2775                if ( isset( $changes['title'] ) ) {
     2776                        if ( ! empty( trim( $changes['title'] ) ) ) {
     2777                                $post['post_title'] = $changes['title'];
     2778                        } else {
     2779                                $attachment_url         = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid'];
     2780                                $title                          = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) );
     2781                                $post['post_title']     = $title;
     2782                                $json_data                      = $title;
     2783                        }
     2784                }
    27752785        }
    27762786
    27772787        if ( isset( $changes['caption'] ) ) {
     
    28192829                wp_update_post( $post );
    28202830        }
    28212831
    2822         wp_send_json_success();
     2832        wp_send_json_success( $json_data );
    28232833}
    28242834
    28252835/**