Giter VIP home page Giter VIP logo

thefrosty / wp-upgrade-task-runner Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 211 KB

Register custom migration tasks that can be scheduled from the plugin settings dashboard in the admin and run as a cron job.

Home Page: https://austin.passy.co/2019/introducing-wordpress-upgrade-task-runner-v2/

JavaScript 3.93% Shell 5.83% PHP 89.88% CSS 0.36%
wordpress-plugin migration-tool ajax php wordpress php80

wp-upgrade-task-runner's Introduction

WordPress Upgrade Task Runner

WP Upgrade Task Runner

PHP from Packagist Latest Stable Version Total Downloads License Build Status codecov

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.

  1. A class needs to be created and this class needs to extend the AbstractTaskRunner class. See the ExampleMigrationTask example class.
  2. Register the new task class via the TaskLoader::REGISTER_TASKS_TAG filter:
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).

wp-upgrade-task-runner's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar thefrosty avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wprobot

wp-upgrade-task-runner's Issues

Add weekly cron for cleanup

In case a user removes any registered tasks that have been run, a weekly cleanup task should run to check remove them from the database options to fix the pending tasks count.

Add capability view/run control

Either via code, or a settings page: allow users to view the tasks, with a "run" cap to trigger the actions.

This will allow users like editors or QA to view tasks, but not run them.

Add Heartbeat listener for cron task + step

On schedule, listen for the cron event to be triggered via the heartbeat (if the heartbeat is on and enabled) and give better feedback on migration task steps.

Heartbeat example, see Stream Live mode.
Migration task, see Redirections plugin (db update).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.