-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwp-queue.php
More file actions
78 lines (65 loc) · 2.03 KB
/
wp-queue.php
File metadata and controls
78 lines (65 loc) · 2.03 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
/**
* Plugin Name: WP Queue
* Plugin URI: https://github.com/rwsite/wp-queue
* Description: Background job processing and WP-Cron management for WordPress. Schedule tasks, manage queues, and monitor cron events.
* Version: 1.1.0
* Author: Aleksei Tikhomirov
* Author URI: https://rwsite.ru
* License: GPL-2.0-or-later
* Text Domain: wp-queue
* Domain Path: /languages/
* Requires PHP: 8.3
* Requires at least: 6.0
*/
if (! defined('ABSPATH')) {
exit;
}
// Prevent loading multiple copies of the plugin
if (defined('WP_QUEUE_VERSION')) {
_doing_it_wrong(__FUNCTION__, 'WP Queue: Multiple copies of the plugin detected. Please deactivate duplicates.', '1.0.0');
return;
}
define('WP_QUEUE_VERSION', '1.1.0');
define('WP_QUEUE_FILE', __FILE__);
define('WP_QUEUE_PATH', plugin_dir_path(__FILE__));
define('WP_QUEUE_URL', plugin_dir_url(__FILE__));
// Autoload: Composer (dev) or custom PSR-4 (production)
if (file_exists(WP_QUEUE_PATH.'vendor/autoload.php')) {
require_once WP_QUEUE_PATH.'vendor/autoload.php';
} else {
spl_autoload_register(static function (string $class): void {
$prefix = 'WPQueue\\';
$baseDir = WP_QUEUE_PATH.'src/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relativeClass = substr($class, $len);
$file = $baseDir.str_replace('\\', '/', $relativeClass).'.php';
if (file_exists($file)) {
require_once $file;
}
});
}
// Bootstrap
add_action('plugins_loaded', static function (): void {
\WPQueue\WPQueue::boot();
});
// Load text domain
add_action('init', static function (): void {
load_plugin_textdomain(
'wp-queue',
false,
dirname(plugin_basename(__FILE__)).'/languages/',
);
});
// Activation
register_activation_hook(__FILE__, static function (): void {
\WPQueue\WPQueue::activate();
});
// Deactivation
register_deactivation_hook(__FILE__, static function (): void {
\WPQueue\WPQueue::deactivate();
});