PHP code example of a5hleyrich / wp-background-processing
1. Go to this page and download the library: Download a5hleyrich/wp-background-processing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
a5hleyrich / wp-background-processing example snippets
class WP_Example_Request extends WP_Async_Request {
/**
* @var string
*/
protected $prefix = 'my_plugin';
/**
* @var string
*/
protected $action = 'example_request';
/**
* Handle a dispatched request.
*
* Override this method to perform any actions
$this->example_request = new WP_Example_Request();
class WP_Example_Process extends WP_Background_Process {
/**
* @var string
*/
protected $prefix = 'my_plugin';
/**
* @var string
*/
protected $action = 'example_process';
/**
* Perform task with queued item.
*
* Override this method to perform any actions ons to perform.
return false;
}
/**
* Complete processing.
*
* Override if applicable, but ensure that the below actions are
* performed, or, call parent::complete().
*/
protected function complete() {
parent::complete();
// Show notice to user or perform some other arbitrary task...
}
}
$this->example_process = new WP_Example_Process();