Skip to content

Instantly share code, notes, and snippets.

@gradosevic
Last active March 9, 2019 10:17
Show Gist options
  • Save gradosevic/e489fd016e38bda3f6db75a0dee343ed to your computer and use it in GitHub Desktop.
Save gradosevic/e489fd016e38bda3f6db75a0dee343ed to your computer and use it in GitHub Desktop.
WP Snippets
<?php
//Allow AGCA plugin access only to one person, specified by username
function agca_access_only_admin(){
if(is_admin()){
$screen = get_current_screen();
if($screen->id === 'tools_page_ag-custom-admin/plugin'){
$user = wp_get_current_user();
//Update this ////////////////////
$accessAllowedOnlyTo = 'admin';
//////////////////////////////////
if($user->data->user_login != $accessAllowedOnlyTo){
wp_die( 'You are not authorized to see this page.' );
}
}
}
}
add_action('current_screen', 'agca_access_only_admin');
//Add custom admin bar image
function my_custom_ab_image() {
echo '<style>
#wp-admin-bar-wp-logo > .ab-item, #wp-admin-bar-wp-logo:hover > .ab-item{
background: url(https://example.com/image.jpg) !important;
background-size: contain !important;
}
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before{
display: none;
}
</style>';
}
add_action('wp_head', 'my_custom_ab_image');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment