Recently Updated Content Widget
Lists the most recently modified posts and pages of any type on the dashboard, with who changed them.
Opens WPIDE on
Code
add_action( 'wp_dashboard_setup', function () {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
wp_add_dashboard_widget( 'wpide_recently_updated', 'Recently Updated', function () {
$items = get_posts( array(
'post_type' => array_values( get_post_types( array( 'show_ui' => true ) ) ),
'post_status' => array( 'publish', 'draft', 'pending', 'future', 'private' ),
'numberposts' => 10,
'orderby' => 'modified',
) );
echo '<ul>';
foreach ( $items as $item ) {
if ( ! current_user_can( 'edit_post', $item->ID ) ) {
continue;
}
$editor_id = (int) get_post_meta( $item->ID, '_edit_last', true );
$editor = $editor_id ? get_userdata( $editor_id ) : false;
printf(
'<li><a href="%1$s">%2$s</a> <span style="color:#646970">%3$s ago%4$s</span></li>',
esc_url( get_edit_post_link( $item->ID ) ),
esc_html( get_the_title( $item ) ? get_the_title( $item ) : '(no title)' ),
esc_html( human_time_diff( get_post_modified_time( 'U', true, $item ), time() ) ),
$editor ? esc_html( ' by ' . $editor->display_name ) : ''
);
}
echo '</ul>';
} );
} );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.