wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_post_revision_title › WordPress Function

Seit2.6.0
Veraltetn/v
wp_post_revision_title ( $revision, $link = true )
Parameter: (2)
  • (int|WP_Post) $revision Revision ID or revision object.
    Erforderlich: Ja
  • (bool) $link Optional. Whether to link to revision's page. Default true.
    Erforderlich: Nein
    Standard: true
Gibt zurück:
  • (string|false) i18n formatted datetimestamp or localized 'Current Revision'.
Definiert in:
Codex:

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



Quellcode

function wp_post_revision_title( $revision, $link = true ) {
	$revision = get_post( $revision );

	if ( ! $revision ) {
		return $revision;
	}

	if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
		return false;
	}

	/* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */
	$datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
	/* translators: %s: Revision date. */
	$autosavef = __( '%s [Autosave]' );
	/* translators: %s: Revision date. */
	$currentf = __( '%s [Current Revision]' );

	$date      = date_i18n( $datef, strtotime( $revision->post_modified ) );
	$edit_link = get_edit_post_link( $revision->ID );
	if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
		$date = "<a href='$edit_link'>$date</a>";
	}

	if ( ! wp_is_post_revision( $revision ) ) {
		$date = sprintf( $currentf, $date );
	} elseif ( wp_is_post_autosave( $revision ) ) {
		$date = sprintf( $autosavef, $date );
	}

	return $date;
}