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'm using admin_footer-{$hook_suffix} to selectively print scripts on the new post page and comments page. This hook is depreciated in 3.1.

I see there's an admin_print_scripts-{$hook_suffix} but this does not print to the footer, rather to the header before any jQuery or other stuff is loaded.

How can I selectively print scripts to the footer of certain admin pages?

share|improve this question
1  
Use wp_enqueue_script inside the function you hook on and set the in_footer parameter to true, and your script will get output in the footer. –  t31os Mar 29 '11 at 11:29

1 Answer 1

up vote 3 down vote accepted

There's an in_footer parameter that you can pass to wp_enqueue_scripts - does that work?

I would hook to admin_enqueue_scripts, check the $page for location, and enqueue your script there, with 'in_footer' as true.

Example:

add_action( 'admin_enqueue_scripts', 'enqueue_my_script' );

function enqueue_my_script( $page ) {
    if ($page !== 'edit.php') return;
    wp_enqueue_script( 'my-script', 'http://path/to/my/local/script', null, null, true );
}
share|improve this answer
    
Can you give me an example of checking $page for location? –  editor Mar 29 '11 at 14:08
    
Thank you. I did not know $page was a synonym for the current page suffix. –  editor Mar 30 '11 at 15:21
1  
Um, yeah, guess I took a shorthand there. There's also the global variable $pagenow which also holds the same information, in case you need to check it where its not being explicitly passed as the context of a hook. –  goldenapples Mar 30 '11 at 20:24
    
There appears to be no $page variable (declared globally or otherwise) in my MU 2.9. $pagenow global worked out however, so thanks for including. –  editor Mar 31 '11 at 17:33

Your Answer

 
discard

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.