wp_post_revision_title_expanded

Retrieve formatted date timestamp of a revision (linked to that revisions's page).

Description

(string|false) wp_post_revision_title_expanded( (int|object) $revision, (bool) $link = true ); 

Returns (string|false)

gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.

Parameters (2)

0. $revision (int|object)
Revision ID or revision object.
1. $link — Optional. (bool) => true
Optional, default is true. Link to revisions's page?

Usage

  1. if ( !function_exists( 'wp_post_revision_title_expanded' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-template.php'; 
  3.  
  4. // Revision ID or revision object. 
  5. $revision = null; 
  6.  
  7. // Optional, default is true. Link to revisions's page? 
  8. $link = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_post_revision_title_expanded($revision, $link); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post-template.php  
  1. function wp_post_revision_title_expanded( $revision, $link = true ) { 
  2. if ( !$revision = get_post( $revision ) ) 
  3. return $revision; 
  4.  
  5. if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) 
  6. return false; 
  7.  
  8. $author = get_the_author_meta( 'display_name', $revision->post_author ); 
  9. /** translators: revision date format, see https://secure.php.net/date */ 
  10. $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); 
  11.  
  12. $gravatar = get_avatar( $revision->post_author, 24 ); 
  13.  
  14. $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 
  15. if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) 
  16. $date = "<a href='$link'>$date</a>"; 
  17.  
  18. $revision_date_author = sprintf( 
  19. /** translators: post revision title: 1: author avatar, 2: author name, 3: time ago, 4: date */ 
  20. __( '%1$s %2$s, %3$s ago (%4$s)' ),  
  21. $gravatar,  
  22. $author,  
  23. human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ),  
  24. $date 
  25. ); 
  26.  
  27. /** translators: %s: revision date with author avatar */ 
  28. $autosavef = __( '%s [Autosave]' ); 
  29. /** translators: %s: revision date with author avatar */ 
  30. $currentf = __( '%s [Current Revision]' ); 
  31.  
  32. if ( !wp_is_post_revision( $revision ) ) 
  33. $revision_date_author = sprintf( $currentf, $revision_date_author ); 
  34. elseif ( wp_is_post_autosave( $revision ) ) 
  35. $revision_date_author = sprintf( $autosavef, $revision_date_author ); 
  36.  
  37. /** 
  38. * Filters the formatted author and date for a revision. 
  39. * @since 4.4.0 
  40. * @param string $revision_date_author The formatted string. 
  41. * @param WP_Post $revision The revision object. 
  42. * @param bool $link Whether to link to the revisions page, as passed into 
  43. * wp_post_revision_title_expanded(). 
  44. */ 
  45. return apply_filters( 'wp_post_revision_title_expanded', $revision_date_author, $revision, $link );