debugging js scripts

What you might do is check the status of the scripts you are trying to enqueue after doing so. Also, be sure to enqueue things inside of an action. e.g. function do_my_enqueue_scripts() { wp_register_script(‘isotope’, get_template_directory_uri() . ‘/js/jquery.isotope.min.js’,array(‘jquery’),”,true); wp_enqueue_script(‘isotope’); } add_action(‘wp_enqueue_scripts’, ‘do_my_enqueue_scripts’); You can use the wp_script_is function to check if they actually get enqueued. e.g. … Read more

Enqueue script multiple times?

I’m going to submit an answer for this based on Milo’s response above to help anyone finding this in the future. I’m just going to put together some simple examples that hopefully illustrate the point, but this isn’t tested code. In my example I have a shortcode for galleries that accepts a Flickr photoset ID, … Read more

Utilizing WordPress’ Admin UI for plugin settings: getting accordion style

Here’s how I do it for my plugin/options page (which is inside a class, thus the $this-> construct): /* enqueue our css */ public function enqueue_options_style( $hook ) { if( $hook == $this->admin_page ) wp_enqueue_style( ‘my-options’, ‘/some-directory/my-options.css’, false, $this->version ); // only present for our plugin’s settings page } $this->admin_page is the slug returned from … Read more

How to change script order?

wp_enqueue_script has $deps parameter which exactly does what you need. wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ) Let’s say that your custom code is in a file named custom.js which is enqueued with a handle my-custom and you want this to be loded before my-script1 which is en-queued with a handle. wp_enqueue_script( ‘my-custom’, ‘/path/to/customjs’, array() … Read more

404 Error on trying to enqueue a JS file

Your syntax is wrong. The action must be defined outside of the callback. Also, you are using plugin_dir_path() function, which gets the path to plugin directoy in the filesystem of the server, not the url. You should use plugin_dir_url() instead. add_action( ‘wp_enqueue_scripts’, ‘myplugin_load_script’ ); function myplugin_load_script() { wp_enqueue_script( ‘myplugin-testjs’, plugin_dir_url( __FILE__ ) . “scripts/myplugin-test.js”, array(‘jquery’), … Read more

wp_enqueue_script called incorrectly

UGH. I solved this. I’m an idiot. I had a file in my theme named admin.php that was setting up wp-admin handlers and the like for a portion of my application. I was including this via include_once( ‘admin.php’ ) from its parent file, and apparently that was calling the main wp-core admin.php file. So yeah. … Read more

wp enqueue script- jQuery not loading

It appears that “mdbootstrap” is built in such a way that it does not support jQuery in No Conflict mode, which is how WordPress runs it. According to this forum thread they were going to add support 2 years ago, but apparently they never did. If you must use this library, then I think the … Read more

enqueue admin styling and scripts only on plugin page

You can use $screen = get_current_screen(); functions to get the current screen and add warp your enqueue method with the if conditions to check the screen. https://codex.wordpress.org/Function_Reference/get_current_screen public function enqueue_scripts() { $screen = get_current_screen(); // Check screen base and page if ( ‘options-general’ === $screen->base && $_GET[‘page’] ===’uwc’ ) { wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) … Read more

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