With `wp_register_script` it is possible to make WP aware of a script without actually loading it. It can later be loaded with `wp_enqueue_script`, but will also automatically load when another script is enqueued that depends on that script.

learn more… | top users | synonyms

0
votes
1answer
13 views

jQuery plugin not loading

I am trying to use the below function to enquue 2 scripts (one internal, one external). The internal one ('custom_script') is working, but the 2nd one ('formValidation') isn't (I get a 'validate() is ...
1
vote
1answer
55 views

wp_register_script(… $in_footer = true) not working

I'd like to load some javascript files in my footer. I tried to accomplish it in functions.php like so: function my_init() { // LOAD JQUERY wp_deregister_script('jquery'); ...
1
vote
1answer
50 views

Where does WordPress register default scripts like jQuery?

I'm figuring out the ins and outs of WordPress. I know that WordPress sets some default filters and actions in /wp-includes/default-filters.php, but where does it register its scripts like jQuery? We ...
-1
votes
1answer
34 views

How to make a customized user registration form using the built in wp-register() template tag

I want to make a registration form in WordPress, but i need it to contain my own custom input fields. For instance, i need it to have an input field such as COUNTRY, SCHOOL, COURSE, YEAR_OF_ADMISSION,...
1
vote
1answer
120 views

wp_enqueue_script with dependencies doesn't work

I'm having this code: wp_register_script('parent','parent.js', array('child'), '1', true); wp_register_script('child', 'child.js', array('grandchild'), '1', true); wp_register_script('grandchild', '...
1
vote
3answers
131 views

Loading scripts with wp_register_script and wp_enqueue_script

How could I include the following script and stylesheet in a wordpress plugin if they only need to load in the admin panel? <script type="text/javascript" src="/wp-includes/js/jquery/jquery.js?ver=...
1
vote
3answers
109 views

WordPress script file version numbers changing in live environment

I'm registering my javascript files for Wordpress in my functions file as so: if( !function_exists( "theme_js" ) ) { function theme_js(){ wp_register_script('wpbs-scripts', ...
0
votes
3answers
67 views

Using wp_enqueue_script on scripts that contain PHP

I'm am working on a WooCommerce website, and have all my jQuery in the footer inside script tags. I use PHP to filter out the needed scripts for any particular page. However, I would like to use the ...
12
votes
3answers
5k 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
1answer
50 views

How should I go about registering JavaScript that isn't a file? [duplicate]

For a plugin I'm creating it generates custom JavaScript that should be executed in the footer of the page. Being that it's custom JavaScript, I can't simply put it in a file and register & ...
0
votes
1answer
40 views

Enqueue script: link not working in page source

I am using the Front-End Editor plugin of Scribu at my website. I want to enqueue it, because I want to use it alongside my caching plugin, but that one only works when JS files are enqueued. The ...
1
vote
3answers
223 views

Why isn't jQuery 2.1 loading in the header?

Because I want to use jQuery 2.1 instead of 1.11, I first have to de-register jQuery. Then register it with the new values. : add_action( 'wp_enqueue_scripts', 'add_scripts' ); function add_scripts()...
0
votes
0answers
13 views

Correct way to update wp_script() url/src? [duplicate]

I tried to update the url/src of the queued $wp_scripts correctly... my aim is to use just relative paths. Therefore I: loaded the $wp_scripts replace the domain and saved the output. But it seems ...
0
votes
2answers
140 views

Localizing script to pass a value to a javascript function

i'm really getting crazy about this. after hours of trials, i can't get out of this. I'm trying to pass a php variable value to an enqueued jquery script but i can't. here is my code. php : ...
0
votes
0answers
56 views

Custom fontend register code problem

I write a php code & shortcode for custom registration form wordpress fontend. But its not work. I can register from wp-admin/wp-login.php?action=register <?php // Custom Register Form ...
0
votes
0answers
94 views

How to wp_enqueue_script with html?

I want to wp_enqueue_script multiple javascript with html and css. I place the html code in a page, but it's not working on my side. Only plain text is displayed. Here's the link: http://goo.gl/...
0
votes
2answers
253 views

Most elegant way to enqueue scripts in function.php with foreach loop

