This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Reply To: replacing prettyphoto, other scripts…

Israel Curtis

I’m not suggesting a proprietary system: apply_filters( 'themeblvd_js_locals', $locals ) is precisely what I had in mind for you to pass the booleans for various script support into themeblvd.js. Then you just add conditional checks within that file for each section of code that deals with a particular feature (prettyphoto, superfish, etc). This is perfectly in keeping with WP standards, and a simple comment line before each section’s conditional test would be sufficient to explain to anyone tinkering under the hood what’s going on.

In fact, just by adding the conditionals to themeblvd.js, even before you modified your global config, you would allow users to disable JS components by passing the localized variables themselves (in combination with manually dequeueing the scripts). This could be a quick intermediate step towards a more comprehensive global config system that would do it all for you – while being fully forward-compatible with those changes once they appeared (as they would be using the same mechanism)

The problem with the current system is that you have hard-coded a bunch of javascript that is not easily disabled without completely replacing the entire script. The principle I’m describing here is no different than “pluggable functions”, which you use generously throughout your php. Just extend the same idea to the javascript components. Otherwise what is required is akin to asking the user to replace the entire /framework/frontend/functions/display.php file just to modify the behavior of the themeblvd_viewport_default() function. Not very update-safe, and prone to errors. IMHO, it’s best for child themes to have their own independent functions that hook, filter, or plug-replace parent theme functionality, rather than taking over parent files completely.

[personal confession] I’m speaking as a previous Thesis power-user, where there’s either a hook, filter, or an options panel to override practically everything without ever touching or replacing the “parent” theme files. This has made it possible for me to safely update the core theme many times without ever worrying about whether my customizations will survive – or whether I’ve managed to find every last bit of new and improved “parent” code to transfer into my custom files.