Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been using Wordpress for a while, and I really like it \o/... I've written plugins for the Joomla platform but I'm sort of struggling getting going on the wordpress platform :

Here's my plan. I'm in the process of writing a plugin that uses Flash to allow the user to record audio from the soundcard (my idea is to allow the user to record a podcast through the web site).

I have a questions (so many questions...) but I'll go with these few :

I am using wp-enqueue to load the Javascript libraries into the page or post as it is loaded. Currently I'm using add_action('init', 'register_libraries'); to register the javascript libraries - and I think that works - but it also shows in the administration page (where this plugin won't be used).

So I had a look a the codex page and it suggests that I should be using init - it says that init is "Typically used by plugins to initialize". But that also includes the administration side, which I don't want for this plugin. Any suggestions what I should do instead?

In addition, and perhaps this should be a separate question - I wanted to load flash during the loading of the plugin - how should I do that - any ideas?...

I know... It's a bit noobish...

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

you should use wp_print_scripts hook for your scripts instead of init and in your callback make sure that you are not in the administration pages something like this:

function register_libraries(){
    if (!is_admin()){
     //enqueue your scripts here

as for adding flash, that should be a separate question just make sure to add more details about it.

share|improve this answer
Any reason you're recommending using wp_print_scripts, rather than wp_enqueue_scripts? +1 for the if ( ! is_admin() ) suggestion, regardless. –  Chip Bennett Feb 16 '12 at 3:54
@ChipBennett good question, it would work either way but its not my favorite workflow, wp_print_scripts is the action that runs when scripts are output to the template. wp_register_script and wp_enqueue_script are functions for registering/enqueueing scripts to be output when wp_print_scripts runs. so in this point it makes no difference –  Bainternet Feb 16 '12 at 8:53
Thanks... i'll add the admin check into my code, and try the wo_print_scripts. I think there's a bit of reading for me to do through the codex... –  Computa_Mike Feb 16 '12 at 9:37
@Bainternet but you're enqueueing scripts; semantically that should be done at the hook for enqueueing scripts. Practically, it should be done there, just as a matter of considerate practice, so that there are still later hooks available to override the action. I treat wp_print_scripts as a last resort only. –  Chip Bennett Feb 16 '12 at 14:35
@ChipBennett that approach is correct in my book too but you still have a filter to remove scripts even at that point. –  Bainternet Feb 16 '12 at 20:30
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.