您可以像下面这样过滤输出:
<?php
/**
* @param $revision_date_author
* @param $revision
* @param $link
* @return mixed
*/
function filter_wp_post_revision_title_expanded( $revision_date_author, $revision, $link ) {
$revision = get_post( $revision );
if ( ! $revision ) {
return $revision;
}
if ( ! in_array( $revision->post_type, array( \'post\', \'page\', \'revision\' ), true ) ) {
return false;
}
$author = get_the_author_meta( \'display_name\', $revision->post_author );
//You can change format Here
$datef = _x( \'F j, Y @ H:i:s\', \'revision date format\' );
$gravatar = get_avatar( $revision->post_author, 24 );
$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>";
}
$revision_date_author = sprintf(
/* translators: Post revision title. 1: Author avatar, 2: Author name, 3: Time ago, 4: Date. */
__( \'%1$s %2$s, %3$s ago (%4$s)\' ),
$gravatar,
$author,
human_time_diff( strtotime( $revision->post_modified_gmt ) ),
$date
);
return $revision_date_author;
};
// Finally add the filter
add_filter( \'wp_post_revision_title_expanded\', \'filter_wp_post_revision_title_expanded\', 10, 3 );
本例中使用的大多数代码都取自实际
wp_post_revision_title_expanded
作用
read more