| 1 |
<?php |
| 2 |
|
| 3 |
namespace AgeGate\Update; |
| 4 |
|
| 5 |
use Asylum\Utility\Storage; |
| 6 |
use AgeGate\Common\Immutable\Constants; |
| 7 |
|
| 8 |
class Uninstall |
| 9 |
{ |
| 10 |
public static function uninstall() |
| 11 |
{ |
| 12 |
// delete options |
| 13 |
foreach (Constants::AGE_GATE_OPTIONS as $option) { |
| 14 |
delete_option($option); |
| 15 |
} |
| 16 |
|
| 17 |
// delete legacy options |
| 18 |
delete_option('age_gate_updated_from'); |
| 19 |
delete_option('wp_age_gate_restrictions'); |
| 20 |
delete_option('wp_age_gate_messages'); |
| 21 |
delete_option('wp_age_gate_validation_messages'); |
| 22 |
delete_option('wp_age_gate_appearance'); |
| 23 |
delete_option('wp_age_gate_advanced'); |
| 24 |
delete_option('wp_age_gate_access'); |
| 25 |
delete_option('age_gate_dev'); |
| 26 |
|
| 27 |
// delete custom css file |
| 28 |
// no longer required |
| 29 |
// wp_delete_file( Storage::storageDir('css', 'age-gate') . '/custom.css' ); |
| 30 |
|
| 31 |
// remove caps |
| 32 |
foreach (wp_roles()->roles ?? [] as $role => $data) { |
| 33 |
$r = get_role($role); |
| 34 |
|
| 35 |
foreach (Constants::AGE_GATE_PERMISSION_ARRAY as $cap) { |
| 36 |
$r->remove_cap($cap); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
// delete version |
| 41 |
delete_option('age_gate_version'); |
| 42 |
} |
| 43 |
} |
| 44 |
|