一個獨立的插件他可能在運行之前需要保存有運行的配置信息,此時就需要在激法插件時,先將配置信息寫入數據庫;而當禁用插件時,應當將此相關信息清除,確保插件不會產生垃圾信息。 (在製作的過程中應該盡的減少耦合性,確定是一個獨立體)此時我們會在激法和禁用插件這兩個鉤子上進行我們的數據初始化和清除的ACTION了。
資料參考: 這裡
[php]
$hm = new FFI_AAM_Hook_Manager;
register_activation_hook( __FILE__, array( &$hm, ‘activationHandler’ );
register_uninstall_hook( __FILE__, array( &$hm, ‘uninstallHandler’ );
class FFI_AAM_Hook_Manager {
public function activationHandler() {
// activation code here
}
public function uninstallHandler() {
// deactivation code here
}
}
[/php]