[wp-trac] [WordPress Trac] #34875: Allow developers to use an extended version of WP_Post (also WP_Term & WP_Comment)

WordPress Trac noreply at wordpress.org
Wed Aug 3 10:37:10 UTC 2016


#34875: Allow developers to use an extended version of WP_Post (also WP_Term &
WP_Comment)
-------------------------------+------------------------------
 Reporter:  flixos90           |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.4
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by flixos90):

 It's been a while, but I was just wondering about introducing a filter in
 `get_post()`. It could be related to this functionality, but could be used
 in other ways too. Looking at `get_term()`, `get_comment()`, `get_site()`
 and `get_network()`, all these functions include a filter of the same
 name. `get_post()` is the only exception here.

 I still think it would be a valuable enhancement for developers to use
 their own post classes based on `WP_Post`. This would not make sense in a
 plugin, but in various custom projects where one has full control over the
 environment. Many use wrapper classes for posts with their own
 functionality, but it's a pain to do so. Writing your own post class
 derived from `WP_Post` and using a filter `get_post` to transform the
 object accordingly would make it a lot easier.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34875#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list