Last active
February 3, 2016 16:05
-
-
Save mustardBees/ad6de2c534f7612bdcb2 to your computer and use it in GitHub Desktop.
Show the WordPress toolbar by default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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