The tag has no wiki summary.

learn more… | top users | synonyms

27
votes
1answer
5k views

Where is the right place to register/enqueue scripts & styles

I am using WordPress 3.1.4 by now. I am confused with where (which hook) do I use: to register and/or enqueue scripts and styles on front- and back-ends? Questions: Which are right hooks to ...
16
votes
3answers
4k views

Check if a script/style was enqueued/registered

Is it possible to test whether a script or a style was registered using wp_register_script/_style or wp_enqueue_script/_style? All functions doesn't return a value and I'm completely clueless. I ...
7
votes
2answers
1k 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 ...
7
votes
1answer
3k views

wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i'm confused

I've been reading up a bit on this subject, but the more I read - the more confused I get. Can someone explain to me in short what's the exact difference between wp_enqueue_scripts, ...
5
votes
1answer
3k 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
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 ...
5
votes
1answer
1k 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', ...
3
votes
1answer
110 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( ...
3
votes
1answer
965 views

How to disable hoverIntent in Wordpress 3.3 admin

I don't like hoverIntent in the new flyout menus or admin bar; to me, it makes my page feel slow. What would be the Wordpress-friendly way to disable hoverIntent (or change its options) in the new ...
2
votes
2answers
153 views

Add a script as a dependency to a registered script

wp_register_script() (see codex) allows you to specify dependencies: scripts that must be loaded before the one being registered is loaded (if it is loaded). But suppose the script is a third-party ...
2
votes
1answer
620 views

enqueue and localize script in footer

I have a script which must run in my footer, after some variables are declared. It works if I just put the code directly in my footer file, but I think best practices dictate I should do this via ...
2
votes
1answer
125 views

changing function wp_register

how can i change function in general-template.php without affecting this core file on this: if ( ! is_user_logged_in() ) { if ( get_option('users_can_register') ) $link = $before . '<a ...
2
votes
2answers
1k views

wp_enqueue_script vs. wp_register_script

Trying to do the right thing here, and tying myself in a knot! So, in my header.php before wp_admin, I have: wp_enqueue_script('commonfunctions', child_template_directory . ...
2
votes
1answer
61 views

Naming script handles right way

I was wondering is there any convention or what is the right way for naming handles in wp_register_script() and wp_register_style() functions? For example if I am developing a plugin that uses ...
1
vote
1answer
359 views

Question about the way that wp_register_script works

Ok so I'm using the Roots Theme for WordPress (https://github.com/retlehs/roots), which, is sort of a starter theme or theme framework. I'm confused about the way that it deregisters the WordPress ...
1
vote
2answers
697 views

Modernizr check first, then move on to wp_register_script()/wp_enqueue_script

I've been playing with Modernizr in WordPress lately and here's something that i'm trying to achive. I'm adding an HTML5 input field in a custom options page, specifically: <input type="number" ...
1
vote
2answers
27 views

Is it possible to add an action to the currently running action?

My question is very simple but I haven't found this answer yet. Here's an example: class MyClass { public function __construct(){ add_action('init', array($this, 'init')); ...
1
vote
1answer
155 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 ...
1
vote
1answer
232 views

After e-junkie payment, send a http post to register user automatically?

I have the workflow thought out: User pays for something on your site using e-junkie. After payment, a http post ( with user email and name gets sent to a wordpress registration script ) and ...
1
vote
1answer
452 views

Including style.css in Child Theme

Twenty Thirteen uses wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() ); in functions.php. Wheter I use it or not use it in twentythirteen-child/functions.php the style.css from Child ...
1
vote
1answer
35 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
34 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
2answers
215 views

Adding scripts to admin page in my theme

In functions.php of my theme I have code to add page in admin area and append scripts to it. But scripts are not loaded. Bellow is code. Commented out add_action lines are the one I did check. // ...
1
vote
1answer
260 views

Help with enqueing scripts in footer after init action

In my functions.php, I have set a register_scripts() and load_scripts(), and hooked them to the 'init' action. I have registered all the scripts to be loaded in the footer, in order to optimize page ...
1
vote
2answers
40 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
361 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
2answers
39 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
2answers
332 views

Trying to get custom js files in my admin header

I'm trying to add a java script file to my admin header and use admin-ajax.php to use ajax in my wp-admin (still learning a lot about the process). I've created a custom folder in my ...
0
votes
2answers
1k 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( ...
0
votes
1answer
828 views

Deregister multiple scripts using a function?

I'm trying to deregsiter multiple scripts using the following function. add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); function my_deregister_javascript() { if ( ...
0
votes
2answers
2k views

How do I get a child theme to load scripts from the parent theme?

Pretty new to WordPress functions, so apologies if this is basic stuff. I've designed a parent theme that registers and enqueues two scripts like so: if ( !function_exists( 'scherzo_scripts' ) ) ...
0
votes
1answer
131 views

Trying to register script in footer

My problem is the script is not registering in the footer it, is just disappearing, although the jquery.js does show up in the head. I have the following code in my theme's functions.php file: ...
0
votes
2answers
83 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
336 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
1answer
888 views

WP deregister, register and enqueue dequeue

a plugin that I bought is loading a few js and css files on all pages, so I wanted to write a new function to deregister the handles, and enqueu them where I wanted. however I am not sure If I have to ...
0
votes
1answer
89 views

Modular CSS and JS in Child Themes

Let's assume that twentythirteen/shortcodes/ exists and inside are folders with shortcodes. 1 folder = 1 shortcode. Each shortcode has: 1 PHP file, 1 CSS file, 1 JS file. ...
0
votes
1answer
226 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? ...
0
votes
2answers
126 views

If a Script has been enqueued but not registered can I still removed it?

There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages. Here is the code for ...
0
votes
1answer
454 views

Register google jquery gets overwritten by plugin

I'm currently using a plugin, which includes jquery version 1.6.4 like this: function thethe_image_slider_head_scripts(){ wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', ...
0
votes
1answer
454 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 ...
0
votes
1answer
161 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
1answer
99 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: ...
0
votes
1answer
80 views

Including files in Child Themes

Twenty Thirteen uses the following in functions.php: require( get_template_directory() . '/inc/custom-header.php' );. When I copy /inc/custom-header.php to twentythirteen-child, it isn't replaced. I ...
0
votes
1answer
44 views

Register through url

Im looking for a solution where you can register through an url. Here's the thing, I want send out an email with a Url link. Best case: If the receiver click's on this link, the automaticly will be ...
0
votes
1answer
203 views

Stop a plugins js and css from loading on all pages and show up only where it is called

This plugin has an unique way of registering styles and scripts so I have no idea on how to stop it from loading on all my pages. After a quick search to see where wp_enqueue_style&script is I ...
0
votes
2answers
499 views

Failing to load my script files in wordpress! i can't figure out what i'm doing wrong

i have customized my .html as a custom wp theme. i have these scripts in my header.php: <script type='text/javascript' src="scripts/jquery-1.8.2.js"></script> <script ...
0
votes
1answer
263 views

Register script/style: Is it possible to customize the version query string via plugin?

Expanding on the question in the title: I would like to find a way (via a plugin) to use timestamps for the JS and CSS file version query strings that are output with wp_register_style and ...
0
votes
3answers
523 views

wp_register_script was called incorrectly

I created this theme and it worked on my site without any problem. When I moved it to another server, I get wp_register_script was called incorrectly. error. I scanned my source code and I didn't use ...
0
votes
0answers
13 views

Register / Enqueue Scripts [migrated]

I am trying to be neat and put all JS into .js files and register and enqueue them. So far I have 'great' success doing so. I have in my functions.php of my theme: wp_register_script( 'myscript', ...
0
votes
0answers
22 views

How to add a profile pic and biographical info at registration page?

I am running a multi-author blog which is also open to new authors registrations. How is it possible that new authors are forced to include the following information to the registration page ...