[wp-hackers] Plugin main file name

Stephen Rider wp-hackers at striderweb.com
Sun Aug 24 14:23:50 GMT 2008


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.

Food for thought.  I'll do a write-up if I get it working. :)

Stephen

-- 
Stephen Rider
<http://striderweb.com/>


On Aug 24, 2008, at 1:23 AM, DD32 wrote:

> My only suggestion for this would be something similar to this:
>
> global $strider_version;
> $strider_version = max($strider_version, 1.5);
>
> action_init(){
> global $strider_version;
> if ( $strider_version == 1.5 && !class_exists('Striders_Core') )
> include 'strider_core.php';
> }
>
> Class Striders_Plugin{
> function(){
> $result = Striders_Core::Method();
> }
> }
>
>
> Then a different plugin:
>
> global $strider_version;
> $strider_version = max($strider_version, 1.0);
>
> action_init(){
> global $strider_version;
> if ( $strider_version == 1.0 && !class_exists('Striders_Core') ) // 
> Will not be reached, because the max version is 1.5 from the above  
> plugin
> include 'inc/striders_core.php';
> }
>
> Class Striders_Plugin2{
> function(){
> $result = Striders_Core::Method();
> }
> }
>
> The result would be that only the latest striders_core class file is  
> included, Theres the downside that you can no longer use  
> inheritance(extend) due to the class being loaded after the rest,  
> but it does solve the problem of only loading the latest class file  
> you have.



More information about the wp-hackers mailing list