wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_dashboard_on_this_day › WordPress Function
Since7.2.0
Deprecatedn/a
› wp_dashboard_on_this_day ( $posts = null )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
| Codex: |
Outputs the On This Day section of the Activity widget.
Source
function wp_dashboard_on_this_day( $posts = null ) {
if ( null === $posts ) {
$posts = wp_dashboard_on_this_day_get_posts();
}
if ( empty( $posts ) ) {
return false;
}
echo '<div id="on-this-day-posts" class="activity-block">';
echo '<h3>' . esc_html__( 'Published On This Day' ) . '</h3>';
echo '<ul>';
foreach ( $posts as $post ) {
/* translators: Date format for posts published in a previous year. */
$date = get_the_date( __( 'M jS, Y' ), $post );
$title = get_the_title( $post );
if ( '' === trim( $title ) ) {
$title = __( '(no title)' );
if ( current_user_can( 'read_post', $post->ID ) && ! post_password_required( $post ) ) {
$excerpt = get_the_excerpt( $post );
if ( is_string( $excerpt ) && '' !== $excerpt ) {
$title .= ' ' . wp_trim_words( $excerpt, 15 );
}
}
}
$can_edit = current_user_can( 'edit_post', $post->ID );
$link = $can_edit ? get_edit_post_link( $post->ID ) : get_permalink( $post );
if ( $can_edit ) {
/* translators: %s: Post title. */
$aria_label = sprintf( __( 'Edit “%s”' ), $title );
} else {
/* translators: %s: Post title. */
$aria_label = sprintf( __( 'View “%s”' ), $title );
}
$author_id = (int) $post->post_author;
$author_name = $author_id > 0 ? (string) get_the_author_meta( 'display_name', $author_id ) : '';
printf(
'<li><span>%1$s</span><span><a href="%2$s" aria-label="%3$s">%4$s</a>',
esc_html( $date ),
esc_url( $link ),
esc_attr( $aria_label ),
esc_html( $title )
);
if ( '' !== trim( $author_name ) && get_current_user_id() !== $author_id ) {
printf(
' <span class="wp-on-this-day-post-author">%s</span>',
esc_html(
sprintf(
/* translators: %s: Post author's display name. */
__( 'by %s' ),
$author_name
)
)
);
}
echo '</span></li>';
}
echo '</ul>';
echo '</div>';
return true;
}