Skip to content

Commit

Permalink
Add deactivation hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Sep 4, 2024
1 parent 53eab76 commit cda2f6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 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
7 changes: 3 additions & 4 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Uninstall the plugin.
*
* Remove autoload from the plugin option.
* Delete the plugin option.
*
* @package Progress_Planner
*/
Expand All @@ -12,6 +12,5 @@
exit;
}

// Remove autoload from the plugin option.
$aaa_option_value = get_option( 'option_optimizer' );
update_option( 'option_optimizer', $aaa_option_value, false );
// Delete the plugin option.
delete_option( 'option_optimizer' );

Check failure on line 16 in uninstall.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 newline at end of file; 0 found

Check failure on line 16 in uninstall.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 newline at end of file; 0 found

0 comments on commit cda2f6b

Please sign in to comment.