[wp-hackers] enqueue script only on settings page?
otto at ottodestruct.com
Mon Sep 20 16:17:42 UTC 2010
On Mon, Sep 20, 2010 at 8:33 AM, John Gadbois <jgadbois at gmail.com> wrote:
> Is it possible to enqueue a script or style only on a settings page created
> via the settings api?
When you add a new settings page, you do this via a call to
add_options_page, or add_submenu_page, or add_whatever_page. One of
the things you specify in these calls is the $menu_slug. This gets
added to the URL when you see your page in the admin screens. So the
URL of your page ends up being
That "whatever" is key here. You can use the action hook of
"admin_enqueue_scripts" to enqueue your scripts, and the first
parameter passed to it will be that "whatever". Check for that, and
enqueue as you see fit.
More information about the wp-hackers