cope with disabled plugin, should fix #10

master
Jean-Christian Paul Denis 2023-01-16 23:47:34 +01:00
parent acde66de52
commit 555c9e2b06
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
2 changed files with 18 additions and 10 deletions

View File

@ -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);
}

View File

@ -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)
);
}
}