wp/wp-admin/includes/revision.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    13  * @since 3.6.0
    13  * @since 3.6.0
    14  *
    14  *
    15  * @param WP_Post|int $post         The post object or post ID.
    15  * @param WP_Post|int $post         The post object or post ID.
    16  * @param int         $compare_from The revision ID to compare from.
    16  * @param int         $compare_from The revision ID to compare from.
    17  * @param int         $compare_to   The revision ID to come to.
    17  * @param int         $compare_to   The revision ID to come to.
    18  * @return array|bool Associative array of a post's revisioned fields and their diffs.
    18  * @return array|false Associative array of a post's revisioned fields and their diffs.
    19  *                    Or, false on failure.
    19  *                    Or, false on failure.
    20  */
    20  */
    21 function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
    21 function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
    22 	$post = get_post( $post );
    22 	$post = get_post( $post );
    23 	if ( ! $post ) {
    23 	if ( ! $post ) {
    66 
    66 
    67 	foreach ( _wp_post_revision_fields( $post ) as $field => $name ) {
    67 	foreach ( _wp_post_revision_fields( $post ) as $field => $name ) {
    68 		/**
    68 		/**
    69 		 * Contextually filter a post revision field.
    69 		 * Contextually filter a post revision field.
    70 		 *
    70 		 *
    71 		 * The dynamic portion of the hook name, `$field`, corresponds to each of the post
    71 		 * The dynamic portion of the hook name, `$field`, corresponds to a name of a
    72 		 * fields of the revision object being iterated over in a foreach statement.
    72 		 * field of the revision object.
       
    73 		 *
       
    74 		 * Possible hook names include:
       
    75 		 *
       
    76 		 *  - `_wp_post_revision_field_post_title`
       
    77 		 *  - `_wp_post_revision_field_post_content`
       
    78 		 *  - `_wp_post_revision_field_post_excerpt`
    73 		 *
    79 		 *
    74 		 * @since 3.6.0
    80 		 * @since 3.6.0
    75 		 *
    81 		 *
    76 		 * @param string  $revision_field The current revision field to compare to or from.
    82 		 * @param string  $revision_field The current revision field to compare to or from.
    77 		 * @param string  $field          The current revision field.
    83 		 * @param string  $field          The current revision field.
    84 		/** This filter is documented in wp-admin/includes/revision.php */
    90 		/** This filter is documented in wp-admin/includes/revision.php */
    85 		$content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );
    91 		$content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );
    86 
    92 
    87 		$args = array(
    93 		$args = array(
    88 			'show_split_view' => true,
    94 			'show_split_view' => true,
       
    95 			'title_left'      => __( 'Removed' ),
       
    96 			'title_right'     => __( 'Added' ),
    89 		);
    97 		);
    90 
    98 
    91 		/**
    99 		/**
    92 		 * Filters revisions text diff options.
   100 		 * Filters revisions text diff options.
    93 		 *
   101 		 *
   273 
   281 
   274 	/**
   282 	/**
   275 	 * If we only have one revision, the initial revision is missing; This happens
   283 	 * If we only have one revision, the initial revision is missing; This happens
   276 	 * when we have an autsosave and the user has clicked 'View the Autosave'
   284 	 * when we have an autsosave and the user has clicked 'View the Autosave'
   277 	 */
   285 	 */
   278 	if ( 1 === sizeof( $revisions ) ) {
   286 	if ( 1 === count( $revisions ) ) {
   279 		$revisions[ $post->ID ] = array(
   287 		$revisions[ $post->ID ] = array(
   280 			'id'         => $post->ID,
   288 			'id'         => $post->ID,
   281 			'title'      => get_the_title( $post->ID ),
   289 			'title'      => get_the_title( $post->ID ),
   282 			'author'     => $authors[ $post->post_author ],
   290 			'author'     => $authors[ $revision->post_author ],
   283 			'date'       => date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_modified ) ),
   291 			'date'       => date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_modified ) ),
   284 			'dateShort'  => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), strtotime( $post->post_modified ) ),
   292 			'dateShort'  => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), strtotime( $post->post_modified ) ),
   285 			/* translators: %s: Human-readable time difference. */
   293 			/* translators: %s: Human-readable time difference. */
   286 			'timeAgo'    => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ),
   294 			'timeAgo'    => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ),
   287 			'autosave'   => false,
   295 			'autosave'   => false,