Ticket #24455: 24455.patch
File 24455.patch, 6.2 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-editor.php
397 397 398 398 $body_class = $editor_id; 399 399 400 if ( $post = get_post() ) {400 if ( $post = get_post() ) 401 401 $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); 402 if ( post_type_supports( $post->post_type, 'post-formats' ) ) {403 $post_format = get_post_format( $post );404 if ( $post_format && ! is_wp_error( $post_format ) )405 $body_class .= ' post-format-' . sanitize_html_class( $post_format );406 else407 $body_class .= ' post-format-standard';408 }409 }410 402 411 403 if ( !empty($set['tinymce']['body_class']) ) { 412 404 $body_class .= ' ' . $set['tinymce']['body_class']; -
wp-includes/js/autosave.js
304 304 (function($){ 305 305 // Returns the data for saving in both localStorage and autosaves to the server 306 306 wp.autosave.getPostData = function() { 307 var ed = typeof tinymce != 'undefined' ? tinymce.activeEditor : null, post_name, parent_id, post_format,cats = [],307 var ed = typeof tinymce != 'undefined' ? tinymce.activeEditor : null, post_name, parent_id, cats = [], 308 308 data = { 309 309 action: 'autosave', 310 310 autosave: true, … … 363 363 if ( $('#auto_draft').val() == '1' ) 364 364 data['auto_draft'] = '1'; 365 365 366 post_format = $('#post_format').val() || '';367 data['post_format'] = post_format == 'standard' ? '' : post_format;368 369 $('.post-formats-fields').find('input[name^="_format_"], textarea[name^="_format_"]').each( function(i, field) {370 data[ field.name ] = field.value || '';371 });372 373 366 return data; 374 367 } 375 368 -
wp-includes/revision.php
59 59 } 60 60 61 61 /** 62 * Determines which post meta fields are revisioned.63 *64 * @since 3.665 * @access private66 *67 * @return array An array of meta keys that should be revisioned.68 */69 function _wp_post_revision_meta_keys() {70 return array(71 '_format_url',72 '_format_link_url',73 '_format_quote_source_url',74 '_format_quote_source_name',75 '_format_image',76 '_format_gallery',77 '_format_audio_embed',78 '_format_video_embed',79 );80 }81 82 /**83 62 * Saves an already existing post as a post revision. 84 63 * 85 64 * Typically used immediately after post updates. … … 129 108 break; 130 109 } 131 110 } 132 133 // Check whether revisioned meta fields have changed.134 foreach ( _wp_post_revision_meta_keys() as $meta_key ) {135 if ( get_post_meta( $post->ID, $meta_key, true ) != get_post_meta( $last_revision->ID, $meta_key, true ) ) {136 $post_has_changed = true;137 break;138 }139 }140 141 // Check whether the post format has changed142 if ( get_post_format( $post->ID ) != get_post_meta( $last_revision->ID, '_revision_post_format', true ) )143 $post_has_changed = true;144 145 111 //don't save revision if post unchanged 146 112 if( ! $post_has_changed ) 147 113 return; … … 274 240 if ( $revision_id ) 275 241 do_action( '_wp_put_post_revision', $revision_id ); 276 242 277 // Save revisioned meta fields.278 foreach ( _wp_post_revision_meta_keys() as $meta_key ) {279 $meta_value = get_post_meta( $post_id, $meta_key, true );280 if ( empty( $meta_value ) )281 continue;282 283 // Use the underlying add_metadata vs add_post_meta to make sure284 // metadata is added to the revision post and not its parent.285 add_metadata( 'post', $revision_id, $meta_key, wp_slash( $meta_value ) );286 }287 288 // Save the post format289 if ( $post_format = get_post_format( $post_id ) )290 add_metadata( 'post', $revision_id, '_revision_post_format', $post_format );291 292 243 return $revision_id; 293 244 } 294 245 … … 359 310 360 311 $update = wp_slash( $update ); //since data is from db 361 312 362 // Restore revisioned meta fields.363 foreach ( _wp_post_revision_meta_keys() as $meta_key ) {364 $meta_value = get_post_meta( $revision['ID'], $meta_key, true );365 if ( empty( $meta_value ) )366 $meta_value = '';367 // Add slashes to data pulled from the db368 update_post_meta( $update['ID'], $meta_key, wp_slash( $meta_value ) );369 }370 371 // Restore post format372 set_post_format( $update['ID'], get_post_meta( $revision['ID'], '_revision_post_format', true ) );373 374 313 $post_id = wp_update_post( $update ); 375 314 if ( ! $post_id || is_wp_error( $post_id ) ) 376 315 return $post_id; … … 505 444 $post->post_title = $preview->post_title; 506 445 $post->post_excerpt = $preview->post_excerpt; 507 446 508 add_filter( 'get_post_metadata', '_wp_preview_meta_filter', 10, 4 );509 add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );510 511 447 return $post; 512 448 } 513 449 … … 530 466 } 531 467 532 468 /** 533 * Filters post meta retrieval to get values from the actual autosave post,534 * and not its parent. Filters revisioned meta keys only.535 *536 * @since 3.6.0537 * @access private538 */539 function _wp_preview_meta_filter( $value, $object_id, $meta_key, $single ) {540 $post = get_post();541 542 if ( $post->ID != $object_id || ! in_array( $meta_key, _wp_post_revision_meta_keys() ) || 'revision' == $post->post_type )543 return $value;544 545 $preview = wp_get_post_autosave( $post->ID );546 if ( ! is_object( $preview ) )547 return $value;548 549 return get_post_meta( $preview->ID, $meta_key, $single );550 }551 552 /**553 * Filters terms lookup to get the post format saved with the preview revision.554 *555 * @since 3.6.0556 * @access private557 */558 function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {559 $post = get_post();560 561 if ( $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type )562 return $terms;563 564 if ( ! $preview = wp_get_post_autosave( $post->ID ) )565 return $terms;566 567 if ( $post_format = get_post_meta( $preview->ID, '_revision_post_format', true ) ) {568 if ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $post_format ), 'post_format' ) )569 $terms = array( $term ); // Can only have one post format570 }571 572 return $terms;573 }574 575 /**576 469 * Gets the post revision version. 577 470 * 578 471 * @since 3.6.0