[wp-hackers] enqueue script only on settings page?

John Gadbois jgadbois at gmail.com
Tue Sep 21 17:30:42 UTC 2010


But can't you add a settings page just by calling register_settings without
actually ever calling an add page function?  I was wondering how to do it in
that situation.

On Mon, Sep 20, 2010 at 12:17 PM, Otto <otto at ottodestruct.com> wrote:

> 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?
>
> Yep.
>
> 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
> /wp-admin/options-general.php?page=whatever.
>
> 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.
>
> -Otto
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list