thefrosty / wp-upgrade-task-runner
A WordPress plugin for developers to write custom migration tasks.
Installs: 17 950
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 3
Type:wordpress-plugin
pkg:composer/thefrosty/wp-upgrade-task-runner
Requires
- php: ^8.1
 - pimple/pimple: ^3.5
 - symfony/http-foundation: ~6.0 || ^7.0
 - thefrosty/wp-utilities: ^3.3
 
Requires (Dev)
- ext-simplexml: *
 - dealerdirect/phpcodesniffer-composer-installer: ^1.0.0
 - phpcompatibility/php-compatibility: ^9.3
 - phpunit/phpunit: ^9
 - roots/wordpress: ~6.1
 - slevomat/coding-standard: ^8.8
 - squizlabs/php_codesniffer: ^3.7
 - wp-cli/wp-cli-bundle: ^2.4
 - wp-coding-standards/wpcs: dev-develop
 - wp-phpunit/wp-phpunit: ~6.1
 - yoast/phpunit-polyfills: ^2.0.0
 
README
Register custom migration tasks that can be triggered from a dashboard in the admin and run via AJAX.
Requirements
PHP >= 8.1
WordPress >= 6.2
The required WordPress version will always be the most recent point release of the previous major release branch.
For both PHP and WordPress requirements, although this library may work with a version below the required versions, they will not be supported and any compatibility is entirely coincidental.
Installation
To install this library, use Composer:
composer require thefrosty/wp-upgrade-task-runner:^2
Getting Started
If a new task is needed, there are only two required steps that are needed.
- A class needs to be created and this class needs to extend the 
AbstractTaskRunnerclass. See theExampleMigrationTaskexample class. - Register the new task class via the 
TaskLoader::REGISTER_TASKS_TAGfilter: 
use TheFrosty\WpUpgradeTaskRunner\Tasks\TaskLoader; \add_filter(TaskLoader::REGISTER_TASKS_TAG, static function(array $tasks): array { $tasks[] = new \Project\SomeCustomTask(); return $tasks; });
The task class
When a class is added, it needs to have a few pre-defined class values. Both the DATE and TITLE constant are required to be unique. These are what registers a one off cron task when manually running the task from the admin page.
The TaskLoader
Add the new class as a property in the TaskLoader class and instantiate it in the register_tasks method (just like
the ExampleMigrationTask).
CLI
Run all registered tasks (not already run) via wp-cli: $ wp upgrade-task-runner.
CLI OPTIONS
 [--task=<class>] : The fully qualified registered task to run.
 [--user=<id>] : The user ID to associate with running said task(s).
                