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

Bootstrap sticky menu in WordPress

I have a menu which I have assigned the affix class using the JS and the data-spy methods but it doesn't work, there are no JS errors in my console (firefox or chrome) and the js and css of BS are at ...
0
votes
1answer
34 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
14 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
16 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
24 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"; ...
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
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__ ...
5
votes
0answers
139 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, ...
0
votes
2answers
27 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 = ...
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
55 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 ...
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 ...
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 ...
6
votes
4answers
755 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
95 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
99 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
84 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: ...
1
vote
3answers
154 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
243 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
319 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 ...
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 ...
0
votes
0answers
31 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 ...
4
votes
1answer
279 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
3answers
158 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
43 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
112 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. ...
0
votes
1answer
56 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'), ...
0
votes
1answer
39 views

Custom CSS not being added by plugin

I am attempting to add custom css through my plugin. I do have wp_head() called in my header. My code is - /** * Enqueue plugin style-file */ function prefix_add_my_stylesheet() { ...
0
votes
0answers
128 views

Blueimp file uploader inside Smart Wizard page

I have looked around and can't seem to find anything that answers the question, but if I am double posting please direct me to where I should be. I am trying to use the Blueimp File Uploader inside ...
0
votes
1answer
55 views

Ajax Request with jQuery not happening

My problem is: Can't do a POST request with jQuery. Down here is the complete description: I created a link in a page (using the plugin PHP code for posts and pages): <?php $nonce = ...
0
votes
1answer
24 views

Overide enqueue in non plugable function via child theme

I am trying to override a non-plugable function using the information on this page but it seems to have no effect. Can anyone see what's wrong. My code is remove_action('wp_print_styles', ...
0
votes
0answers
89 views

How do I display the handle for all front-end enqueued scripts in plugin options page?

I use the following function in my plugin to display all the scripts handles in my plugin options page but it display only the handles of admin scripts: function my_detected_scripts() { global ...
0
votes
0answers
49 views

How to get transient cache to work with wp_enqueue_script

So I have this page that has various shortcodes on it. Each shortcode may have wp_enqueue_script to load say jQuery accordion or tabs. Now I am wanted to cache the page for better performance so I ...
2
votes
1answer
177 views

Dynamically Load Styles and Scripts from Theme Functions.php

I am attempting to dynamically load stylesheets and scripts based on the template name. So if I have a template named page-signup.php then it will load the corresponding stylesheet page-signup.css and ...
2
votes
2answers
127 views

Correct Method to run scripts with dependencies without enqueue?

With enqueue you would change $deps to your script or array of scripts that are needed to run first for your script to work. <?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ...
0
votes
2answers
169 views

$.browser Undefined Seemingly Causing Faulty Page Display

At this site I have an error using the parent theme's jquery.PrettyPhoto.js This causes tabs not to load well nor gallery to work well it seems. The error states TypeError: $.browser is undefined ...
1
vote
1answer
40 views

Execute only on a certain page

I"m trying to get the block of code below to load only when it's the contact page but it doesn't seem to wotk. Any ideas what the problem could be. Still pretty much new to PHP. if ...
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, ...
2
votes
2answers
958 views

WordPress Script Loading/Unloading — wp_deregister_script('jquery')

I have a few questions relating to WordPress loading / unloading up javascript tools. After reading a nicely written response to a question by Pieter Goosen, that got me to do a bit of studying and a ...
1
vote
1answer
54 views

How resource intensive is wp_register_script()?

I'm trying to use the has_shortcode() function to only load certain scripts when there is a shortcode in the post's content, with this code: wp_register_script( 'shortcode-js-file' , FILE_URI, array( ...
2
votes
1answer
1k views

How to get a jQuery script to run on a page?

I am having a hard time figuring out how to get a jQuery script to run on a Wordpress page of mine the "correct" way. I have followed this article and implemented what the first answer says to do. ...