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

0
votes
1answer
56 views

JavaScript Libraries in WordPress

I understand that in order to use a JavaScript library in WordPress, such as jQuery, we have to use the following code to prevent conflicts: function my_scripts_method() { wp_enqueue_script( ...
0
votes
1answer
67 views

wp_enqueue doesn't load dependencies

I'm trying to load style.css but rest.css should be included first. I don't understand why reset.css is not included function addMyScript() { wp_register_style('style', ...
0
votes
1answer
237 views

In jquery use php variable to execute an enqueued jquery file

I am loading some jquery on a specific Wordpress admin page, the jquery loads and works fine but I need have this jquery only trigger if a php variable exists. In php I would just write a function ...
0
votes
2answers
749 views

if custom posts type exists and there are posts load script

I have registered a custom post type 'featured_post'. I am looking for a way to test if the blog home page has any 'featured_post' posts on it and if it has load a javascript file. The ...
0
votes
2answers
330 views

Loading Scripts For Specific Template

I'm attempting to load a couple of scripts based on the template in use. However, the is_page_template is not activating. From my functions.php in the child theme I have: function sectionDescription ...
0
votes
0answers
53 views

Using array page name together with page id to deregister script

If I use this: if (is_page(array(blabla-test-page, 20726, 20720, 38881))) {wp_deregister_script( 'gdsr_script' ); } the blabla-test-page looks like it overrides different pages, even if certain ...
16
votes
3answers
4k views

Check if a script/style was enqueued/registered

Is it possible to test whether a script or a style was registered using wp_register_script/_style or wp_enqueue_script/_style? All functions doesn't return a value and I'm completely clueless. I ...
2
votes
2answers
2k views

How to load JQuery easing script in wordpress?

Ok, first of all, I know how to do this manually. I could just download easing, place it in my plugin folder and load it using wp_enqueue_script. However, I want to load my script in a long-term way, ...
0
votes
1answer
53 views

Checking for 'gallery' shortcode using strpos always returns false

I want to conditionally enqueue a script and stylesheet depending on whether the [gallery] shortcode is used in posts. Here is how I am doing it (based on): function doraemon_scripts() { if( ...
0
votes
1answer
286 views

loading javascript CDN with local fallback (not jQuery)

I'm trying to modify this to register and enqueue a jQuery plugin from a CDN with local fallback. However, when the URL fails (or if I give it a fake url) Firebug receives 2 aborted calls to the URL ...
16
votes
5answers
7k views

How do I enqueue styles/scripts on certain /wp-admin pages?

I have two simple functions that load stuff using wp_enqueue_style() and wp_enqueue_script(), something like these: function admin_custom_css() { wp_enqueue_style( 'stylesheet_name', ...
0
votes
1answer
152 views

enqueue script if page is not equal to

I'm registering some js scripts in my function.php, I have 2 versions of one js file, one FOR the homepage, and one for every other page. I've managed to get this to work to register the homepage ...
0
votes
1answer
158 views

wp_localize_script not create variable in head section

I try to make an ajax function in wordpress and I enqueued my script and declared my variables like this in functions.php: function my_enqueue_scripts() { wp_enqueue_script( 'load_post', ...
2
votes
3answers
127 views

How to detect if a function has been fired on any page so scripts/styles can be loaded conditionally

I'm building a small gallery plugin and I'd like to only load scripts/styles onto the page IF the gallery has been loaded via the template tag. The template tag can take a post ID parameter when used ...
1
vote
0answers
267 views

Getting jquery to work with custom theme

I am trying to get some jquery plugins to work with my custom theme. Up until now I was doing this: function my_scripts_method() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', ...
1
vote
1answer
206 views

When is it too late to call the action wp_enqueue_scripts?

I'm creating a plugin that always enqueues a script in the footer. I also have a function that if called would enqueue an additional script that depends on the other one. Here is the basic format of ...
1
vote
1answer
1k views

jquery-ui-autocomplete is not loaded with wp_enqueue_script

when I load the default jquery-ui-autocomplete script from wordpress via wp_enqueue_script( 'jquery-ui-autocomplete', '', array( 'jquery-ui-widget', 'jquery-ui-position' ), '1.8.6' ); it is ...
0
votes
1answer
183 views

plugin's script and style enqueing not working on Thesis

I've published a plugin on WP repository that allows some theming for Gravity Forms. This plugin as been tested with Twenty Ten, and Twenty Eleven. When I've tried to test it in a site that uses ...
0
votes
0answers
77 views

Javascript not defined but included

I am attempting to implement a javascript function within a page. It is implemented correctly in the header and loads correctly: <?php function forceNumber2() { wp_enqueue_script( ...
0
votes
1answer
340 views

wp_localize_script is not adding a global variable for javascript

So I've read a few tutorials on ajax and the codex documentation on it and I think I understand now how it is supposed to work, however it appears that wp_localize_script is not doing anything at all. ...
1
vote
1answer
51 views

Prioritizing wp enqueue scripts error

I wanted to load the following two scripts before any other script so I added priority 1 and 2, however I am getting an error. I read it on a tutorial that this is how to prioritize ...
1
vote
1answer
49 views

Overriding a function in wordpress

A theme that I bought is adding unnecessary inline JS code that is not needed in the front page. /* Scripts - dynamic css */ add_action('wp_footer', 'upme_custom_scripts'); function ...
0
votes
1answer
466 views

Javascript on Registration Page

I've been trying to figure out how to implement javascript on my registration page with no luck. I've read the documentation on wordpress about properly including js, have searched for relevant ...
0
votes
2answers
642 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
1answer
374 views

wp_enqueue_script Doesn't Work?

It's pretty standard, I enqueue script and style for admin page. function admin_custom(){ wp_enqueue_script('js', plugins_url('adm.js', __FILE__)); wp_enqueue_style('css', ...
-2
votes
1answer
27 views

Which jQueryUI handles are predefined in wordpress?

In section 4 of this blog entry jQueryUI is loaded by wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-datepicker', $pluginfolder . ...
1
vote
1answer
440 views

Including style.css in Child Theme

Twenty Thirteen uses wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() ); in functions.php. Wheter I use it or not use it in twentythirteen-child/functions.php the style.css from Child ...
0
votes
1answer
89 views

Modular CSS and JS in Child Themes

Let's assume that twentythirteen/shortcodes/ exists and inside are folders with shortcodes. 1 folder = 1 shortcode. Each shortcode has: 1 PHP file, 1 CSS file, 1 JS file. ...
0
votes
1answer
103 views

Child Theme - what is the scope of overwriting files?

I noticed that creating twentythirteen-child/archive.php overwrites twentythirteen/archive.php but creating twentythirteen-child/shortcodes/drop-cap/drop-cap.php does not overwrite ...
0
votes
1answer
79 views

Including files in Child Themes

Twenty Thirteen uses the following in functions.php: require( get_template_directory() . '/inc/custom-header.php' );. When I copy /inc/custom-header.php to twentythirteen-child, it isn't replaced. I ...
1
vote
2answers
61 views

Enqueue never runs

My enqueue scripts are never called I can't figure out why. All my paths are correct and I'm assuming the code is correct Functions.php function tim_enqueue_default_scripts() { if (ENVIRONMENT ...
0
votes
0answers
73 views

jQuery does not enqueue for my purpose… (before an inline script in the footer)

Following How to add a javascript snippet to the footer that requires jQuery I am trying to load jQuery before my script does stuff but it's not working. This is it working when I include jQuery ...
4
votes
3answers
268 views

Best Practices for Seperating jQuery from HTML/PHP

I am creating several jQuery scripts to help validate forms before they are submitted. I have read that it is best to always separate jQuery scripts into a separate file so that you can load the ...
0
votes
1answer
1k views

chosen jquery library not loading - is not a function error

I am trying to load the chosen library: http://harvesthq.github.com/chosen/ I am enqueuing a .js file as below: wp_register_script( 'js_custom', plugin_dir_url( __FILE__ ) . 'js/jquery.js', false ); ...
2
votes
1answer
2k views

How do I implement the Wordpress Iris picker into my plugin on the front-end?

This question here is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a ...
1
vote
1answer
200 views

Can't load JS File

I'm trying to load two JS files. But some how its not working. Tried both of these, and the console window doesn't complain of unable to load the file, it never was in the head. Also, I'm having a ...
0
votes
2answers
314 views

Enqueue scripts inside a class in a plugin

I have a plugin like this: <?php /* Plugin Name: MyPlugin */ class MyPlugin { public function __construct() { add_action('wp_enqueue_scripts', array($this, 'enqueueAssets')); } ...
1
vote
1answer
765 views

wp_head() - list hooked actions with priorities?

I'd like to add something to wp_head() but I'm aiming precise location (like after style.css but before rtl.css and before my other custom script). I'm wondering if it's possible to list everything ...
1
vote
2answers
539 views

Load multiple Javascript scripts

I have three Javascript script that I need to load - imagesLoaded.js lazyload-1.8.4.js and cd.js cd.js contains my functions that use imagesLoaded.js and lazyload-1.8.4.js. Do load them ...
0
votes
1answer
200 views

Stop a plugins js and css from loading on all pages and show up only where it is called

This plugin has an unique way of registering styles and scripts so I have no idea on how to stop it from loading on all my pages. After a quick search to see where wp_enqueue_style&script is I ...
0
votes
2answers
182 views

Enque Javascript in Footer?

I currently enque jQuery like so - how do I move this to the footer instead? // Enque: jQuery if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11); function my_jquery_enqueue() ...
0
votes
1answer
68 views

How to enqueue some javascript source once per page

I need my plugin to generate the following - once per page: <script type="text/javascript" src="https://<ritc url for js file>"></script> <script type="text/javascript"> ...
0
votes
1answer
175 views

Linking wp_enqueue can't find the javascript file (adds “?ver=x.x.x” to the src)

So I'm trying to link in a javascript file the right way, by using this: --functions.php-- function custom_scripts() { wp_register_script('myscript','/backdrop.js',array('jquery')); ...
2
votes
4answers
3k views

Asynchronous Javascript Loaders

I'd like to take advantage of loading my scripts while the page is loading. ie. Yepnope, head.js etc... But I also want to be able to enqueue the script so other plugins don't try adding their own. ...
0
votes
2answers
266 views

enqueue_script doesn't work with HTML5 blank theme

I am trying to enqueue a couple of js files using something like this code: function scripts_function() { wp_register_script('mapbox', 'http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'); ...
0
votes
2answers
72 views

wp_enqueue_scripts hangs

In the following snippet, when I add the wp_enqueue_scripts call, the page freezes. What am I doing wrong? function my_enqueue_stuff() { if ( is_front_page() ) { wp_enqueue_style('style', ...
0
votes
0answers
54 views

How to load script-related styles automatically?

Scenario: It is common that a JS dependency is bundled with a style file to work properly (just think about your favorite slideshow jQuery plugin). AFAIK, in this situation, the script and style have ...
1
vote
1answer
161 views

Problem with wp_enqueue_scripts in plugin

I've created the following plugin which requires a js library, however attempts to load the plugin with the line add_action( 'wp_enqueue_scripts', 'calc_script' ); in place fail with the error ...
3
votes
1answer
545 views

How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?

How would I go about combining multiple CSS files and concatenating my scripts if they're being enqueued as WordPress recommends? My site is pretty slow and would like to optimize for performance.
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 ...