Ticket #6813: pess-this-content-fix.patch
| File pess-this-content-fix.patch, 2.2 KB (added by azaozz, 5 years ago) |
|---|
-
wp-admin/press-this.php
20 20 $quick['post_title'] = $_REQUEST['post_title']; 21 21 $quick['post_content'] = ''; 22 22 23 $posted = str_replace('<br />', "\n", str_replace('<p>', '', $_REQUEST['content']));24 $posted = str_replace('</p>', "\n\n", $posted);25 26 23 // insert the post with nothing in it, to get an ID 27 24 $post_ID = wp_insert_post($quick, true); 28 25 … … 30 27 switch ( $_REQUEST['post_type'] ) { 31 28 case 'text': 32 29 case 'quote': 33 $content .= $ posted;30 $content .= $_REQUEST['content']; 34 31 break; 35 32 36 33 case 'photo': 37 $content = $ posted;34 $content = $_REQUEST['content']; 38 35 39 36 foreach( (array) $_REQUEST['photo_src'] as $key => $image) { 40 37 // escape quote for matching 41 38 $quoted = preg_quote2($image); 42 39 43 40 // 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 ) { 45 42 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 46 43 // Replace the POSTED content <img> with correct uploaded ones. 47 44 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); … … 53 50 case "video": 54 51 if($_REQUEST['embed_code']) 55 52 $content .= $_REQUEST['embed_code']."\n\n"; 56 $content .= $ posted;53 $content .= $_REQUEST['content']; 57 54 break; 58 55 } 59 56 // set the post_content 60 $quick['post_content'] = preg_replace("/\n\n+/", "\n\n", $content);57 $quick['post_content'] = $content; 61 58 62 59 // error handling for $post 63 60 if ( is_wp_error($post_ID)) { … … 305 302 wp_enqueue_style('press-this'); 306 303 wp_enqueue_style( 'colors' ); 307 304 wp_enqueue_script('post'); 305 wp_enqueue_script('editor_functions'); 308 306 309 307 do_action('admin_print_styles'); 310 308 do_action('admin_print_scripts'); … … 348 346 tab_focus : ":next", 349 347 plugins : "safari,inlinepopups", 350 348 entities : "38,amp,60,lt,62,gt", 351 force_p_newlines : true 349 force_p_newlines : true, 350 save_callback : 'switchEditors.saveCallback' 352 351 }); 353 352 <?php } ?> 354 353