I am trying to load a custom styles sheet but only for administrators
My code works fine by itself:
function admin_style() {
wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');
}
add_action('admin_enqueue_scripts', 'admin_style');
However, when I try to create a conditional based on the role, it can not get it to fire:
function role_exists( $role ) {
if( ! empty( $role ) ) {
return $GLOBALS['wp_roles']->administrator( $role );
}
return false;
}
function admin_style() {
wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');
}
if( role_exists( 'administrator' ) ) {
return
add_action('admin_enqueue_scripts', 'admin_style');
}