我试图从CDN加载jquery,而不是用wordpress本机加载。在我的功能中。php我已经完成了如下操作,确保它只发生在前端:
function replace_jquery() {
if (!is_admin()) {
wp_deregister_script(\'jquery\');
wp_register_script(\'jquery2\', \'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\');
wp_enqueue_script(\'jquery2\');
}
}
add_action(\'init\', \'replace_jquery\');
尽管如此,当我尝试登录管理区域时,我会遇到一系列错误,首先是:Notice: wp_deregister_script was called <strong>incorrectly</strong>.
Do not deregister the <code>jquery</code> script in the administration area.
To target the front-end theme, use the <code>wp_enqueue_scripts</code> hook.
Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.
(This message was added in version 3.6.0.) in /app/public/wp-includes/functions.php on line 4204
有时它不会抛出此错误,有时也会抛出此错误。我做错了什么?