Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered. You could either link a script with a handle previously registered using the wp_register_script() function, ...

learn more… | top users | synonyms

3
votes
1answer
108 views

Hyphens vs. periods in the script slug in wp_register_script?

I have seen script and style handles written in two different ways in wp_register_script and wp_enqueue_script (the same applies to wp_register_style and wp_enqueue_style): wp_register_script( ...
1
vote
3answers
2k views

How do I force wp_enqueue_scripts to load at the END of <head>?

I am loading scripts via wp_enqueue_scripts in my child theme. The only problem is that my style.css script get loaded BEFORE plugin scripts, yet I need to override the css in the plugins with my ...
0
votes
1answer
313 views

wp_enqueue_scripts called twice?

I had some problem with WP recognizing a is_single condition for loading scripts called in function.php. I put a error_log(is_single()) to check what was going on. When opening a post page the log ...
0
votes
2answers
648 views

include jquery plugin file not working

My code for include js as follows: function you_fancy_js(){ wp_register_script( 'custom-script', plugins_url( '/js/jquery.js', __FILE__ ), array( 'jquery', 'jquery-ui-1.8.18.custom.min', ...
1
vote
2answers
280 views

Script won't load via plugin class

I'm not sure why this script is not loading or producing any load errors via Firebug. Here is my plugin script: class AV_Slideshow{ function __construct(){ $this->hooks(); } function ...
0
votes
1answer
720 views

wp_enqueue_scripts in a plugin's class

I'm trying to enqueue jQuery UI in a plugin under a class method. I have this so far: class AV_Slider { function slider_load_js(){ wp_register_script('jquery-ui-core', ...
0
votes
1answer
253 views

Enqueueing Scripts/Styles mid-page

Since WP 3.3, the codex has been updated for both wp_enqueue_script and wp_enqueue_style that you can now enqueue both mid-page (within the HTML body). I see this as an advantage because: It's ...
1
vote
1answer
2k views

force enqueue script to be first in order of prominence

I have a few scripts which are being enqueued, the problem is that I want to force the order of prominece to which these scripts are loaded. There is one in particular which is loaded from a plugin ...
1
vote
2answers
103 views

Enqueue scripts to a specific header-<name>.php?

I've multiple header files (header-name.php), they are mainly being used by different custom post types. Is there any way to enqueue script to only a specific header? At this moment I'm targeting it ...
0
votes
1answer
306 views

Adding Pinterest Script Before Closing Body Tag

According to the Pinterest website in order to add the Pinterest button to any page I have to add the following just below the closing body tag: <script type="text/javascript" ...
1
vote
2answers
267 views

Enqueued scripts and styles loading in WordPress Dashboard as well

For a moment, I wondered if my test site got hacked -- my WordPress site's dashboard was all broken (cosmetically). But when i looked at the source code of the page, I noticed that the "scripts and ...
5
votes
1answer
3k views

Register and enqueue conditional (browser-specific) javascript files?

The WP.SE community has always advised the use of wp_register_script and wp_enqueue_script for adding scripts in a theme/template (and likewise, wp_register_style and wp_enqueue_style for ...
3
votes
1answer
1k views

Is This The Most Efficient Way To Add Javascript Files?

I am currently rewriting an HTML template into a Wordpress theme. It has a lot of code dependencies, and I'm wondering if this is the proper, most efficient way to add it. This code is listed in my ...
2
votes
1answer
2k views

How do I get the $handle for all enqueued scripts?

Is there some way to get the $handle for each script that has been enqueued? Is there some array that holds all the handles so that I can loop through it and do something using each $handle?
0
votes
2answers
181 views

How to execute a simple php script in WP (I don't think wp_enque_script applies here)

I have a wordpress page where I want to include a budget calculation tool. This budget calculation tool is of course tied to a php script that executes the fields in the budget calculation tool. This ...
1
vote
1answer
310 views

Check if page/post has any anchors that link to an image jpg/gif/png

What I'm aiming to do is add fancybox to a site I'm developing, but I only want to enqueue the JS/CSS etc if the page/post needs it. My thoughts are that I would need to check all the anchor tags on ...
2
votes
1answer
1k views

Problem using is_single() to enqueue script from functions.php

I'm having trouble only adding scripts to single post pages. I need to both include and exclude certain scripts using is_single() but it doesn't work either way I try it. I have the template tag on ...
0
votes
1answer
61 views

Wordpress Plugin Authoring question about jquery and css

When I'm writing a plugin, do I assume that jquery is included, or should I always wp_enqueue_script it and let wordpress figure it out? Also, what's the best practice for getting an image path ...
2
votes
2answers
687 views

Is it possible to enqueue a script from a widget method (of extended WP_Widget object)?

I am creating a widget plugin that a user could potentially use multiple iterations of the widget multiple times on a single widget-area / multiple widget-areas on a single page. Because of its ...
1
vote
1answer
278 views

Enqueue script with url_query variables?

Is there an easy way to enqueue a JavaScript file with url_query values populated? I have a php file underneath my js directory with JavaScript headers that I want to generate some dynamic JavaScript ...
0
votes
1answer
232 views

wp_enqueue_script does not recognize my js file?

my wp_enqueue_script does not seem to work, i can't understand why : i have a child theme of twenty ten, i wrote this in my functions.php file (in my theme) : <?php function my_scripts_method() ...
0
votes
1answer
239 views

Plugins loading multiple copies of JQuery

I'm having issues where multiple copies of jQuery are being loaded onto the page via plugins that require jQuery. I Just want to confirm that if I have 3 plugins active on my page, that all properly ...
0
votes
1answer
238 views

Page not found when trying to link to files in child theme directory

I'm trying to create a child theme based on Toolbox 1.4 by Automattic. I have my scripts file saved as child_theme/js/scripts.js on my server and I enqueue it by using wp_enqueue_script( 'scripts', ...
2
votes
1answer
1k views

require.js to load javascript

whilst wp_enqueue_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts ...
0
votes
1answer
227 views

Loading Images from Javascript on the Front End

I'm getting some 404 errors on image paths in this plugin I'm building. I'm trying to build a plugin that has some Javascript and images (like a close icon and a progress bar) that I want to load on ...
3
votes
2answers
5k views

Notice that the wp_enqueue_style is not being called correctly!

I get this error due to one of the plugins which I rely on. Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, ...
3
votes
2answers
302 views

What are the benefits of using wp_enqueue_script?

Is there any real benefit to using wp_enqueue_script on small self-managed sites? For instance, Modernizr, why enqueue it through a function rather than call it directly inside the document head? I ...
1
vote
1answer
3k views

How do I make script load after jquery?

function load_my_script(){ wp_register_script( 'my_script', get_template_directory_uri() . '/js/myscript.js', 'jquery' ); wp_enqueue_script( 'my_script', 'jquery'); } add_action('wp_enqueue_scripts', ...
1
vote
1answer
155 views

getting a js file for one page

wp_register_script('SliderViewer', '/js/SliderViewer-1.2.js'); wp_enqueue_script('SliderViewer'); get_header(); however, mydomain.com/js/SliderViewer-1.2.js doesn't exist. My js is in the ftp at ...
3
votes
3answers
1k views

How to enqueue script if widget is displayed on page?

I created a widget that uses a jquery plugin, and I used is_active_widget to enqueue the script, it's working fine but it's also including the script even on pages that doesn't show this widget. so is ...
1
vote
2answers
809 views

Is there a way to set the order of wp_footer hooked functions?

I was wondering if we can set the order of a function hooked to wp_footer(), I created a function that echos: <script> ajsfunction(); </script> and I also enqueued the js file of this ...
1
vote
2answers
100 views

Making a plugin only available on the front-end for the logged in super admin

I made a little plugin that enqueues 1 .js file and 1 .css file into a theme's front-end. All it does it load a grid on top of the theme so I can visualise the design. If this plugin was activated ...
0
votes
1answer
450 views

admin_enqueue_scripts not rending JS file correctly

I'll keep this short and sweet, I want to load a JS file in the admin panel as part of my plugin, and through tons of research I have a few different options that have all ended with the same problem ...
12
votes
2answers
574 views

Conditionally enqueue a widget's script/stylesheet in HEAD (only when present on page!)

I've been trying to load scripts and styles for a WordPress widget with the following conditions... The scripts MUST load in the HEAD (else they break). The scripts must ONLY load when the widget ...
0
votes
1answer
179 views

Need help with adding jQuery script to WP and calling script to page

I've written a pretty simple jQuery script, and I don't know how to call it. It's in its own directory. First, how do I register it, and then how do I enqueue it? I assume that's the order it's done ...
3
votes
3answers
1k views

How can I remove the site URL from enqueued scripts and styles?

I'm dealing with an SSL issue and I would like to strip the domain from all scripts and styles being output via wp_enqueue_scripts. This would result in all scripts and styles being displayed with a ...
0
votes
2answers
1k views

Best Way to Include Scripts on a Specific Template Page

This is something that has always confused me and I could use some help. I want to do four things directly above the closing body tag: include jQuery (WordPress version is fine) include a jQuery ...
0
votes
2answers
129 views

JavaScript enque stopped working

Somewhere along the line I have messed up my js enqueue I am not sure how. I have the following in my functions.php file and I am including <?php wp_footer(); ?> in my footer.php before the js ...
8
votes
5answers
5k views

Including jQuery and JavaScript files the correct way

I'm having some trouble with this. I'm not sure how to do it the correct way, and I read so many different techniques and ways to do it that I don't know what to make of it. Some questions and ...
4
votes
1answer
2k views

wp_enqueue script my_javascript_file in the footer

I am trying to place my_javascript_file in the footer. According to the documentation $in_footer is the fifth value and it is a boolean so I have it set to true. Currently it doesn't show up anywhere, ...
0
votes
1answer
505 views

wp_enqueue_script not loading my custom js file

I am using the following code below in my functions.php, However app.js is not found when I inspect it in the resources tab. It is looking for it in ...
0
votes
2answers
400 views

thickbox never gets called (weird behavior)

I have the exact same files (except for wp-config) running on a local server and a test server, and in my functions.php I have this: function len_scripts() { if (!is_admin()): ...
0
votes
1answer
409 views

unable to wp_enqueue_script('suggest');

i'm not able to enqueue the built in autosuggest script in my wordpress theme. wp_enqueue_script('suggest'); my current workaround for that problem is to deregister, register manually an then ...
0
votes
1answer
91 views

How can I print out a single stylesheet or javascript link?

I know I can use enqueue_script and enqueue_style to register scripts and stylesheets, however I'm trying to print out just the link to the adminbar css: <link rel='stylesheet' id='admin-bar-css' ...
0
votes
1answer
112 views

Loading scripts on a single page plants the script in the footer

I'm using this code to plant a script on a spesific page, it works but inserts the script into the bottom of the page not the top - I'm at a loss to explain why! Is there a way to do this that results ...
0
votes
1answer
870 views

wp_enqueue_script jquery and jquery ui not working

I am using the following script to call my Jquery and Jquery UI as well as a custom-script.js. Currently it works to the point of being able to see the resource in the inspector and the tag's are ...
0
votes
1answer
821 views

Deregister multiple scripts using a function?

I'm trying to deregsiter multiple scripts using the following function. add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); function my_deregister_javascript() { if ( ...
-1
votes
1answer
87 views

wp_enqueue has a resource but doesn't generate a script tag [duplicate]

Possible Duplicate: wp_enqueue_script isn't connecting my custom js file I am really confused as to how wp_enqueue_script works. I have the following code in my header, and when I ...
1
vote
1answer
283 views

wp_enqueue_script isn't connecting my custom js file

I am using wp_enqeue_script to link to a custom.js file in my plugins folder. However I am expecting a link to show up on the page but it doesn't is there something else I am supposed to other than ...
12
votes
1answer
3k views

How to use wordpress default Password Strength Meter script

I have enqueued wordpress default password strength meter but don't know how to use it. Currently the codex page doesn't give any link to its documentation. Does any one have any links to its demo ...