-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbakrypt-wc-extension.php
70 lines (57 loc) · 1.74 KB
/
bakrypt-wc-extension.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
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Plugin Name: Brand Guard QR
* Plugin URI: https://bakrypt.io
* Description: Mint your products into the Cardano Blockchain
* Version: 1.3.8
* Author: Wolfgang Leon
* Author URI: https://bakrypt.io/
* Developer: Wolfgang Leon
* Developer URI: https://bakrypt.io/pool/
* Text Domain: bakrypt-wc-extension
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* WC requires at least: 7.1
* WC tested up to: 9.1.4
*
*/
defined('ABSPATH') || exit;
define('WCBAK_ABSPATH', __DIR__ . '/');
define('WCBAK_PLUGIN_FILE', __FILE__);
# Autoload Classes with Composer
require_once "vendor/autoload.php";
// Initiate wc bakrypt class
use BakExtension\core\BakWCExtension;
# Add custom interval for every 3 minutes
add_filter('cron_schedules', 'bak_add_every_three_minutes');
function bak_add_every_three_minutes($schedules)
{
$schedules['every_three_minutes'] = array(
'interval' => 180,
'display' => __('Every 3 Minutes', 'textdomain')
);
return $schedules;
}
function wcbakrypt_init()
{
BakWCExtension::init();
}
add_action('plugins_loaded', 'wcbakrypt_init', 11);
// ========= Cron Tasks =======
function cron_activate()
{
if (!wp_next_scheduled('bak_plugin_cron_task')) {
// Schedule the cron task to run every 3 minutes
wp_schedule_event(time(), 'every_three_minutes', 'bak_plugin_cron_task');
}
}
function cron_deactivate()
{
wp_clear_scheduled_hook('bak_plugin_cron_task');
// Remove the lock when the task is completed
delete_transient('bak_plugin_cron_lock');
}
register_activation_hook(WCBAK_PLUGIN_FILE, 'cron_activate');
add_action('bak_plugin_cron_task', array("BakExtension\core\Cron", "bak_run_cron_task"), 12);
register_deactivation_hook(WCBAK_PLUGIN_FILE, 'cron_deactivate');