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

-1
votes
1answer
133 views

jQuery issue and wp_enqueue_script

Actually i have one theme with enqueue for insert jquery code and reference for the core and also jquery iu Bus happend things that i don´t understad, actually as i tell until i need insert code for ...
5
votes
5answers
1k views

Adding Additional Attributes in Script Tag for 3rd party JS

I ran into this when attempting to integrate Dropbox's drop in chooser API to a plugin I'm writing. The API documentation instructs you to place the following script tag at the top of your file: ...
1
vote
1answer
115 views

How to undo deregister script and use local versions?

The WordPress theme I am using deregisters the jQuery and jQuery UI libraries and registers google-hosted versions instead of the libraries from wp-includes. Here is the code in `functions. UPDATE: ...
0
votes
1answer
72 views

How to enqueue scripts in right way in a plugin?

I am developing a wordpress plugin and just came out with a problem with enqueue scripts. I want to enqueue JQUERY UI (.js) and (.css) in my plugin. Is it better to enqueue it from Google CDN or ...
0
votes
1answer
58 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
89 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
295 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
0answers
63 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 ...
0
votes
2answers
392 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 ...
4
votes
3answers
1k views

How to add stylesheets only to pages with specific shortcode?

I'm running a function on pages where the shortcode [make-me-a-map] is used. It enqueues javascript to the page and makes a map. That part works fine (woot!) but I'm having trouble with adding the ...
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, ...
1
vote
1answer
626 views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
0
votes
1answer
63 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
201 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
212 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
141 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
420 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
265 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
2k 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
0answers
109 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
411 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
55 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
62 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
619 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 ...
-2
votes
1answer
34 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 . ...
0
votes
1answer
111 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
102 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. ...
1
vote
1answer
649 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 ...
1
vote
1answer
103 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 ...
0
votes
0answers
75 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 ...
1
vote
2answers
69 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 ...
5
votes
3answers
314 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 ...
1
vote
1answer
398 views

Trying to add script to specific admin page is not working

What I am trying to achieve is to load a .js file on an edit.php page, however the code is not working specifically for this page. I've applied the same code type of code to other CPT pages, but for ...
0
votes
2answers
590 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
1k 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
809 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
231 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
189 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() ...
1
vote
1answer
281 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
1answer
69 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
183 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')); ...
0
votes
2answers
334 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
84 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', ...
1
vote
0answers
59 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
183 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 ...
1
vote
0answers
136 views

Is it possible to enqueue the Youtube API script or does it have to be inline?

The code below is the main part of a function in my functions.php which returns a div and script which ultimately output a youtube API iframe to the template where the code had been called from. At ...
0
votes
1answer
85 views

Ordering stylesheet above <style> using functions.php

I'm loading a stylesheet and a style into the header using functions.php. This works but the stylesheet is being presented below the <style>. I need to order the stylesheet above the style ...
-1
votes
1answer
86 views

Errors while Loading Most Recent Version of jQuery

I am trying to set up my WordPress so that it will use the most recent version of jQuery. Here is what I have done so far: functions.php <? add_action( 'wp_enqueue_scripts', 'RegisterJQuery' ); ...
2
votes
1answer
292 views

Using get_option() in JavaScript

Previously, I used the get_option() function to get an option in PHP, like this: $width = get_option('my_width'); This is inside a shortcode function. Now, I want to have an option in JavaScript. ...
0
votes
1answer
85 views

Enqueueing scripts selectively & activation where needed

If I enqueue my scripts selectively, for instance I have a slider I only want to load on homepage, which is activated in main-js, e.g: wp_enqueue_script( 'main-js' ); if ( is_front_page() ) { ...