When do I really need remove_filter or remove_action?
-
Hi!
I read a few tutorials that suggest you have to clean up your wordpress plugin (when deactivating) by removing all filters and actions that you have set. Is that right? I found nothing like that in other plugin-code… So when do I really need these functions?
This is my code until now:
<?php /* Plugin Name: WordPress-Plugin Vorlage Plugin URI: http://www.iscope.de Description: WordPress-Plugin Vorlage Author: Fabian Heinrich <fheinrich@iscope.de> Author URI: http://www.iscope.de Version: 0.0.1 */ if(!class_exists('myPlugin')) { class myPlugin { function __construct() { register_activation_hook( __FILE__, array(&$this, 'activate')); register_deactivation_hook( __FILE__, array(&$this, 'deactivate')); } function activate() { // hier setzen wir unsere Hooks, z.B.: add_action('edit_category_form', array(&$this, 'myHookCategory')); } function deactivate() { // hier räumen wir wieder auf, wenn das Plugin deaktiviert wird, z.B.: remove_action('edit_category_form', array(&$this, 'myHookCategory')); } function myHookCategory() { // hier kommt der Quelltext, den wir ins System bringen wollen echo '<h3>Mein erster Hook, yay!</h3>'; } } } else { $myPluginObject = new myPlugin(); if (isset($myPluginObject)) { add_action('init', array(&$myPluginObject, 'activate')); } } ?>
P.S.: Does someone know, why there is an add_action added after initializing the object? With initializing it, the constructor is called, isn’t it? So I dont understand that part…
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘When do I really need remove_filter or remove_action?’ is closed to new replies.