PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.1.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.1.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / schedule.php

schedule.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.1.0, at includes/schedule.php

42 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace StoreEngine;
3
4 use StoreEngine\Schedules\Order;
5 use StoreEngine\Utils\Geolocation;
6 use StoreEngine\Classes\LogCleanup;
7 use StoreEngine\Classes\EmailLogCleanup;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class Schedule {
14
15 public static function init() {
16 Order::init();
17
18 add_action( 'action_scheduler_ensure_recurring_actions', [ __CLASS__, 'register_recurring_actions' ] );
19 add_action( 'storeengine/geolocation/maxmind/db-update', [ Geolocation::class, 'update_maxmind_db' ] );
20 add_action( 'storeengine/logs/auto_cleanup', [ LogCleanup::class, 'execute_cleanup' ] );
21 add_action( 'storeengine/email_log/auto_cleanup', [ EmailLogCleanup::class, 'execute_cleanup' ] );
22 }
23
24 public static function register_recurring_actions() {
25 if ( ! function_exists( 'as_schedule_recurring_action' ) || ! function_exists( 'as_schedule_single_action' ) ) {
26 return;
27 }
28
29 $gmt_offset = get_option( 'gmt_offset' );
30 $offset_hours = ( $gmt_offset > 0 ? '-' : '+' ) . absint( $gmt_offset ) . ' hours';
31 $tomorrow_6am = strtotime( 'tomorrow 06:00 am ' . $offset_hours );
32
33 $tomorrow_2am = strtotime( 'tomorrow 02:00 am ' . $offset_hours );
34 $tomorrow_3am = strtotime( 'tomorrow 03:00 am ' . $offset_hours );
35
36 as_schedule_recurring_action( $tomorrow_6am, 15 * DAY_IN_SECONDS, 'storeengine/geolocation/maxmind/db-update', [], 'storeengine', true );
37
38 as_schedule_recurring_action( $tomorrow_2am, DAY_IN_SECONDS, 'storeengine/logs/auto_cleanup',[], 'storeengine', true );
39 as_schedule_recurring_action( $tomorrow_3am, DAY_IN_SECONDS, 'storeengine/email_log/auto_cleanup', [], 'storeengine', true );
40 }
41 }
42