Skip to content

Instantly share code, notes, and snippets.

@renventura
Created January 28, 2016 17:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save renventura/29fa18b7064264e1ba82 to your computer and use it in GitHub Desktop.
Save renventura/29fa18b7064264e1ba82 to your computer and use it in GitHub Desktop.
Add a full-width dashboard widget in WordPress
<?php // Mind this opening PHP tag
/**
* Adds hidden content to admin_footer, then shows with jQuery, and inserts after welcome panel
*
* @author Ren Ventura <EngageWP.com>
* @see http://www.engagewp.com/how-to-create-full-width-dashboard-widget-wordpress
*/
add_action( 'admin_footer', 'rv_custom_dashboard_widget' );
function rv_custom_dashboard_widget() {
// Bail if not viewing the main dashboard page
if ( get_current_screen()->base !== 'dashboard' ) {
return;
}
?>
<div id="custom-id" class="welcome-panel" style="display: none;">
<div class="welcome-panel-content">
<h2>Welcome to WordPress!</h2>
<p class="about-description">We’ve assembled some links to get you started:</p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<h3>Get Started</h3>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="http://localhost:8888/uw-website/wp-admin/customize.php">Customize Your Site</a>
<a class="button button-primary button-hero hide-if-customize" href="http://localhost:8888/uw-website/wp-admin/themes.php">Customize Your Site</a>
<p class="hide-if-no-customize">or, <a href="http://localhost:8888/uw-website/wp-admin/themes.php">change your theme completely</a></p>
</div>
<div class="welcome-panel-column">
<h3>Next Steps</h3>
<ul>
<li><a href="http://localhost:8888/uw-website/wp-admin/post.php?post=2557&amp;action=edit" class="welcome-icon welcome-edit-page">Edit your front page</a></li>
<li><a href="http://localhost:8888/uw-website/wp-admin/post-new.php?post_type=page" class="welcome-icon welcome-add-page">Add additional pages</a></li>
<li><a href="http://localhost:8888/uw-website/wp-admin/post-new.php" class="welcome-icon welcome-write-blog">Add a blog post</a></li>
<li><a href="http://localhost:8888/uw-website/" class="welcome-icon welcome-view-site">View your site</a></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3>More Actions</h3>
<ul>
<li><div class="welcome-icon welcome-widgets-menus">Manage <a href="http://localhost:8888/uw-website/wp-admin/widgets.php">widgets</a> or <a href="http://localhost:8888/uw-website/wp-admin/nav-menus.php">menus</a></div></li>
<li><a href="http://localhost:8888/uw-website/wp-admin/options-discussion.php" class="welcome-icon welcome-comments">Turn comments on or off</a></li>
<li><a href="https://codex.wordpress.org/First_Steps_With_WordPress" class="welcome-icon welcome-learn-more">Learn more about getting started</a></li>
</ul>
</div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function($) {
$('#welcome-panel').after($('#custom-id').show());
});
</script>
<?php }
@imbdev
Copy link

imbdev commented Aug 7, 2017

Doesn't work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment