Created
          March 6, 2011 17:27 
        
      - 
      
- 
        Save markjaquith/857430 to your computer and use it in GitHub Desktop. 
    Example code for doing activate/deactivate/uninstall hooks in a WordPress plugin
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // Change /*CUSTOMIZE_THIS*/ to a unique name (two places). Go ahead, make it long. | |
| // Like, your initials, and your full plugin name. | |
| // e.g. MTJ_Some_Awesome_Plugin_Controller | |
| /*CUSTOMIZE_THIS*/_Controller::init(); | |
| class /*CUSTOMIZE_THIS*/_Controller { | |
| function init() { | |
| register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) ); | |
| register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) ); | |
| } | |
| function activate() { | |
| // Add options, initiate cron jobs here | |
| register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) ); | |
| } | |
| function deactivate() { | |
| // Remove cron jobs here | |
| } | |
| function uninstall() { | |
| // Delete options here | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
When is the uninstall hook fired? I seem not to be able to fire it.