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.

When adding a function to "admin_enqueue_scripts" a hook is passed to the function. It looks like this "toplevel_page_nameofyourpage". That works great, but how is it different from checking the $_GET variable to see which page you are on? Is one preferred over the other? Why?

I'm only talking about when you create your own menu, not the default admin pages.

share|improve this question
add comment

1 Answer

The advantage of using the value provided by Wordpress in the hook variable is future compatibility with Wordpress Versions and not having to worry about $_GET variable manipulation by way of the user or another Wordpress plugin.

Checking the $_GET array works, but can be unreliable especially when other poorly coded plugins start messing with the $_GET array, because it is not a global constant and can be modified.

share|improve this answer
    
that's a good point –  John Feb 5 '13 at 20:01
add comment

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.