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
32 views

Understanding wp_enqueue_style

I am trying to understand how wordpress works, but I am having issue understanding how wp_enqueue_style(), wp_enqueue_script() works in relation to page output. From my understanding, these functions ...
0
votes
0answers
12 views

Enqueue more than 2 scripts from cdn with a callback

this subject has been covered here and it works but my questions is how to do this for more urls? for example i need to load bootsrap js / css, font awesome, animated.css from external cdn but with ...
0
votes
1answer
15 views

plugins_url() incorrectly returning wp-include directory

I doubt there's a bug with plugins_url() but this is some odd behaviour I'm seeing. I have the following in an activated plugin function include_masonry() { wp_enqueue_script( 'masonry', ...
0
votes
1answer
21 views

custom template - override plugin template in child theme - issue with scripts

I'm using a custom template for the single-listing.php from WP Listings. I've used my own theme (Canvas by woothemes) single post template, and included the wp-listings code. ...
0
votes
1answer
19 views

jQuery + more won't load in header

We moved jQuery to the footer using the following code: function jquery_enque_fix() { if( !is_admin() ) { // Enqueue so we can grab the built-in version wp_enqueue_script( 'jquery' ); ...
1
vote
2answers
41 views

Benefits to enqueuing site scripts/stylesheets?

I'm aware of a similar question here: What are the benefits of using wp_enqueue_script? - However, what differs is I'm talking about a site with a pre concatenated/minified stylesheet and site ...
0
votes
2answers
32 views

Dequeuing scripts for all pages but the home page

I'm trying to dequeue some scripts from a plugin that I only need for the home page. For the home page, I'm using a file called front-page.php with this on top to make it a home template: <?php /* ...
1
vote
0answers
23 views

Override do_item() Function to Add Extra Attribute to Scripts

The WordPress file that do_item() is in can be found here: class.wp-scripts.php Line 142 Line 144 $this->print_html .= "<script type='text/javascript' src='$src'></script>\n"; ...
3
votes
2answers
109 views

Get list of scripts / styles and show file which enqueued them

I want to show what scripts and styles have loaded on a page and which plugin / theme / file has added them to the page. We can show all scripts and styles using: <?php global $wp_scripts, ...
1
vote
1answer
647 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
29 views

Using wp_enqueue_script in a wordpress plugin

This is my current code: <script src="http://unibet-affiliate.enetscores.com/xjs/hour/theme/affiliate/361/client"></script> <script> ...
0
votes
2answers
824 views

Deregister scripts on unnecessary pages using remove_action

To all would-be close-voters: This question is not a duplicate, because I need to remove all scripts added by plugin using remove_action. In Very stubborn wp_register_script / add_action vs ...
0
votes
2answers
2k views

How to Add a Custom Script to Customize.php

I am having a rather difficult time adding a script to the 3.4 Theme Customizer (i.e., customize.php). If I want, I can deregister jquery and add it from googleapi as follows: wp_deregister_script( ...
4
votes
1answer
278 views

Concatenate and minify dependencies for enqueued JavaScript files

I'm loading a JavaScript file using wp_enqueue_script into my theme. However, along with it, I'm loading several jQuery files as well, as dependencies for the enqueued script (which has already been ...
0
votes
0answers
18 views

How add style in wp after main theme style.css

I try add style via plugin which should overwrite main theme style.css I use this code but it is not help me. function css() { wp_enqueue_style( 'css', plugins_url( '/css/style.css', __FILE__ ...
0
votes
2answers
26 views

Adding Dropbox dropin js using wp_enqueue_script

I want to add a new Dropbox Drop In Chooser button to my site. To include the code in a simple page you use <script type = "text/javascript" src = ...
5
votes
0answers
132 views

Loading a script with a dependency, is unloading another script's dependency

First, I'm aware that my question is happening in the context of my work with the WooCommerce plugin, which would normally make it off-topic. However, I think my question relates to wp_enqueue_script, ...
1
vote
1answer
417 views

Move jQuery to the bottom of the page whilst keeping the WordPress jQuery

I wish to move jQuery to the bottom of the page on my theme, to speed up loading times. Previously I was doing this by replacing it with Google's CDN version but I have been told that is a bad thing ...
0
votes
1answer
21 views

Get info (url) from already enqueued styles

I am building a theme and using Easy google fonts WordPress Plugin. I created several typography controls within Theme Customizer for Post content,Post header, Author page content, Single Post ...
0
votes
1answer
54 views

Calling wp_localize_script in a different function

I am trying to localize a variable in a javascript below.. The scenario is that I want to dynamically get the post_id and localize it in the jquery I have enqueued through wp_enqueue_scripts. Here's ...
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 ...
0
votes
1answer
27 views

Loop through arguments of a function

When I'm trying to create a loop for a object oriented approach (I think) php prompts me with 2 errors. I think it has to do something that a array ($args) can't be used on on a place where I should ...
0
votes
2answers
54 views

Problem enqueuing scripts on not single posts

I have this code to enqueue a script file when the page is not single.php (neither admin page): //functions.php /********************** Add JS file **************************/ function ...
6
votes
4answers
754 views

Is there a JavaScript API? How to access public and private data in JS?

According to this post there is no built-in JavaScript API for Wordpress. Therefore developers who want to build on AJAX seem to come up all with their own solution which doesn't seem right to me. ...
0
votes
3answers
92 views

Don't load scripts if on mobile/tablet

Would like to ask the question is it possible to stop the laoding of some scripts when viewed on a mobile/tablet device ? In the theme functions file you have wp_enqueue_script(...). How would you go ...
2
votes
1answer
95 views

Enqueue Scripts / Styles when shortcode is present

What is the idea way to register/enqueue scripts and/or styles for use in plugins? I recently made a plugin simple plugin to add the user avatar/gravatar with a shortcode. I have different style ...
0
votes
3answers
78 views

Why is my css and js not enqueued until footer?

add_action( 'wp_enqueue_scripts', function ( ) { global $post,$pageparent; if(in_array($pageparent, array($post->ID,$post->post_parent))){ wp_enqueue_style( 'products_pages', ...
0
votes
1answer
39 views

Script work on non logged in user but not work for logged in user?

I am currently working with jquery and wordpress plugin. jQuery(document).ready(function($) { $('.btn').click(function(){ alert("hello world"); }); }); This code working very well ...
1
vote
1answer
83 views

Using multiple versions of jQuery while still calling it like WP likes

I have two JS plugins inside my plugin. One uses jQuery 1.7.1 and the other 1.9.1. I need to have each of them use different version. This is how things are at the moment: Plugin php file: ...
11
votes
1answer
6k views

How do I dequeue a parent theme's CSS file?

My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php: add_action( ...
4
votes
3answers
193 views

How to echo JS right after enqueued script to put it into noConflict mode?

I want to include and use third party JavaScript file (Bootstrap Tooltip) in my plugin. Since Bootstrap is highly popular framework and tooltip() is rather generic name I want to make use of included ...
15
votes
4answers
2k views

Could the WP script/style loader be used to concatenate and gzip scripts and styles in the front-end?

WP has a nice javascript loader included in wp-admin: http://core.trac.wordpress.org/browser/tags/3.0.4/wp-admin/load-scripts.php and a CSS loader: ...
1
vote
3answers
152 views

Can I add styles to footer with $wp_styles->add_data?

I'm working on a script to easily move js and css scripts to the footer using the add_data function in $wp_scripts and $wp_styles. I know for scripts that if the group is greater than 0 the script ...
4
votes
3answers
242 views

Combine enqueue js without affecting dependencies

I want to combine little javascript files while keeping other script's dependencies for them. Is there any way? Details: New version of BuddyPress enqueue 6-7 little javascripts: // Legacy ...
0
votes
0answers
50 views

Check for Twitter Bootstrap Loaded

I am developing a plugin that uses Twitter Bootstrap Modals, but would like to prevent loading bootstrap if it's already loaded. <a ...
0
votes
1answer
312 views

jQuery is not defined, working on local server but not online

here's my problem: Chrome console: Uncaught ReferenceError: jQuery is not defined jquery-ui.min.js:6 Uncaught ReferenceError: jQuery is not defined slider.js:1 Uncaught ReferenceError: ...
0
votes
1answer
56 views

Best way to enqueue extremely popular scripts like bootstrap and font awesome

Scripts and Styles like bootstrap and font awesome are used on hundreds/thousands of plugins. Whats the best way to check for this? If two scripts aren't registered with exact same name they'll both ...
2
votes
3answers
6k views

Can't enqueue scripts in the footer?

The WordPress codex says: $in_footer (boolean) (optional) Normally scripts are placed in the section. If this parameter is true the script is placed at the bottom of the . This requires ...
0
votes
1answer
30 views

Generating embed code for users to share

Recently I was stuck by an idea to let users and other bloggers to embed the entire page on of my blog on to their blogs. The problem is I have to change the URL every time in code and the codes ...
5
votes
3answers
317 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
0answers
30 views

How do I get my theme scripts to load in a custom theme built from Bootstrap

I have created my own theme, pretty much from scratch, using Bootstrap 3.x. If just refer to the scripts from my footer.php file, it works. However, if I try to do it the right way, using ...
2
votes
2answers
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 ...
0
votes
3answers
154 views

How do I enqueue a JavaScript in my footer via the functions.php file?

Okay, so I'm well familiar with the way to properly enqueue a stylesheet or JavaScript in the WordPress header via the functions.php file. Recently though I came across a situation that has me ...
0
votes
1answer
42 views

How to enqueue default scripts with dependency?

I'm developing a plugin and for that I need jQuery and jQuery datepicker. I's taught that WordPress already enqueued some scripts, and I found 'jquery' and 'jquery-ui-datepicker' there. Where the ...
0
votes
2answers
109 views

deregister scripts on certain page

i need to exclude certain scripts from running on a certain page. i have tried this code but it's not working - when i inspect the page the scripts are still being loaded into the footer of my page. ...
2
votes
1answer
335 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 ...
10
votes
5answers
7k views

wp enqueue inline script due to dependancies

Is there a way to use wp_enqueue_script() for inline scripts? I'm doing this because my inline script depends on another script and i would like the flexibility of inserting it after it's loaded. ...
4
votes
2answers
2k views

Using wp_enqueue_script on shortcode function handler

I have this code function this_is_my_shortcode(){ wp_register_script('per-pas-belanja-online', plugins_url('js/per-pas-belanja-online.js', __FILE__), array('jquery'), '1.0.0'); ...
0
votes
1answer
54 views

Use an array of page template slugs and $hook

I'm using the function below to load some javascript that removes the checkbox in the User Profile that is used to toggle the Visual Editor: //Remove Visual Editor option in User Profile function ...
1
vote
3answers
54 views

Javascript not included

I have tried to include my javascript file in the following way: function theme_scripts() { wp_enqueue_scripts( 'custom-script', get_template_directory_uri() . '/js/menu-fix.js',array('jQuery'), ...