Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_save_post_revision_check_for_changes

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
93      if ( $revisions = wp_get_post_revisions( $post_id ) ) {
94           // grab the last revision, but not an autosave
95           foreach ( $revisions as $revision ) {
96                if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
97                     $last_revision = $revision;
98                     break;
99                }
100           }
101
102           if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision, $post ) ) {
103                $post_has_changed = false;
104
105                foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
106                     if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) {
107                          $post_has_changed = true;
108                          break;
109                     }
110                }
111                //don't save revision if post unchanged