Enqueue script in specific page

Inside admin-header.php, there’s the following set of hooks: do_action(‘admin_enqueue_scripts’, $hook_suffix); do_action(“admin_print_styles-$hook_suffix”); do_action(‘admin_print_styles’); do_action(“admin_print_scripts-$hook_suffix”); do_action(‘admin_print_scripts’); do_action(“admin_head-$hook_suffix”); do_action(‘admin_head’); The one to always use it admin_enqueue_scripts, both for stylesheet and scripts. More info in this answer. It has one additional argument, the $hook_suffix. This argument is exactly the same as the return value that you get from add_submenu_page() … Read more

Why I can’t add a CSS style in this WordPress theme?

You are using plugins_url – therefore pointing to completly different directory than your current theme. If you are just trying to enqueue a theme style do it like this: function load_theme_styles() { wp_enqueue_style(‘main-css’, get_template_directory_uri() . ‘/style.css’, array(), ‘1.0’, ‘all’); } add_action(‘wp_enqueue_scripts’, ‘load_theme_styles’); the wp_enqueue_style takes some parameters. In the example above I am using: A … Read more

How to control what jQuery version to include, with wp_enqueue_script

That’s the size of the minified jQuery nowadays 🙂 You can load the latest from Google: wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js”), false, ‘1.8.2’); Please keep in mind that this can cause issues moving forward, as you are forcing WordPress to load a certain version of jQuery instead of the version bundled with it. There are plugins out … Read more

Remove extra Google Maps script

EDIT : use wp_enqueue_script as you want (enqueue in header or footer after jQuery as you want) to enqueue file called something like : gmap.js included in your plugin wp_enqueue_script(‘custom-gmap’, plugin_dir_url( __FILE__ ).’inc/js/gmap.js’, array(‘jquery’), false, true);//just change your path and name of file write this in your Js file 🙂 $(document).ready(function() { if (typeof google … Read more

Get only enqueued styles and scripts of the current theme

The first argument of preg_match is supposed to be a pattern, not a string, so it’s probably not comparing the way you expect. Use strpos instead: function wpse_275760_theme_scripts() { global $wp_scripts; $stylesheet_uri = get_stylesheet_directory_uri(); foreach( $wp_scripts->queue as $handle ) { $obj = $wp_scripts->registered[$handle]; $obj_handle = $obj->handle; $obj_uri = $obj->src; if ( strpos( $obj_uri, $stylesheet_uri ) … Read more

Get list of scripts / styles and show file which enqueued them

This is not possible the way you think. It would maybe be possible if you use Reflections or debug_backtrace(), but there’s no reliable way to do this. WordPress does not keep a stack or queue where it tracks file names. The only thing I could imagine is just hooking into the action and inside wp_enqueue_scripts(): … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)