WordPress.org

Make WordPress Core

Ticket #10715: press-this-patch.patch

File press-this-patch.patch, 1.3 KB (added by noel, 6 years ago)

This fixes titles and also the order of delete and die

  • wp-admin/press-this.php

     
    4343        // define some basic variables 
    4444        $quick['post_status'] = 'draft'; // set as draft first 
    4545        $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null; 
    46         $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : ''; 
    47         $quick['post_title'] = isset($_POST['title']) ? $_POST['title'] : ''; 
    48         $quick['post_content'] = ''; 
     46        $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null; 
     47        $quick['post_title'] = ( trim($_POST['title']) != '' ) ? $_POST['title'] : '  '; 
     48        $quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : '';  
    4949 
    5050        // insert the post with nothing in it, to get an ID 
    5151        $post_ID = wp_insert_post($quick, true); 
     
    6868        $quick['post_content'] = $content; 
    6969        // error handling for $post 
    7070        if ( is_wp_error($post_ID)) { 
     71                wp_delete_post($post_ID); 
    7172                wp_die($id); 
    72                 wp_delete_post($post_ID); 
    7373        // error handling for media_sideload 
    7474        } elseif ( is_wp_error($upload)) { 
     75                wp_delete_post($post_ID); 
    7576                wp_die($upload); 
    76                 wp_delete_post($post_ID); 
    7777        } else { 
    7878                $quick['ID'] = $post_ID; 
    7979                wp_update_post($quick);