A client side scripting language useful for making interactive web sites
35
votes
3answers
10k views
What is the preferred way to add custom javascript files to the site?
I've already added my scripts, but I wanted to know the preferred way.
I just put a <script> tag directly in the header.php of my template.
Is there a preferred method of inserting external or ...
7
votes
1answer
2k views
How to add defer=“defer” tag in plugin javascripts?
I couldn't add defer tag in plugin javascripts. Google developer pagespeed test suggests me to add defer tag in contact form 7 javascripts.
This is how contact form 7 includes javascript in header.
...
10
votes
2answers
688 views
Does the functions.php file ever get called during an AJAX call? Debug AJAX
Trying to figure out an issue a fellow programmer is having. I was wondering if the functions.php file get called at all when you do admin side AJAX? I know that when you do an AJAX call a part of ...
1
vote
1answer
250 views
wp_enqueue_script isn't connecting my custom js file
I am using wp_enqeue_script to link to a custom.js file in my plugins folder. However I am expecting a link to show up on the page but it doesn't is there something else I am supposed to other than ...
1
vote
2answers
854 views
How to trap “Publish” button to check for meta box validation?
I'm trying to do some form validation on my custom meta box, and I remember somewhere reading about some javascript function to disable/enable the Publish button - except I can't find it.
How do I ...
7
votes
3answers
6k views
Loading scripts only if a particular shortcode or widget is present
I needed a way to filter a page/posts content before it was loaded so I could add scripts to the header if a specific shortcode was present. After much searching I came across this on ...
10
votes
2answers
876 views
pass object/JSON to wp_localize_script
I've got a working piece of javascript that contains an object literal.
But I need to localize it, and I'm ytrying to figure out how to rewrite it so that I can get wp_localize_script() to accet it, ...
2
votes
4answers
2k views
Adding a class (arrows) to main menu links that have children?
I'm wondering if it is possible to add different classes to second/third/fourth/etc-level items that have children in Appearance > Menus tree?
That's how I call the menu:
<?php $menu_args = ...
2
votes
2answers
3k views
Comment form validation
How can I set the validation rules for the comment field?
I change the value of commenter name/e-mail/homepage onmouseover and onblur (I use this instead of labels - so if the field is empty it ...
1
vote
4answers
5k views
How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
I'm building a plugin and I want to add bits of javascript in the admin head but only for certain admin pages. I don't mean pages as in a WordPress page that you create yourself but rather existing ...
8
votes
3answers
4k views
Validating Custom Meta Box Values & Required Fields
Something which I have never seen covered is the best way to validate that specific form fields are filled out correctly for custom post type meta boxes.
I am looking to get expert opinions on how ...
5
votes
2answers
455 views
Modifying a JS file with data from plugin settings
I have a plugin that, among other things, has a javascript file that requires a few user specific settings. What would be the best way to get those settings into javascript from the plugin's settings ...
6
votes
5answers
4k 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 ...
2
votes
1answer
186 views
Ajax template: how to handle head section
I know it's easy stuff, but I'm new to this and I can't understand which is the best approach.
Background
The template I'm working on is a dual theme Desktop/Mobile, UA Sniffing based.
Now I just ...
11
votes
4answers
1k 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:
...