[wp-hackers] Community conventions for custom post types?

zanematthew at gmail.com zanematthew at gmail.com
Sat Aug 4 22:48:27 UTC 2012


Coming from other frameworks (ZF, Kohana, Proprietary PHP, PHP + Smarty), I
tend to do CPT's like MVC...

wp-content/my-plugin/plugin.php // authoring and calls bootstrap
wp-content/my-plugin/boostrap.php // this file handles auto-loading, and
creating files.
wp-content/my-plugin/models/cars.php // this would be the post type
wp-content/my-plugin/controllers/cars_controller.php // this would be
functions, etc. related to ONLY cars model
wp-content/my-plugin/assets/stylesheets/cars.css, // this file is
automatically created for you
wp-content/my-plugin/assets/javascript/cars.js, // this file is
automatically created for you

FYI, I have an abstract class, which is extended for making models (CPTs)
easier to create. Here's a Gist <https://gist.github.com/3260411> of how I
create CPTs.

Yes, there is basically one css and js per model, but on the production
site they (the css & js) files are concatenated and minified using Googles
Closure into one file.


On Sat, Aug 4, 2012 at 7:17 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: Can't find where <p> and <br /> tags are coming       from
>       (William P. Davis)
>    2. Re: Can't find where <p> and <br /> tags are comingfrom
>       (Diana K. C)
>    3. Re: Community conventions for custom post types? (Beau Lebens)
>    4. Re: Community conventions for custom post types? (Ryann Micua)
>    5. Re: Community conventions for custom post types? (Ryann Micua)
>    6. Re: How to exntend wp_xmlrpc_server in plugin (Ryan McCue)
>    7. Re: Community conventions for custom post types?
>       (photofantaisie at gmail.com)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 3 Aug 2012 23:49:37 +0000
> From: "William P. Davis" <will.davis at gmail.com>
> Subject: Re: [wp-hackers] Can't find where <p> and <br /> tags are
>         coming  from
> To: wp-hackers at lists.automattic.com
> Message-ID:
>
> <1281285667-1344037781-cardhu_decombobulator_blackberry.rim.net-1902631581- at b17.c4.bise6.blackberry
> >
>
> Content-Type: text/plain
>
> WordPress automatically adds p and be tags to the content before you echo
> it. To get around that, either make your code into a shortcode (preferable)
> or remove all line breaks from your code.
>
> Will
> Sent from my BlackBerry
>
> -----Original Message-----
> From: "Diana K. C" <dianakac at gmail.com>
> Sender: wp-hackers-bounces at lists.automattic.com
> Date: Fri, 3 Aug 2012 20:46:51
> To: <wp-hackers at lists.automattic.com>
> Reply-To: wp-hackers at lists.automattic.com
> Subject: [wp-hackers] Can't find where <p> and <br /> tags are coming from
>
> I needed to hardcode a plugin that retrieves Picasa Album, it works ok but
> don't know why P e BR tags are appearing, I tried to strip_tags, trim etc
> and can't get rid of them. Echoing works but then gets out before anything
> else in site as always :(
>
> I think is something wrong in php, but maybe something to do with xml?!
> Thanks for any help.
>
>
>
> The bit that outputs code I changed a bit is:
>
>   $html_gallery = '<ul class="gallery-list row">'."\n";
>
>    foreach ($feed as $entry) {
>     $title = $entry->getTitle();
>     $summary = $entry->getSummary();
>     $stuff = $entry->getMediaGroup()->getContent();
>     $url = $stuff[0]->getUrl();
>     $thumbnail = $entry->getMediaGroup()->getThumbnail();
>     $tags = $entry->getMediaGroup()->getKeywords();
>     $size = $entry->getGphotoSize();
>     $height = $entry->getGphotoHeight();
>     $width = $entry->getGphotoWidth();
>
>     $html_gallery .= "\n \t".'<li class="gallery-item"><a href="'.$url.'"
> class="lightbox"><figure><img class="imgpicasa"
> src="'.$thumbnail[2]->url.'" width="'.$thumbnail[1]->width.'"
> height="'.$thumbnail[1]->height.'"/><figcaption></figcaption></figure></a></li>';
> //SOMETHING WRONG HERE?
>
>    }
>    $html_gallery .= '</ul>';
>
>    $content = $html_gallery.$content;
>
>     return strip_tags($content,'<ul><li><a><figure><figcaption><img>');
>   }
>
>
>
> The wrong output (<br/> and <p> breaking layout :(  ):
> <li class="gallery-item"><a href="
> http://lh6.ggpht.com/-C1JJV9zcwr8/TVms7N1oktI/AAAAAAAAAss/wFdr1BpCPys/DSCN1215.JPG"
> class="lightbox"><br />
> <figure><img class="imgpicasa" src="
> http://lh6.ggpht.com/-C1JJV9zcwr8/TVms7N1oktI/AAAAAAAAAss/wFdr1BpCPys/s288/DSCN1215.JPG"
> width="144" height="108"/><br />
> <figcaption></figcaption>
> </figure>
> <p></a></li>
> FULL PLUGIN CODE BEFORE MOD: http://pastebin.com/Zfasaz1J
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> ------------------------------
>
> Message: 2
> Date: Fri, 3 Aug 2012 21:03:50 -0300
> From: "Diana K. C" <dianakac at gmail.com>
> Subject: Re: [wp-hackers] Can't find where <p> and <br /> tags are
>         comingfrom
> To: <wp-hackers at lists.automattic.com>
> Message-ID: <00d801cd71d4$a46350b0$2200a8c0 at TITA>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>         reply-type=original
>
> Thanks Will,
>
> Pardon, but you say compress it, like the whole code in a single line?!
>
> I removed the tags on output ("\n \t")  but still the code outputs with
> breaks and html tags.
>
>
> ----- Original Message -----
> From: "William P. Davis" <will.davis at gmail.com>
> To: <wp-hackers at lists.automattic.com>
> Sent: Friday, August 03, 2012 8:49 PM
> Subject: Re: [wp-hackers] Can't find where <p> and <br /> tags are
> comingfrom
>
>
> > WordPress automatically adds p and be tags to the content before you echo
> > it. To get around that, either make your code into a shortcode
> > (preferable) or remove all line breaks from your code.
> >
> > Will
> > Sent from my BlackBerry
> >
> > -----Original Message-----
> > From: "Diana K. C" <dianakac at gmail.com>
> > Sender: wp-hackers-bounces at lists.automattic.com
> > Date: Fri, 3 Aug 2012 20:46:51
> > To: <wp-hackers at lists.automattic.com>
> > Reply-To: wp-hackers at lists.automattic.com
> > Subject: [wp-hackers] Can't find where <p> and <br /> tags are coming
> from
> >
> > I needed to hardcode a plugin that retrieves Picasa Album, it works ok
> but
> > don't know why P e BR tags are appearing, I tried to strip_tags, trim etc
> > and can't get rid of them. Echoing works but then gets out before
> anything
> > else in site as always :(
> >
> > I think is something wrong in php, but maybe something to do with xml?!
> > Thanks for any help.
> >
> >
> >
> > The bit that outputs code I changed a bit is:
> >
> >  $html_gallery = '<ul class="gallery-list row">'."\n";
> >
> >   foreach ($feed as $entry) {
> >    $title = $entry->getTitle();
> >    $summary = $entry->getSummary();
> >    $stuff = $entry->getMediaGroup()->getContent();
> >    $url = $stuff[0]->getUrl();
> >    $thumbnail = $entry->getMediaGroup()->getThumbnail();
> >    $tags = $entry->getMediaGroup()->getKeywords();
> >    $size = $entry->getGphotoSize();
> >    $height = $entry->getGphotoHeight();
> >    $width = $entry->getGphotoWidth();
> >
> >    $html_gallery .= "\n \t".'<li class="gallery-item"><a href="'.$url.'"
> > class="lightbox"><figure><img class="imgpicasa"
> > src="'.$thumbnail[2]->url.'" width="'.$thumbnail[1]->width.'"
> >
> height="'.$thumbnail[1]->height.'"/><figcaption></figcaption></figure></a></li>';
> > //SOMETHING WRONG HERE?
> >
> >   }
> >   $html_gallery .= '</ul>';
> >
> >   $content = $html_gallery.$content;
> >
> >    return strip_tags($content,'<ul><li><a><figure><figcaption><img>');
> >  }
> >
> >
> >
> > The wrong output (<br/> and <p> breaking layout :(  ):
> > <li class="gallery-item"><a
> > href="
> http://lh6.ggpht.com/-C1JJV9zcwr8/TVms7N1oktI/AAAAAAAAAss/wFdr1BpCPys/DSCN1215.JPG
> "
> > class="lightbox"><br />
> > <figure><img class="imgpicasa"
> > src="
> http://lh6.ggpht.com/-C1JJV9zcwr8/TVms7N1oktI/AAAAAAAAAss/wFdr1BpCPys/s288/DSCN1215.JPG
> "
> > width="144" height="108"/><br />
> > <figcaption></figcaption>
> > </figure>
> > <p></a></li>
> > FULL PLUGIN CODE BEFORE MOD: http://pastebin.com/Zfasaz1J
> > _______________________________________________
> > 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: 3
> Date: Fri, 3 Aug 2012 21:44:52 -0400
> From: Beau Lebens <beau at dentedreality.com.au>
> Subject: Re: [wp-hackers] Community conventions for custom post types?
> To: wp-hackers at lists.automattic.com
> Message-ID:
>         <
> CAFuJWcfGWbexxZVEQ9p08tYg5w386KE3Y55iCu_TdVxHMHDwkQ at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I haven't heard of something like this around CPTs or Taxonomies, but
> I know there is, for example, this one around custom fields for Geo:
> http://codex.wordpress.org/Geodata
>
>
> On Fri, Aug 3, 2012 at 7:45 PM, onlyunusedname <onlyunusedname at gmail.com>
> wrote:
> > I mean, I take Lionel's point that a lot of the premium themes are "doing
> > it wrong" which kind of reduces my suggestion to: Let's all do it wrong
> in
> > the same way.
> >
> > But often (this week in particular) I catch myself wishing for just this
> > sort of consensus.
> >
> >
> >
> > On Fri, Aug 3, 2012 at 7:27 PM, onlyunusedname <onlyunusedname at gmail.com
> >wrote:
> >
> >> I think all I really meant, Ade, was to extend the concept of Post
> Formats
> >> to common  Custom Post Types and Custom Taxonomies that I routinely see
> >> others implementing for CMSs.  Maybe it's not really necessary.
> >>
> >> Once upon a time (pre-3.1) if you wanted to do targeted styling for an
> >> "aside-like" post  and I wanted to do targeted styling for an
> "aside-like"
> >> post we would both probably implement that in a very similar but not
> >> interoperable way.  Which would probably be relatively easy to resolve.
> >>  But now we can just know that we are both just using the aside post
> format.
> >>
> >> Today, if I get two restaurant clients with two restaurant "Premium"
> >> themes, they very frequently will have two different sets of very, very
> >> similar but not interoperable custom post types and/or taxonomies and/or
> >> meta.  I just thought it would be nice if I could say that my
> >> restaurant-related theme or plugin was "Portable Menu Taxonomy Spec
> >> vX.X-compatible" (or what have you) it could add up to a big time save.
> >>
> >> I mean, if everyone building a restaurant CMS (or art gallery CMS or
> >> whatever common CMS implementation) knew where to go for the consensus
> spec
> >> and there were snippets for everyone to register everything in the same
> >> manner...  (And if you had a solution that was very uncommon, well this
> >> wouldn't pertain to you.)  Or would that just create more hassle than it
> >> eliminated?
> >>
> >> On Fri, Aug 3, 2012 at 6:41 PM, Ade Walker <photofantaisie at gmail.com
> >wrote:
> >>
> >>> 2012/8/3 onlyunusedname <onlyunusedname at gmail.com>
> >>>
> >>> > For example, if developer A implements a custom post type with custom
> >>> > taxonomies for menu items on a restaurant CMS, it would be great if
> >>> > developer B could take for granted the conventions developer A was
> >>> using.
> >>> >
> >>>
> >>> Hi,
> >>>
> >>> I'm curious too. Can you give an example or two of the kind of
> conventions
> >>> you are thinking of?
> >>>
> >>> Thanks.
> >>> _______________________________________________
> >>> 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: 4
> Date: Sat, 04 Aug 2012 09:46:05 +0800
> From: Ryann Micua <ryannmicua at gmail.com>
> Subject: Re: [wp-hackers] Community conventions for custom post types?
> To: wp-hackers at lists.automattic.com
> Message-ID: <501C7EDD.60700 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hmmmm.. what you're looking at is a lot like asking developers to
> *register* a custom post type they create in to some sort of central
> repository.
>
> or maybe creating a custom post type plugin for some of the most
> commonly used custom post types i.e. portfolio, menu
>
> and tell other devs to extend those custom post types instead.
>
> or just ask the core team to add *common* custom post types into core
> (which I doubt is going to happen) like post formats.
>
> > I mean, I take Lionel's point that a lot of the premium themes are "doing
> > it wrong" which kind of reduces my suggestion to: Let's all do it wrong
> in
> > the same way.
> >
> > But often (this week in particular) I catch myself wishing for just this
> > sort of consensus.
>
> --
> *Ryann Micua*
> /Web Developer/
> ------------------------------------------------------------------------
>
> Website: /www.pogidude.com/
> Skype: /rmicua/
> Mobile: /+639169273059/
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sat, 04 Aug 2012 09:52:29 +0800
> From: Ryann Micua <ryannmicua at gmail.com>
> Subject: Re: [wp-hackers] Community conventions for custom post types?
> To: wp-hackers at lists.automattic.com
> Message-ID: <501C805D.2000106 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> But I think the idea of having a place where authors can reuse commonly
> used post types is a good idea. The hard part here is getting other devs
> to use it. But, once it gets big enough, who knows where it goes.
>
> Theme developers could then use the custom post type plugins here as
> dependencies for their themes.. (assuming they can be persuaded them to
> use this)
>
> Basically, I think this is more of an developer education issue.
>
> --
> *Ryann Micua*
> /Web Developer/
> ------------------------------------------------------------------------
>
> Website: /www.pogidude.com/
> Skype: /rmicua/
> Mobile: /+639169273059/
>
>
>
> ------------------------------
>
> Message: 6
> Date: Sat, 04 Aug 2012 12:01:47 +1000
> From: Ryan McCue <lists at rotorised.com>
> Subject: Re: [wp-hackers] How to exntend wp_xmlrpc_server in plugin
> To: wp-hackers at lists.automattic.com
> Message-ID: <501C828B.6030208 at rotorised.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Kurt Payne wrote:
> > I was looking for docs on opcode caches being able to cache classes
> > declared in if-blocks and couldn't find any...
>
>
> >From memory: because it's declared inside a function, it can't be loaded
> up when the file is loaded (compile-time) as PHP doesn't know if it's
> going to be declared or not until it's run (run-time). So, the opcodes
> can be cached, but the symbol table can't be loaded from cache until the
> function is run.
>
> Best source I can find is Rasmus in IRC:
> http://stackoverflow.com/a/1397160/2575
>
> Thanks,
>
> --
> Ryan McCue
> <http://ryanmccue.info/>
>
>
> ------------------------------
>
> Message: 7
> Date: Sat, 04 Aug 2012 11:17:09 +0000
> From: photofantaisie at gmail.com
> Subject: Re: [wp-hackers] Community conventions for custom post types?
> To: wp-hackers at lists.automattic.com
> Message-ID: <047d7b62205016f44e04c66ec9e3 at google.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes
>
> My initial reaction was that this is a great idea. I've also come up
> against the issues the OP raised, and have been a little frustrated that I
> have had to reinvent the wheel to maintain some sort of compatibility with
> a plugin or theme.
>
> However, what are we really talking about here? Off the top of my head, the
> main areas where one would like to see consistency are in naming
> conventions, eg post_type 'restaurant', rather than 'restaurants', for
> example, so that template naming is predictable, and rewrite rules. So, one
> convention could be that, like 'post' and 'page', the CPT registered name
> must be singular. But once you get beyond this, I'm not sure much can be
> standardised. For example, I would not support a convention that says
> that 'restaurant' must be non-hierarchical. In my use case, I may
> need 'restaurant' to be hierarchical. (Note: I hope I'm not
> misunderstanding the kind of conventions that people are thinking about.)
>
> Re dev education, I would certainly like to see further promotion and
> reinforcement that CPTs and CTAX's should never be are registered by a
> theme, only a plugin.
>
>
> ------------------------------
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
> End of wp-hackers Digest, Vol 91, Issue 10
> ******************************************
>



-- 
"The following will cause your email to be flagged:
*u, ur, sumthing, sumeone, dat, dis, ight, dere, plz, thx*"

Zane Matthew Kolnik
443-804-8161
http://bmxraceevents.com/
http:/zanematthew.com/ <http://blog.zanematthew.com/>
http://twitter.com/zanematthew/


More information about the wp-hackers mailing list