Last active
March 6, 2020 04:20
-
-
Save brunolimadevelopment/7e964da0fd2768816e5c2829d67b0c4f to your computer and use it in GitHub Desktop.
[WP] Carregando CSS e JS para customizar o Admin
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
// VERIFICA O TIPO DE USUÁRIO | |
function is_site_admin(){ | |
return in_array( | |
'administrator', wp_get_current_user()->roles | |
); | |
} | |
// CRIA OS ARQUIVOS DE STYLO E JS E CHAMA NO HEADER DO ADMIN | |
function load_admin_styles_custom() { | |
if (is_site_admin()) { | |
$screen = get_current_screen(); | |
if ($screen->id == 'edit-post' ) { | |
wp_enqueue_style( 'mystyle', get_template_directory_uri() . '/assets/css/mystyle.css', false, '1.0.0' ); | |
wp_enqueue_script( 'myscript', get_template_directory_uri() . '/assets/js/myscript.js', false, '1.0.0' ); | |
} | |
} | |
} | |
add_action( 'admin_enqueue_scripts', 'load_admin_styles_custom' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment