PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / LegacySubscriptions / includes / give-recurring-cron.php

give-recurring-cron.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/LegacySubscriptions/includes/give-recurring-cron.php

87 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Give Recurring Cron
4 *
5 * @package Give
6 * @copyright Copyright (c) 2016, GiveWP
7 * @license https://opensource.org/licenses/gpl-license GNU Public License
8 * @since 1.0
9 */
10
11 // Exit if accessed directly
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * The Recurring Reminders Class
18 *
19 * @since 2.19.0 - migrated from give-recurring
20 */
21 class Give_Recurring_Cron {
22
23 protected $db;
24
25 /**
26 * Get things started
27 *
28 * @since 1.0
29 */
30 public function __construct() {
31 $this->init();
32 }
33
34 /**
35 * Set up our actions and properties
36 *
37 * @since 1.0
38 */
39 public function init() {
40
41 $this->db = new Give_Subscriptions_DB;
42
43 add_action( 'give_daily_scheduled_events', array( $this, 'check_for_expired_subscriptions' ) );
44 add_action( 'give_weekly_scheduled_events', array( $this, 'delete_old_sync_logs' ) );
45 }
46
47 /**
48 * Check for expired subscriptions once per day and mark them as expired
49 *
50 * @since 1.0
51 */
52 public function check_for_expired_subscriptions() {
53
54 $args = array(
55 'status' => 'active',
56 'number' => 999999,
57 'expiration' => array(
58 'start' => date( 'Y-n-d 00:00:00', strtotime( '-1 day', current_time( 'timestamp' ) ) ),
59 'end' => date( 'Y-n-d 23:59:59', strtotime( '-1 day', current_time( 'timestamp' ) ) )
60 )
61
62 );
63
64 $subs = $this->db->get_subscriptions( $args );
65
66 if ( ! empty( $subs ) ) {
67
68 foreach ( $subs as $sub ) {
69
70 // TODO: Run sync here.
71
72 }
73
74 }
75
76 }
77
78 /**
79 * Deletes old Sync log data.
80 *
81 * @since 1.3
82 */
83 public function delete_old_sync_logs() {
84
85 }
86 }
87