wp_post_revision_title

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

Description

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

Returns (string|false)

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' ) ) { 
  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($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( $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. /** translators: revision date format, see https://secure.php.net/date */ 
  9. $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); 
  10. /** translators: %s: revision date */ 
  11. $autosavef = __( '%s [Autosave]' ); 
  12. /** translators: %s: revision date */ 
  13. $currentf = __( '%s [Current Revision]' ); 
  14.  
  15. $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 
  16. if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) 
  17. $date = "<a href='$link'>$date</a>"; 
  18.  
  19. if ( !wp_is_post_revision( $revision ) ) 
  20. $date = sprintf( $currentf, $date ); 
  21. elseif ( wp_is_post_autosave( $revision ) ) 
  22. $date = sprintf( $autosavef, $date ); 
  23.  
  24. return $date;