[wp-trac] [WordPress Trac] #12955: Add get_post filter

WordPress Trac noreply at wordpress.org
Fri Oct 16 03:00:37 UTC 2015


#12955: Add get_post filter
------------------------------------+-----------------------------
 Reporter:  JohnLamansky            |       Owner:
     Type:  feature request         |      Status:  new
 Priority:  normal                  |   Milestone:  Future Release
Component:  Posts, Post Types       |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+-----------------------------

Comment (by MikeSchinkel):

 So attached is another way to skin this cat.

 1. Added a `WP_Post::make_instance()` method that is to be called instead
 of `new WP_Post()` except inside core.  2. Added deprecation warning if
 `new WP_Post()` is called in a theme or plugin directly.
 3. Added a `'make_post_instance'` to filter instances when `new WP_Post()`
 is called.
 4. Added a `'get_virtual_post_instance'` for when the SQL query in
 `WP_Post::get_instance()` fails to find a post in the database. This will
 allow code to retrieve the post via API and then return a valid post.

 This approach is in advance of caching.

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


More information about the wp-trac mailing list