Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Last active January 2, 2016 06:19
Show Gist options
  • Save michaelschofield/8262753 to your computer and use it in GitHub Desktop.
Save michaelschofield/8262753 to your computer and use it in GitHub Desktop.
A welcome screen in the WordPress dashboard, but not using the actual welcome_panel hook because even customizing that will show only to site admins. Instead, this creates an admin notice and uses the welcome panel markup.
/* ==================
* Custom Welcome Panel
*/ // This is a custom welcome panel, sort of. The
// correct way of updating the welcome panel content
// is still only visible to users that can edit_theme_options.
// This takes the welcome-panel styles and adds it as an admin_notice.
function ms_welcome_panel() {
$screen = get_current_screen();
if ( $screen->base == 'dashboard' ) {
echo
'<div class="wrap">'.
'<h2></h2>'.
'<div id="welcome-panel" class="welcome-panel">'.
'<section class="welcome-panel-content">' .
'<h3>A Heading</h3>' .
'<p class="about-description">A description or blurb.</p>'.
'<div class="welcome-column-container">'.
'<div class="welcome-panel-column">'.
'<a class="button button-primary button-hero" href="#yourlink" target="new">Button</a>'.
'<p>Some text.</p>'.
'</div>'.
'<div class="welcome-panel-column">'.
'<a class="button button-hero" href="#yourlink">Second Button</a>'.
'<p>Some text</p>'.
'</div>'.
'</div>' .
'</section>'.
'</div>'.
'</div>';
}
}
remove_action( 'welcome_panel', 'wp_welcome_panel');
add_action( 'admin_notices', 'ms_welcome_panel' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment