Shortcut Buttons Dashboard Widget
Puts big buttons for the most common tasks, like writing a post or editing menus, at the top of the dashboard. Ideal for clients.
Opens WPIDE on
Code
// Label => array( admin path, capability needed ).
$wpide_dashboard_shortcuts = array(
'Write a post' => array( 'post-new.php', 'edit_posts' ),
'Add a page' => array( 'post-new.php?post_type=page', 'edit_pages' ),
'Media' => array( 'upload.php', 'upload_files' ),
'Menus' => array( 'nav-menus.php', 'edit_theme_options' ),
'Comments' => array( 'edit-comments.php', 'moderate_comments' ),
);
add_action( 'wp_dashboard_setup', function () use ( $wpide_dashboard_shortcuts ) {
wp_add_dashboard_widget( 'wpide_shortcuts', 'Shortcuts', function () use ( $wpide_dashboard_shortcuts ) {
echo '<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px">';
foreach ( $wpide_dashboard_shortcuts as $label => $shortcut ) {
if ( ! current_user_can( $shortcut[1] ) ) {
continue;
}
printf(
'<a class="button button-hero" style="text-align:center;white-space:normal" href="%s">%s</a>',
esc_url( admin_url( $shortcut[0] ) ),
esc_html( $label )
);
}
echo '</div>';
} );
} );
Notes
Menus only exist in classic themes; use site-editor.php?path=/navigation for block themes.
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.