when I load the default jquery-ui-autocomplete script from wordpress via
wp_enqueue_script( 'jquery-ui-autocomplete', '', array( 'jquery-ui-widget', 'jquery-ui-position' ), '1.8.6' );
it is embedded, and all works fine, except the annoying notice message in debug mode:
Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks ...
The solution therefore is quite easy, only wrap the wp_enqueue_script
call:
function add_scripts(){
wp_enqueue_script( 'jquery-ui-autocomplete', '', array( 'jquery-ui-widget', 'jquery-ui-position' ), '1.8.6' ); //don't loads the autocomplete
wp_enqueue_script( 'jquery-ui-autocomplete'); //same as above
}
add_action('wp_enqueue_scripts', 'add_scripts');
BUT these technique doesn't embeds the jquery-ui-autocomplete script
, only the annoying message disappear. The only way the jquery-ui-autocomplete
script is embed, is without wrapping it ...
Where is my error? According to the documentation in the codex it should be done by wrapping the call and simply call wp_enqueue_script( 'jquery-ui-autocomplete');
inside.
BR, mybecks