WordPress.org

Make WordPress Core

Changeset 24397


Ignore:
Timestamp:
06/02/2013 01:29:44 AM (6 years ago)
Author:
azaozz
Message:

Remove saving of post_format in autosave and revisions, fixes #24455

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/autosave.js

    r24328 r24397  
    305305// Returns the data for saving in both localStorage and autosaves to the server
    306306wp.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 = [],
    308308        data = {
    309309            action: 'autosave',
     
    363363    if ( $('#auto_draft').val() == '1' )
    364364        data['auto_draft'] = '1';
    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     });
    372365
    373366    return data;
  • trunk/wp-includes/revision.php

    r24178 r24397  
    5757
    5858    return $return;
    59 }
    60 
    61 /**
    62  * Determines which post meta fields are revisioned.
    63  *
    64  * @since 3.6
    65  * @access private
    66  *
    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     );
    8059}
    8160
     
    130109                }
    131110            }
    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 changed
    142             if ( get_post_format( $post->ID ) != get_post_meta( $last_revision->ID, '_revision_post_format', true ) )
    143                 $post_has_changed = true;
    144 
    145111            //don't save revision if post unchanged
    146112            if( ! $post_has_changed )
     
    274240    if ( $revision_id )
    275241        do_action( '_wp_put_post_revision', $revision_id );
    276 
    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 sure
    284         // 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 format
    289     if ( $post_format = get_post_format( $post_id ) )
    290         add_metadata( 'post', $revision_id, '_revision_post_format', $post_format );
    291242
    292243    return $revision_id;
     
    360311    $update = wp_slash( $update ); //since data is from db
    361312
    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 db
    368         update_post_meta( $update['ID'], $meta_key, wp_slash( $meta_value ) );
    369     }
    370 
    371     // Restore post format
    372     set_post_format( $update['ID'], get_post_meta( $revision['ID'], '_revision_post_format', true ) );
    373 
    374313    $post_id = wp_update_post( $update );
    375314    if ( ! $post_id || is_wp_error( $post_id ) )
     
    506445    $post->post_excerpt = $preview->post_excerpt;
    507446
    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 
    511447    return $post;
    512448}
     
    528464        add_filter('the_preview', '_set_preview');
    529465    }
    530 }
    531 
    532 /**
    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.0
    537  * @access private
    538  */
    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.0
    556  * @access private
    557  */
    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 format
    570     }
    571 
    572     return $terms;
    573466}
    574467
Note: See TracChangeset for help on using the changeset viewer.