check for the current screen

Those variables and functions only exist in the admin area, and aren’t for frontend use. You will need to use a different mechanism for the frontend.

Additionally:

  • the docs say that you have to call this after the admin_init hook, calling on that hook will always return null
  • the function is not loaded on all admin pages, e.g. the customizer
  • Use it on the current_screen hook or later

When in doubt, read the documentation

Leave a Comment