Make WordPress Core

Ticket #13382: 13382.diff

File 13382.diff, 4.5 KB (added by adamsilverstein, 9 years ago)
  • wp-admin/edit-form-advanced.php

     
    178178
    179179// Detect if there exists an autosave newer than the post and if that autosave is different than the post
    180180if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
    181         foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
     181        foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
    182182                if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
    183183                        $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
    184184                        break;
  • wp-admin/includes/post.php

     
    16421642                // If the new autosave has the same content as the post, delete the autosave.
    16431643                $post = get_post( $post_id );
    16441644                $autosave_is_different = false;
    1645                 foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields() ) ) as $field ) {
     1645                foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
    16461646                        if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
    16471647                                $autosave_is_different = true;
    16481648                                break;
  • wp-admin/includes/revision.php

     
    5454
    5555        $return = array();
    5656
    57         foreach ( _wp_post_revision_fields() as $field => $name ) {
     57        foreach ( _wp_post_revision_fields( $post ) as $field => $name ) {
    5858                /**
    5959                 * Contextually filter a post revision field.
    6060                 *
  • wp-includes/revision.php

     
    1818 *
    1919 * @staticvar array $fields
    2020 *
    21  * @param array $post     Optional. A post array to be processed for insertion as a post revision.
    22  * @param bool  $autosave Optional. Is the revision an autosave?
     21 * @param array|object $post     Optional. A post array, or a WP_Post Object to be processed for insertion as a post revision.
     22 * @param bool         $autosave Optional. Is the revision an autosave?
    2323 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
    2424 */
    2525function _wp_post_revision_fields( $post = null, $autosave = false ) {
    2626        static $fields = null;
    2727
     28        if ( is_object( $post ) ) {
     29                $post = get_post( $post, ARRAY_A );
     30        }
     31
    2832        if ( is_null( $fields ) ) {
    2933                // Allow these to be versioned
    3034                $fields = array(
     
    4650                 *
    4751                 * @param array $fields List of fields to revision. Contains 'post_title',
    4852                 *                      'post_content', and 'post_excerpt' by default.
     53                 * @param array $post   A post array being processed for insertion as a post revision.
    4954                 */
    50                 $fields = apply_filters( '_wp_post_revision_fields', $fields );
     55                $fields = apply_filters( '_wp_post_revision_fields', $fields, $post );
    5156
    5257                // WP uses these internally either in versioning or elsewhere - they cannot be versioned
    5358                foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect )
     
    127132                if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) {
    128133                        $post_has_changed = false;
    129134
    130                         foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
     135                        foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) {
    131136                                if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) {
    132137                                        $post_has_changed = true;
    133138                                        break;
     
    333338                return $revision;
    334339
    335340        if ( !is_array( $fields ) )
    336                 $fields = array_keys( _wp_post_revision_fields() );
     341                $fields = array_keys( _wp_post_revision_fields( $revision ) );
    337342
    338343        $update = array();
    339344        foreach ( array_intersect( array_keys( $revision ), $fields ) as $field ) {