[wp-trac] Re: [WordPress Trac] #7875: consolidate plugin/theme/core upgrade/install functions

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 3 11:26:22 GMT 2009


#7875: consolidate plugin/theme/core upgrade/install functions
-----------------------------+----------------------------------------------
 Reporter:  DD32             |       Owner:  anonymous  
     Type:  enhancement      |      Status:  new        
 Priority:  highest omg bbq  |   Milestone:  2.8        
Component:  Administration   |     Version:  2.7        
 Severity:  major            |    Keywords:  needs-patch
-----------------------------+----------------------------------------------

Comment(by DD32):

 I've actually got a free weekend for once again...

 I'm thinking a base class that does most of the basic steps:
 {{{
 Class Upgrader:
 +filesystem init()

  Generic funcs:
 +download archive()
 +unpack archive()
 +install files to location($srchive_source, $location)
 +delete files/folders()

  Specific funcs (probably in child classes)
 +plugin::install()
 +plugin::upgrade()
 +theme::install()
 +theme::upgrade()
  (Which all call the parents functions in order, with needed params)

 }}}

 The major problem is strings, Plugin and Theme strings are different, The
 error messages need to reflect the component.. So that'll be something
 that needs to be worked around.

 My original plan was to have the child class set $this->strings['no_dir']
 ='No Plugin directory found', but that has its downsides, rather
 unreadable code. Perhaps moving to returning WP_Error('unique_error'), and
 then handling that {{{ if( error_type($error, 'unique_error) return
 WP_error(',,;', 'The plugin couldnt be unpacked'); }}}

 The Plugin/Theme install/upgrade functionalities could be easily handled
 by a single piece of UI code, due to the simple nature of the output. It
 might be possible to link some plugin hooks in so that a custom class
 (like you want) could use the majority of the same code.

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


More information about the wp-trac mailing list