PHP code example of tekod / wp-queue

1. Go to this page and download the library: Download tekod/wp-queue 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/ */

    

tekod / wp-queue example snippets


$queue = WpQueue('mailer');
$queue->init([
    'Storage' => new \Tekod\WpQueue\Storage\Wpdb($wpdb, 'wpqueue_mailer_jobs'),
]);

$queue->add('SendEmail', ['To'=>'[email protected]', 'Body'=>'Hi.']);

$queue->registerJobHandler('SendEmail', [MyClass::class, 'handle']);

public static function handle(Job $job) {
    $data = $job->getData();
    wp_mail($data['To'], 'Subject', $data['Body']);
    $job->setHandled();
}

$queue->run();