{"id":73036,"date":"2017-12-22T04:00:16","date_gmt":"2017-12-22T04:00:16","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/wordpress-background-worker\/"},"modified":"2017-12-27T10:22:16","modified_gmt":"2017-12-27T10:22:16","slug":"async-background-worker","status":"publish","type":"plugin","link":"https:\/\/snd.wordpress.org\/plugins\/async-background-worker\/","author":2113389,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0","stable_tag":"trunk","tested":"4.9.29","requires":"4.4","requires_php":"","requires_plugins":"","header_name":"Async Background Worker","header_author":"todiadiyatmo","header_description":"Aysinchrounous Background Worker for WordPress","assets_banners_color":"","last_updated":"2017-12-27 10:22:16","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"http:\/\/todiadiyatmo.com\/","rating":0,"author_block_rating":0,"active_installs":10,"downloads":1387,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["changelog","description"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[150982,150981],"plugin_category":[],"plugin_contributors":[149986,79276],"plugin_business_model":[],"class_list":["post-73036","plugin","type-plugin","status-publish","hentry","plugin_tags-async-background-worker","plugin_tags-background-worker","plugin_contributors-gamaup","plugin_contributors-todiadiatmo","plugin_committers-todiadiatmo"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/async-background-worker.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial Release<\/li>\n<\/ul>\n\n<!--section=description-->\n<p>Async Background Worker, more information please visit this page <a href=\"https:\/\/tonjoo.github.io\/async-background-worker\/\" title=\"Documentation\">https:\/\/tonjoo.github.io\/async-background-worker\/<\/a><\/p>\n\n<h3>Sample Usage<\/h3>\n\n<h4>What is it ?<\/h4>\n\n<p>WordPress background worker plugin that enable WordPress to interact with beanstalkd work queue.<\/p>\n\n<h4>Why we need a worker ?<\/h4>\n\n<p>We can run a very long task in the background, for example we need to import 100.000 row into WordPress databases. Instead of doing the 100.000 import in one job, we can separate the job into many smaller job which is safer.<\/p>\n\n<h4>WP-CLI<\/h4>\n\n<p>Make sure you have WP CLI installed on your system<\/p>\n\n<h4>Support Forum<\/h4>\n\n<p><a href=\"https:\/\/forum.tonjoostudio.com\/thread-category\/async-background-worker\/\" title=\"Support\">https:\/\/forum.tonjoostudio.com\/thread-category\/async-background-worker\/<\/a><\/p>\n\n<h3>Add job to queue<\/h3>\n\n<ol>\n<li><p>Add new job to new worker queue using <code>add_async_job<\/code> command<\/p>\n\n<pre><code>$job = new stdClass();  \n\/\/ the function to run  \n$job-&gt;function = 'function_to_execute_on_background';  \n\/\/ our user entered data  \n$job-&gt;user_data = array('data'=&gt;'some_data');\nadd_async_job($job);\n<\/code><\/pre><\/li>\n<li><p>Implement function<\/p>\n\n<pre><code>function function_to_execute_on_background($data) {\n    \/\/do something usefull\n    echo \"Background job executed successfully\\n\";\n}\n<\/code><\/pre><\/li>\n<li><p>Run <code>wp background-worker listen<\/code><\/p><\/li>\n<\/ol>\n\n<h3>Command<\/h3>\n\n<ul>\n<li><p><code>wp background-worker<\/code>\nRun Async Background Worker once.<\/p><\/li>\n<li><p><code>wp background-worker listen<\/code>\nRun Async Background Worker in loop (contiously), this is what you want for background worker. WordPress framework is restart in each loop.<\/p><\/li>\n<li><p><code>wp background-worker listen-daemon<\/code>\nRun Async Background Worker in loop (contiously) without restart the WordPress framework. <strong>NOTE<\/strong> if you use this mode, any code change will not be reflected. You must restart the Async Background Worker each time you change code. This save memory and speed up thing.<\/p><\/li>\n<\/ul>","raw_excerpt":"Async Background Worker, more information please visit this page [https:\/\/tonjoo.github.io\/async-background-worker\/](https:\/\/tonjoo.github.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/73036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=73036"}],"author":[{"embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/todiadiatmo"}],"wp:attachment":[{"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=73036"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=73036"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=73036"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=73036"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=73036"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/snd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=73036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}