661 | | * Determines if the specified post's most recent revision matches the post (by checking post_modified). |
662 | | * |
663 | | * @package WordPress |
664 | | * @subpackage Post_Revisions |
665 | | * @since 3.6.0 |
666 | | * |
667 | | * @param int|object $post Post ID or post object. |
668 | | * @return bool false if not a match, otherwise true. |
669 | | */ |
670 | | function _wp_last_revision_matches_current_post( $post ) { |
671 | | if ( ! $post = get_post( $post ) ) |
672 | | return false; |
673 | | |
674 | | if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) |
675 | | return false; |
676 | | |
677 | | foreach ( $revisions as $revision ) { |
678 | | if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) { |
679 | | $last_revision = $revision; |
680 | | break; |
681 | | } |
682 | | } |
683 | | |
684 | | // No revisions yet, only autosaves |
685 | | if ( ! isset( $last_revision ) ) |
686 | | return false; |
687 | | |
688 | | $post_has_changed = false; |
689 | | if ( $last_revision->post_modified == $post->post_modified ) { |
690 | | foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { |
691 | | if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) { |
692 | | $post_has_changed = true; |
693 | | break; |
694 | | } |
695 | | } |
696 | | } else { |
697 | | return false; |
698 | | } |
699 | | |
700 | | return ! $post_has_changed; |
701 | | } |
702 | | |
703 | | /** |