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
2answers
979 views

Setting Variable Path to Template Directory inside Script

I have HTML5 Template with 5 pages. I am converting it to a WordPress Theme. I have a contact page. This page includes 'forms.js' script to send contact form data to 'MailHandler.php' file. Inside ...
0
votes
1answer
505 views

Using jquery-1.7.2.min.js instead of the wordpress jquery

I have been trying to deregister the wordpress native jquery and use my version that i have downloaded.At first everything was working fine with the wordpress resident jquery albeit replacing $ with ...
0
votes
3answers
1k views

Loading Modernizr (or other JavaScript libraries) for use in a plugin

Download a copy of Modernizr, put it in your plugin’s directory and simply enqueue the script whenever needed. Done. The problem is that Modernizr may already be loaded by another plugin. You ...
0
votes
3answers
1k views

What can I hook into after_setup_theme?

I'm wondering what can I or should I NOT hook to after_setup_theme? I'm wondering because I have been told that I shouldn't hook wp_enqueue_style to it, but I have seen other places using it to hook ...
0
votes
1answer
56 views

Why do I have to specify all parameters for wp_enqueue_script to load my jquery in the footer? [closed]

wp_enqueue_script('jquery', includes_url() . 'js/jquery.js', array(''), '1.7.2', true); // loads in the footer wp_enqueue_script('jquery','', array(''), '', true); // loads in the head I just think ...
2
votes
2answers
4k views

wp enqueue style on specific page templates

I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. ...
5
votes
1answer
380 views

What does wp-list.js do?

Pretty straightforward question! What does wp-list.js do? It's listed in the wp_enqueue_script codex page as one of the WP included javascript libraries. Thanks!
1
vote
1answer
435 views

wp_enqueuescript won't load in footer even with true value set?

Below is my code for enqueue my scripts and css. I am trying to get the JavaScripts to load in the footer of my site, but when I view source I see them loading in the header. I suppose the "true" ...
1
vote
2answers
2k views

Enqueue jQuery in WordPress

Building my first theme from scratch in Wordpress 3.4.1, I know Wordpress already has the latest version of the JQuery via Google. I have read about issue's if the script is not called properly, so ...
2
votes
2answers
478 views

How to move style from template file to <head> section?

Imagine the following situation: //header.php contains: <header id="header">logo and navigation</header> //my-template.php contains: <?php get_header(); ?> <style ...
0
votes
1answer
289 views

wp_enqueue_script before wp_head

If this works (and it's the way people do in a bunch of themes around the web): <html> <head> <!-- stuff --> <?php wp_enqueue_script('jquery'); ?> <?php ...
0
votes
1answer
78 views

admin_print_styles incuding $_SERVER['DOCUMENT_ROOT']

All the Javascript isn't working in the admin area on my production server. Locally it works fine. I have narrowed it down to /wp-admin/wp-header.php line 72-78 do_action('admin_print_styles'); ...
0
votes
2answers
2k views

WP_enqueue_script() loads them always in wp_footer()?

This is my example code placed in functions.php: function my_init_method() { wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core', false, array('jquery'), false, false); ...
0
votes
3answers
184 views

scripts not enqueueing

I have been beating my head against this for a couple of hours now and can't seem to figure it out. I am trying to enqueue a script into my page with the following code in my functions.php. function ...
1
vote
1answer
373 views

issues with wp_enqueue_script in my plugin

So I am working on a plugin and am trying to trigger a js file whenever a post is saved. I have been reading up on this all morning and cannot seem to find why this is not working. Any advice? If I ...
0
votes
2answers
822 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 ...
4
votes
1answer
189 views

Which method is best to enqueue scripts

I'm currently authoring the development of a plugin for wordpress, and I'm having trouble figuring out which would be the best way to add scripts to the plugin. I'm in the process of adding more ...
3
votes
1answer
115 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
347 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
742 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
297 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
809 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
266 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
111 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
320 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
281 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 ...
6
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 ...
3
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
198 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 ...
2
votes
1answer
323 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
62 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
743 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
298 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
241 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
267 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
272 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
239 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
6k 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
326 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
157 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
884 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
103 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
477 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 ...