admin管理员组文章数量:1390794
I have read all the previous posts about this but can't seem to get my head around what is wrong with my code. This is in a plugin that I have written. I thought I had it sorted but looks like I haven't is it the order in which I am calling these?
function gedshow_ajaxurl() {
echo '<script type="text/javascript">
var ajaxurl = "' . admin_url('admin-ajax.php') . '";
</script>';
}
add_action('wp_head', 'gedshow_ajaxurl');
wp_enqueue_script('jquery');
add_action('admin_menu', 'gedshow_setup_menu');
function mw_enqueue_color_picker( $hook_suffix ) {
// first check that $hook_suffix is appropriate for your admin page
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'my-script-handle', plugins_url('my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
}
add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );
function gedshow_enqueue_styles(){
$file_url = plugins_url('gedshow.css',__FILE__);
wp_enqueue_style('sp_stylesheet',$file_url);
}
add_action( 'wp_enqueue_scripts','gedshow_enqueue_styles');
I have read all the previous posts about this but can't seem to get my head around what is wrong with my code. This is in a plugin that I have written. I thought I had it sorted but looks like I haven't is it the order in which I am calling these?
function gedshow_ajaxurl() {
echo '<script type="text/javascript">
var ajaxurl = "' . admin_url('admin-ajax.php') . '";
</script>';
}
add_action('wp_head', 'gedshow_ajaxurl');
wp_enqueue_script('jquery');
add_action('admin_menu', 'gedshow_setup_menu');
function mw_enqueue_color_picker( $hook_suffix ) {
// first check that $hook_suffix is appropriate for your admin page
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'my-script-handle', plugins_url('my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
}
add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );
function gedshow_enqueue_styles(){
$file_url = plugins_url('gedshow.css',__FILE__);
wp_enqueue_style('sp_stylesheet',$file_url);
}
add_action( 'wp_enqueue_scripts','gedshow_enqueue_styles');
Share
Improve this question
asked Feb 26, 2020 at 14:35
ColinColin
1356 bronze badges
1 Answer
Reset to default 1Removing wp_enqueue_script('jquery');
will fix your problem.
Put jquery
into deps
parameter of wp_enqueue_script function.
本文标签: warningsI have this error notice 39wpenqueuescript was called incorrectly39 in my plugin
版权声明:本文标题:warnings - I have this error notice 'wp_enqueue_script was called incorrectly' in my plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744713923a2621290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论