[wp-hackers] Plugin main file name

DD32 wordpress at dd32.id.au
Sun Aug 24 06:23:15 GMT 2008


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.


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.

Yes, Its a mess.. But thats what you get if you want to base seperate  
plugins off a single core file which may change.




On Sun, 24 Aug 2008 00:10:50 +1000, Stephen Rider  
<wp-hackers at striderweb.com> wrote:

> I'm not very familiar with the inner workings of the plugin stuff at
> WP/extend, so I have a question for you all.
>
> I'm creating a "core" file for my plugins that is a standardized chunk
> of common code.  In doing so, it would be handy for me if the main
> plugin file was the same for each plugin.  The _directory_ is
> different, of course, but I want the plugin file itself to be
> plugin_main.php or something like that.
>
> Thus, in wp-content/plugins/...
>
> myplugin/plugin_main.php
> anotherplugin/plugin_main.php
> thirdplugin/plugin_main.php
>
> Is this a bad idea for some reason I don't know about?  If down the
> road I put these on WP-extend, will it screw up updates or auto-
> install or something?
>
> Thanks.
>
> Stephen
>
>




More information about the wp-hackers mailing list