我正在构建一个 WordPress 主题,它将很快需要 jQuery UI(只是核心和效果,不包括 CSS)(http://hildasjcr.org.uk)。我正在使用我自己构建的 jQuery 和 jQuery UI,因为我需要使用 jQuery Effects 并且我喜欢“$”符号。我已将脚本包含在 functions.php 中,如下所示:
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_template_directory_uri() . "/js/jquery-1.7.2.min.js");
wp_enqueue_script( 'jquery' );
wp_deregister_script( 'jqueryui' );
wp_register_script( 'jqueryui', get_template_directory_uri() . "/js/jquery-ui-1.8.21.custom.min.js");
wp_enqueue_script( 'jqueryui' );
wp_register_script( 'footer', get_template_directory_uri() . "/js/footer.js");
wp_enqueue_script( 'footer' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
它给出了以下 HTML 代码(剥离到相关位):
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Current Students</title>
<link rel="stylesheet" type="text/css" media="all" href="http://hildasjcr.org.uk/wp-content/themes/hildas/style.css" />
<script type='text/javascript' src='http://hildasjcr.org.uk/wp-content/themes/hildas/js/jquery-1.7.2.min.js?ver=3.3.2'></script>
<script type='text/javascript' src='http://hildasjcr.org.uk/wp-content/themes/hildas/js/jquery-ui-1.8.21.custom.min.js?ver=3.3.2'></script>
<script type='text/javascript' src='http://hildasjcr.org.uk/wp-content/themes/hildas/js/footer.js?ver=3.3.2'></script>
</head>
不幸的是,jQuery UI 似乎已加载但无法使用 - jQuery 运行良好,但 jQuery UI 函数均未定义。
我什至可以在 Chrome 的开发人员工具面板中看到 jQuery UI,并阅读其中的代码。
那么,出了什么问题,我该如何解决?