我试图通过一些管理页面来获取WordPress的教程。我添加了具有wp_enqueue_style
功能的标准css和js文件。它工作正常,但在enqueue.php文件中,命令不起作用。
我的代码在enqueue.php中:
<?php
function theme_load_admin_scripts($hook){
if('toplevel_page_theme_option' != $hook){
return;
}
wp_register_style('theme_admin', get_template_directory_uri() . '/css/theme.admin.css', array(), '1.0.0', 'all');
wp_enqueue_style('theme_admin');
wp_enqueue_media();
wp_register_script('theme-admin-script', get_template_directory_uri() . '/inc/js/theme.admin.js', array('jquery'), '1.0.0', true);
wp_enqueue_script('theme-admin-script');
}
add_action('admin_enqueue_scripts', 'theme_load_admin_scripts');
?>
答案 0 :(得分:0)
使用admin_init
add_action('admin_init', 'theme_load_admin_scripts');
https://codex.wordpress.org/Plugin_API/Action_Reference/admin_init