[wp-hackers] Plugin main file name

Andrew Ozz admin at laptoptips.ca
Sun Aug 24 15:08:11 GMT 2008

Stephen Rider wrote:
> This is essentially what I was trying to do, except that you never 
> actually create an object, you just call functions with the ::
>> If you really wanted to use extends still though, a thought just 
>> occured to me: Put your class which extends into a new file, and 
>> include it on the init hook, but hook it late after all the other init 
>> hooks have run, that should mean that the Striders_Core class has been 
>> included.
> That might be the key right there.  Maybe I can figure out a way to load 
> all the plugins, and have something hooked to call the correct core file 
> at the end, and then create all the objects for all the plugins at 
> once.  Potential there....
> I could build an array of each copy of the core file containing version 
> and path.  Then at the end look at the versions and load the highest 
> one, then load the plugin classes.

I can see the value in this: someone has several of your plugins 
installed, updates one and all get to use the new "main" code. May get a 
bit messy as it will have to support all the old versions of the plugins 
that use it.

Loading it at init or plugins_loaded seems late though, may want to use 
it while loading the plugins too.

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.

More information about the wp-hackers mailing list