WordPress 版本 3.3 发布已有一个星期了,前些天有朋友问到 WP 主题在加载脚本与样式表时报错的问题,报错内容如下(需开启 WP_DEBUG 模式):
Notice:
wp_enqueue_scriptwas called incorrectly. Scripts and styles should not be registered or enqueued until thewp_enqueue_scripts,admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.)
在许多场合中,不管是制作修改主题或插件,我们都需要调用一些 JavaScript 库,或者样式表等。这时,我们不应该直接去修改主题的 header.php,或者添加代码到