{"id":33991156,"url":"https://github.com/duckdev/wp-queue-process","last_synced_at":"2026-04-18T23:04:03.776Z","repository":{"id":56973075,"uuid":"391600238","full_name":"duckdev/wp-queue-process","owner":"duckdev","description":"WordPress background queue processing library ","archived":false,"fork":false,"pushed_at":"2021-08-02T07:34:33.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T18:48:04.774Z","etag":null,"topics":["background-processing","queue","wordpress"],"latest_commit_sha":null,"homepage":"https://github.com/duckdev/wp-queue-process","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duckdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-01T10:46:53.000Z","updated_at":"2021-08-02T07:33:40.000Z","dependencies_parsed_at":"2022-08-21T10:20:38.844Z","dependency_job_id":null,"html_url":"https://github.com/duckdev/wp-queue-process","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/duckdev/wp-queue-process","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdev%2Fwp-queue-process","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdev%2Fwp-queue-process/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdev%2Fwp-queue-process/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdev%2Fwp-queue-process/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duckdev","download_url":"https://codeload.github.com/duckdev/wp-queue-process/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdev%2Fwp-queue-process/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31987885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"ssl_error","status_checked_at":"2026-04-18T20:23:29.375Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-processing","queue","wordpress"],"created_at":"2025-12-13T06:39:45.153Z","updated_at":"2026-04-18T23:04:03.739Z","avatar_url":"https://github.com/duckdev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"http://duckdev.com\" target=\"_blank\"\u003e\n    \u003cimg width=\"200px\" src=\"https://duckdev.com/wp-content/uploads/2020/12/cropped-duckdev-logo-mid.png\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n# WP Queue Process\n\nWP Queue Process can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.\n\n* Inspired by [TechCrunch WP Asynchronous Tasks](https://github.com/techcrunch/wp-async-task).\n* Forked from [WP Background Processing](https://github.com/deliciousbrains/wp-background-processing) with few extra options.\n\n__Requires PHP 5.2+__\n\n## Install\n\nThe recommended way to install this library in your project is by loading it through Composer:\n\n```\ncomposer require duckdev/wp-queue-process\n```\n\n## Usage\n\n### Async Request\n\nAsync requests are useful for pushing slow one-off tasks such as sending emails to a background process. Once the request has been dispatched it will process in the background instantly.\n\nExtend the `\\DuckDev\\Queue\\Async` class:\n\n```php\nclass WP_Example_Request extends \\DuckDev\\Queue\\Async {\n\n\t/**\n\t * @var string\n\t */\n\tprotected $action = 'example_request';\n\n\t/**\n\t * Handle\n\t *\n\t * Override this method to perform any actions required\n\t * during the async request.\n\t */\n\tprotected function handle() {\n\t\t// Actions to perform\n\t}\n}\n```\n\n##### `protected $action`\n\nShould be set to a unique name.\n\n##### `protected function handle()`\n\nShould contain any logic to perform during the non-blocking request. The data passed to the request will be accessible via `$_POST`.\n\n##### Dispatching Requests\n\nInstantiate your request:\n\n`$this-\u003eexample_request = new WP_Example_Request();`\n\nAdd data to the request if required:\n\n`$this-\u003eexample_request-\u003edata( array( 'value1' =\u003e $value1, 'value2' =\u003e $value2 ) );`\n\nFire off the request:\n\n`$this-\u003eexample_request-\u003edispatch();`\n\nChaining is also supported:\n\n`$this-\u003eexample_request-\u003edata( array( 'data' =\u003e $data ) )-\u003edispatch();`\n\n### Background Process\n\nBackground processes work in a similar fashion to async requests but they allow you to queue tasks. Items pushed onto the queue will be processed in the background once the queue has been dispatched. Queues will also scale based on available server resources, so higher end servers will process more items per batch. Once a batch has completed the next batch will start instantly.\n\nHealth checks run by default every 5 minutes to ensure the queue is running when queued items exist. If the queue has failed it will be restarted.\n\nQueues work on a first in first out basis, which allows additional items to be pushed to the queue even if it’s already processing.\n\nExtend the `\\DuckDev\\Queue\\Task` class:\n\n```php\nclass WP_Example_Process extends \\DuckDev\\Queue\\Task {\n\n\t/**\n\t * @var string\n\t */\n\tprotected $action = 'example_process';\n\n\t/**\n\t * Task\n\t *\n\t * Override this method to perform any actions required on each\n\t * queue item. Return the modified item for further processing\n\t * in the next pass through. Or, return false to remove the\n\t * item from the queue.\n\t *\n\t * @param mixed  $item  Queue item to iterate over\n\t * @param string $group Group name of the task (Useful when performing multiple tasks).\n\t *                    \n\t * @return mixed\n\t */\n\tprotected function task( $item, $group ) {\n\t\t// Actions to perform\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Complete\n\t *\n\t * Override if applicable, but ensure that the below actions are\n\t * performed, or, call parent::complete().\n\t */\n\tprotected function complete() {\n\t\tparent::complete();\n\n\t\t// Show notice to user or perform some other arbitrary task...\n\t}\n}\n```\n\n##### `protected $action`\n\nShould be set to a unique name.\n\n##### `protected function task( $item )`\n\nShould contain any logic to perform on the queued item. Return `false` to remove the item from the queue or return `$item` to push it back onto the queue for further processing. If the item has been modified and is pushed back onto the queue the current state will be saved before the batch is exited.\n\n##### `protected function complete()`\n\nOptionally contain any logic to perform once the queue has completed.\n\n##### Dispatching Processes\n\nInstantiate your process:\n\n`$this-\u003eexample_process = new WP_Example_Process();`\n\n**Note:** You must instantiate your process unconditionally. All requests should do this, even if nothing is pushed to the queue.\n\nPush items to the queue:\n\n```php\nforeach ( $items as $item ) {\n    $this-\u003eexample_process-\u003epush_to_queue( $item );\n}\n```\n\nOr directly set the queue items:\n\n```php\n$this-\u003eexample_process-\u003eset_queue( $items );\n```\n\nAnd then save and dispatch the queue:\n\n`$this-\u003eexample_process-\u003esave( 'my-task' ')-\u003edispatch();`\n\n### BasicAuth\n\nIf your site is behind BasicAuth, both async requests and background processes will fail to complete. This is because WP Background Processing relies on the [WordPress HTTP API](http://codex.wordpress.org/HTTP_API), which requires you to attach your BasicAuth credentials to requests. The easiest way to do this is using the following filter:\n\n```php\nfunction ddqueue_http_request_args( $r, $url ) {\n\t$r['headers']['Authorization'] = 'Basic ' . base64_encode( USERNAME . ':' . PASSWORD );\n\n\treturn $r;\n}\nadd_filter( 'http_request_args', 'ddqueue_http_request_args', 10, 2);\n```\n\n### Credits\n* This is a forked, improved library of [WP Background Processing](https://github.com/deliciousbrains/wp-background-processing).\n* Maintained by [Joel James](https://github.com/joel-james/)\n\n### License\n\n[GPLv2+](http://www.gnu.org/licenses/gpl-2.0.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduckdev%2Fwp-queue-process","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduckdev%2Fwp-queue-process","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduckdev%2Fwp-queue-process/lists"}