[theme-reviewers] Reset scripts on theme settings page

ethan anwar ethananwar at yahoo.com
Mon Feb 17 18:33:48 UTC 2014

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

// 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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20140217/4f6476e0/attachment.html>

More information about the theme-reviewers mailing list