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.


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.

  • that's a good point – John Feb 5 '13 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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