Skip to content

Commit

Permalink
Merge pull request #23 from Emilia-Capital/add/deactivation
Browse files Browse the repository at this point in the history
Add deactivation & uninstall hooks
  • Loading branch information
jdevalk authored Sep 6, 2024
2 parents f867f36 + 3b1b7ad commit d01319e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions aaa-option-optimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require_once __DIR__ . '/src/autoload.php';

register_activation_hook( __FILE__, 'aaa_option_optimizer_activation' );
register_deactivation_hook( __FILE__, 'aaa_option_optimizer_deactivation' );

/**
* Activation hooked function to store start stats.
Expand All @@ -46,6 +47,16 @@ function aaa_option_optimizer_activation() {
);
}

/**
* Deactivation hooked function to remove autoload from the plugin option.
*
* @return void
*/
function aaa_option_optimizer_deactivation() {
$aaa_option_value = get_option( 'option_optimizer' );
update_option( 'option_optimizer', $aaa_option_value, false );
}

/**
* Initializes the plugin.
*
Expand Down
16 changes: 16 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Uninstall the plugin.
*
* Delete the plugin option.
*
* @package Progress_Planner
*/

// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}

// Delete the plugin option.
delete_option( 'option_optimizer' );

0 comments on commit d01319e

Please sign in to comment.