Ticket #3757: 3757b.diff
File 3757b.diff, 2.3 KB (added by , 18 years ago) |
---|
-
wp-admin/admin-functions.php
22 22 23 23 24 24 // Check for autosave collisions 25 $temp_id = false; 25 26 if ( isset($_POST['temp_ID']) ) { 26 27 $temp_id = (int) $_POST['temp_ID']; 27 28 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) … … 33 34 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write 34 35 $_POST['post_ID'] = $draft_ids[$temp_id]; 35 36 unset($_POST['temp_ID']); 36 relocate_children( $temp_id, $_POST['post_ID'] );37 37 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 38 38 return edit_post(); 39 39 } … … 112 112 add_meta( $post_ID ); 113 113 114 114 // Reunite any orphaned attachments with their parent 115 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 116 $draft_ids = array(); 117 if ( $draft_temp_id = array_search( $post_ID, $draft_ids ) ) 118 relocate_children( $draft_temp_id, $post_ID ); 119 if ( $temp_id && $temp_id != $draft_temp_id ) 120 relocate_children( $temp_id, $post_ID ); 121 115 122 // Update autosave collision detection 116 123 if ( $temp_id ) { 117 relocate_children( $temp_id, $post_ID );118 124 $draft_ids[$temp_id] = $post_ID; 119 125 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 120 126 } … … 139 145 140 146 $post = & get_post( $post_ID, ARRAY_A ); 141 147 142 $search = "#<a[^>]+rel=('|\" 148 $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie"; 143 149 144 150 // See if we have any rel="attachment" links 145 151 if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) ) 146 152 return; 147 153 148 154 $i = 0; 149 $search = "#[\s]+rel=(\"|' )(.*? )wp-att-(\d+)\\1#i";155 $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i"; 150 156 foreach ( $anchor_matches[0] as $anchor ) { 151 157 if ( 0 == preg_match( $search, $anchor, $id_matches ) ) 152 158 continue; … … 279 285 280 286 add_meta( $post_ID ); 281 287 282 wp_update_post( $_POST );288 wp_update_post( $_POST ); 283 289 290 // Reunite any orphaned attachments with their parent 291 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 292 $draft_ids = array(); 293 if ( $draft_temp_id = array_search( $post_ID, $draft_ids ) ) 294 relocate_children( $draft_temp_id, $post_ID ); 295 284 296 // Now that we have an ID we can fix any attachment anchor hrefs 285 297 fix_attachment_links( $post_ID ); 286 298