PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / freemius / includes / entities / class-fs-subscription.php
foogallery / freemius / includes / entities Last commit date
class-fs-affiliate-terms.php 3 years ago class-fs-affiliate.php 3 years ago class-fs-billing.php 3 years ago class-fs-entity.php 3 years ago class-fs-payment.php 8 months ago class-fs-plugin-info.php 3 years ago class-fs-plugin-license.php 8 months ago class-fs-plugin-plan.php 8 months ago class-fs-plugin-tag.php 8 months ago class-fs-plugin.php 3 years ago class-fs-pricing.php 3 years ago class-fs-scope-entity.php 3 years ago class-fs-site.php 8 months ago class-fs-subscription.php 3 years ago class-fs-user.php 8 months ago index.php 3 years ago
class-fs-subscription.php
147 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.0.9
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class FS_Subscription extends FS_Entity {
14
15 #region Properties
16
17 /**
18 * @var number
19 */
20 public $user_id;
21 /**
22 * @var number
23 */
24 public $install_id;
25 /**
26 * @var number
27 */
28 public $plan_id;
29 /**
30 * @var number
31 */
32 public $license_id;
33 /**
34 * @var float
35 */
36 public $total_gross;
37 /**
38 * @var float
39 */
40 public $amount_per_cycle;
41 /**
42 * @var int # of months
43 */
44 public $billing_cycle;
45 /**
46 * @var float
47 */
48 public $outstanding_balance;
49 /**
50 * @var int
51 */
52 public $failed_payments;
53 /**
54 * @var string
55 */
56 public $gateway;
57 /**
58 * @var string
59 */
60 public $external_id;
61 /**
62 * @var string|null
63 */
64 public $trial_ends;
65 /**
66 * @var string|null Datetime of the next payment, or null if cancelled.
67 */
68 public $next_payment;
69 /**
70 * @since 2.3.1
71 *
72 * @var string|null Datetime of the cancellation.
73 */
74 public $canceled_at;
75 /**
76 * @var string|null
77 */
78 public $vat_id;
79 /**
80 * @var string Two characters country code
81 */
82 public $country_code;
83
84 #endregion Properties
85
86 /**
87 * @param object|bool $subscription
88 */
89 function __construct( $subscription = false ) {
90 parent::__construct( $subscription );
91 }
92
93 static function get_type() {
94 return 'subscription';
95 }
96
97 /**
98 * Check if subscription is active.
99 *
100 * @author Vova Feldman (@svovaf)
101 * @since 1.0.9
102 *
103 * @return bool
104 */
105 function is_active() {
106 if ( $this->is_canceled() ) {
107 return false;
108 }
109
110 return (
111 ! empty( $this->next_payment ) &&
112 strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME
113 );
114 }
115
116 /**
117 * @author Vova Feldman (@svovaf)
118 * @since 2.3.1
119 *
120 * @return bool
121 */
122 function is_canceled() {
123 return ! is_null( $this->canceled_at );
124 }
125
126 /**
127 * Subscription considered to be new without any payments
128 * if the next payment should be made within less than 24 hours
129 * from the subscription creation.
130 *
131 * @author Vova Feldman (@svovaf)
132 * @since 1.0.9
133 *
134 * @return bool
135 */
136 function is_first_payment_pending() {
137 return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
138 }
139
140 /**
141 * @author Vova Feldman (@svovaf)
142 * @since 1.1.7
143 */
144 function has_trial() {
145 return ! is_null( $this->trial_ends );
146 }
147 }