Pending Review Dashboard Widget
Shows everything waiting for review on the dashboard, with the author and a direct link to review it.
Opens WPIDE on
Code
add_action( 'wp_dashboard_setup', function () {
if ( ! current_user_can( 'edit_others_posts' ) ) {
return;
}
wp_add_dashboard_widget( 'wpide_pending_review', 'Waiting for Review', function () {
$pending = get_posts( array(
'post_type' => 'any',
'post_status' => 'pending',
'numberposts' => 20,
'orderby' => 'date',
'order' => 'ASC',
) );
if ( ! $pending ) {
echo '<p>Nothing is waiting for review.</p>';
return;
}
echo '<table class="widefat striped"><tbody>';
foreach ( $pending as $item ) {
$type = get_post_type_object( $item->post_type );
printf(
'<tr><td><a href="%1$s"><strong>%2$s</strong></a><br><small>%3$s by %4$s</small></td><td style="text-align:right">%5$s</td></tr>',
esc_url( get_edit_post_link( $item->ID ) ),
esc_html( get_the_title( $item ) ? get_the_title( $item ) : '(no title)' ),
esc_html( $type ? $type->labels->singular_name : $item->post_type ),
esc_html( get_the_author_meta( 'display_name', $item->post_author ) ),
esc_html( get_the_date( '', $item ) )
);
}
echo '</tbody></table>';
} );
} );
Notes
Oldest submissions are listed first.
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.