worldline-for-woocommerce
Last commit date
assets
1 week ago
inc
1 week ago
languages
1 week ago
modules
1 week ago
shared
1 week ago
src
1 week ago
vendor
1 week ago
.eslintrc.js
1 week ago
BUILD_INFO.txt
1 week ago
LICENSE
1 week ago
SECURITY.md
1 week ago
class-plugin.php
1 week ago
composer.json
1 week ago
config.php
1 week ago
package.json
1 week ago
readme.txt
1 week ago
tsconfig.json
1 week ago
uninstall.php
1 week ago
webpack.config.js
1 week ago
worldline-for-woocommerce.php
1 week ago
uninstall.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Uninstalls the plugin. |
| 5 | * |
| 6 | * @package Inpsyde\WorldlineForWoocommerce |
| 7 | */ |
| 8 | declare (strict_types=1); |
| 9 | namespace Syde\Vendor\Worldline; |
| 10 | |
| 11 | use Syde\Vendor\Worldline\Inpsyde\Modularity\Package; |
| 12 | use Syde\Vendor\Worldline\Inpsyde\WorldlineForWoocommerce\Uninstall\DatabaseCleaner; |
| 13 | use Syde\Vendor\Worldline\Psr\Container\ContainerInterface; |
| 14 | if (!\defined('WP_UNINSTALL_PLUGIN')) { |
| 15 | die('Direct access not allowed.'); |
| 16 | } |
| 17 | $mainPluginFile = __DIR__ . "/worldline-for-woocommerce.php"; |
| 18 | if (!\file_exists($mainPluginFile)) { |
| 19 | return; |
| 20 | } |
| 21 | require $mainPluginFile; |
| 22 | (static function () : void { |
| 23 | $autoloadPath = __DIR__ . "/vendor/autoload.php"; |
| 24 | if (\file_exists($autoloadPath) && !\class_exists('Syde\\Vendor\\Worldline\\Inpsyde\\WorldlineForWoocommerce\\CoreModule')) { |
| 25 | require $autoloadPath; |
| 26 | } |
| 27 | try { |
| 28 | $bootstrap = (require __DIR__ . '/inc/bootstrap.php'); |
| 29 | $onError = (require __DIR__ . '/inc/error.php'); |
| 30 | $modules = (require __DIR__ . '/inc/modules.php')(); |
| 31 | $modules = \apply_filters('wlop.modules_list', $modules); |
| 32 | $package = $bootstrap(__FILE__, $onError, ...$modules); |
| 33 | \assert($package instanceof Package); |
| 34 | $container = $package->container(); |
| 35 | \assert($container instanceof ContainerInterface); |
| 36 | $shouldClearDb = $container->get('config.clear_data_on_uninstall'); |
| 37 | if ($shouldClearDb !== \true) { |
| 38 | return; |
| 39 | } |
| 40 | global $wpdb; |
| 41 | $table = $wpdb->prefix . 'product_type'; |
| 42 | $wpdb->query("DROP TABLE IF EXISTS `{$table}`"); |
| 43 | $dbCleaner = $container->get('uninstall.db-cleaner'); |
| 44 | \assert($dbCleaner instanceof DatabaseCleaner); |
| 45 | $dbCleaner->clearAll(); |
| 46 | } catch (\Throwable $throwable) { |
| 47 | $message = \sprintf('<strong>Error:</strong> %s <br><pre>%s</pre>', $throwable->getMessage(), $throwable->getTraceAsString()); |
| 48 | \add_action('all_admin_notices', static function () use($message) { |
| 49 | $class = 'notice notice-error'; |
| 50 | \printf('<div class="%1$s"><p>%2$s</p></div>', \esc_attr($class), \wp_kses_post($message)); |
| 51 | }); |
| 52 | } |
| 53 | })(); |
| 54 |