Changeset 23928
- Timestamp:
- 04/06/2013 11:18:52 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r23862 r23928 1280 1280 $new_autosave['post_author'] = $post_author; 1281 1281 1282 // Auto-save revisioned meta fields too.1282 // Auto-save revisioned meta fields. 1283 1283 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 1284 if ( ! isset( $_POST[ $meta_key ] ) ) 1285 continue; 1286 1287 // Use the underlying delete_metadata and add_metadata vs delete_post_meta 1288 // and add_post_meta to make sure we're working with the actual revision meta. 1289 delete_metadata( 'post', $new_autosave['ID'], $meta_key ); 1290 add_metadata( 'post', $new_autosave['ID'], $meta_key, $_POST[ $meta_key ] ); 1284 if ( isset( $_POST[ $meta_key ] ) && get_post_meta( $new_autosave['ID'], $meta_key, true ) != $_POST[ $meta_key ] ) { 1285 // Use the underlying delete_metadata and add_metadata vs delete_post_meta 1286 // and add_post_meta to make sure we're working with the actual revision meta. 1287 delete_metadata( 'post', $new_autosave['ID'], $meta_key ); 1288 1289 if ( ! empty( $_POST[ $meta_key ] ) ) 1290 add_metadata( 'post', $new_autosave['ID'], $meta_key, $_POST[ $meta_key ] ); 1291 } 1292 } 1293 1294 // Save the post format if different 1295 if ( isset( $_POST['post_format'] ) && get_post_meta( $new_autosave['ID'], '_revision_post_format', true ) != $_POST['post_format'] ) { 1296 delete_metadata( 'post', $new_autosave['ID'], '_revision_post_format' ); 1297 1298 if ( ! empty( $_POST['post_format'] ) ) 1299 add_metadata( 'post', $new_autosave['ID'], '_revision_post_format', $_POST['post_format'] ); 1291 1300 } 1292 1301 -
trunk/wp-includes/js/autosave.js
r23886 r23928 306 306 // Returns the data for saving in both localStorage and autosaves to the server 307 307 wp.autosave.getPostData = function() { 308 var ed = typeof tinymce != 'undefined' ? tinymce.activeEditor : null, post_name, parent_id, cats = [],308 var ed = typeof tinymce != 'undefined' ? tinymce.activeEditor : null, post_name, parent_id, post_format, cats = [], 309 309 data = { 310 310 action: 'autosave', … … 364 364 if ( $('#auto_draft').val() == '1' ) 365 365 data['auto_draft'] = '1'; 366 367 post_format = $('#post_format').val() || ''; 368 data['post_format'] = post_format == 'standard' ? '' : post_format; 369 370 $('.post-formats-fields').find('input[name^="_wp_format_"], textarea[name^="_wp_format_"]').each( function(i, field) { 371 data[ field.name ] = field.value || ''; 372 }); 366 373 367 374 return data; -
trunk/wp-includes/revision.php
r23898 r23928 135 135 // Check whether revisioned meta fields have changed. 136 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) ) {137 if ( get_post_meta( $post->ID, $meta_key, true ) != get_post_meta( $last_revision->ID, $meta_key, true ) ) { 138 138 $post_has_changed = true; 139 139 break; 140 140 } 141 141 } 142 143 // Check whether the post format has changed 144 if ( get_post_format( $post->ID ) != get_post_meta( $last_revision->ID, '_revision_post_format', true ) ) 145 $post_has_changed = true; 142 146 143 147 //don't save revision if post unchanged … … 281 285 // Save revisioned meta fields. 282 286 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 283 $meta_value s = get_post_meta( $post_id, $meta_key);284 if ( false === $meta_values)287 $meta_value = get_post_meta( $post_id, $meta_key, true ); 288 if ( empty( $meta_value ) ) 285 289 continue; 286 290 287 291 // Use the underlying add_metadata vs add_post_meta to make sure 288 292 // 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 } 293 add_metadata( 'post', $revision_id, $meta_key, wp_slash( $meta_value ) ); 294 } 295 296 // Save the post format 297 if ( $post_format = get_post_format( $post_id ) ) 298 add_metadata( 'post', $revision_id, '_revision_post_format', $post_format ); 292 299 293 300 return $revision_id; … … 367 374 // Restore revisioned meta fields. 368 375 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 } 376 $meta_value = get_post_meta( $revision['ID'], $meta_key, true ); 377 if ( empty( $meta_value ) ) 378 $meta_value = ''; 379 // Add slashes to data pulled from the db 380 update_post_meta( $update['ID'], $meta_key, wp_slash( $meta_value ) ); 381 } 382 383 // Restore post format 384 set_post_format( $update['ID'], get_post_meta( $revision['ID'], '_revision_post_format', true ) ); 377 385 378 386 $post_id = wp_update_post( $update ); … … 506 514 507 515 add_filter( 'get_post_metadata', '_wp_preview_meta_filter', 10, 4 ); 516 add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); 508 517 509 518 return $post; … … 540 549 541 550 return get_post_meta( $preview->ID, $meta_key, $single ); 551 } 552 553 /** 554 * Filters terms lookup to get the post format saved with the preview revision. 555 * 556 * @since 2.6 557 * @access private 558 */ 559 function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { 560 $post = get_post(); 561 562 if ( $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) 563 return $terms; 564 565 if ( ! $preview = wp_get_post_autosave( $post->ID ) ) 566 return $terms; 567 568 if ( $post_format = get_post_meta( $preview->ID, '_revision_post_format', true ) ) { 569 if ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $post_format ), 'post_format' ) ) 570 $terms = array( $term ); // Can only have one post format 571 } 572 573 return $terms; 542 574 } 543 575
Note: See TracChangeset
for help on using the changeset viewer.