Ticket #6813: pess-this-content-fix.patch

File pess-this-content-fix.patch, 2.2 kB (added by azaozz, 5 months ago)
  • wp-admin/press-this.php

    old new  
    2020        $quick['post_title'] = $_REQUEST['post_title']; 
    2121        $quick['post_content'] = ''; 
    2222 
    23         $posted = str_replace('<br />', "\n", str_replace('<p>', '', $_REQUEST['content'])); 
    24         $posted = str_replace('</p>', "\n\n", $posted); 
    25  
    2623        // insert the post with nothing in it, to get an ID 
    2724        $post_ID = wp_insert_post($quick, true); 
    2825 
     
    3027        switch ( $_REQUEST['post_type'] ) { 
    3128                case 'text': 
    3229                case 'quote': 
    33                         $content .= $posted
     30                        $content .= $_REQUEST['content']
    3431                        break; 
    3532 
    3633                case 'photo': 
    37                         $content = $posted
     34                        $content = $_REQUEST['content']
    3835 
    3936                        foreach( (array) $_REQUEST['photo_src'] as $key => $image) { 
    4037                                // escape quote for matching 
    4138                                $quoted = preg_quote2($image); 
    4239 
    4340                                // see if files exist in content - we don't want to upload non-used selected files. 
    44                                 if( strpos($posted, $quoted) !== false ) { 
     41                                if( strpos($_REQUEST['content'], $quoted) !== false ) { 
    4542                                        $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 
    4643                                        // Replace the POSTED content <img> with correct uploaded ones. 
    4744                                        if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 
     
    5350                case "video": 
    5451                        if($_REQUEST['embed_code'])  
    5552                                $content .= $_REQUEST['embed_code']."\n\n"; 
    56                         $content .= $posted
     53                        $content .= $_REQUEST['content']
    5754                        break; 
    5855                } 
    5956        // set the post_content 
    60         $quick['post_content'] = preg_replace("/\n\n+/", "\n\n", $content)
     57        $quick['post_content'] = $content
    6158 
    6259        // error handling for $post 
    6360        if ( is_wp_error($post_ID)) { 
     
    305302        wp_enqueue_style('press-this'); 
    306303        wp_enqueue_style( 'colors' ); 
    307304        wp_enqueue_script('post'); 
     305        wp_enqueue_script('editor_functions'); 
    308306 
    309307        do_action('admin_print_styles'); 
    310308        do_action('admin_print_scripts'); 
     
    348346                                tab_focus : ":next", 
    349347                                plugins : "safari,inlinepopups", 
    350348                                entities : "38,amp,60,lt,62,gt", 
    351                                 force_p_newlines : true 
     349                                force_p_newlines : true, 
     350                                save_callback : 'switchEditors.saveCallback' 
    352351                        }); 
    353352    <?php } ?> 
    354353