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

Register script in one plugin, and enqueue it in another

Prioritize your actions, so the register_style function runs first. (notice the third parameter in the add_action function) add_action( ‘wp_enqueue_scripts’, ‘other_register_styles’, 11 ); function other_register_styles() { wp_register_style( ‘style’, PATH . ‘assets/css/style.min.css’ ); wp_enqueue_style( ‘style’ ); // Working as expected wp_enqueue_style( ‘fontawesome’ ); // Currently not working! } The default priority is 10, so you just need … 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

Enqueue script in header

You just have your arguments lined up wrong. Change the line to wp_enqueue_script( ‘ajax-products’, plugins_url( ‘/js/ajax.js’, __FILE__ ), array(‘jquery’), ‘1.2’, false ); You can use plugins_url() with the second parameter of __FILE__ to get the directory of the specific pluign, and in the first argument you pass the relative location of your script. The rest … Read more

Loading scripts with wp_register_script and wp_enqueue_script

There are probably various ways to do this – personally I use the following for loading some small scripts only on the “new” and “edit” pages (datepicker etc.): function load_my_admin_scripts( $hook ) { if (( $hook == ‘post.php’ || $hook == ‘post-new.php’ )) { wp_enqueue_script( ‘my-datepicker’, // name / handle of the script SCRIPTS . ‘script.js’, … Read more

How to To Filter wp_enqueue_script() Scripts on Some Pages

You can prevent adding a script to a specific WordPress page by checking if whether we are on that page or not is_page($page_id): function add_js() { wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”, false, null); wp_enqueue_script(‘jquery’); wp_enqueue_script( ‘bootstrap-js’, get_template_directory_uri() .’/js/bootstrap.min.js’, array(‘jquery’),”,true ); wp_enqueue_script( ‘colorbox-js’, get_template_directory_uri() .’/js/jquery.colorbox-min.js’, array(‘jquery’),”,true ); $pages … 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

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