Codex tools: Log in
Contents |
admin_print_scripts mainly used to echo inline javascript.
admin_print_scripts should not be used to enqueue styles or scripts on the admin pages. Use admin_enqueue_scripts instead.
<?php add_action( 'admin_print_scripts', 'function_name' ); ?>
where "function_name" is the name of the function to be called.
function admin_inline_js(){
echo "<script type='text/javascript'>\n";
echo 'var pluginUrl = "'.WP_PLUGIN_URL . '/my_plugin/'.'"';
echo "\n</script>";
}
add_action( 'admin_print_scripts', 'admin_inline_js' );
result
<script type='text/javascript'> var pluginUrl = "http://website.com/wp-content/plugins/my_plugin/" </script>
admin_print_scripts should not be used to enqueue styles or scripts on the admin pages. Use admin_enqueue_scripts instead.
wp_enqueue_scripts - for enqueuing on the front end
login_enqueue_scripts - for enqueuing on the login page
admin_enqueue_scripts - for enqueuing on admin pages