forked from 10up/WP-Minions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-minions.php
58 lines (47 loc) · 1.46 KB
/
wp-minions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Plugin Name: WP Minions
* Description: Job Queue for WordPress
* Version: 4.1.0
* Author: Chris Marslender, Darshan Sawardekar, 10up
* Author URI: http://10up.com/
* License: GPLv2 or later
*/
require_once __DIR__ . '/autoload.php';
/*
* Users with setups where multiple installs share a common wp-config.php or $table_prefix can use this to segregate jobs from each site
*/
if ( ! defined( 'WP_ASYNC_TASK_SALT' ) ) {
define( 'WP_ASYNC_TASK_SALT', '' );
}
/**
* Adds a single async task to the gearman job queue.
*
* @param string $hook The action that will be called when running this job.
* @param array $args An array of args that should be passed to the callback when the action hook is called.
* @param string $priority Priority of the job (low, normal, high). Default normal.
*
* @since 0.1
*/
function wp_async_task_add( $hook, $args = array(), $priority = 'normal' ) {
$plugin = \WpMinions\Plugin::get_instance();
return $plugin->add( $hook, $args, $priority );
}
function wp_async_task_init() {
wp_minions_autoloader();
$plugin = \WpMinions\Plugin::get_instance();
$plugin->enable();
$GLOBALS['wp_async_task'] = $plugin;
}
add_action( 'plugins_loaded', function() {
global $wp_async_task;
if ( class_exists( 'Debug_Bar_Extender' ) ) {
Debug_Bar_Extender::instance()->trace_var( $wp_async_task );
}
});
add_action( 'plugins_loaded', function() {
// Init
if ( ! defined( 'PHPUNIT_RUNNER' ) ) {
wp_async_task_init();
}
}, 9 );