I wonder is there a way of running wp_register_script and enqueue with the help of foreach loop to manage label and dir? For example, function wbs_app_components(){ $scripts_list=array( ...
0
votes
0answers
23 views

Why would javascript files be included in header on one site, but not others?

Why might some javascript files be included in the head section on one site, but in the footer of hundreds of other similar sites? I have several different multisite Wordpress installations on my ...
0
votes
2answers
246 views

Use wp_enqueue_scripts from included php file

I've got a realy hair pulling problem here. I've started cleaning up a plugin i've made and sort some of the functions in diffrent files. but i've got a problem with wp_enqueue_scripts. when i ...
1
vote
1answer
682 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
712 views

Jquery function working in Dev Console but not otherwise [duplicate]

Can someone help me utilize native wordpress jquery to run my function? The only working test i have done is to load an external jquery resouce via the chrome dev console and then add my function to ...
0
votes
1answer
2k views

How to properly dequeue scripts and styles in child theme?

I made a parent theme and a child theme in one of my project. I enqueued CSS and JavaScripts in my parent theme like below: function project_necessary_scripts() { //Stylesheets ...
0
votes
0answers
157 views

how to change the wp register page url from www.site.com/register-2 to www.site.com/register

I was playing around with buddy press and had to create and delete the register page before i found the register page properly on my site. I want to keep my site clean and now when I create a new ...
-1
votes
1answer
1k views

Enqueue scripts in the footer

I'm trying to modify a plugin for enqueue scripts in the footer, because my jQuery link is in the footer. The plugin: add_action('wp_enqueue_scripts', 'fjgwpp_addCSSandJS'); function ...
19
votes
1answer
12k views

When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()?

I'm having trouble understanding when you need to use wp_register_script(). Currently, I just use something like: add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); function enqueue() {...
5
votes
1answer
2k 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', plugins_url('...
0
votes
1answer
138 views

wp wp_register_script function results type parameter missing

I used the following code wp_register_script('jquery', get_bloginfo('template_directory').'/js/jquery.js', false, '',false); wp_enqueue_script('jquery'); It includes the script as <...
0
votes
0answers
67 views

custom script not loading at admin pages

I want to load a custom script on the admin pages. Seems simple right. Still, for some reason the script is not loading. I've tried putting this in my themes functions: add_action( '...
0
votes
2answers
3k 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( '...
1
vote
1answer
818 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: ...
8
votes
3answers
3k views

Remove ?ver= from wp_register_script

I'm getting nags on google speed test regarding the querystrings in my scripts. So, I'm trying to remove them by passing false as the argument for that parameter. However, it does not seem to have ...
1
vote
1answer
3k views

Using wp_register_style to load CSS in footer?

I realise you can enqueue JS in the footer using wp_register_script as there is a $in_footer parameter for doing so. However, there isn't one for wp_register_style it seems. Is there a way to enqueue ...
1
vote
1answer
460 views

Plugin and theme script load order

I'm building a plugin that adds scripts to the page using wp_register_script and wp_enqueue_script. However, when the page loads, it's loading the plugin scripts before the theme's scripts. This is ...
0
votes
1answer
94 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
0answers
83 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 ...
1
vote
4answers
1k views

jquery won't load in footer

I wanted to move jquery to the site's footer, but that doesn't work. I've tried it with the following code. As you can see, I have a couple of another scripts and they load correctly on the footer. ...
8
votes
1answer
5k 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 stylesheets)....
2
votes
2answers
2k 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 ); ?&...
1
vote
1answer
94 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( ...
1
vote
1answer
1k views

plugins_url function mixes system path and URL

In my WordPress widget I use the following code: wp_register_script('jquery-ui.widget', plugins_url('assets/js/jquery-ui-1.9.2.widget.js', dirname( __FILE__ ))); Unfortunately, the code gives me an ...
0
votes
2answers
127 views

Register scripts located in child theme?

I'm having a lot of trouble registering scripts located in a child theme folder: This works fine: function register_scripts() { wp_register_script( 'newsletter', get_template_directory_uri() . '/...
0
votes
1answer
2k views

Strange error from functions.php files (wp_register_script)

I'm trying to migrate a wordpress site, and I'm receiving this error when debugging on the new server: Notice: wp_register_script was called incorrectly. Scripts and styles should not be ...
0
votes
2answers
300 views

How to register and enqueue JavaScript files without breaking plugin dependencies?

In theme development, what is the best way to register and enqueue JavaScript files to avoid problems with plugins? I want to create a theme which uses scripts like jQuery, Masonry and so on. I ...
0
votes
1answer
422 views

include script that depends on modernizr?

first time i am trying to include script to wordpress,but after several hours reading wordpress codex and answers all over the web ,i still dont success to link the script to modernizr, they both show ...
0
votes
1answer
294 views

How to add GET variable after script url?

So, I've registered and enqueued my script. http://mysite.com/wp-content/plugins/my-plugin/script.js?ver=3.6 But how do I add a GET variable on the script src url? http://mysite.com/wp-content/...
0
votes
1answer
141 views

can't access dashboard and showing forbidden page

i cant access my dashboard. after i make true the wp-debug it shows the following error. Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued ...
1
vote
1answer
41 views

Not sure if enqueuing js scripts properly

When I put this code right above the closing of my body tag it works, but when I try to enqueue it, it breaks. I'm thinking maybe jQuery isn't getting called? The snippet is from here FUNCTIONS.PHP ...
1
vote
1answer
389 views

Can't see why my scripts aren't loading when I register and enqueue them

I'm trying to replace "hardcoded" calls in my header.php by registering and enqueueing them in functions.php. JQuery 1.8.3 loads as desired, but the other scripts don't. Here's what I'm using: ...
-3
votes
1answer
102 views

Trying to use wp_register_script/style and enqueu them from an array - getting an error [duplicate]

here is what i got so far: // my array $this->headersArray = array( array('handle' => 'buy_mobile_funcs', 'src' => 'jsFunctions', 'extention' => 'js', 'deps' => '', 'media' => ...
1
vote
0answers
1k views

wp_enqueue_script() doesn't work with AJAX

My problem is: I made an AJAX call using this code wp_enqueue_script( 'prefix-myscript-name', plugins_url( 'js/ajaxcall.js', __FILE__ ) ); I made the call and the AJAX just going fine. I used this ...