Ticket #39108: 39108.patch
File 39108.patch, 1.2 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
2759 2759 wp_send_json_error(); 2760 2760 } 2761 2761 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(); 2764 2765 2765 2766 if ( 'attachment' != $post['post_type'] ) { 2766 2767 wp_send_json_error(); … … 2771 2772 } 2772 2773 2773 2774 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 } 2775 2785 } 2776 2786 2777 2787 if ( isset( $changes['caption'] ) ) { … … 2819 2829 wp_update_post( $post ); 2820 2830 } 2821 2831 2822 wp_send_json_success( );2832 wp_send_json_success( $json_data ); 2823 2833 } 2824 2834 2825 2835 /**