Skip to content

Commit

Permalink
Added plugin uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
W1W1-M committed Jul 6, 2023
1 parent 6a5669b commit 46bc3f1
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions wp-plugintemplate/uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php /** @noinspection PhpRedundantClosingTagInspection */

wp_tarteaucitron_uninstall();

/**
* @since 1.0.0
*
* @return void
*/
function wp_tarteaucitron_uninstall(): void {
try {
wordpress_plugin_uninstall_called();
delete_options();
} catch( Exception $exception ) {
exit( $exception->getMessage() );
}
}

/**
* @since 1.0.0
*
* @throws Exception
*
* @return bool
*/
function wordpress_plugin_uninstall_called(): bool {
if ( defined( 'WP_UNINSTALL_PLUGIN' ) ) {
return true;
} else {
$exception = new Exception( 'Improper plugin uninstall call' );
error_log( $exception->getMessage() );
throw $exception;
}
}

/**
* @since 1.0.0
*
* @throws Exception
*
* @return void
*/
function delete_options(): void {
delete_option( 'wp_plugintemplate_dummy' );
}

?>

0 comments on commit 46bc3f1

Please sign in to comment.