0
votes
1answer
25 views

WP Plugin Running before jQuery

Can somebody please take a look at this, I'm really getting frustrated with it. I'm having problems with jquery and a plugin. I've setup a WP theme here if you would like to preview. I've also got ...
0
votes
0answers
41 views

how to remove scripts loaded in the footer

Is it possible to remove scripts that are loaded in the footer in wordpress? I currently have the code that works for scripts but only for the one's that are added in the header via wp_enqueue_script. ...
1
vote
2answers
130 views

enqueue script only if it is not already enqueue

I want to include a script in a shortcode output, so I am trying this: function my_shortcode( $atts, $content = null ) { extract(shortcode_atts(array( 'title' => '', ), ...
1
vote
1answer
59 views

Enqueue Wordpress plugin scripts below all other JS

I am developing a simple Wordpress app but I am having an issue as all of the plugin scripts are rendered before those which are enqueued in my functions.php. Here is a sample section of the ...
1
vote
1answer
134 views

How to run a external JavaScript file on wp-admin if admin, and other if normal user?

I'm new to WordPress plugins, and I'm trying to load a external JS/jQuery file with some scripts I need. It needs to run in the wp-admin page (not just once when activated). There is a JS file for a ...
1
vote
1answer
85 views

Where to call wp_enqueue_script in a plugin with custom template?

I am writing my first plugin and I have this code in the main plugin php to replace home page with custom template add_filter( 'template_include', 'replace_home_page' ); function replace_home_page( ...
0
votes
1answer
38 views

why the wp_register_script doesn't work for register_activation_hook

I want to register a script when my plugin is activated. So I wrote: register_activation_hook(__FILE__, 'register_script'); function register_script(){ ...
0
votes
1answer
36 views

How to know what are the style sheets are available in wordpess?

I just like to use jquery-ui Style Sheet but i don't know whether it's pre-installed in WordPress or not b'coz without knowing that i think it will create a problem. what in case it is available in ...
0
votes
1answer
62 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 ...
1
vote
1answer
137 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 ...
0
votes
1answer
275 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. ...
0
votes
0answers
72 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 ...
0
votes
2answers
180 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')); } ...
0
votes
1answer
70 views

Enqueue ONLY Plugin Styles and Scripts

Is there a way to enqueue only plugin styles and scripts without wp_head? I have a plugin I'm working on which overrides the page template, but I still want to include all other plugins without ...
2
votes
0answers
147 views

Multisite plugin development and wp_enqueue_script

I have a plugin I'm developing. It works fine on a single site version of WordPress. It installs on a multisite version of WordPress, it appears to work on the admin pages, but when the plugin ...
1
vote
2answers
164 views

Avoiding Duplicate function names in Post Loop (WP_Footer script)

Say I created a plugin that injects content (used as a shortcode) into a post. I'm trying to push that code for each post to the bottom of the page. This works fine, however when you are on an ...
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 ...
4
votes
1answer
182 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 ...
1
vote
2answers
241 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
599 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
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 ...
0
votes
1answer
202 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 ...
1
vote
2answers
97 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 ...
11
votes
2answers
511 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 ...
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 ...
0
votes
1answer
388 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 ...
5
votes
1answer
957 views

Load js/css files only on specific admin UI pages

How do I adapt this solution to work with my plugin? (Please see the link). I enqueue my css and js script as follows: function my_plugin_init() { wp_enqueue_script('my_plugin_script', ...
0
votes
1answer
119 views

Why does this fail: Disabling plugins enqueue_script() in functions.php

I'm trying to use the method presented here: Restricting a Plugin to Only Load its CSS and JS on Selected Pages? In the plugin 'syntax-highlighter-compress' I've got the following code: function ...
1
vote
3answers
6k views

How to add a javascript snippet to the footer that requires jQuery

I know I can add a script file to the footer of wordpress that requires jquery using this code: <?php function my_scripts_method() { // register your script location, dependencies and version ...
0
votes
1answer
70 views

should i be checking for jquery before enqueing it in a plugin

At the start of a typical plugin which uses jquery I have something like the following wp_deregister_script('jquery'); wp_register_script('jquery', ...
3
votes
2answers
569 views

jQuery in header or footer

From my reading it seems there is a good case for loading scripts like jquery and dependencies into the footer as a preference if possible; however 2 things confuse me which. Firstly the default for ...
2
votes
2answers
159 views

Inserting JS snippet in the footer if there is no wp_footer?

I wrote a plugin which uses wp_enqueue_script() which will include the snippet in either the header or footer depending on the parameters you pass it. The in_footer parameter works great - if the ...
1
vote
1answer
155 views

Replacing Scripts in Admin Load_Scripts

I'm currently creating a plugin that requires me to overwrite one of the Wordpress admin panel javascript files. I have recreated the file with the changes, I need to know how to replace the existing ...