WordPress Wednesdays: Get the Current Page

I was writing some functions that are used in the admin for my commercial WordPress theme: Lucidity and stumbled upon a great variable in WordPress: $pagenow. This variable will return the current page you are on and is great form admin functions – especially those that you want to only make available on certain pages.

To use this – just add it to your functions as a global variable, then you can use it to load in specific js/functions:

global $pagenow;
if (($pagenow == 'admin.php') && ($_GET['page'] == 'sdac_appearance')) {}

This proved to be very helpful when dealing with some finicky JS.