[wp-hackers] Plugin main file name
Robert R. Marsh, SJ
rmarshsj at hotmail.com
Sat Aug 23 23:21:13 GMT 2008
Stephen,
It was versioning issues that led me to separate the core code into another
plugin -- even though, as Ozh points out, it can feel odd needing two
plugins to do one job.
Rob
rmarsh.com
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of
> Stephen Rider
> Sent: 23 August 2008 23:45
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Plugin main file name
>
>
> On Aug 23, 2008, at 2:48 PM, Ozh wrote:
>
> > On Sat, Aug 23, 2008 at 4:10 PM, Stephen Rider
> > <wp-hackers at striderweb.com> wrote:
> >> myplugin/plugin_main.php
> >> anotherplugin/plugin_main.php
> >> thirdplugin/plugin_main.php
> >
> > Make everything in plugin_main.php within a "if
> > (!class_exists('strider_main')) class strider_main{}", and whenever
> > you update this file, update all your plugins that use it
>
> Here's what I did, but I still have a question.
>
> I normally put all of a plugin's function in a class -- to
> avoid naming conflicts and to aid in making reusable code.
>
> So what I did is this: I have my "core" class -- strider_core().
> Class strider_core contains all the common code that is
> reused across pretty much all my plugins. This file is
> included with each plugin.
>
> Then, in the main plugin file, I require_once the core file,
> then create the plugin's class like so:
>
> class myplugin extends strider_core { ... }
>
> That way myplugin includes everything from strider_core, plus
> all the code particular to the plugin that I add to myplugin.
>
> The strider_core class declaration is wrapped in if( !
> class_exists( 'strider_core' ) { ... }
> That way if there are multiple of my plugins installed, they
> don't try to declare the class multiple times.
>
> Okay, here's the question:
>
> I want to give strider_core a version number. I want the
> if() clause that checks for the class to ALSO check the
> version of the class (if it exists). If the existing class
> is a lower version number (such as from an older version of
> the other plugin) I want go ahead with declaring the class
> again with the newer code.
>
> Is there a way to redeclare a class in PHP?
>
> Any ideas? I'm stuck.
>
> Stephen
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list