| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file runs when the plugin in uninstalled (deleted). |
| 4 |
* This will not run when the plugin is deactivated. |
| 5 |
* Ideally you will add all your clean-up scripts here |
| 6 |
* that will clean-up unused meta, options, etc. in the database. |
| 7 |
* |
| 8 |
* @package Bricksable/Uninstall |
| 9 |
*/ |
| 10 |
|
| 11 |
// If plugin is not being uninstalled, exit (do nothing). |
| 12 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
// Do something here if plugin is being uninstalled. |
| 17 |
if ( 'on' === get_option( 'bricksable_uninstall_on_delete' ) ) { |
| 18 |
// Remove all matching options from the database. |
| 19 |
foreach ( wp_load_alloptions() as $option => $value ) { |
| 20 |
if ( strpos( $option, 'bricksable_' ) !== false ) { |
| 21 |
delete_option( $option ); |
| 22 |
} |
| 23 |
} |
| 24 |
} |