WP Snippets
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 | |
//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