Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Last active February 3, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustardBees/ad6de2c534f7612bdcb2 to your computer and use it in GitHub Desktop.
Save mustardBees/ad6de2c534f7612bdcb2 to your computer and use it in GitHub Desktop.
Show the WordPress toolbar by default
<?php
/**
* Show the toolbar by default
*
* We only want to set this preference once per user so we save a flag which is
* checked before modifying their user settings.
*
* @author iWeb
* @link https://goo.gl/z384Uj
*/
function iweb_show_toolbar() {
if ( in_array( $GLOBALS['pagenow'], array( 'post.php', 'post-new.php' ) ) ) {
$user_id = get_current_user_id();
// This is a one time deal, bail if the user has already had their default set
if ( get_user_meta( $user_id, 'iweb_show_toolbar', true ) ) {
return;
}
set_user_setting( 'hidetb', '1' );
update_user_meta( $user_id, 'iweb_show_toolbar', true );
}
}
add_filter( 'admin_init', 'iweb_show_toolbar' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment