From 555c9e2b06b0ba31b940f51c97732e759964ec61 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 16 Jan 2023 23:47:34 +0100 Subject: [PATCH] cope with disabled plugin, should fix #10 --- _uninstall.php | 6 ++++++ inc/Uninstall.php | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/_uninstall.php b/_uninstall.php index e825aa1..99a9c0c 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -13,6 +13,12 @@ declare(strict_types=1); $uninstall = implode('\\', ['Dotclear', 'Plugin', basename(__DIR__), 'Uninstall']); + +// cope with disabled plugin +if (!class_exists($uninstall)) { + require implode(DIRECTORY_SEPARATOR, [__DIR__, 'inc', 'Uninstall.php']); +} + if ($uninstall::init()) { $uninstall::process($this); } diff --git a/inc/Uninstall.php b/inc/Uninstall.php index 49abd65..9ad4cca 100644 --- a/inc/Uninstall.php +++ b/inc/Uninstall.php @@ -16,10 +16,12 @@ namespace Dotclear\Plugin\improve; class Uninstall { - private static $init = false; + private static $pid = ''; + protected static $init = false; public static function init(): bool { + self::$pid = basename(dirname(__DIR__)); self::$init = defined('DC_RC_PATH'); return self::$init; @@ -37,7 +39,7 @@ class Uninstall /* action */ 'delete_all', /* ns */ - Core::id(), + self::$pid, /* desc */ __('delete all settings') ); @@ -48,7 +50,7 @@ class Uninstall /* action */ 'delete', /* ns */ - Core::id(), + self::$pid, /* desc */ __('delete plugin files') ); @@ -59,7 +61,7 @@ class Uninstall /* action */ 'delete', /* ns */ - Core::id(), + self::$pid, /* desc */ __('delete the version number') ); @@ -70,9 +72,9 @@ class Uninstall /* action */ 'delete_all', /* ns */ - Core::id(), + self::$pid, /* desc */ - sprintf(__('delete all %s settings'), Core::id()) + sprintf(__('delete all %s settings'), self::$pid) ); $uninstaller->addDirectAction( @@ -81,9 +83,9 @@ class Uninstall /* action */ 'delete', /* ns */ - Core::id(), + self::$pid, /* desc */ - sprintf(__('delete %s plugin files'), Core::id()) + sprintf(__('delete %s plugin files'), self::$pid) ); $uninstaller->addDirectAction( @@ -92,9 +94,9 @@ class Uninstall /* action */ 'delete', /* ns */ - Core::id(), + self::$pid, /* desc */ - sprintf(__('delete %s version number'), Core::id()) + sprintf(__('delete %s version number'), self::$pid) ); } }