[wp-trac] [WordPress Trac] #17236: Make it easier to subclass custom header and background

WordPress Trac wp-trac at lists.automattic.com
Mon Apr 25 20:50:14 UTC 2011


#17236: Make it easier to subclass custom header and background
-----------------------------+-----------------------------
 Reporter:  Otto42           |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Themes           |    Version:
 Severity:  normal           |   Keywords:
-----------------------------+-----------------------------
 The functions that add the custom header and background contain code like
 this:

 {{{
 require_once( ABSPATH . 'wp-admin/custom-header.php' );
 $custom_image_header = new Custom_Image_Header( $admin_header_callback,
 $admin_image_div_callback );
 add_action( 'admin_menu', array( &$custom_image_header, 'init' ) );
 }}}

 This makes it difficult to extend those classes, since they're referenced
 here directly. Replacing them with subclasses involves not only modifying
 the global after the fact, but removing and re-adding the action hook to
 the newly created sub-class item.

 The fact that this base class is only included at this point also makes it
 difficult to load your own subclass at the right time, since you have to
 add the custom image header first, then load, then remove the action hook,
 then replace the class, then do the action hook yourself...

 It would be nice if it was possible to more easily replace these globals
 (both header and background) with a different class at the time of
 definition here. I'm not sure of the best way to do this. Perhaps with a
 hook allowing the user to replace the class before the add_action? Or by
 having the new itself use a class of the users own defining.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17236>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list