Skip to content

Commit

Permalink
fix: upgrader action key
Browse files Browse the repository at this point in the history
  • Loading branch information
vermorag committed Dec 16, 2024
1 parent 09c7710 commit b80405b
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use Cdek\UI\Frontend;
use Cdek\Validator\CheckoutValidator;
use RuntimeException;
use WP_Upgrader;

class Loader
{
Expand Down Expand Up @@ -106,6 +105,15 @@ private static function checkRequirements(): void
}
}

public static function upgrade(): void
{
TaskManager::scheduleExecution();

foreach (self::MIGRATORS as $migrator) {
(new $migrator)();
}
}

public static function deactivate(): void
{
TaskManager::cancelExecution();
Expand Down Expand Up @@ -146,24 +154,23 @@ public static function getPluginPath(?string $path = null): string
return plugin_dir_path(self::$pluginMainFilePath).($path !== null ? ltrim($path, DIRECTORY_SEPARATOR) : '');
}

public static function scheduleUpgrade(WP_Upgrader $_wp, array $options): void
/** @noinspection MissingParameterTypeDeclarationInspection */
public static function scheduleUpgrade($wp, array $options): void
{
if (($options['action'] !== 'update' ||
$options['type'] !== 'plugin' ||
!in_array(self::$pluginMainFile, $options['plugins'] ?? [], true))) {
if ($options['type'] !== 'plugin') {
return;
}

as_schedule_single_action(time() + 60, Config::UPGRADE_HOOK_NAME, [], 'cdekdelivery', true);
}

public static function upgrade(): void
{
TaskManager::scheduleExecution();
if ($options['action'] === 'install' && $wp->new_plugin_data['Name'] !== self::$pluginName) {
return;
}

foreach (self::MIGRATORS as $migrator) {
(new $migrator)();
if (($options['action'] === 'update' &&
!in_array(self::$pluginMainFile, $options['plugins'] ?? [], true))) {
return;
}

as_schedule_single_action(time() + 60, Config::UPGRADE_HOOK_NAME, [], 'cdekdelivery', true);
}

public function __invoke(string $pluginMainFile): void
Expand Down

0 comments on commit b80405b

Please sign in to comment.