[theme-reviewers] Reset scripts on theme settings page

Chip Bennett chip at chipbennett.net
Mon Feb 17 18:47:48 UTC 2014

I think Themes should properly enqueue their own scripts on their own
settings pages, and not otherwise mess with other scripts enqueued by core
or other Plugins.

If you find conflicting/offending Plugins, post to those Plugins'
review/support forums, and if necessary, report them to plugins at . Plugins
that misbehave by outputting scripts in inappropriate places in the
WP-Admin probably shouldn't be hosted in the WPORG Plugin directory, and
I'm sure the Plugins team will want to be aware of them.

On Mon, Feb 17, 2014 at 1:33 PM, ethan anwar <ethananwar at yahoo.com> wrote:

> Hello again!
> Every now and then I get reports from users that certain elements on my
> theme's settings page don't work. Sometimes it's jQuery altogether so they
> can't edit anything, other times it's farbtastic and so on.
> For my themes I do the script loading carefully via the
> admin_print_scripts-{page-hook} so they're only loaded on the settings
> page. Apparently many plugins (available in extend even) don't do this. So
> a lot of JS is loaded (even re-loaded) on the theme's settings page which
> sometimes causes incompatibilities and cripples my theme's setting page
> functionality.
> Now of course users don't care for the reason behind this and a lot of
> time is wasted on debugging, finding the 'faulty' plugins, giving
> explanations and so on. Not to mention some pretty bad reviews for the
> theme on wordpress.org. And there are so many plugins out there that this
> will always be a problem unless I do something about it.
> So to keep it short (too late for that?) I found this workaround: I reset
> all scripts via WP_Scripts then load the ones WordPress needs and then the
> one the theme needs. Again, all this would only happen on the theme
> settings page. Here's how it would look:
> function parabola_admin_scripts() {
> // clean up all scripts that may interfere with the theme
> global $wp_scripts;
> $wp_scripts = new WP_Scripts;
> // restore wp basic scripts
> wp_enqueue_script('jquery');
> wp_enqueue_script('common');
> wp_enqueue_script('admin-bar');
> wp_enqueue_script('utils');
> wp_enqueue_script('wp-auth-check');
> wp_enqueue_script('wp-pointer');
> // the rest of theme-specific scripts...
> }
> add_action('admin_print_scripts-'.$page, 'parabola_admin_scripts');
> My question, since I want to implement this in all my themes, is: is this
> acceptable? Would it be a problem to 'reset' the default WP scripts on the
> theme settings page?
> Thanks a lot,
> Kay
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20140217/4c6bcd45/attachment.html>

More information about the theme-reviewers mailing list