[wp-trac] [WordPress Trac] #4389: Improve plugin activate and deactivate hooks

WordPress Trac wp-trac at lists.automattic.com
Fri Jun 1 15:11:21 GMT 2007


#4389: Improve plugin activate and deactivate hooks
--------------------------+-------------------------------------------------
 Reporter:  Otto42        |       Owner:  anonymous
     Type:  enhancement   |      Status:  new      
 Priority:  normal        |   Milestone:  2.4      
Component:  Optimization  |     Version:           
 Severity:  major         |    Keywords:           
--------------------------+-------------------------------------------------
 The activate and deactivate hooks are clumsy, at best. Because they rely
 on the name of the plugin file being a constant, renaming a plugin file
 will break them. Even worse, the plugin path is part of that name, so
 putting a plugin in a subdirectory that it was not expecting (for users
 that want to keep things organized) will also break these.

 Instead, how about adding an optional tag to the Plugin header, like so:
 {{{
 <?php
 /*
 Plugin Name: Name Of The Plugin
 Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
 Description: A brief description of the plugin.
 Version: The plugin's Version Number, e.g.: 1.0
 Author: Name Of The Plugin Author
 Author URI: http://URI_Of_The_Plugin_Author
 Activate: activate_function_hook
 Deactivate: deactivate_function_hook
 */
 ?>
 }}}

 When a plugin is activated or deactivated, that tag can be read from its
 header and then the hook specified can be called to trigger that action in
 the plugin. This provides an absolutely certain way to call activate or
 deactivate functions in a plugin, without relying on the filename and
 filepath that the plugin happens to be in.

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


More information about the wp-trac mailing list