Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deactivation & uninstall hooks #23

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' );
Loading