[wp-hackers] Degrading gracefully with deactivated plugins?

Owen Winkler ringmaster at midnightcircus.com
Mon Mar 28 22:15:40 GMT 2005


> Matthew Mullenweg wrote:
>> Many plugin functions (time_since, etc) could be embedded directly in 
>> theme files, which would eliminate any bundling issues. Perhaps we 
>> could make this more formal by having a file (extra-functions.php) 
>> that was loaded with plugins if it existed for a theme.

Yes, I like this.  It should be included after all plugins are loaded, 
so that it can do something like:

if(!is_callable('time_since')) {
	function time_since() {
		echo 'Download <a href="#">Time Since</a>';
	}
}

I like the idea of putting some of the responsibility for getting the 
theme to work properly on the theme developer, as opposed to the user or 
plugin developer.

If there was a way (and I think there is probably an existing plugin 
hook that might work) for this theme file to integrate itself into the 
Presentation panel and display the plugins it requires compared to the 
plugins that are installed and activated, that would be supercool.



Mark Jaquith wrote:
> Perhaps they could all be placed in a subdirectory of the theme 
> directory.  /themes/my-theme/plugins/  That's how I've been doing it 
> (along with code in the theme to include every file in the plugins 
> directory.  Another thing is that you have to be careful of function 
> redeclaration, in the case that someone already has that plugin 
> installed.  I usually just wrap the entire plugin file in a giant 
> "is_function()" that checks the main function of the plugin (no need to 
> check every single function... if one of the plugin's functions has 
> already been declared, they all probably have).

You point out a couple of several issues that you could have with this 
already.  First is that you have to pack all of the plugins your theme 
uses with your theme, which I can imagine isn't fun for you from a 
maintenance standpoint.  Additionaly, as you point out, you then have to 
check the functions you've included to be sure that they don't already 
have those functions installed.

Potentially, support for these plugins would come from the original 
plugin developer, but you've moved all their code to a non-standard 
place (your theme directory) and wrapped it in is_function() calls. 
Imagine the headache for a plugin developer who didn't know you did this 
trying to figure out how their plugin is working on a site when it's not 
installed in the plugins directory.

I'm all for making things easy on the user, but I wonder if this would 
result in more downstream problems than the one it's trying to solve.

Owen



More information about the wp-hackers mailing list