[wp-hackers] Plugin main file name

Andrew Ozz admin at laptoptips.ca
Tue Aug 26 04:38:02 GMT 2008


Stephen Rider wrote:
> 
> On Aug 24, 2008, at 10:08 AM, Andrew Ozz wrote:
> 
>> Why not add an option with the version number and the path to the 
>> latest file. The version number can even be included in the file name, 
>> something like: main_20080824.php. Then when the first plugin is 
>> loading, it can check where the latest file is and load it first.
>>
>> If another plugin is installed with an older version of the main file, 
>> it can check the version and not overwrite the path.
> 
> This might be a better version than mine.  As best I see it I would have 
> to recursively view the entire plugins directory looking for 
> strider_core files though, and as you suggest the version would have to 
> be in the filename.  Once it's found once I could set a $global or 
> CONSTANT so I don't re-search for each plugin.
> 
> Not sure if this is better or worse than what I've figured out.  Worth 
> keeping in mind if there are problems with what I've got working.  My 
> main concern is the late launching of those plugins in the other system 
> (on plugins_loaded).

I was actually thinking more along these lines:

1. Activating a plugin:
- get_option('my_main_file'); This option contains the path to the file 
and the version number.
- if true -> check the version
     - if current main.php is newer -> update the option
- else -> add the option

2. When loading a plugin check if class is defined/functions exist, etc. 
If not:
- get_option('my_main_file');
- include main.php at the path from the option and define the class/add 
constant etc.

Can also look at get_option('active_plugins') to figure out when more 
than one plugin will need main.php.


More information about the wp-hackers mailing list