我在我的插件中使用 wordpress mediaupload 功能。
Error: jQuery is not defined
Source File: http://localhost/my_wp/wp-admin/load-scripts.php?c=0&load=utils,thickbox,media-upload&ver=4ec4a484079ac4122099967c5457437d
Line: 19
这是我的插件加载时的错误消息。当我看到代码时,媒体上传脚本首先加载,然后 jquery 正在加载。这是我的代码
add_action( 'admin_enqueue_scripts', 'wpvote_include_files' );
function wpvote_include_files() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_register_script('my-upload', WPVOTE_PLUGIN_URL.'wpmediaupload_scripts.js', array('jquery','media-upload','thickbox'));
wp_enqueue_script('my-upload');
}
这是我的页面源代码
<script type='text/javascript' src='http://localhost/my_wp/wp-admin/load-scripts.php?c=0&load=utils,thickbox,media-upload&ver=4ec4a484079ac4122099967c5457437d'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=3.3.2'></script>