[wp-trac] [WordPress Trac] #12267: Upgrade loop objects to provide identical presentational interfaces.

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 23 02:01:57 UTC 2010


#12267: Upgrade loop objects to provide identical presentational interfaces.
-------------------------+--------------------------------------------------
 Reporter:  andy         |       Owner:     
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.0
Component:  General      |     Version:     
 Severity:  normal       |    Keywords:     
-------------------------+--------------------------------------------------

Comment(by prettyboymp):

 I'd like to suggest changing the way the properties are set and accessed
 so that all the original data in the db_object is still accessible.
 Instead of assigning all the properties to WP_Object during construction,
 can't the WP_Object just have a *private* $db_object property that is then
 accessed by _get methods, ei:


 {{{
 Class WP_Object {
 /*private*/ $db_ojbect;

   function get_property($property_name) {
     if(isset($this->db_object->$property_name))
       return $this->db_object->$property_name;
     return null;
   }

   function get_title() {
     return $this->get_property('title');
   }
 }

 class WP_Post extends WP_Object {

   function get_title() {
     return $this->get_property('post_title');
   }
 }
 }}}

 This also allows a filter to eventually be added to get_property().

 I also don't know if WP_Page should be a separate class.  Especially with
 the addition of custom post_types.  Its data is so similar to posts and
 different enough from other presentable data, that being able see that is
 of type WP_Post and being able to get the post_type from it should be
 enough.

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


More information about the wp-trac mailing list