The following content was written on December 25th, 2011
WordPress 版本 3.3 中,对主题加载脚本与样式表的过程强制要求在 action wp_enqueue_scripts 和 admin_enqueue_scripts 进行处理,详细内容请见:WordPress 3.3 中加载脚本与样式表的新途径(http://www.ychong.com/wordpress-v-3-3-enqueue-scripts-and-styles/)。
The following content was written on September 10th, 2011
在许多场合中,不管是制作修改主题或插件,我们都需要调用一些 JavaScript 库,或者样式表等。这时,我们不应该直接去修改主题的 header.php,或者添加代码到 wp_head() 或 wp_footer() 钩子上,而是要使用 WordPress 官方文档建议使用的 WP 内建的 wp_enqueue_script() 和 wp_enqueue_style() 等函数进行操作。
本文将详细介绍这几个函数的作用和标准用法,以及其他等效办法的利弊。