Source View: wp_prepare_revision_for_js

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.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

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
228            *     @type string     $timeAgo    GMT-aware amount of time ago the revision was modified.
229            *     @type bool       $autosave   Whether the revision is an autosave.
230            *     @type bool       $current    Whether the revision is both not an autosave and the post
231            *                                  modified date matches the revision modified date (GMT-aware).
232            *     @type bool|false $restoreUrl URL if the revision can be restored, false otherwise.
233            * }
234            * @param WP_Post $revision       The revision's WP_Post object.
235            * @param WP_Post $post           The revision's parent WP_Post object.
236            */
237           $revisions[ $revision->ID ] = apply_filters( 'wp_prepare_revision_for_js', $revisions_data, $revision, $post );
238      }
239
240      /**
241       * If we only have one revision, the initial revision is missing; This happens
242       * when we have an autsosave and the user has clicked 'View the Autosave'
243       */
244      if ( 1 === sizeof( $revisions ) ) {
245           $revisions[ $post->ID ] = array(
246                'id'         => $post->ID,