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

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 8 15:32:54 UTC 2011


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

Comment (by filosofo):

 Replying to [comment:39 scribu]:
 > I was going to say it's going to be hard for multiple plugins to extend
 these classes.
 >
 > But then I figured we can use the {{{__call()}}} magic method, since
 we're on PHP5 now:
 >
 > {{{
 > function __call( $method, $args ) {
 >   array_unshift( $args, $this );
 >   return do_action_ref_array( "post_{$method}", $args );
 > }
 > }}}

 We don't need that.  The descendant constructors can just assign the
 respective properties their object-specific values.

 For example, the ancestor class defines the `get_title` method:

 {{{
 function get_title() {
    return $this->_title;
 }
 }}}

 So for post objects upon instantiation:

 {{{
 $this->_title = $this->post_title;
 }}}

 and for terms:

 {{{
 $this->_title = $this->name;
 }}}

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


More information about the wp-trac mailing list