-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupgrade-task-runner.php
60 lines (53 loc) · 1.7 KB
/
upgrade-task-runner.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
/**
* A WordPress plugin for developers to write custom migration tasks.
* @wordpress-plugin
* Plugin Name: Upgrade Task Runner
* Plugin URI: https://github.com/thefrosty/wp-upgrade-task-runner
* Description: A WordPress plugin for developers to write custom migration tasks.
* Version: 2.8.0
* Author: Austin Passy
* Author URI: https://github.com/thefrosty
* Requires at least: 6.2
* Tested up to: 6.5.0
* Requires PHP: 8.1
*/
namespace TheFrosty\WpUpgradeTaskRunner;
const SLUG = 'wp-upgrade-task-runner';
const VERSION = '2.8.0';
use TheFrosty\WpUpgradeTaskRunner\Cli\DispatchTasks;
use TheFrosty\WpUpgradeTaskRunner\Upgrade\DbUpgrade;
use TheFrosty\WpUpgradeTaskRunner\Upgrade\TaskCountCheck;
use TheFrosty\WpUtilities\Plugin\PluginFactory;
use TheFrosty\WpUtilities\WpAdmin\DisablePluginUpdateCheck;
use function add_action;
use function class_exists;
use function defined;
use const WP_CLI;
$plugin = PluginFactory::create(SLUG);
$container = $plugin->getContainer();
$container->register(new ServiceProvider());
$plugin
->add(new DisablePluginUpdateCheck())
->add($container[ServiceProvider::UPGRADE_PROVIDER])
->add($container[ServiceProvider::TASK_LOADER])
->addOnConditionDeferred(
DispatchTasks::class,
static fn(): bool => defined('\WP_CLI') && WP_CLI && class_exists('\WP_CLI'),
null,
'plugins_loaded',
'init',
10,
false,
[$container]
)
->addOnHook(DbUpgrade::class, 'admin_menu', null, true)
->addOnHook(TaskCountCheck::class, 'admin_menu', null, true);
add_action(
'plugins_loaded',
static function () use ($plugin): void {
$plugin->initialize();
},
5
);