[wp-trac] [WordPress Trac] #26877: Allow get_post() to accept a custom post object instead of only WP_Post
WordPress Trac
noreply at wordpress.org
Mon Feb 17 20:54:43 UTC 2014
#26877: Allow get_post() to accept a custom post object instead of only WP_Post
------------------------------------+-----------------------------
Reporter: MikeSchinkel | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+-----------------------------
Comment (by MikeSchinkel):
Replying to [comment:2 wonderboymusic]:
> This isn't very convincing, and wasn't on the other ticket you pasted
the same code example.
> Is this really worth 2 separate tickets?
I assume you are replying to me, the OP? If yes, what other ticket are
you talking about? In my memory I only posted this one ticket on this
topic.
> You want to subclass a model so that you can use a theme function on one
of the global `$post`'s properties?
I don't understand what you mean by _"use a theme function"_; Are you
saying that because I chose `title()` as the one methods I showed ''(vs.
one of the other 25+ methods in my actual class)'' that I am ''"using a
theme function?"'' If yes, note that rather than overwhelm the reader I
was trying to show the smallest example I could, and yes ~$post->title()`
is not that beneficial. But `$post->the_video_embed()`,
`$post->the_featured_image()` and `$post->do_show_excerpt()` might help
you visualize it better.
What I want to do is be able to add properties and behavior to the `$post`
object so that when I pass the `$post` object around, especially through
other people's code that the properties and behavior follow along with it.
This is just OOP 101 and wasn't something I though needed had to be made
highly convincing.
I understand and appreciate [/ticket/24672#comment:3 @nacin's reluctance
to remove final] which is why my patch did not propose final but instead
used containment. The problem is we can't use containment if all the
methods that would work with posts throw away our instances when they call
`get_post()` which is the reason for my proposal.
If someone wants to add their own functionality like this they can't do it
compatibly with WordPress; they have to write a fully custom theme vs.
just add their own selected theme template files.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26877#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list