[wp-hackers] Re: wp-hackers Digest, Vol 43, Issue 38

buzzup Ram rrajeshbab at gmail.com
Sun Aug 24 06:09:16 GMT 2008


Stephen,

strider_core() is your core class and you seperate it out into a .php
file.Now this is being reused by all your plugins, as you mentioned.

Then why do you want to maintain duplicate copies of this file.You have the
core files in its own directory and include this directory in every plugin
that you intent to code.

The idea of maintaining duplicate copies and versions suck.You don't
maintain duplicate versions of a reusable class in object oriented
programming.

Cheers,
Rajesh

On Sun, Aug 24, 2008 at 8:44 AM, <wp-hackers-request at lists.automattic.com>wrote:

> Send wp-hackers mailing list submissions to
>        wp-hackers at lists.automattic.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.automattic.com/mailman/listinfo/wp-hackers
> or, via email, send a message with subject or body 'help' to
>        wp-hackers-request at lists.automattic.com
>
> You can reach the person managing the list at
>        wp-hackers-owner at lists.automattic.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of wp-hackers digest..."
>
>
> Today's Topics:
>
>   1. Re: Plugin main file name (Stephen Rider)
>   2. Re: Plugin main file name (Stephen Rider)
>   3. RE: Plugin main file name (Robert R. Marsh, SJ)
>   4. Re: Shortcodes in the Sidebar (Viper007Bond)
>   5. Re: Shortcodes in the Sidebar (Dan Coulter)
>   6. Re: Block auto formatting of post content? (DD32)
>   7. Re: Shortcodes in the Sidebar (DD32)
>   8. Re: Shortcodes in the Sidebar (Dan Coulter)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 23 Aug 2008 17:45:29 -0500
> From: Stephen Rider <wp-hackers at striderweb.com>
> Subject: Re: [wp-hackers] Plugin main file name
> To: wp-hackers at lists.automattic.com
> Message-ID: <FB8325E8-8344-44C3-B6F3-521F14D15154 at striderweb.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> 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
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 23 Aug 2008 18:16:58 -0500
> From: Stephen Rider <wp-hackers at striderweb.com>
> Subject: Re: [wp-hackers] Plugin main file name
> To: wp-hackers at lists.automattic.com
> Message-ID: <B5B904DA-186A-466F-9C0F-D13C103B301C at striderweb.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> 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
> >
> > I find this a better solution than rmarsh' plugin library: you get one
> > of his plugins, try to run it and, oops, no, can't work, you need to
> > download an extra file. Clunky.
>
> The funny thing is, Ozh isn't answering the question i waas asking,r
> eally, but he was answering the question I ended up wanting to ask.
>
> What I was originally talking about was not a "core" class, but that
> different plugins would have the same filename.  That is, myplugin/
> plugin_main.php IS the myplugin file; anotherplugin/plugin_main.php IS
> the anotherplugin file.  Same file name, different directories.
>
> I was originally asking if that was a bad idea.  It's a moot point
> now, because I turned to the "extend class" method instead of the file
> inclusions I was originally trying out....
>
> Stephen
>
> --
> Stephen Rider
> <http://striderweb.com/>
>
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 24 Aug 2008 00:21:13 +0100
> From: "Robert R. Marsh, SJ" <rmarshsj at hotmail.com>
> Subject: RE: [wp-hackers] Plugin main file name
> To: <wp-hackers at lists.automattic.com>
> Message-ID: <BAY119-DAV2B92343BBF832C6126D2FC1650 at phx.gbl>
> Content-Type: text/plain;       charset="US-ASCII"
>
> 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
> >
>
>
>
> ------------------------------
>
> Message: 4
> Date: Sat, 23 Aug 2008 19:16:33 -0700
> From: Viper007Bond <viper at viper007bond.com>
> Subject: Re: [wp-hackers] Shortcodes in the Sidebar
> To: wp-hackers at lists.automattic.com
> Message-ID:
>        <8f93a7390808231916n76d92f4dxb2aba97fd5314556 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Why did you create a class just for one function?
>
> On Sat, Aug 23, 2008 at 10:38 AM, Dan Coulter <dan at dancoulter.com> wrote:
>
> > Someone was asking me how to use shortcodes from one of my plugins in the
> > sidebar, and I figured the text widget could handle it (with a plugin, of
> > course).  I couldn't find one pre-made so I whipped one up.  If anyone
> else
> > would find it useful, I've put it up on Extend:
> >
> > http://wordpress.org/extend/plugins/sidebar-shortcodes/
> >
> > 1 download so far! OMG!
> >
> > --
> > Dan Coulter
> > http://dancoulter.com/
> > http://phpflickr.com/
> > http://blogsforbands.com/
> >
> > Hey, I got nothing to do today but smile
> > -Simon and Garfunkel
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
> Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
>
>
> ------------------------------
>
> Message: 5
> Date: Sat, 23 Aug 2008 21:35:35 -0500
> From: "Dan Coulter" <dan at dancoulter.com>
> Subject: Re: [wp-hackers] Shortcodes in the Sidebar
> To: wp-hackers at lists.automattic.com
> Message-ID:
>        <5dc2163e0808231935v384c42beh85eb34cc8ad2b5da at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Sat, Aug 23, 2008 at 9:16 PM, Viper007Bond <viper at viper007bond.com
> >wrote:
>
> > Why did you create a class just for one function?
> >
>
> Force of habit :D
>
> --
> Dan Coulter
> http://dancoulter.com/
> http://phpflickr.com/
> http://blogsforbands.com/
>
> Hey, I got nothing to do today but smile
> -Simon and Garfunkel
>
>
> ------------------------------
>
> Message: 6
> Date: Sun, 24 Aug 2008 13:08:01 +1000
> From: DD32 <wordpress at dd32.id.au>
> Subject: Re: [wp-hackers] Block auto formatting of post content?
> To: wp-hackers at lists.automattic.com
> Message-ID: <op.ugdeznv5k6w4mc at dd32.no-ip.com>
> Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8
>
> except of course, Remember, that its actually stored in
> $post->post_content.. Just incase anyones confused :)
>
> On Wed, 20 Aug 2008 19:58:41 +1000, Viper007Bond <viper at viper007bond.com>
> wrote:
>
> > $post->the_content is exactly as it came out of the database.
> >
> > the_content() is essentially just   echo apply_filters( 'the_content',
> > $post->the_content );
> >
> > --
> > Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
> >
> >
> > On Wed, Aug 20, 2008 at 2:49 AM, Abel Cheung <abelcheung at gmail.com>
> > wrote:
> >
> >> On Tue, Aug 19, 2008 at 11:12 AM, Viper007Bond <viper at viper007bond.com>
> >> wrote:
> >> > Instead of the_content(), just use echo $post->the_content in your
> >> theme.
> >>
> >> With $post->the_content all other plugins doing other content
> >> conversion would not work as well, not just wpautop, is it?
> >>
> >> Abel
> >>
> >>
> >> >
> >> > On Mon, Aug 18, 2008 at 8:02 PM, Stephen Rider <
> >> wp-hackers at striderweb.com>wrote:
> >> >
> >> >> Two questions:
> >> >>
> >> >> 1) Is there a way to prevent _any_ auto formatting for a particular
> >> post?
> >> >>  I want to allow content to be shown without any added <p>, <br>,
> >> etc...
> >> >>  Display it _exactly_ as it was entered.
> >> >>
> >> >> 2) Is there a way for a plugin to allow use of a page template that
> >> is
> >> >> located in the plugin folder, or MUST it be moved to the theme
> >> folder?
> >> >>
> >> >> Thanks,
> >> >> Stephen
> >> >>
> >> >>
> >> >> --
> >> >> Stephen Rider
> >> >> <http://striderweb.com/>
> >> >>
> >> >>
> >> >>
> >> >> _______________________________________________
> >> >> wp-hackers mailing list
> >> >> wp-hackers at lists.automattic.com
> >> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Viper007Bond | http://www.viper007bond.com/ |
> >> http://www.finalgear.com/
> >> > _______________________________________________
> >> > wp-hackers mailing list
> >> > wp-hackers at lists.automattic.com
> >> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> >
> >>
> >>
> >>
> >> --
> >> Abel Cheung   (GPG Key: 0xC67186FF)
> >> Key fingerprint: 671C C7AE EFB5 110C D6D1  41EE 4152 E1F1 C671 86FF
> >> --------------------------------------------------------------------
> >> * My blog: http://me.abelcheung.org/
> >> * Opensource Application Knowledge Assoc. - http://oaka.org/
> >> _______________________________________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.com
> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
> ------------------------------
>
> Message: 7
> Date: Sun, 24 Aug 2008 13:08:45 +1000
> From: DD32 <wordpress at dd32.id.au>
> Subject: Re: [wp-hackers] Shortcodes in the Sidebar
> To: wp-hackers at lists.automattic.com
> Message-ID: <op.ugde0vfuk6w4mc at dd32.no-ip.com>
> Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8
>
> On Sun, 24 Aug 2008 12:35:35 +1000, Dan Coulter <dan at dancoulter.com>
> wrote:
>
> > On Sat, Aug 23, 2008 at 9:16 PM, Viper007Bond
> > <viper at viper007bond.com>wrote:
> >
> >> Why did you create a class just for one function?
> >>
> >
> > Force of habit :D
>
> For that matter, Why not just do
> add_filter('widget_text', 'do_shortcode');
>
> :)
>
>
> ------------------------------
>
> Message: 8
> Date: Sat, 23 Aug 2008 22:14:34 -0500
> From: "Dan Coulter" <dan at dancoulter.com>
> Subject: Re: [wp-hackers] Shortcodes in the Sidebar
> To: wp-hackers at lists.automattic.com
> Message-ID:
>        <5dc2163e0808232014n74e9155bi2bbb2f7f0dac8098 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Sat, Aug 23, 2008 at 10:08 PM, DD32 <wordpress at dd32.id.au> wrote:
>
> > For that matter, Why not just do
> > add_filter('widget_text', 'do_shortcode');
> >
>
> Poop! Why didn't I see that? Oh well, I guess it's a good thing I mentioned
> it here.  It's a little throwaway plugin, so I'm not surprised that there
> is
> a much simpler way to do it.  I'll revise it.
>
> Obviously, this is something that anyone could put into their own plugin(s)
> if they wanted to enable shortcodes for their users, but since I didn't
> want
> to change the behavior for my users that weren't going to use it, I decided
> to put it out on its own.
>
> --
> Dan Coulter
> http://dancoulter.com/
> http://phpflickr.com/
> http://blogsforbands.com/
>
> Hey, I got nothing to do today but smile
> -Simon and Garfunkel
>
>
> ------------------------------
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
> End of wp-hackers Digest, Vol 43, Issue 38
> ******************************************
>


More information about the wp-hackers mailing list