Hi,
I'm trying to add some jQuery script (a simple alert at this point) to my header, but when I use wp_print_scripts it places it above the code that links the jQuery file.
If I use admin_head instead of wp_print_scripts, everything works find because my code is placed lower then the JS link in the <head> section of the page.
Any ideas? Here is my code for inserting:
....inside my plugin class
function adminHead() {
wp_enqueue_script('jquery');
?>
<script type="text/javascript">
jQuery(document).ready(function(){
alert('test');
});
</script>
<?php
}
..... outside of my plugin class
add_action( 'wp_print_scripts', array( &$pluginclassname, 'adminHead') );
And here is the generated code in my <head>
<script type='text/javascript' src='http://localhost/cc/wp-includes/js/jquery/jquery.js?ver=1.2.3'></script>
<script type='text/javascript' src='http://localhost/cc/wp-admin/js/common.js?ver=20080318'></script>
<script type='text/javascript' src='http://localhost/cc/wp-includes/js/jquery/jquery.color.js?ver=2.0-4561'></script>
<script type="text/javascript">
jQuery(document).ready(function(){
alert('test');
});
</script>
<script type="text/javascript">
jQuery(function() {
jQuery('#dashboard_incoming_links div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=incominglinks');
jQuery('#dashboard_primary div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=devnews');
jQuery('#dashboard_secondary div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=planetnews');
jQuery('#dashboard_plugins div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=plugins');
});
</script>
Any help would be great. Thanks.