PHP code example of duckdev / wp-queue-process

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

    

duckdev / wp-queue-process example snippets


class WP_Example_Request extends \DuckDev\Queue\Async {

	/**
	 * @var string
	 */
	protected $action = 'example_request';

	/**
	 * Handle
	 *
	 * Override this method to perform any actions 

class WP_Example_Process extends \DuckDev\Queue\Task {

	/**
	 * @var string
	 */
	protected $action = 'example_process';

	/**
	 * Task
	 *
	 * Override this method to perform any actions m to iterate over
	 * @param string $group Group name of the task (Useful when performing multiple tasks).
	 *                    
	 * @return mixed
	 */
	protected function task( $item, $group ) {
		// Actions to perform

		return false;
	}

	/**
	 * Complete
	 *
	 * 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...
	}
}

foreach ( $items as $item ) {
    $this->example_process->push_to_queue( $item );
}

$this->example_process->set_queue( $items );

function ddqueue_http_request_args( $r, $url ) {
	$r['headers']['Authorization'] = 'Basic ' . base64_encode( USERNAME . ':' . PASSWORD );

	return $r;
}
add_filter( 'http_request_args', 'ddqueue_http_request_args', 10, 2);