[wp-trac] [WordPress Trac] #14302: Object Property getters and setters

WordPress Trac wp-trac at lists.automattic.com
Mon Jan 31 15:45:46 UTC 2011


#14302: Object Property getters and setters
-------------------------+-----------------------------
 Reporter:  filosofo     |       Owner:  filosofo
     Type:  enhancement  |      Status:  accepted
 Priority:  normal       |   Milestone:  Future Release
Component:  Post Types   |     Version:  3.0
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------------

Comment (by filosofo):

 Another way of putting the need for `set_post_property()`: why is it if
 the information is stored in `postmeta`, we can update properties
 individually, but if it it's stored in `posts` we can't?


 E.g.: With my event custom post type, I should be able to do the
 following:

 {{{
 set_post_property( get_the_ID(), 'title', 'My Event' );
 set_post_property( get_the_ID(), 'location', '123 Main Street' );
 }}}

 For "location," I ''can'' do that: `update_post_meta( get_the_ID(),
 'location', '123 Main Street' );`


 For "title, I have to retrieve and re-save the entire post:

 {{{
 $event_object = get_post( get_the_ID(), ARRAY_A );
 $event_object['post_title'] = 'My Event';
 wp_update_post( $event_object );
 }}}


 I'm saying that it's a poor API that requires me to know the underlying
 database schema in order to use the API.  ''At the API level'' we should
 be agostic about the underlying database structure.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14302#comment:14>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list