Changeset 23859
- Timestamp:
- 03/29/2013 10:37:44 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/revision.php
r23849 r23859 59 59 60 60 return $return; 61 } 62 63 /** 64 * Determines which post meta fields are revisioned. 65 * 66 * @since 3.6 67 * @access private 68 * @return array An array of meta keys that should be revisioned. 69 */ 70 function _wp_post_revision_meta_keys() { 71 return array( 72 '_wp_format_url', 73 '_wp_format_quote', 74 '_wp_format_quote_source', 75 '_wp_format_image', 76 '_wp_format_gallery', 77 '_wp_format_audio', 78 '_wp_format_video', 79 ); 61 80 } 62 81 … … 114 133 } 115 134 135 // Check whether revisioned meta fields have changed. 136 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 137 if ( get_post_meta( $post->ID, $meta_key ) != get_post_meta( $last_revision->ID, $meta_key ) ) { 138 $post_has_changed = true; 139 break; 140 } 141 } 142 116 143 //don't save revision if post unchanged 117 144 if( ! $post_has_changed ) … … 241 268 return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); 242 269 270 $post_id = $post['ID']; 243 271 $post = _wp_post_revision_fields( $post, $autosave ); 244 272 $post = wp_slash($post); //since data is from db … … 250 278 if ( $revision_id ) 251 279 do_action( '_wp_put_post_revision', $revision_id ); 280 281 // Save revisioned meta fields. 282 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 283 $meta_values = get_post_meta( $post_id, $meta_key ); 284 if ( false === $meta_values ) 285 continue; 286 287 // Use the underlying add_metadata vs add_post_meta to make sure 288 // metadata is added to the revision post and not its parent. 289 foreach ( $meta_values as $meta_value ) 290 add_metadata( 'post', $revision_id, $meta_key, $meta_value ); 291 } 252 292 253 293 return $revision_id; … … 324 364 325 365 $update = wp_slash( $update ); //since data is from db 366 367 // Restore revisioned meta fields. 368 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 369 delete_post_meta( $update['ID'], $meta_key ); 370 $meta_values = get_post_meta( $revision['ID'], $meta_key ); 371 if ( false === $meta_values ) 372 continue; 373 374 foreach ( $meta_values as $meta_value ) 375 add_post_meta( $update['ID'], $meta_key, $meta_value ); 376 } 326 377 327 378 $post_id = wp_update_post( $update );
Note: See TracChangeset
for help on using the changeset viewer.