Passed
Push — master ( 32890d...b6d11a )
by Brian
13:10
created
includes/gateways/class-getpaid-manual-gateway.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Manual Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+    protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title        = __( 'Test Gateway', 'invoicing' );
43
-        $this->method_title = __( 'Test Gateway', 'invoicing' );
42
+        $this->title        = __('Test Gateway', 'invoicing');
43
+        $this->method_title = __('Test Gateway', 'invoicing');
44 44
 
45
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
45
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
46 46
     }
47 47
 
48 48
     /**
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55 55
 	 * @return array
56 56
 	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
57
+	public function process_payment($invoice, $submission_data, $submission) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
61 61
 
62 62
         // (Maybe) activate subscriptions.
63
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
63
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
64 64
 
65
-        if ( ! empty( $subscriptions ) ) {
66
-            $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
65
+        if (!empty($subscriptions)) {
66
+            $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
67 67
 
68
-            foreach ( $subscriptions as $subscription ) {
69
-                if ( $subscription->exists() ) {
70
-                    $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
71
-                    $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
68
+            foreach ($subscriptions as $subscription) {
69
+                if ($subscription->exists()) {
70
+                    $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
71
+                    $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
72 72
 
73
-                    $subscription->set_next_renewal_date( $expiry );
74
-                    $subscription->set_date_created( current_time( 'mysql' ) );
75
-                    $subscription->set_profile_id( $invoice->generate_key( 'manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
73
+                    $subscription->set_next_renewal_date($expiry);
74
+                    $subscription->set_date_created(current_time('mysql'));
75
+                    $subscription->set_profile_id($invoice->generate_key('manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
76 76
                     $subscription->activate();
77 77
                 }
78 78
             }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         }
81 81
 
82 82
         // Send to the success page.
83
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
83
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
84 84
 
85 85
     }
86 86
 
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
      * @param WPInv_Subscription $subscription
92 92
 	 */
93
-	public function maybe_renew_subscription( $subscription ) {
93
+	public function maybe_renew_subscription($subscription) {
94 94
 
95 95
         // Ensure its our subscription && it's active.
96
-        if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
96
+        if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) {
97 97
 
98 98
             // Renew the subscription.
99 99
             $subscription->add_payment(
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	 * @param GetPaid_Form_Item[] $items
117 117
 	 * @return WPInv_Invoice
118 118
 	 */
119
-	public function process_addons( $invoice, $items ) {
119
+	public function process_addons($invoice, $items) {
120 120
 
121
-        foreach ( $items as $item ) {
122
-            $invoice->add_item( $item );
121
+        foreach ($items as $item) {
122
+            $invoice->add_item($item);
123 123
         }
124 124
 
125 125
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-gateway.php 1 patch
Spacing   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Authorize.net Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+    protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
55
+	public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function __construct() {
68 68
 
69
-        $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70
-        $this->method_title         = __( 'Authorize.Net', 'invoicing' );
71
-        $this->notify_url           = getpaid_get_non_query_string_ipn_url( $this->id );
69
+        $this->title                = __('Credit Card / Debit Card', 'invoicing');
70
+        $this->method_title         = __('Authorize.Net', 'invoicing');
71
+        $this->notify_url           = getpaid_get_non_query_string_ipn_url($this->id);
72 72
 
73
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
74
-        add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) );
73
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
74
+        add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice'));
75 75
         parent::__construct();
76 76
     }
77 77
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 * @param int $invoice_id 0 or invoice id.
82 82
 	 * @param GetPaid_Payment_Form $form Current payment form.
83 83
 	 */
84
-    public function payment_fields( $invoice_id, $form ) {
84
+    public function payment_fields($invoice_id, $form) {
85 85
 
86 86
         // Let the user select a payment method.
87 87
         echo $this->saved_payment_methods();
88 88
 
89 89
         // Show the credit card entry form.
90
-        echo $this->new_payment_method_entry( $this->get_cc_form( true ) );
90
+        echo $this->new_payment_method_entry($this->get_cc_form(true));
91 91
     }
92 92
 
93 93
     /**
@@ -100,79 +100,79 @@  discard block
 block discarded – undo
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101 101
 	 * @return string|WP_Error Payment profile id.
102 102
 	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
103
+	public function create_customer_profile($invoice, $submission_data, $save = true) {
104 104
 
105 105
         // Remove non-digits from the number
106
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
106
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
107 107
 
108 108
         // Generate args.
109 109
         $args = array(
110 110
             'createCustomerProfileRequest' => array(
111 111
                 'merchantAuthentication'   => $this->get_auth_params(),
112 112
                 'profile'                  => array(
113
-                    'merchantCustomerId'   => getpaid_limit_length( $invoice->get_user_id(), 20 ),
114
-                    'description'          => getpaid_limit_length( $invoice->get_full_name(), 255 ),
115
-                    'email'                => getpaid_limit_length( $invoice->get_email(), 255 ),
113
+                    'merchantCustomerId'   => getpaid_limit_length($invoice->get_user_id(), 20),
114
+                    'description'          => getpaid_limit_length($invoice->get_full_name(), 255),
115
+                    'email'                => getpaid_limit_length($invoice->get_email(), 255),
116 116
                     'paymentProfiles'      => array(
117 117
                         'customerType'     => 'individual',
118 118
 
119 119
                         // Billing information.
120 120
                         'billTo'           => array(
121
-                            'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
122
-                            'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
123
-                            'address'      => getpaid_limit_length( $invoice->get_address(), 60 ),
124
-                            'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
125
-                            'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
126
-                            'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
127
-                            'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
121
+                            'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
122
+                            'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
123
+                            'address'      => getpaid_limit_length($invoice->get_address(), 60),
124
+                            'city'         => getpaid_limit_length($invoice->get_city(), 40),
125
+                            'state'        => getpaid_limit_length($invoice->get_state(), 40),
126
+                            'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
127
+                            'country'      => getpaid_limit_length($invoice->get_country(), 60),
128 128
                         ),
129 129
 
130 130
                         // Payment information.
131
-                        'payment'          => $this->get_payment_information( $submission_data['authorizenet'] ),
131
+                        'payment'          => $this->get_payment_information($submission_data['authorizenet']),
132 132
                     )
133 133
                 ),
134
-                'validationMode'           => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
134
+                'validationMode'           => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
135 135
             )
136 136
         );
137 137
 
138
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice );
138
+        $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice);
139 139
 
140
-        if ( is_wp_error( $response ) ) {
140
+        if (is_wp_error($response)) {
141 141
 
142 142
             // In case the payment profile already exists remotely.
143
-            if ( 'dup_payment_profile' == $response->get_error_code() ) {
144
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
145
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
146
-                return strtok( '.' );
143
+            if ('dup_payment_profile' == $response->get_error_code()) {
144
+                $customer_profile_id = strtok($response->get_error_message(), '.');
145
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
146
+                return strtok('.');
147 147
             }
148 148
 
149 149
             // In case the customer profile already exists remotely.
150
-            if ( 'E00039' == $response->get_error_code() ) {
151
-                $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() );
152
-                $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id );
153
-                return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save );
150
+            if ('E00039' == $response->get_error_code()) {
151
+                $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message());
152
+                $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id);
153
+                return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save);
154 154
             }
155 155
 
156 156
             return $response;
157 157
         }
158 158
 
159
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId );
159
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId);
160 160
 
161 161
         // Save the payment token.
162
-        if ( $save ) {
162
+        if ($save) {
163 163
             $this->save_token(
164 164
                 array(
165 165
                     'id'      => $response->customerPaymentProfileIdList[0],
166
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
166
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4),
167 167
                     'default' => true,
168
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
168
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
169 169
                 )
170 170
             );
171 171
         }
172 172
 
173 173
         // Add a note about the validation response.
174 174
         $invoice->add_note(
175
-            sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ),
175
+            sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]),
176 176
             false,
177 177
             false,
178 178
             true
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return string|WP_Error Profile id.
190 190
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
191 191
 	 */
192
-	public function get_customer_profile( $profile_id ) {
192
+	public function get_customer_profile($profile_id) {
193 193
 
194 194
         // Generate args.
195 195
         $args = array(
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             )
200 200
         );
201 201
 
202
-        return $this->post( $args, false );
202
+        return $this->post($args, false);
203 203
 
204 204
     }
205 205
 
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
215 215
 	 * @return string|WP_Error Profile id.
216 216
 	 */
217
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
217
+	public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) {
218 218
 
219 219
         // Remove non-digits from the number
220
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
220
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
221 221
 
222 222
         // Prepare card details.
223
-        $payment_information                          = $this->get_payment_information( $submission_data['authorizenet'] );
223
+        $payment_information                          = $this->get_payment_information($submission_data['authorizenet']);
224 224
 
225 225
         // Authorize.NET does not support saving the same card twice.
226
-        $cached_information                           = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice );
226
+        $cached_information                           = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice);
227 227
 
228
-        if ( $cached_information ) {
228
+        if ($cached_information) {
229 229
             return $cached_information;
230 230
         }
231 231
 
@@ -238,34 +238,34 @@  discard block
 block discarded – undo
238 238
 
239 239
                     // Billing information.
240 240
                     'billTo'           => array(
241
-                        'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
242
-                        'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
243
-                        'address'      => getpaid_limit_length( $invoice->get_address(), 60 ),
244
-                        'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
245
-                        'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
246
-                        'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
247
-                        'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
241
+                        'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
242
+                        'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
243
+                        'address'      => getpaid_limit_length($invoice->get_address(), 60),
244
+                        'city'         => getpaid_limit_length($invoice->get_city(), 40),
245
+                        'state'        => getpaid_limit_length($invoice->get_state(), 40),
246
+                        'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
247
+                        'country'      => getpaid_limit_length($invoice->get_country(), 60),
248 248
                     ),
249 249
 
250 250
                     // Payment information.
251 251
                     'payment'          => $payment_information
252 252
                 ),
253
-                'validationMode'       => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
253
+                'validationMode'       => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
254 254
             )
255 255
         );
256 256
 
257
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice );
257
+        $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice);
258 258
 
259
-        if ( is_wp_error( $response ) ) {
259
+        if (is_wp_error($response)) {
260 260
 
261 261
             // In case the payment profile already exists remotely.
262
-            if ( 'dup_payment_profile' == $response->get_error_code() ) {
263
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
264
-                $payment_profile_id  = strtok( '.' );
265
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
262
+            if ('dup_payment_profile' == $response->get_error_code()) {
263
+                $customer_profile_id = strtok($response->get_error_message(), '.');
264
+                $payment_profile_id  = strtok('.');
265
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
266 266
 
267 267
                 // Cache payment profile id.
268
-                $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id );
268
+                $this->add_payment_profile_to_cache($payment_information, $payment_profile_id);
269 269
 
270 270
                 return $payment_profile_id;
271 271
             }
@@ -274,29 +274,29 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         // Save the payment token.
277
-        if ( $save ) {
277
+        if ($save) {
278 278
             $this->save_token(
279 279
                 array(
280 280
                     'id'      => $response->customerPaymentProfileId,
281
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
281
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4),
282 282
                     'default' => true,
283
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
283
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
284 284
                 )
285 285
             );
286 286
         }
287 287
 
288 288
         // Cache payment profile id.
289
-        $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId );
289
+        $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId);
290 290
 
291 291
         // Add a note about the validation response.
292 292
         $invoice->add_note(
293
-            sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ),
293
+            sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse),
294 294
             false,
295 295
             false,
296 296
             true
297 297
         );
298 298
 
299
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile );
299
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile);
300 300
 
301 301
         return $response->customerPaymentProfileId;
302 302
     }
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
      * @param array $payment_details.
309 309
 	 * @return array|false Profile id.
310 310
 	 */
311
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
311
+	public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) {
312 312
 
313
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
314
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
313
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
314
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
315 315
 
316
-        if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) {
316
+        if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) {
317 317
             return false;
318 318
         }
319 319
 
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
             'getCustomerPaymentProfileRequest' => array(
323 323
                 'merchantAuthentication'   => $this->get_auth_params(),
324 324
                 'customerProfileId'        => $customer_profile,
325
-                'customerPaymentProfileId' => $cached_information[ $payment_details ],
325
+                'customerPaymentProfileId' => $cached_information[$payment_details],
326 326
             )
327 327
         );
328 328
 
329
-        $response = $this->post( $args, $invoice );
329
+        $response = $this->post($args, $invoice);
330 330
 
331
-        return is_wp_error( $response ) ? false : $cached_information[ $payment_details ];
331
+        return is_wp_error($response) ? false : $cached_information[$payment_details];
332 332
 
333 333
     }
334 334
 
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
      * @param array $payment_details.
340 340
      * @param string $payment_profile_id.
341 341
 	 */
342
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
342
+	public function add_payment_profile_to_cache($payment_details, $payment_profile_id) {
343 343
 
344
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
345
-        $cached_information = is_array( $cached_information ) ? $cached_information : array();
346
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
344
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
345
+        $cached_information = is_array($cached_information) ? $cached_information : array();
346
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
347 347
 
348
-        $cached_information[ $payment_details ] = $payment_profile_id;
349
-        update_option( 'getpaid_authorize_net_cached_profiles', $cached_information );
348
+        $cached_information[$payment_details] = $payment_profile_id;
349
+        update_option('getpaid_authorize_net_cached_profiles', $cached_information);
350 350
 
351 351
     }
352 352
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @return string|WP_Error Profile id.
360 360
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
361 361
 	 */
362
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
362
+	public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) {
363 363
 
364 364
         // Generate args.
365 365
         $args = array(
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             )
371 371
         );
372 372
 
373
-        return $this->post( $args, false );
373
+        return $this->post($args, false);
374 374
 
375 375
     }
376 376
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
384 384
 	 * @return WP_Error|object
385 385
 	 */
386
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
386
+	public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) {
387 387
 
388 388
         // Generate args.
389 389
         $args = array(
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
                         )
404 404
                     ),
405 405
                     'order'                    => array(
406
-                        'invoiceNumber'        => getpaid_limit_length( $invoice->get_number(), 20 ),
406
+                        'invoiceNumber'        => getpaid_limit_length($invoice->get_number(), 20),
407 407
                     ),
408
-                    'lineItems'                => array( 'lineItem' => $this->get_line_items( $invoice ) ),
408
+                    'lineItems'                => array('lineItem' => $this->get_line_items($invoice)),
409 409
                     'tax'                      => array(
410 410
                         'amount'               => $invoice->get_total_tax(),
411
-                        'name'                 => __( 'TAX', 'invoicing' ),
411
+                        'name'                 => __('TAX', 'invoicing'),
412 412
                     ),
413
-                    'poNumber'                 => getpaid_limit_length( $invoice->get_number(), 25 ),
413
+                    'poNumber'                 => getpaid_limit_length($invoice->get_number(), 25),
414 414
                     'customer'                 => array(
415
-                        'id'                   => getpaid_limit_length( $invoice->get_user_id(), 25 ),
416
-                        'email'                => getpaid_limit_length( $invoice->get_email(), 25 ),
415
+                        'id'                   => getpaid_limit_length($invoice->get_user_id(), 25),
416
+                        'email'                => getpaid_limit_length($invoice->get_email(), 25),
417 417
                     ),
418 418
                     'customerIP'               => $invoice->get_ip(),
419 419
                 )
420 420
             )
421 421
         );
422 422
 
423
-        if ( 0 == $invoice->get_total_tax() ) {
424
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
423
+        if (0 == $invoice->get_total_tax()) {
424
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
425 425
         }
426 426
 
427
-        return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice );
427
+        return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice);
428 428
 
429 429
     }
430 430
 
@@ -434,29 +434,29 @@  discard block
 block discarded – undo
434 434
      * @param stdClass $result Api response.
435 435
 	 * @param WPInv_Invoice $invoice Invoice.
436 436
 	 */
437
-	public function process_charge_response( $result, $invoice ) {
437
+	public function process_charge_response($result, $invoice) {
438 438
 
439 439
         wpinv_clear_errors();
440 440
 		$response_code = (int) $result->transactionResponse->responseCode;
441 441
 
442 442
 		// Succeeded.
443
-		if ( 1 == $response_code || 4 == $response_code ) {
443
+		if (1 == $response_code || 4 == $response_code) {
444 444
 
445 445
 			// Maybe set a transaction id.
446
-			if ( ! empty( $result->transactionResponse->transId ) ) {
447
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
446
+			if (!empty($result->transactionResponse->transId)) {
447
+				$invoice->set_transaction_id($result->transactionResponse->transId);
448 448
 			}
449 449
 
450
-			$invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
450
+			$invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true);
451 451
 
452
-			if ( 1 == $response_code ) {
452
+			if (1 == $response_code) {
453 453
 				return $invoice->mark_paid();
454 454
 			}
455 455
 
456
-			$invoice->set_status( 'wpi-onhold' );
456
+			$invoice->set_status('wpi-onhold');
457 457
         	$invoice->add_note(
458 458
                 sprintf(
459
-                    __( 'Held for review: %s', 'invoicing' ),
459
+                    __('Held for review: %s', 'invoicing'),
460 460
                     $result->transactionResponse->messages->message[0]->description
461 461
                 )
462 462
 			);
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 
466 466
 		}
467 467
 
468
-        wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) );
468
+        wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing'));
469 469
 
470
-        if ( ! empty( $result->transactionResponse->errors ) ) {
470
+        if (!empty($result->transactionResponse->errors)) {
471 471
             $errors = (object) $result->transactionResponse->errors;
472
-            wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) );
472
+            wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText));
473 473
         }
474 474
 
475 475
     }
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @param array $card Card details.
482 482
 	 * @return array
483 483
 	 */
484
-	public function get_payment_information( $card ) {
484
+	public function get_payment_information($card) {
485 485
         return array(
486 486
 
487
-            'creditCard'         => array (
487
+            'creditCard'         => array(
488 488
                 'cardNumber'     => $card['cc_number'],
489 489
                 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'],
490 490
                 'cardCode'       => $card['cc_cvv2'],
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param WPInv_Invoice $invoice Invoice.
501 501
 	 * @return string
502 502
 	 */
503
-	public function get_customer_profile_meta_name( $invoice ) {
504
-        return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
503
+	public function get_customer_profile_meta_name($invoice) {
504
+        return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
505 505
     }
506 506
 
507 507
     /**
@@ -512,34 +512,34 @@  discard block
 block discarded – undo
512 512
      * @param WPInv_Invoice $invoice
513 513
 	 * @return WP_Error|string The payment profile id
514 514
 	 */
515
-	public function validate_submission_data( $submission_data, $invoice ) {
515
+	public function validate_submission_data($submission_data, $invoice) {
516 516
 
517 517
         // Validate authentication details.
518 518
         $auth = $this->get_auth_params();
519 519
 
520
-        if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) {
521
-            return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') );
520
+        if (empty($auth['name']) || empty($auth['transactionKey'])) {
521
+            return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing'));
522 522
         }
523 523
 
524 524
         // Validate the payment method.
525
-        if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) {
526
-            return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') );
525
+        if (empty($submission_data['getpaid-authorizenet-payment-method'])) {
526
+            return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing'));
527 527
         }
528 528
 
529 529
         // Are we adding a new payment method?
530
-        if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) {
530
+        if ('new' != $submission_data['getpaid-authorizenet-payment-method']) {
531 531
             return $submission_data['getpaid-authorizenet-payment-method'];
532 532
         }
533 533
 
534 534
         // Retrieve the customer profile id.
535
-        $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
535
+        $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
536 536
 
537 537
         // Create payment method.
538
-        if ( empty( $profile_id ) ) {
539
-            return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
538
+        if (empty($profile_id)) {
539
+            return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
540 540
         }
541 541
 
542
-        return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
542
+        return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
543 543
 
544 544
     }
545 545
 
@@ -550,32 +550,32 @@  discard block
 block discarded – undo
550 550
 	 * @param WPInv_Invoice $invoice Invoice.
551 551
 	 * @return array
552 552
 	 */
553
-	public function get_line_items( $invoice ) {
553
+	public function get_line_items($invoice) {
554 554
         $items = array();
555 555
 
556
-        foreach ( $invoice->get_items() as $item ) {
556
+        foreach ($invoice->get_items() as $item) {
557 557
 
558 558
             $amount  = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
559 559
             $items[] = array(
560
-                'itemId'      => getpaid_limit_length( $item->get_id(), 31 ),
561
-                'name'        => getpaid_limit_length( $item->get_raw_name(), 31 ),
562
-                'description' => getpaid_limit_length( $item->get_description(), 255 ),
563
-                'quantity'    => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ),
560
+                'itemId'      => getpaid_limit_length($item->get_id(), 31),
561
+                'name'        => getpaid_limit_length($item->get_raw_name(), 31),
562
+                'description' => getpaid_limit_length($item->get_description(), 255),
563
+                'quantity'    => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()),
564 564
                 'unitPrice'   => (float) $amount,
565 565
                 'taxable'     => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(),
566 566
             );
567 567
 
568 568
         }
569 569
 
570
-        foreach ( $invoice->get_fees() as $fee_name => $fee ) {
570
+        foreach ($invoice->get_fees() as $fee_name => $fee) {
571 571
 
572
-            $amount  = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
572
+            $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
573 573
 
574
-            if ( $amount > 0 ) {
574
+            if ($amount > 0) {
575 575
                 $items[] = array(
576
-                    'itemId'      => getpaid_limit_length( $fee_name, 31 ),
577
-                    'name'        => getpaid_limit_length( $fee_name, 31 ),
578
-                    'description' => getpaid_limit_length( $fee_name, 255 ),
576
+                    'itemId'      => getpaid_limit_length($fee_name, 31),
577
+                    'name'        => getpaid_limit_length($fee_name, 31),
578
+                    'description' => getpaid_limit_length($fee_name, 255),
579 579
                     'quantity'    => '1',
580 580
                     'unitPrice'   => (float) $amount,
581 581
                     'taxable'     => false,
@@ -596,36 +596,36 @@  discard block
 block discarded – undo
596 596
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
597 597
 	 * @return array
598 598
 	 */
599
-	public function process_payment( $invoice, $submission_data, $submission ) {
599
+	public function process_payment($invoice, $submission_data, $submission) {
600 600
 
601 601
         // Validate the submitted data.
602
-        $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
602
+        $payment_profile_id = $this->validate_submission_data($submission_data, $invoice);
603 603
 
604 604
         // Do we have an error?
605
-        if ( is_wp_error( $payment_profile_id ) ) {
606
-            wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() );
607
-            wpinv_send_back_to_checkout( $invoice );
605
+        if (is_wp_error($payment_profile_id)) {
606
+            wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message());
607
+            wpinv_send_back_to_checkout($invoice);
608 608
         }
609 609
 
610 610
         // Save the payment method to the order.
611
-        update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id );
611
+        update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id);
612 612
 
613 613
         // Check if this is a subscription or not.
614
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
615
-        if ( ! empty( $subscriptions ) ) {
616
-            $this->process_subscription( $invoice, $subscriptions );
614
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
615
+        if (!empty($subscriptions)) {
616
+            $this->process_subscription($invoice, $subscriptions);
617 617
         }
618 618
 
619 619
         // If it is free, send to the success page.
620
-        if ( ! $invoice->needs_payment() ) {
620
+        if (!$invoice->needs_payment()) {
621 621
             $invoice->mark_paid();
622
-            wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
622
+            wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
623 623
         }
624 624
 
625 625
         // Charge the payment profile.
626
-        $this->process_initial_payment( $invoice );
626
+        $this->process_initial_payment($invoice);
627 627
 
628
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
628
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
629 629
 
630 630
         exit;
631 631
 
@@ -636,23 +636,23 @@  discard block
 block discarded – undo
636 636
 	 *
637 637
      * @param WPInv_Invoice $invoice Invoice.
638 638
 	 */
639
-	protected function process_initial_payment( $invoice ) {
639
+	protected function process_initial_payment($invoice) {
640 640
 
641
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
642
-        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
643
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
641
+		$payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
642
+        $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
643
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
644 644
 
645 645
 		// Do we have an error?
646
-		if ( is_wp_error( $result ) ) {
647
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
648
-			wpinv_send_back_to_checkout( $invoice );
646
+		if (is_wp_error($result)) {
647
+			wpinv_set_error($result->get_error_code(), $result->get_error_message());
648
+			wpinv_send_back_to_checkout($invoice);
649 649
 		}
650 650
 
651 651
 		// Process the response.
652
-		$this->process_charge_response( $result, $invoice );
652
+		$this->process_charge_response($result, $invoice);
653 653
 
654
-		if ( wpinv_get_errors() ) {
655
-			wpinv_send_back_to_checkout( $invoice );
654
+		if (wpinv_get_errors()) {
655
+			wpinv_send_back_to_checkout($invoice);
656 656
 		}
657 657
 
658 658
 	}
@@ -663,30 +663,30 @@  discard block
 block discarded – undo
663 663
      * @param WPInv_Invoice $invoice Invoice.
664 664
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
665 665
 	 */
666
-	public function process_subscription( $invoice, $subscriptions ) {
666
+	public function process_subscription($invoice, $subscriptions) {
667 667
 
668 668
         // Check if there is an initial amount to charge.
669
-        if ( (float) $invoice->get_total() > 0 ) {
670
-			$this->process_initial_payment( $invoice );
669
+        if ((float) $invoice->get_total() > 0) {
670
+			$this->process_initial_payment($invoice);
671 671
         }
672 672
 
673 673
         // Activate the subscriptions.
674
-        $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
674
+        $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
675 675
 
676
-        foreach ( $subscriptions as $subscription ) {
677
-            if ( $subscription->exists() ) {
678
-                $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
679
-                $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
676
+        foreach ($subscriptions as $subscription) {
677
+            if ($subscription->exists()) {
678
+                $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
679
+                $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
680 680
 
681
-                $subscription->set_next_renewal_date( $expiry );
682
-                $subscription->set_date_created( current_time( 'mysql' ) );
683
-                $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
681
+                $subscription->set_next_renewal_date($expiry);
682
+                $subscription->set_date_created(current_time('mysql'));
683
+                $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
684 684
                 $subscription->activate();
685 685
             }
686 686
         }
687 687
 
688 688
 		// Redirect to the success page.
689
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
689
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
690 690
 
691 691
     }
692 692
 
@@ -696,11 +696,11 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
      * @param WPInv_Subscription $subscription
698 698
 	 */
699
-	public function maybe_renew_subscription( $subscription ) {
699
+	public function maybe_renew_subscription($subscription) {
700 700
 
701 701
         // Ensure its our subscription && it's active.
702
-        if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
703
-            $this->renew_subscription( $subscription );
702
+        if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) {
703
+            $this->renew_subscription($subscription);
704 704
         }
705 705
 
706 706
 	}
@@ -710,28 +710,28 @@  discard block
 block discarded – undo
710 710
 	 *
711 711
      * @param WPInv_Subscription $subscription
712 712
 	 */
713
-	public function renew_subscription( $subscription ) {
713
+	public function renew_subscription($subscription) {
714 714
 
715 715
 		// Generate the renewal invoice.
716 716
 		$new_invoice = $subscription->create_payment();
717 717
 		$old_invoice = $subscription->get_parent_payment();
718 718
 
719
-        if ( empty( $new_invoice ) ) {
720
-            $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
719
+        if (empty($new_invoice)) {
720
+            $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false);
721 721
             $subscription->failing();
722 722
             return;
723 723
         }
724 724
 
725 725
         // Charge the payment method.
726
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
727
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
728
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
726
+		$payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
727
+		$customer_profile   = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true);
728
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice);
729 729
 
730 730
 		// Do we have an error?
731
-		if ( is_wp_error( $result ) ) {
731
+		if (is_wp_error($result)) {
732 732
 
733 733
 			$old_invoice->add_note(
734
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
734
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()),
735 735
 				true,
736 736
 				false,
737 737
 				true
@@ -742,12 +742,12 @@  discard block
 block discarded – undo
742 742
 		}
743 743
 
744 744
 		// Process the response.
745
-		$this->process_charge_response( $result, $new_invoice );
745
+		$this->process_charge_response($result, $new_invoice);
746 746
 
747
-		if ( wpinv_get_errors() ) {
747
+		if (wpinv_get_errors()) {
748 748
 
749 749
 			$old_invoice->add_note(
750
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
750
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()),
751 751
 				true,
752 752
 				false,
753 753
 				true
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 
758 758
         }
759 759
 
760
-        $subscription->add_payment( array(), $new_invoice );
760
+        $subscription->add_payment(array(), $new_invoice);
761 761
         $subscription->renew();
762 762
     }
763 763
 
@@ -768,34 +768,34 @@  discard block
 block discarded – undo
768 768
 	 * @param GetPaid_Form_Item[] $items
769 769
 	 * @return WPInv_Invoice
770 770
 	 */
771
-	public function process_addons( $invoice, $items ) {
771
+	public function process_addons($invoice, $items) {
772 772
 
773 773
         global $getpaid_authorize_addons;
774 774
 
775 775
         $getpaid_authorize_addons = array();
776
-        foreach ( $items as $item ) {
776
+        foreach ($items as $item) {
777 777
 
778
-            if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) {
778
+            if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) {
779 779
                 $getpaid_authorize_addons[] = $item;
780 780
             }
781 781
 
782 782
         }
783 783
 
784
-        if ( empty( $getpaid_authorize_addons ) ) {
784
+        if (empty($getpaid_authorize_addons)) {
785 785
             return;
786 786
         }
787 787
 
788 788
         $invoice->recalculate_total();
789 789
 
790
-        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
791
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
790
+        $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
791
+		$customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
792 792
 
793
-        add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
794
-        $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
795
-        remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) );
793
+        add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2);
794
+        $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
795
+        remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'));
796 796
 
797
-        if ( is_wp_error( $result ) ) {
798
-            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
797
+        if (is_wp_error($result)) {
798
+            wpinv_set_error($result->get_error_code(), $result->get_error_message());
799 799
             return;
800 800
         }
801 801
 
@@ -808,19 +808,19 @@  discard block
 block discarded – undo
808 808
      * @param array $args
809 809
 	 * @return array
810 810
 	 */
811
-    public function filter_addons_request( $args ) {
811
+    public function filter_addons_request($args) {
812 812
 
813 813
         global $getpaid_authorize_addons;
814 814
         $total = 0;
815 815
 
816
-        foreach ( $getpaid_authorize_addons as $addon ) {
816
+        foreach ($getpaid_authorize_addons as $addon) {
817 817
             $total += $addon->get_sub_total();
818 818
         }
819 819
 
820 820
         $args['createTransactionRequest']['transactionRequest']['amount'] = $total;
821 821
 
822
-        if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) {
823
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
822
+        if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) {
823
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
824 824
         }
825 825
 
826 826
         return $args;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
     public function sandbox_notice() {
834 834
 
835 835
         return sprintf(
836
-            __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ),
836
+            __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'),
837 837
             '<a href="https://developer.authorize.net/hello_world/testing_guide.html">',
838 838
             '</a>'
839 839
         );
@@ -845,42 +845,42 @@  discard block
 block discarded – undo
845 845
 	 *
846 846
 	 * @param array $admin_settings
847 847
 	 */
848
-	public function admin_settings( $admin_settings ) {
848
+	public function admin_settings($admin_settings) {
849 849
 
850 850
         $currencies = sprintf(
851
-            __( 'Supported Currencies: %s', 'invoicing' ),
852
-            implode( ', ', $this->currencies )
851
+            __('Supported Currencies: %s', 'invoicing'),
852
+            implode(', ', $this->currencies)
853 853
         );
854 854
 
855 855
         $admin_settings['authorizenet_active']['desc'] .= " ($currencies)";
856
-        $admin_settings['authorizenet_desc']['std']     = __( 'Pay securely using your credit or debit card.', 'invoicing' );
856
+        $admin_settings['authorizenet_desc']['std']     = __('Pay securely using your credit or debit card.', 'invoicing');
857 857
 
858 858
         $admin_settings['authorizenet_login_id'] = array(
859 859
             'type' => 'text',
860 860
             'id'   => 'authorizenet_login_id',
861
-            'name' => __( 'API Login ID', 'invoicing' ),
862
-            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>',
861
+            'name' => __('API Login ID', 'invoicing'),
862
+            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>',
863 863
         );
864 864
 
865 865
         $admin_settings['authorizenet_transaction_key'] = array(
866 866
             'type' => 'text',
867 867
             'id'   => 'authorizenet_transaction_key',
868
-            'name' => __( 'Transaction Key', 'invoicing' ),
868
+            'name' => __('Transaction Key', 'invoicing'),
869 869
         );
870 870
 
871 871
         $admin_settings['authorizenet_signature_key'] = array(
872 872
             'type' => 'text',
873 873
             'id'   => 'authorizenet_signature_key',
874
-            'name' => __( 'Signature Key', 'invoicing' ),
875
-            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
874
+            'name' => __('Signature Key', 'invoicing'),
875
+            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
876 876
         );
877 877
 
878 878
         $admin_settings['authorizenet_ipn_url'] = array(
879 879
             'type'     => 'ipn_url',
880 880
             'id'       => 'authorizenet_ipn_url',
881
-            'name'     => __( 'Webhook URL', 'invoicing' ),
881
+            'name'     => __('Webhook URL', 'invoicing'),
882 882
             'std'      => $this->notify_url,
883
-            'desc'     => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
883
+            'desc'     => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
884 884
             'custom'   => 'authorizenet',
885 885
             'readonly' => true,
886 886
         );
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-legacy-gateway.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Authorize.net Legacy Payment Gateway class.
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	 * @param WPInv_Invoice $invoice Invoice.
29 29
 	 * @return string
30 30
 	 */
31
-	public function get_api_url( $invoice ) {
32
-        return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
31
+	public function get_api_url($invoice) {
32
+        return $this->is_sandbox($invoice) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
33 33
     }
34 34
 
35 35
     /**
@@ -40,48 +40,48 @@  discard block
 block discarded – undo
40 40
      * @param WPInv_Invoice $invoice Invoice.
41 41
 	 * @return stdClass|WP_Error
42 42
 	 */
43
-    public function post( $post, $invoice ){
43
+    public function post($post, $invoice) {
44 44
 
45
-        $url      = $this->get_api_url( $invoice );
45
+        $url      = $this->get_api_url($invoice);
46 46
         $response = wp_remote_post(
47 47
             $url,
48 48
             array(
49 49
                 'headers'          => array(
50 50
                     'Content-Type' => 'application/json; charset=utf-8'
51 51
                 ),
52
-                'body'             => json_encode( $post ),
52
+                'body'             => json_encode($post),
53 53
                 'method'           => 'POST'
54 54
             )
55 55
         );
56 56
 
57
-        if ( is_wp_error( $response ) ) {
57
+        if (is_wp_error($response)) {
58 58
             return $response;
59 59
         }
60 60
 
61
-        $response = wp_unslash( wp_remote_retrieve_body( $response ) );
61
+        $response = wp_unslash(wp_remote_retrieve_body($response));
62 62
         $response = preg_replace('/\xEF\xBB\xBF/', '', $response); // https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851
63
-        $response = json_decode( $response );
63
+        $response = json_decode($response);
64 64
 
65
-        if ( empty( $response ) ) {
66
-            return new WP_Error( 'invalid_reponse', __( 'Invalid gateway response', 'invoicing' ) );
65
+        if (empty($response)) {
66
+            return new WP_Error('invalid_reponse', __('Invalid gateway response', 'invoicing'));
67 67
         }
68 68
 
69
-        if ( $response->messages->resultCode == 'Error' ) {
69
+        if ($response->messages->resultCode == 'Error') {
70 70
 
71
-            if ( $this->is_sandbox( $invoice ) ) {
72
-                wpinv_error_log( $response );
71
+            if ($this->is_sandbox($invoice)) {
72
+                wpinv_error_log($response);
73 73
             }
74 74
 
75
-            if ( $response->messages->message[0]->code == 'E00039' && ! empty( $response->customerProfileId )  && ! empty( $response->customerPaymentProfileId ) ) {
76
-                return new WP_Error( 'dup_payment_profile', $response->customerProfileId . '.' . $response->customerPaymentProfileId );
75
+            if ($response->messages->message[0]->code == 'E00039' && !empty($response->customerProfileId) && !empty($response->customerPaymentProfileId)) {
76
+                return new WP_Error('dup_payment_profile', $response->customerProfileId . '.' . $response->customerPaymentProfileId);
77 77
             }
78 78
 
79
-            if ( ! empty( $response->transactionResponse ) && ! empty( $response->transactionResponse->errors ) ) {
79
+            if (!empty($response->transactionResponse) && !empty($response->transactionResponse->errors)) {
80 80
                 $error = $response->transactionResponse->errors[0];
81
-                return new WP_Error( $error->errorCode, $error->errorText );
81
+                return new WP_Error($error->errorCode, $error->errorText);
82 82
             }
83 83
 
84
-            return new WP_Error( $response->messages->message[0]->code, $response->messages->message[0]->text );
84
+            return new WP_Error($response->messages->message[0]->code, $response->messages->message[0]->text);
85 85
         }
86 86
 
87 87
         return $response;
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	public function get_auth_params() {
98 98
 
99 99
         return array(
100
-            'name'           => $this->get_option( 'login_id' ),
101
-            'transactionKey' => $this->get_option( 'transaction_key' ),
100
+            'name'           => $this->get_option('login_id'),
101
+            'transactionKey' => $this->get_option('transaction_key'),
102 102
         );
103 103
 
104 104
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param WPInv_Subscription $subscription Subscription.
111 111
      * @param WPInv_Invoice $invoice Invoice.
112 112
 	 */
113
-	public function cancel_subscription( $subscription, $invoice ) {
113
+	public function cancel_subscription($subscription, $invoice) {
114 114
 
115 115
         // Backwards compatibility. New version do not use authorize.net subscriptions.
116 116
         $this->post(
@@ -135,38 +135,38 @@  discard block
 block discarded – undo
135 135
         $this->maybe_process_old_ipn();
136 136
 
137 137
         // Validate the IPN.
138
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
139
-		    wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) );
138
+        if (empty($_POST) || !$this->validate_ipn()) {
139
+		    wp_die('Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array('response' => 500));
140 140
         }
141 141
 
142 142
         // Event type.
143
-        $posted = json_decode( file_get_contents( 'php://input' ) );
144
-        if ( empty( $posted ) ) {
145
-            wp_die( 'Invalid JSON', 'Authorize.NET IPN', array( 'response' => 500 ) );
143
+        $posted = json_decode(file_get_contents('php://input'));
144
+        if (empty($posted)) {
145
+            wp_die('Invalid JSON', 'Authorize.NET IPN', array('response' => 500));
146 146
         }
147 147
 
148 148
         // Process the IPN.
149
-        $posted = (object) wp_unslash( $posted );
149
+        $posted = (object) wp_unslash($posted);
150 150
 
151 151
         // Process refunds.
152
-        if ( 'net.authorize.payment.refund.created' == $posted->eventType ) {
153
-            $invoice = new WPInv_Invoice( $posted->payload->merchantReferenceId );
154
-            $this->validate_ipn_invoice( $invoice, $posted->payload );
152
+        if ('net.authorize.payment.refund.created' == $posted->eventType) {
153
+            $invoice = new WPInv_Invoice($posted->payload->merchantReferenceId);
154
+            $this->validate_ipn_invoice($invoice, $posted->payload);
155 155
             $invoice->refund();
156 156
         }
157 157
 
158 158
         // Held funds approved.
159
-        if ( 'net.authorize.payment.fraud.approved' == $posted->eventType ) {
160
-            $invoice = new WPInv_Invoice( $posted->payload->id );
161
-            $this->validate_ipn_invoice( $invoice, $posted->payload );
162
-            $invoice->mark_paid( false, __( 'Payment released', 'invoicing' ) );
159
+        if ('net.authorize.payment.fraud.approved' == $posted->eventType) {
160
+            $invoice = new WPInv_Invoice($posted->payload->id);
161
+            $this->validate_ipn_invoice($invoice, $posted->payload);
162
+            $invoice->mark_paid(false, __('Payment released', 'invoicing'));
163 163
         }
164 164
 
165 165
         // Held funds declined.
166
-        if ( 'net.authorize.payment.fraud.declined' == $posted->eventType ) {
167
-            $invoice = new WPInv_Invoice( $posted->payload->id );
168
-            $this->validate_ipn_invoice( $invoice, $posted->payload );
169
-            $invoice->set_status( 'wpi-failed', __( 'Payment declined', 'invoicing' ) );
166
+        if ('net.authorize.payment.fraud.declined' == $posted->eventType) {
167
+            $invoice = new WPInv_Invoice($posted->payload->id);
168
+            $this->validate_ipn_invoice($invoice, $posted->payload);
169
+            $invoice->set_status('wpi-failed', __('Payment declined', 'invoicing'));
170 170
             $invoice->save();
171 171
         }
172 172
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
      * @param object $payload
182 182
 	 * @return void
183 183
 	 */
184
-	public function validate_ipn_invoice( $invoice, $payload ) {
185
-        if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) {
184
+	public function validate_ipn_invoice($invoice, $payload) {
185
+        if (!$invoice->exists() || $payload->id != $invoice->get_transaction_id()) {
186 186
             exit;
187 187
         }
188 188
     }
@@ -194,32 +194,32 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function maybe_process_old_ipn() {
196 196
 
197
-        $data = wp_unslash( $_POST );
197
+        $data = wp_unslash($_POST);
198 198
 
199 199
         // Only process subscriptions subscriptions.
200
-        if ( empty( $_POST['x_subscription_id'] ) ) {
200
+        if (empty($_POST['x_subscription_id'])) {
201 201
             return;
202 202
         }
203 203
 
204 204
         // Check validity.
205
-        $this->validate_old_ipn_signature( $data );
205
+        $this->validate_old_ipn_signature($data);
206 206
 
207 207
         // Fetch the associated subscription.
208
-        $subscription_id = WPInv_Subscription::get_subscription_id_by_field( $_POST['x_subscription_id'] );
209
-        $subscription    = new WPInv_Subscription( $subscription_id );
208
+        $subscription_id = WPInv_Subscription::get_subscription_id_by_field($_POST['x_subscription_id']);
209
+        $subscription    = new WPInv_Subscription($subscription_id);
210 210
 
211 211
         // Abort if it is missing or completed.
212
-        if ( ! $subscription->get_id() || $subscription->has_status( 'completed' ) ) {
212
+        if (!$subscription->get_id() || $subscription->has_status('completed')) {
213 213
             return;
214 214
         }
215 215
 
216 216
         // Payment status.
217
-        if ( 1 == $_POST['x_response_code'] ) {
217
+        if (1 == $_POST['x_response_code']) {
218 218
 
219 219
             // Renew the subscription.
220 220
             $subscription->add_payment(
221 221
                 array(
222
-                    'transaction_id' => sanitize_text_field( $data['x_trans_id'] ),
222
+                    'transaction_id' => sanitize_text_field($data['x_trans_id']),
223 223
                     'gateway'        => $this->id
224 224
                 )
225 225
             );
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
      *
239 239
      * @param array $posted
240 240
 	 */
241
-	public function validate_old_ipn_signature( $posted ) {
241
+	public function validate_old_ipn_signature($posted) {
242 242
 
243
-        $signature = $this->get_option( 'signature_key' );
244
-        if ( ! empty( $signature ) ) {
245
-            $login_id  = $this->get_option( 'login_id' );
243
+        $signature = $this->get_option('signature_key');
244
+        if (!empty($signature)) {
245
+            $login_id  = $this->get_option('login_id');
246 246
             $trans_id  = $_POST['x_trans_id'];
247 247
             $amount    = $_POST['x_amount'];
248
-            $hash      = hash_hmac ( 'sha512', "^$login_id^$trans_id^$amount^", hex2bin( $signature ) );
248
+            $hash      = hash_hmac('sha512', "^$login_id^$trans_id^$amount^", hex2bin($signature));
249 249
 
250
-            if ( ! hash_equals( $hash, $posted['x_SHA2_Hash'] ) ) {
251
-                wpinv_error_log( $posted['x_SHA2_Hash'], "Invalid signature. Expected $hash" );
250
+            if (!hash_equals($hash, $posted['x_SHA2_Hash'])) {
251
+                wpinv_error_log($posted['x_SHA2_Hash'], "Invalid signature. Expected $hash");
252 252
                 exit;
253 253
             }
254 254
 
@@ -261,28 +261,28 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function validate_ipn() {
263 263
 
264
-        wpinv_error_log( 'Validating Authorize.NET IPN response' );
264
+        wpinv_error_log('Validating Authorize.NET IPN response');
265 265
 
266
-        if ( empty( $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) {
266
+        if (empty($_SERVER['HTTP_X_ANET_SIGNATURE'])) {
267 267
             return false;
268 268
         }
269 269
 
270
-        $signature = $this->get_option( 'signature_key' );
270
+        $signature = $this->get_option('signature_key');
271 271
 
272
-        if ( empty( $signature ) ) {
273
-            wpinv_error_log( 'Error: You have not set a signature key' );
272
+        if (empty($signature)) {
273
+            wpinv_error_log('Error: You have not set a signature key');
274 274
             return false;
275 275
         }
276 276
 
277
-        $hash  = hash_hmac ( 'sha512', file_get_contents( 'php://input' ), hex2bin( $signature ) );
277
+        $hash = hash_hmac('sha512', file_get_contents('php://input'), hex2bin($signature));
278 278
 
279
-        if ( hash_equals( $hash, $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) {
280
-            wpinv_error_log( 'Successfully validated the IPN' );
279
+        if (hash_equals($hash, $_SERVER['HTTP_X_ANET_SIGNATURE'])) {
280
+            wpinv_error_log('Successfully validated the IPN');
281 281
             return true;
282 282
         }
283 283
 
284
-        wpinv_error_log( 'IPN hash is not valid' );
285
-        wpinv_error_log(  $_SERVER['HTTP_X_ANET_SIGNATURE']  );
284
+        wpinv_error_log('IPN hash is not valid');
285
+        wpinv_error_log($_SERVER['HTTP_X_ANET_SIGNATURE']);
286 286
         return false;
287 287
 
288 288
     }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 1 patch
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119 119
 	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
120
+	public function __construct($read = 0) {
121
+		$this->data         = array_merge($this->data, $this->extra_data);
122 122
 		$this->default_data = $this->data;
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array
129 129
 	 */
130 130
 	public function __sleep() {
131
-		return array( 'id' );
131
+		return array('id');
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 	 * If the object no longer exists, remove the ID.
138 138
 	 */
139 139
 	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
140
+		$this->__construct(absint($this->id));
141 141
 
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
142
+		if (!empty($this->last_error)) {
143
+			$this->set_id(0);
144 144
 		}
145 145
 
146 146
 	}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function __clone() {
154 154
 		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
155
+		if (!empty($this->meta_data)) {
156
+			foreach ($this->meta_data as $array_key => $meta) {
157
+				$this->meta_data[$array_key] = clone $meta;
158
+				if (!empty($meta->id)) {
159
+					$this->meta_data[$array_key]->id = null;
160 160
 				}
161 161
 			}
162 162
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
202
+	public function get_status($context = 'view') {
203
+		return $this->get_prop('status', $context);
204 204
     }
205 205
 
206 206
 	/**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 * @param  bool $force_delete Should the data be deleted permanently.
211 211
 	 * @return bool result
212 212
 	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->exists() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
213
+	public function delete($force_delete = false) {
214
+		if ($this->data_store && $this->exists()) {
215
+			$this->data_store->delete($this, array('force_delete' => $force_delete));
216
+			$this->set_id(0);
217 217
 			return true;
218 218
 		}
219 219
 		return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return int
227 227
 	 */
228 228
 	public function save() {
229
-		if ( ! $this->data_store ) {
229
+		if (!$this->data_store) {
230 230
 			return $this->get_id();
231 231
 		}
232 232
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 		 * @param GetPaid_Data          $this The object being saved.
237 237
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238 238
 		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
239
+		do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store);
240 240
 
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
241
+		if ($this->get_id()) {
242
+			$this->data_store->update($this);
243 243
 		} else {
244
-			$this->data_store->create( $this );
244
+			$this->data_store->create($this);
245 245
 		}
246 246
 
247 247
 		/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param GetPaid_Data          $this The object being saved.
251 251
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252 252
 		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
253
+		do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store);
254 254
 
255 255
 		return $this->get_id();
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string Data in JSON format.
263 263
 	 */
264 264
 	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
265
+		return wp_json_encode($this->get_data());
266 266
 	}
267 267
 
268 268
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return array
273 273
 	 */
274 274
 	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
275
+		return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data()));
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return array
283 283
 	 */
284 284
 	public function get_data_keys() {
285
-		return array_keys( $this->data );
285
+		return array_keys($this->data);
286 286
 	}
287 287
 
288 288
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 */
294 294
 	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
295
+		return array_keys($this->extra_data);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param mixed $meta Meta value to check.
303 303
 	 * @return bool
304 304
 	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
305
+	protected function filter_null_meta($meta) {
306
+		return !is_null($meta->value);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_meta_data() {
316 316
 		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
317
+		return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta')));
318 318
 	}
319 319
 
320 320
 	/**
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $key Key to check.
325 325
 	 * @return bool   true if it's an internal key, false otherwise
326 326
 	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
327
+	protected function is_internal_meta_key($key) {
328
+		$internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true);
329 329
 
330
-		if ( ! $internal_meta_key ) {
330
+		if (!$internal_meta_key) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
334
+		$has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key));
335 335
 
336
-		if ( ! $has_setter_or_getter ) {
336
+		if (!$has_setter_or_getter) {
337 337
 			return false;
338 338
 		}
339 339
 
340 340
 		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
341
+		getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing'), $key), '1.0.19');
342 342
 
343 343
 		return true;
344 344
 	}
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 *
354 354
 	 */
355
-	public function __set( $key, $value ) {
355
+	public function __set($key, $value) {
356 356
 
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
357
+		if ('id' == strtolower($key)) {
358
+			return $this->set_id($value);
359 359
 		}
360 360
 
361
-		if ( method_exists( $this, "set_$key") ) {
361
+		if (method_exists($this, "set_$key")) {
362 362
 
363 363
 			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
364
+			getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19');
365 365
 
366
-			call_user_func( array( $this, "set_$key" ), $value );
366
+			call_user_func(array($this, "set_$key"), $value);
367 367
 		} else {
368
-			$this->set_prop( $key, $value );
368
+			$this->set_prop($key, $value);
369 369
 		}
370 370
 
371 371
 	}
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	/**
374 374
      * Margic method for retrieving a property.
375 375
      */
376
-    public function __get( $key ) {
376
+    public function __get($key) {
377 377
 
378 378
         // Check if we have a helper method for that.
379
-        if ( method_exists( $this, 'get_' . $key ) ) {
379
+        if (method_exists($this, 'get_' . $key)) {
380 380
 
381
-			if ( 'post_type' != $key ) {
381
+			if ('post_type' != $key) {
382 382
 				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' );
383
+				getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19');
384 384
 			}
385 385
 
386
-            return call_user_func( array( $this, 'get_' . $key ) );
386
+            return call_user_func(array($this, 'get_' . $key));
387 387
         }
388 388
 
389 389
         // Check if the key is in the associated $post object.
390
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
390
+        if (!empty($this->post) && isset($this->post->$key)) {
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
394
+		return $this->get_prop($key);
395 395
 
396 396
     }
397 397
 
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context What the value is for. Valid values are view and edit.
405 405
 	 * @return mixed
406 406
 	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
407
+	public function get_meta($key = '', $single = true, $context = 'view') {
408 408
 
409 409
 		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $key ) ) {
410
+		$_key = str_replace('_wpinv', '', $key);
411
+		$_key = str_replace('wpinv', '', $_key);
412
+		if ($this->is_internal_meta_key($key)) {
413 413
 			$function = 'get_' . $_key;
414 414
 
415
-			if ( is_callable( array( $this, $function ) ) ) {
415
+			if (is_callable(array($this, $function))) {
416 416
 				return $this->{$function}();
417 417
 			}
418 418
 		}
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 		// Read the meta data if not yet read.
421 421
 		$this->maybe_read_meta_data();
422 422
 		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
423
+		$array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true);
424 424
 		$value      = $single ? '' : array();
425 425
 
426
-		if ( ! empty( $array_keys ) ) {
426
+		if (!empty($array_keys)) {
427 427
 			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
428
+			if ($single) {
429
+				$value = $meta_data[current($array_keys)]->value;
430 430
 			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
431
+				$value = array_intersect_key($meta_data, array_flip($array_keys));
432 432
 			}
433 433
 		}
434 434
 
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
435
+		if ('view' === $context) {
436
+			$value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
437 437
 		}
438 438
 
439 439
 		return $value;
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 	 * @param  string $key Meta Key.
447 447
 	 * @return boolean
448 448
 	 */
449
-	public function meta_exists( $key = '' ) {
449
+	public function meta_exists($key = '') {
450 450
 		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
451
+		$array_keys = wp_list_pluck($this->get_meta_data(), 'key');
452
+		return in_array($key, $array_keys, true);
453 453
 	}
454 454
 
455 455
 	/**
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 	 * @since 1.0.19
459 459
 	 * @param array $data Key/Value pairs.
460 460
 	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
461
+	public function set_meta_data($data) {
462
+		if (!empty($data) && is_array($data)) {
463 463
 			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
464
+			foreach ($data as $meta) {
465 465
 				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
466
+				if (isset($meta['key'], $meta['value'], $meta['id'])) {
467 467
 					$this->meta_data[] = new GetPaid_Meta_Data(
468 468
 						array(
469 469
 							'id'    => $meta['id'],
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 	 * @param string|array $value Meta value.
486 486
 	 * @param bool         $unique Should this be a unique key?.
487 487
 	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
488
+	public function add_meta_data($key, $value, $unique = false) {
489
+		if ($this->is_internal_meta_key($key)) {
490 490
 			$function = 'set_' . $key;
491 491
 
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
492
+			if (is_callable(array($this, $function))) {
493
+				return $this->{$function}($value);
494 494
 			}
495 495
 		}
496 496
 
497 497
 		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
498
+		if ($unique) {
499
+			$this->delete_meta_data($key);
500 500
 		}
501 501
 		$this->meta_data[] = new GetPaid_Meta_Data(
502 502
 			array(
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
 	 * @param  string|array $value Meta value.
518 518
 	 * @param  int          $meta_id Meta ID.
519 519
 	 */
520
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
521
-		if ( $this->is_internal_meta_key( $key ) ) {
520
+	public function update_meta_data($key, $value, $meta_id = 0) {
521
+		if ($this->is_internal_meta_key($key)) {
522 522
 			$function = 'set_' . $key;
523 523
 
524
-			if ( is_callable( array( $this, $function ) ) ) {
525
-				return $this->{$function}( $value );
524
+			if (is_callable(array($this, $function))) {
525
+				return $this->{$function}($value);
526 526
 			}
527 527
 		}
528 528
 
@@ -530,33 +530,33 @@  discard block
 block discarded – undo
530 530
 
531 531
 		$array_key = false;
532 532
 
533
-		if ( $meta_id ) {
534
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
535
-			$array_key  = $array_keys ? current( $array_keys ) : false;
533
+		if ($meta_id) {
534
+			$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true);
535
+			$array_key  = $array_keys ? current($array_keys) : false;
536 536
 		} else {
537 537
 			// Find matches by key.
538 538
 			$matches = array();
539
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
540
-				if ( $meta->key === $key ) {
539
+			foreach ($this->meta_data as $meta_data_array_key => $meta) {
540
+				if ($meta->key === $key) {
541 541
 					$matches[] = $meta_data_array_key;
542 542
 				}
543 543
 			}
544 544
 
545
-			if ( ! empty( $matches ) ) {
545
+			if (!empty($matches)) {
546 546
 				// Set matches to null so only one key gets the new value.
547
-				foreach ( $matches as $meta_data_array_key ) {
548
-					$this->meta_data[ $meta_data_array_key ]->value = null;
547
+				foreach ($matches as $meta_data_array_key) {
548
+					$this->meta_data[$meta_data_array_key]->value = null;
549 549
 				}
550
-				$array_key = current( $matches );
550
+				$array_key = current($matches);
551 551
 			}
552 552
 		}
553 553
 
554
-		if ( false !== $array_key ) {
555
-			$meta        = $this->meta_data[ $array_key ];
554
+		if (false !== $array_key) {
555
+			$meta        = $this->meta_data[$array_key];
556 556
 			$meta->key   = $key;
557 557
 			$meta->value = $value;
558 558
 		} else {
559
-			$this->add_meta_data( $key, $value, true );
559
+			$this->add_meta_data($key, $value, true);
560 560
 		}
561 561
 	}
562 562
 
@@ -566,13 +566,13 @@  discard block
 block discarded – undo
566 566
 	 * @since 1.0.19
567 567
 	 * @param string $key Meta key.
568 568
 	 */
569
-	public function delete_meta_data( $key ) {
569
+	public function delete_meta_data($key) {
570 570
 		$this->maybe_read_meta_data();
571
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
571
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true);
572 572
 
573
-		if ( $array_keys ) {
574
-			foreach ( $array_keys as $array_key ) {
575
-				$this->meta_data[ $array_key ]->value = null;
573
+		if ($array_keys) {
574
+			foreach ($array_keys as $array_key) {
575
+				$this->meta_data[$array_key]->value = null;
576 576
 			}
577 577
 		}
578 578
 	}
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 	 * @since 1.0.19
584 584
 	 * @param int $mid Meta ID.
585 585
 	 */
586
-	public function delete_meta_data_by_mid( $mid ) {
586
+	public function delete_meta_data_by_mid($mid) {
587 587
 		$this->maybe_read_meta_data();
588
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
588
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true);
589 589
 
590
-		if ( $array_keys ) {
591
-			foreach ( $array_keys as $array_key ) {
592
-				$this->meta_data[ $array_key ]->value = null;
590
+		if ($array_keys) {
591
+			foreach ($array_keys as $array_key) {
592
+				$this->meta_data[$array_key]->value = null;
593 593
 			}
594 594
 		}
595 595
 	}
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @since 1.0.19
601 601
 	 */
602 602
 	protected function maybe_read_meta_data() {
603
-		if ( is_null( $this->meta_data ) ) {
603
+		if (is_null($this->meta_data)) {
604 604
 			$this->read_meta_data();
605 605
 		}
606 606
 	}
@@ -612,42 +612,42 @@  discard block
 block discarded – undo
612 612
 	 * @since 1.0.19
613 613
 	 * @param bool $force_read True to force a new DB read (and update cache).
614 614
 	 */
615
-	public function read_meta_data( $force_read = false ) {
615
+	public function read_meta_data($force_read = false) {
616 616
 
617 617
 		// Reset meta data.
618 618
 		$this->meta_data = array();
619 619
 
620 620
 		// Maybe abort early.
621
-		if ( ! $this->get_id() || ! $this->data_store ) {
621
+		if (!$this->get_id() || !$this->data_store) {
622 622
 			return;
623 623
 		}
624 624
 
625 625
 		// Only read from cache if the cache key is set.
626 626
 		$cache_key = null;
627
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
628
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
629
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
627
+		if (!$force_read && !empty($this->cache_group)) {
628
+			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
629
+			$raw_meta_data = wp_cache_get($cache_key, $this->cache_group);
630 630
 		}
631 631
 
632 632
 		// Should we force read?
633
-		if ( empty( $raw_meta_data ) ) {
634
-			$raw_meta_data = $this->data_store->read_meta( $this );
633
+		if (empty($raw_meta_data)) {
634
+			$raw_meta_data = $this->data_store->read_meta($this);
635 635
 
636
-			if ( ! empty( $cache_key ) ) {
637
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
636
+			if (!empty($cache_key)) {
637
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
638 638
 			}
639 639
 
640 640
 		}
641 641
 
642 642
 		// Set meta data.
643
-		if ( is_array( $raw_meta_data ) ) {
643
+		if (is_array($raw_meta_data)) {
644 644
 
645
-			foreach ( $raw_meta_data as $meta ) {
645
+			foreach ($raw_meta_data as $meta) {
646 646
 				$this->meta_data[] = new GetPaid_Meta_Data(
647 647
 					array(
648 648
 						'id'    => (int) $meta->meta_id,
649 649
 						'key'   => $meta->meta_key,
650
-						'value' => maybe_unserialize( $meta->meta_value ),
650
+						'value' => maybe_unserialize($meta->meta_value),
651 651
 					)
652 652
 				);
653 653
 			}
@@ -662,28 +662,28 @@  discard block
 block discarded – undo
662 662
 	 * @since 1.0.19
663 663
 	 */
664 664
 	public function save_meta_data() {
665
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
665
+		if (!$this->data_store || is_null($this->meta_data)) {
666 666
 			return;
667 667
 		}
668
-		foreach ( $this->meta_data as $array_key => $meta ) {
669
-			if ( is_null( $meta->value ) ) {
670
-				if ( ! empty( $meta->id ) ) {
671
-					$this->data_store->delete_meta( $this, $meta );
672
-					unset( $this->meta_data[ $array_key ] );
668
+		foreach ($this->meta_data as $array_key => $meta) {
669
+			if (is_null($meta->value)) {
670
+				if (!empty($meta->id)) {
671
+					$this->data_store->delete_meta($this, $meta);
672
+					unset($this->meta_data[$array_key]);
673 673
 				}
674
-			} elseif ( empty( $meta->id ) ) {
675
-				$meta->id = $this->data_store->add_meta( $this, $meta );
674
+			} elseif (empty($meta->id)) {
675
+				$meta->id = $this->data_store->add_meta($this, $meta);
676 676
 				$meta->apply_changes();
677 677
 			} else {
678
-				if ( $meta->get_changes() ) {
679
-					$this->data_store->update_meta( $this, $meta );
678
+				if ($meta->get_changes()) {
679
+					$this->data_store->update_meta($this, $meta);
680 680
 					$meta->apply_changes();
681 681
 				}
682 682
 			}
683 683
 		}
684
-		if ( ! empty( $this->cache_group ) ) {
685
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
686
-			wp_cache_delete( $cache_key, $this->cache_group );
684
+		if (!empty($this->cache_group)) {
685
+			$cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
686
+			wp_cache_delete($cache_key, $this->cache_group);
687 687
 		}
688 688
 	}
689 689
 
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 * @since 1.0.19
694 694
 	 * @param int $id ID.
695 695
 	 */
696
-	public function set_id( $id ) {
697
-		$this->id = absint( $id );
696
+	public function set_id($id) {
697
+		$this->id = absint($id);
698 698
 	}
699 699
 
700 700
 	/**
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 	 * @param string $status New status.
705 705
 	 * @return array details of change.
706 706
 	 */
707
-	public function set_status( $status ) {
707
+	public function set_status($status) {
708 708
         $old_status = $this->get_status();
709 709
 
710
-		$this->set_prop( 'status', $status );
710
+		$this->set_prop('status', $status);
711 711
 
712 712
 		return array(
713 713
 			'from' => $old_status,
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	public function set_defaults() {
724 724
 		$this->data    = $this->default_data;
725 725
 		$this->changes = array();
726
-		$this->set_object_read( false );
726
+		$this->set_object_read(false);
727 727
 	}
728 728
 
729 729
 	/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	 * @since 1.0.19
733 733
 	 * @param boolean $read Should read?.
734 734
 	 */
735
-	public function set_object_read( $read = true ) {
735
+	public function set_object_read($read = true) {
736 736
 		$this->object_read = (bool) $read;
737 737
 	}
738 738
 
@@ -757,33 +757,33 @@  discard block
 block discarded – undo
757 757
 	 *
758 758
 	 * @return bool|WP_Error
759 759
 	 */
760
-	public function set_props( $props, $context = 'set' ) {
760
+	public function set_props($props, $context = 'set') {
761 761
 		$errors = false;
762 762
 
763
-		$props = wp_unslash( $props );
764
-		foreach ( $props as $prop => $value ) {
763
+		$props = wp_unslash($props);
764
+		foreach ($props as $prop => $value) {
765 765
 			try {
766 766
 				/**
767 767
 				 * Checks if the prop being set is allowed, and the value is not null.
768 768
 				 */
769
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
769
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
770 770
 					continue;
771 771
 				}
772 772
 				$setter = "set_$prop";
773 773
 
774
-				if ( is_callable( array( $this, $setter ) ) ) {
775
-					$this->{$setter}( $value );
774
+				if (is_callable(array($this, $setter))) {
775
+					$this->{$setter}($value);
776 776
 				}
777
-			} catch ( Exception $e ) {
778
-				if ( ! $errors ) {
777
+			} catch (Exception $e) {
778
+				if (!$errors) {
779 779
 					$errors = new WP_Error();
780 780
 				}
781
-				$errors->add( $e->getCode(), $e->getMessage() );
781
+				$errors->add($e->getCode(), $e->getMessage());
782 782
 				$this->last_error = $e->getMessage();
783 783
 			}
784 784
 		}
785 785
 
786
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
786
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
787 787
 	}
788 788
 
789 789
 	/**
@@ -796,14 +796,14 @@  discard block
 block discarded – undo
796 796
 	 * @param string $prop Name of prop to set.
797 797
 	 * @param mixed  $value Value of the prop.
798 798
 	 */
799
-	protected function set_prop( $prop, $value ) {
800
-		if ( array_key_exists( $prop, $this->data ) ) {
801
-			if ( true === $this->object_read ) {
802
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
803
-					$this->changes[ $prop ] = $value;
799
+	protected function set_prop($prop, $value) {
800
+		if (array_key_exists($prop, $this->data)) {
801
+			if (true === $this->object_read) {
802
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
803
+					$this->changes[$prop] = $value;
804 804
 				}
805 805
 			} else {
806
-				$this->data[ $prop ] = $value;
806
+				$this->data[$prop] = $value;
807 807
 			}
808 808
 		}
809 809
 	}
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 * @since 1.0.19
825 825
 	 */
826 826
 	public function apply_changes() {
827
-		$this->data    = array_replace( $this->data, $this->changes );
827
+		$this->data    = array_replace($this->data, $this->changes);
828 828
 		$this->changes = array();
829 829
 	}
830 830
 
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
 	 * @param  string $context What the value is for. Valid values are view and edit.
850 850
 	 * @return mixed
851 851
 	 */
852
-	protected function get_prop( $prop, $context = 'view' ) {
852
+	protected function get_prop($prop, $context = 'view') {
853 853
 		$value = null;
854 854
 
855
-		if ( array_key_exists( $prop, $this->data ) ) {
856
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
855
+		if (array_key_exists($prop, $this->data)) {
856
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
857 857
 
858
-			if ( 'view' === $context ) {
859
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
858
+			if ('view' === $context) {
859
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
860 860
 			}
861 861
 		}
862 862
 
@@ -870,13 +870,13 @@  discard block
 block discarded – undo
870 870
 	 * @param string         $prop Name of prop to set.
871 871
 	 * @param string|integer $value Value of the prop.
872 872
 	 */
873
-	protected function set_date_prop( $prop, $value ) {
873
+	protected function set_date_prop($prop, $value) {
874 874
 
875
-		if ( empty( $value ) ) {
876
-			$this->set_prop( $prop, null );
875
+		if (empty($value)) {
876
+			$this->set_prop($prop, null);
877 877
 			return;
878 878
 		}
879
-		$this->set_prop( $prop, $value );
879
+		$this->set_prop($prop, $value);
880 880
 
881 881
 	}
882 882
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @param string $code             Error code.
888 888
 	 * @param string $message          Error message.
889 889
 	 */
890
-	protected function error( $code, $message ) {
890
+	protected function error($code, $message) {
891 891
 		$this->last_error = $message;
892 892
 	}
893 893
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 */
900 900
 	public function exists() {
901 901
 		$id = $this->get_id();
902
-		return ! empty( $id );
902
+		return !empty($id);
903 903
 	}
904 904
 
905 905
 }
Please login to merge, or discard this patch.
includes/class-getpaid-subscription-notification-emails.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This class handles subscription notificaiton emails.
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function init_hooks() {
47 47
 
48
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
48
+		add_filter('getpaid_get_email_merge_tags', array($this, 'subscription_merge_tags'), 10, 2);
49
+		foreach ($this->subscription_actions as $hook => $email_type) {
50 50
 
51
-			$email = new GetPaid_Notification_Email( $email_type );
51
+			$email = new GetPaid_Notification_Email($email_type);
52 52
 
53
-			if ( ! $email->is_active() ) {
53
+			if (!$email->is_active()) {
54 54
 				continue;
55 55
 			}
56 56
 
57
-			if ( method_exists( $this, $email_type ) ) {
58
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
57
+			if (method_exists($this, $email_type)) {
58
+				add_action($hook, array($this, $email_type), 100, 2);
59 59
 				continue;
60 60
 			}
61 61
 
62
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
62
+			do_action('getpaid_subscription_notification_email_register_hook', $email_type, $hook);
63 63
 
64 64
 		}
65 65
 
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	 * @param array $merge_tags
72 72
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73 73
 	 */
74
-	public function subscription_merge_tags( $merge_tags, $object ) {
74
+	public function subscription_merge_tags($merge_tags, $object) {
75 75
 
76
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
76
+		if (is_a($object, 'WPInv_Subscription')) {
77 77
 			$merge_tags = array_merge(
78 78
 				$merge_tags,
79
-				$this->get_subscription_merge_tags( $object )
79
+				$this->get_subscription_merge_tags($object)
80 80
 			);
81 81
 		}
82 82
 
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
 	 * @param WPInv_Subscription $subscription
91 91
 	 * @return array
92 92
 	 */
93
-	public function get_subscription_merge_tags( $subscription ) {
93
+	public function get_subscription_merge_tags($subscription) {
94 94
 
95 95
 		// Abort if it does not exist.
96
-		if ( ! $subscription->get_id() ) {
96
+		if (!$subscription->get_id()) {
97 97
 			return array();
98 98
 		}
99 99
 
100
-		$invoice    = $subscription->get_parent_invoice();
100
+		$invoice = $subscription->get_parent_invoice();
101 101
 		return array(
102
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
-			'{subscription_id}'               => absint( $subscription->get_id() ),
107
-			'{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
-			'{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
102
+			'{subscription_renewal_date}'     => getpaid_format_date_value($subscription->get_next_renewal_date(), __('Never', 'invoicing')),
103
+			'{subscription_created}'          => getpaid_format_date_value($subscription->get_date_created()),
104
+			'{subscription_status}'           => sanitize_text_field($subscription->get_status_label()),
105
+			'{subscription_profile_id}'       => sanitize_text_field($subscription->get_profile_id()),
106
+			'{subscription_id}'               => absint($subscription->get_id()),
107
+			'{subscription_recurring_amount}' => sanitize_text_field(wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency())),
108
+			'{subscription_initial_amount}'   => sanitize_text_field(wpinv_price($subscription->get_initial_amount(), $invoice->get_currency())),
109
+			'{subscription_recurring_period}' => getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''),
110 110
 			'{subscription_bill_times}'       => $subscription->get_bill_times(),
111
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
111
+			'{subscription_url}'              => esc_url($subscription->get_view_url()),
112 112
 		);
113 113
 
114 114
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return bool
121 121
 	 */
122
-	public function should_send_notification( $invoice ) {
122
+	public function should_send_notification($invoice) {
123 123
 		return 0 != $invoice->get_id();
124 124
 	}
125 125
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 * @param WPInv_Invoice $invoice
130 130
 	 * @return array
131 131
 	 */
132
-	public function get_recipients( $invoice ) {
133
-		$recipients = array( $invoice->get_email() );
132
+	public function get_recipients($invoice) {
133
+		$recipients = array($invoice->get_email());
134 134
 
135 135
 		$cc = $invoice->get_email_cc();
136 136
 
137
-		if ( ! empty( $cc ) ) {
138
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
137
+		if (!empty($cc)) {
138
+			$cc = array_map('sanitize_email', wpinv_parse_list($cc));
139
+			$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
140 140
 		}
141 141
 
142 142
 		return $recipients;
@@ -150,63 +150,63 @@  discard block
 block discarded – undo
150 150
 	 * @param string $type
151 151
 	 * @param array $extra_args Extra template args.
152 152
 	 */
153
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
153
+	public function send_email($subscription, $email, $type, $extra_args = array()) {
154 154
 
155 155
 		// Abort in case the parent invoice does not exist.
156 156
 		$invoice = $subscription->get_parent_invoice();
157
-		if ( ! $this->should_send_notification( $invoice ) ) {
157
+		if (!$this->should_send_notification($invoice)) {
158 158
 			return;
159 159
 		}
160 160
 
161
-		if ( apply_filters( 'getpaid_skip_subscription_email', false, $type, $subscription ) ) {
161
+		if (apply_filters('getpaid_skip_subscription_email', false, $type, $subscription)) {
162 162
 			return;
163 163
 		}
164 164
 
165
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
165
+		do_action('getpaid_before_send_subscription_notification', $type, $subscription, $email);
166 166
 
167
-		$recipients  = $this->get_recipients( $invoice );
167
+		$recipients  = $this->get_recipients($invoice);
168 168
 		$mailer      = new GetPaid_Notification_Email_Sender();
169 169
 		$merge_tags  = $email->get_merge_tags();
170
-		$content     = $email->get_content( $merge_tags, $extra_args );
171
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
170
+		$content     = $email->get_content($merge_tags, $extra_args);
171
+		$subject     = $email->add_merge_tags($email->get_subject(), $merge_tags);
172 172
 		$attachments = $email->get_attachments();
173 173
 
174 174
 		$result = $mailer->send(
175
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
175
+			apply_filters('getpaid_subscription_email_recipients', wpinv_parse_list($recipients), $email),
176 176
 			$subject,
177 177
 			$content,
178 178
 			$attachments
179 179
 		);
180 180
 
181 181
 		// Maybe send a copy to the admin.
182
-		if ( $email->include_admin_bcc() ) {
182
+		if ($email->include_admin_bcc()) {
183 183
 			$mailer->send(
184 184
 				wpinv_get_admin_email(),
185
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
185
+				$subject . __(' - ADMIN BCC COPY', 'invoicing'),
186 186
 				$content,
187 187
 				$attachments
188 188
 			);
189 189
 		}
190 190
 
191
-		if ( $result ) {
191
+		if ($result) {
192 192
 			$invoice->add_system_note(
193 193
 				sprintf(
194
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
195
-					sanitize_key( $type ),
196
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
194
+					__('Successfully sent %s notification email to %s.', 'invoicing'),
195
+					sanitize_key($type),
196
+					$email->is_admin_email() ? __('admin') : __('the customer')
197 197
 				)
198 198
 			);
199 199
 		} else {
200 200
 			$invoice->add_system_note(
201 201
 				sprintf(
202
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
203
-					sanitize_key( $type ),
204
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
202
+					__('Failed sending %s notification email to %s.', 'invoicing'),
203
+					sanitize_key($type),
204
+					$email->is_admin_email() ? __('admin') : __('the customer')
205 205
 				)
206 206
 			);	
207 207
 		}
208 208
 
209
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
209
+		do_action('getpaid_after_send_subscription_notification', $type, $subscription, $email);
210 210
 
211 211
 	}
212 212
 
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param WPInv_Subscription $subscription
217 217
 	 */
218
-	public function subscription_trial( $subscription ) {
218
+	public function subscription_trial($subscription) {
219 219
 
220
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
221
-		$this->send_email( $subscription, $email, __FUNCTION__ );
220
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
221
+		$this->send_email($subscription, $email, __FUNCTION__);
222 222
 
223 223
 	}
224 224
 
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param WPInv_Subscription $subscription
229 229
 	 */
230
-	public function subscription_cancelled( $subscription ) {
230
+	public function subscription_cancelled($subscription) {
231 231
 
232
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
233
-		$this->send_email( $subscription, $email, __FUNCTION__ );
232
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
233
+		$this->send_email($subscription, $email, __FUNCTION__);
234 234
 
235 235
 	}
236 236
 
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @param WPInv_Subscription $subscription
241 241
 	 */
242
-	public function subscription_expired( $subscription ) {
242
+	public function subscription_expired($subscription) {
243 243
 
244
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
245
-		$this->send_email( $subscription, $email, __FUNCTION__ );
244
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
245
+		$this->send_email($subscription, $email, __FUNCTION__);
246 246
 
247 247
 	}
248 248
 
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param WPInv_Subscription $subscription
253 253
 	 */
254
-	public function subscription_complete( $subscription ) {
254
+	public function subscription_complete($subscription) {
255 255
 
256
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
257
-		$this->send_email( $subscription, $email, __FUNCTION__ );
256
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
257
+		$this->send_email($subscription, $email, __FUNCTION__);
258 258
 
259 259
 	}
260 260
 
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	public function renewal_reminder() {
266 266
 
267
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
267
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
268 268
 
269 269
 		// Fetch reminder days.
270
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
270
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
271 271
 
272 272
 		// Abort if non is set.
273
-		if ( empty( $reminder_days ) ) {
273
+		if (empty($reminder_days)) {
274 274
 			return;
275 275
 		}
276 276
 
277 277
 		// Fetch matching subscriptions.
278
-        $args  = array(
278
+        $args = array(
279 279
             'number'             => -1,
280 280
 			'count_total'        => false,
281 281
 			'status'             => 'trialling active',
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
             ),
285 285
 		);
286 286
 
287
-		foreach ( $reminder_days as $days ) {
288
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
287
+		foreach ($reminder_days as $days) {
288
+			$date = date_parse(date('Y-m-d', strtotime("+$days days", current_time('timestamp'))));
289 289
 
290 290
 			$args['date_expires_query'][] = array(
291 291
 				'year'  => $date['year'],
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 
296 296
 		}
297 297
 
298
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
298
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
299 299
 
300
-        foreach ( $subscriptions as $subscription ) {
300
+        foreach ($subscriptions as $subscription) {
301 301
 
302 302
 			// Skip packages.
303
-			if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) {
303
+			if (get_post_meta($subscription->get_product_id(), '_wpinv_type', true) != 'package') {
304 304
 				$email->object = $subscription;
305
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
305
+            	$this->send_email($subscription, $email, __FUNCTION__);
306 306
 			}
307 307
 
308 308
 		}
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Spacing   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69 69
 	 * @param  bool $deprecated
70 70
 	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
71
+	function __construct($subscription = 0, $deprecated = false) {
72 72
 
73
-		parent::__construct( $subscription );
73
+		parent::__construct($subscription);
74 74
 
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
75
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
76
+			$this->set_id($subscription);
77
+		} elseif ($subscription instanceof self) {
78
+			$this->set_id($subscription->get_id());
79
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
80
+			$this->set_id($subscription_id);
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83 83
 		} else {
84
-			$this->set_object_read( true );
84
+			$this->set_object_read(true);
85 85
 		}
86 86
 
87 87
 		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
88
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
89 89
 
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
90
+		if ($this->get_id() > 0) {
91
+			$this->data_store->read($this);
92 92
 		}
93 93
 
94 94
 	}
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0.19
104 104
 	 * @return int
105 105
 	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
106
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
107 107
         global $wpdb;
108 108
 
109 109
 		// Trim the value.
110
-		$value = trim( $value );
110
+		$value = trim($value);
111 111
 
112
-		if ( empty( $value ) ) {
112
+		if (empty($value)) {
113 113
 			return 0;
114 114
 		}
115 115
 
116
-		if ( 'invoice_id' == $field ) {
116
+		if ('invoice_id' == $field) {
117 117
 			$field = 'parent_payment_id';
118 118
 		}
119 119
 
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 		);
126 126
 
127 127
 		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
128
+		if (empty($field) || !in_array($field, $fields)) {
129 129
 			return 0;
130 130
 		}
131 131
 
132 132
 		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
133
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
134
+		if (!empty($subscription_id)) {
135 135
 			return $subscription_id;
136 136
 		}
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
140 140
         $subscription_id  = (int) $wpdb->get_var(
141
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
141
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
144
+		if (empty($subscription_id)) {
145 145
 			return 0;
146 146
 		}
147 147
 
148 148
 		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
149
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
150 150
 
151 151
 		return $subscription_id;
152 152
 	}
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
158
+		wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids');
159
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids');
160
+		wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids');
161
+		wp_cache_delete($this->get_id(), 'getpaid_subscriptions');
162 162
 	}
163 163
 
164 164
 	/**
165 165
      * Checks if a subscription key is set.
166 166
      */
167
-    public function _isset( $key ) {
168
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
167
+    public function _isset($key) {
168
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
169 169
 	}
170 170
 
171 171
 	/*
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 * @param  string $context View or edit context.
191 191
 	 * @return int
192 192
 	 */
193
-	public function get_customer_id( $context = 'view' ) {
194
-		return (int) $this->get_prop( 'customer_id', $context );
193
+	public function get_customer_id($context = 'view') {
194
+		return (int) $this->get_prop('customer_id', $context);
195 195
 	}
196 196
 
197 197
 	/**
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	 * @param  string $context View or edit context.
202 202
 	 * @return WP_User|false WP_User object on success, false on failure.
203 203
 	 */
204
-	public function get_customer( $context = 'view' ) {
205
-		return get_userdata( $this->get_customer_id( $context ) );
204
+	public function get_customer($context = 'view') {
205
+		return get_userdata($this->get_customer_id($context));
206 206
 	}
207 207
 
208 208
 	/**
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 * @param  string $context View or edit context.
213 213
 	 * @return int
214 214
 	 */
215
-	public function get_parent_invoice_id( $context = 'view' ) {
216
-		return (int) $this->get_prop( 'parent_payment_id', $context );
215
+	public function get_parent_invoice_id($context = 'view') {
216
+		return (int) $this->get_prop('parent_payment_id', $context);
217 217
 	}
218 218
 
219 219
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param  string $context View or edit context.
224 224
 	 * @return int
225 225
 	 */
226
-    public function get_parent_payment_id( $context = 'view' ) {
227
-        return $this->get_parent_invoice_id( $context );
226
+    public function get_parent_payment_id($context = 'view') {
227
+        return $this->get_parent_invoice_id($context);
228 228
 	}
229 229
 
230 230
 	/**
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
      * @since  1.0.0
234 234
      * @return int
235 235
      */
236
-    public function get_original_payment_id( $context = 'view' ) {
237
-        return $this->get_parent_invoice_id( $context );
236
+    public function get_original_payment_id($context = 'view') {
237
+        return $this->get_parent_invoice_id($context);
238 238
     }
239 239
 
240 240
 	/**
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 * @param  string $context View or edit context.
245 245
 	 * @return WPInv_Invoice
246 246
 	 */
247
-	public function get_parent_invoice( $context = 'view' ) {
248
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
247
+	public function get_parent_invoice($context = 'view') {
248
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
249 249
 	}
250 250
 
251 251
 	/**
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @param  string $context View or edit context.
256 256
 	 * @return WPInv_Invoice
257 257
 	 */
258
-    public function get_parent_payment( $context = 'view' ) {
259
-        return $this->get_parent_invoice( $context );
258
+    public function get_parent_payment($context = 'view') {
259
+        return $this->get_parent_invoice($context);
260 260
 	}
261 261
 
262 262
 	/**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @param  string $context View or edit context.
267 267
 	 * @return int
268 268
 	 */
269
-	public function get_product_id( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'product_id', $context );
269
+	public function get_product_id($context = 'view') {
270
+		return (int) $this->get_prop('product_id', $context);
271 271
 	}
272 272
 
273 273
 	/**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param  string $context View or edit context.
278 278
 	 * @return WPInv_Item
279 279
 	 */
280
-	public function get_product( $context = 'view' ) {
281
-		return new WPInv_Item( $this->get_product_id( $context ) );
280
+	public function get_product($context = 'view') {
281
+		return new WPInv_Item($this->get_product_id($context));
282 282
 	}
283 283
 
284 284
 	/**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @param  string $context View or edit context.
291 291
 	 * @return string
292 292
 	 */
293
-	public function get_gateway( $context = 'view' ) {
294
-		return $this->get_parent_invoice( $context )->get_gateway();
293
+	public function get_gateway($context = 'view') {
294
+		return $this->get_parent_invoice($context)->get_gateway();
295 295
 	}
296 296
 
297 297
 	/**
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 	 * @param  string $context View or edit context.
302 302
 	 * @return string
303 303
 	 */
304
-	public function get_period( $context = 'view' ) {
305
-		return $this->get_prop( 'period', $context );
304
+	public function get_period($context = 'view') {
305
+		return $this->get_prop('period', $context);
306 306
 	}
307 307
 
308 308
 	/**
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	 * @param  string $context View or edit context.
313 313
 	 * @return int
314 314
 	 */
315
-	public function get_frequency( $context = 'view' ) {
316
-		return (int) $this->get_prop( 'frequency', $context );
315
+	public function get_frequency($context = 'view') {
316
+		return (int) $this->get_prop('frequency', $context);
317 317
 	}
318 318
 
319 319
 	/**
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 	 * @param  string $context View or edit context.
324 324
 	 * @return float
325 325
 	 */
326
-	public function get_initial_amount( $context = 'view' ) {
327
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
326
+	public function get_initial_amount($context = 'view') {
327
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
328 328
 	}
329 329
 
330 330
 	/**
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 	 * @param  string $context View or edit context.
335 335
 	 * @return float
336 336
 	 */
337
-	public function get_recurring_amount( $context = 'view' ) {
338
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
337
+	public function get_recurring_amount($context = 'view') {
338
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
339 339
 	}
340 340
 
341 341
 	/**
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @param  string $context View or edit context.
346 346
 	 * @return int
347 347
 	 */
348
-	public function get_bill_times( $context = 'view' ) {
349
-		return (int) $this->get_prop( 'bill_times', $context );
348
+	public function get_bill_times($context = 'view') {
349
+		return (int) $this->get_prop('bill_times', $context);
350 350
 	}
351 351
 
352 352
 	/**
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param  string $context View or edit context.
357 357
 	 * @return string
358 358
 	 */
359
-	public function get_transaction_id( $context = 'view' ) {
360
-		return $this->get_prop( 'transaction_id', $context );
359
+	public function get_transaction_id($context = 'view') {
360
+		return $this->get_prop('transaction_id', $context);
361 361
 	}
362 362
 
363 363
 	/**
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 * @param  string $context View or edit context.
368 368
 	 * @return string
369 369
 	 */
370
-	public function get_created( $context = 'view' ) {
371
-		return $this->get_prop( 'created', $context );
370
+	public function get_created($context = 'view') {
371
+		return $this->get_prop('created', $context);
372 372
 	}
373 373
 
374 374
 	/**
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param  string $context View or edit context.
379 379
 	 * @return string
380 380
 	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_created( $context );
381
+	public function get_date_created($context = 'view') {
382
+		return $this->get_created($context);
383 383
 	}
384 384
 
385 385
 	/**
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	public function get_time_created() {
392 392
 		$created = $this->get_date_created();
393
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
393
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
394 394
 	}
395 395
 
396 396
 	/**
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
404
-        $date = $this->get_date_created( $context );
403
+	public function get_date_created_gmt($context = 'view') {
404
+        $date = $this->get_date_created($context);
405 405
 
406
-        if ( $date ) {
407
-            $date = get_gmt_from_date( $date );
406
+        if ($date) {
407
+            $date = get_gmt_from_date($date);
408 408
         }
409 409
 		return $date;
410 410
 	}
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return string
418 418
 	 */
419
-	public function get_next_renewal_date( $context = 'view' ) {
420
-		return $this->get_prop( 'expiration', $context );
419
+	public function get_next_renewal_date($context = 'view') {
420
+		return $this->get_prop('expiration', $context);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param  string $context View or edit context.
428 428
 	 * @return string
429 429
 	 */
430
-	public function get_expiration( $context = 'view' ) {
431
-		return $this->get_next_renewal_date( $context );
430
+	public function get_expiration($context = 'view') {
431
+		return $this->get_next_renewal_date($context);
432 432
 	}
433 433
 
434 434
 	/**
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	public function get_expiration_time() {
441 441
 		$expiration = $this->get_expiration();
442 442
 
443
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
-			return current_time( 'timestamp' );
443
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
444
+			return current_time('timestamp');
445 445
 		}
446 446
 
447
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
447
+		$expiration = strtotime($expiration, current_time('timestamp'));
448
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
449 449
 	}
450 450
 
451 451
 	/**
@@ -455,11 +455,11 @@  discard block
 block discarded – undo
455 455
 	 * @param  string $context View or edit context.
456 456
 	 * @return string
457 457
 	 */
458
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
459
-        $date = $this->get_next_renewal_date( $context );
458
+	public function get_next_renewal_date_gmt($context = 'view') {
459
+        $date = $this->get_next_renewal_date($context);
460 460
 
461
-        if ( $date ) {
462
-            $date = get_gmt_from_date( $date );
461
+        if ($date) {
462
+            $date = get_gmt_from_date($date);
463 463
         }
464 464
 		return $date;
465 465
 	}
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 	 * @param  string $context View or edit context.
472 472
 	 * @return string
473 473
 	 */
474
-	public function get_trial_period( $context = 'view' ) {
475
-		return $this->get_prop( 'trial_period', $context );
474
+	public function get_trial_period($context = 'view') {
475
+		return $this->get_prop('trial_period', $context);
476 476
 	}
477 477
 
478 478
 	/**
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @param  string $context View or edit context.
483 483
 	 * @return string
484 484
 	 */
485
-	public function get_status( $context = 'view' ) {
486
-		return $this->get_prop( 'status', $context );
485
+	public function get_status($context = 'view') {
486
+		return $this->get_prop('status', $context);
487 487
 	}
488 488
 
489 489
 	/**
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 * @param  string $context View or edit context.
494 494
 	 * @return string
495 495
 	 */
496
-	public function get_profile_id( $context = 'view' ) {
497
-		return $this->get_prop( 'profile_id', $context );
496
+	public function get_profile_id($context = 'view') {
497
+		return $this->get_prop('profile_id', $context);
498 498
 	}
499 499
 
500 500
 	/*
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 	 * @since 1.0.19
510 510
 	 * @param  int $value The customer's id.
511 511
 	 */
512
-	public function set_customer_id( $value ) {
513
-		$this->set_prop( 'customer_id', (int) $value );
512
+	public function set_customer_id($value) {
513
+		$this->set_prop('customer_id', (int) $value);
514 514
 	}
515 515
 
516 516
 	/**
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 	 * @since 1.0.19
520 520
 	 * @param  int $value The parent invoice id.
521 521
 	 */
522
-	public function set_parent_invoice_id( $value ) {
523
-		$this->set_prop( 'parent_payment_id', (int) $value );
522
+	public function set_parent_invoice_id($value) {
523
+		$this->set_prop('parent_payment_id', (int) $value);
524 524
 	}
525 525
 
526 526
 	/**
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	 * @since 1.0.19
530 530
 	 * @param  int $value The parent invoice id.
531 531
 	 */
532
-    public function set_parent_payment_id( $value ) {
533
-        $this->set_parent_invoice_id( $value );
532
+    public function set_parent_payment_id($value) {
533
+        $this->set_parent_invoice_id($value);
534 534
 	}
535 535
 
536 536
 	/**
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
      * @since 1.0.19
540 540
 	 * @param  int $value The parent invoice id.
541 541
      */
542
-    public function set_original_payment_id( $value ) {
543
-        $this->set_parent_invoice_id( $value );
542
+    public function set_original_payment_id($value) {
543
+        $this->set_parent_invoice_id($value);
544 544
 	}
545 545
 
546 546
 	/**
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 * @since 1.0.19
550 550
 	 * @param  int $value The subscription product id.
551 551
 	 */
552
-	public function set_product_id( $value ) {
553
-		$this->set_prop( 'product_id', (int) $value );
552
+	public function set_product_id($value) {
553
+		$this->set_prop('product_id', (int) $value);
554 554
 	}
555 555
 
556 556
 	/**
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	 * @since 1.0.19
560 560
 	 * @param  string $value The renewal period.
561 561
 	 */
562
-	public function set_period( $value ) {
563
-		$this->set_prop( 'period', $value );
562
+	public function set_period($value) {
563
+		$this->set_prop('period', $value);
564 564
 	}
565 565
 
566 566
 	/**
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 	 * @since 1.0.19
570 570
 	 * @param  int $value The subscription frequency.
571 571
 	 */
572
-	public function set_frequency( $value ) {
573
-		$value = empty( $value ) ? 1 : (int) $value;
574
-		$this->set_prop( 'frequency', absint( $value ) );
572
+	public function set_frequency($value) {
573
+		$value = empty($value) ? 1 : (int) $value;
574
+		$this->set_prop('frequency', absint($value));
575 575
 	}
576 576
 
577 577
 	/**
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @since 1.0.19
581 581
 	 * @param  float $value The initial subcription amount.
582 582
 	 */
583
-	public function set_initial_amount( $value ) {
584
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
583
+	public function set_initial_amount($value) {
584
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
585 585
 	}
586 586
 
587 587
 	/**
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @since 1.0.19
591 591
 	 * @param  float $value The recurring subcription amount.
592 592
 	 */
593
-	public function set_recurring_amount( $value ) {
594
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
593
+	public function set_recurring_amount($value) {
594
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
595 595
 	}
596 596
 
597 597
 	/**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @since 1.0.19
601 601
 	 * @param  int $value Bill times.
602 602
 	 */
603
-	public function set_bill_times( $value ) {
604
-		$this->set_prop( 'bill_times', (int) $value );
603
+	public function set_bill_times($value) {
604
+		$this->set_prop('bill_times', (int) $value);
605 605
 	}
606 606
 
607 607
 	/**
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param string $value Bill times.
612 612
 	 */
613
-	public function set_transaction_id( $value ) {
614
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
613
+	public function set_transaction_id($value) {
614
+		$this->set_prop('transaction_id', sanitize_text_field($value));
615 615
 	}
616 616
 
617 617
 	/**
@@ -620,15 +620,15 @@  discard block
 block discarded – undo
620 620
 	 * @since 1.0.19
621 621
 	 * @param string $value strtotime compliant date.
622 622
 	 */
623
-	public function set_created( $value ) {
624
-        $date = strtotime( $value );
623
+	public function set_created($value) {
624
+        $date = strtotime($value);
625 625
 
626
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
626
+        if ($date && $value !== '0000-00-00 00:00:00') {
627
+            $this->set_prop('created', date('Y-m-d H:i:s', $date));
628 628
             return;
629 629
         }
630 630
 
631
-		$this->set_prop( 'created', '' );
631
+		$this->set_prop('created', '');
632 632
 
633 633
 	}
634 634
 
@@ -638,8 +638,8 @@  discard block
 block discarded – undo
638 638
 	 * @since 1.0.19
639 639
 	 * @param string $value strtotime compliant date.
640 640
 	 */
641
-	public function set_date_created( $value ) {
642
-		$this->set_created( $value );
641
+	public function set_date_created($value) {
642
+		$this->set_created($value);
643 643
     }
644 644
 
645 645
 	/**
@@ -648,15 +648,15 @@  discard block
 block discarded – undo
648 648
 	 * @since 1.0.19
649 649
 	 * @param string $value strtotime compliant date.
650 650
 	 */
651
-	public function set_next_renewal_date( $value ) {
652
-		$date = strtotime( $value );
651
+	public function set_next_renewal_date($value) {
652
+		$date = strtotime($value);
653 653
 
654
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
654
+        if ($date && $value !== '0000-00-00 00:00:00') {
655
+            $this->set_prop('expiration', date('Y-m-d H:i:s', $date));
656 656
             return;
657 657
 		}
658 658
 
659
-		$this->set_prop( 'expiration', '' );
659
+		$this->set_prop('expiration', '');
660 660
 
661 661
 	}
662 662
 
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
 	 * @since 1.0.19
667 667
 	 * @param string $value strtotime compliant date.
668 668
 	 */
669
-	public function set_expiration( $value ) {
670
-		$this->set_next_renewal_date( $value );
669
+	public function set_expiration($value) {
670
+		$this->set_next_renewal_date($value);
671 671
     }
672 672
 
673 673
 	/**
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
 	 * @since 1.0.19
677 677
 	 * @param string $value trial period e.g 1 year.
678 678
 	 */
679
-	public function set_trial_period( $value ) {
680
-		$this->set_prop( 'trial_period', $value );
679
+	public function set_trial_period($value) {
680
+		$this->set_prop('trial_period', $value);
681 681
 	}
682 682
 
683 683
 	/**
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 	 * @since 1.0.19
687 687
 	 * @param string $new_status    New subscription status.
688 688
 	 */
689
-	public function set_status( $new_status ) {
689
+	public function set_status($new_status) {
690 690
 
691 691
 		// Abort if this is not a valid status;
692
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
692
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
693 693
 			return;
694 694
 		}
695 695
 
696
-		$this->set_prop( 'status', $new_status );
696
+		$this->set_prop('status', $new_status);
697 697
 
698
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
699
-		if ( true === $this->object_read && $old_status !== $new_status ) {
698
+		$old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status();
699
+		if (true === $this->object_read && $old_status !== $new_status) {
700 700
 			$this->status_transition = array(
701 701
 				'from'   => $old_status,
702 702
 				'to'     => $new_status,
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 	 * @since 1.0.19
712 712
 	 * @param  string $value the remote profile id.
713 713
 	 */
714
-	public function set_profile_id( $value ) {
715
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
714
+	public function set_profile_id($value) {
715
+		$this->set_prop('profile_id', sanitize_text_field($value));
716 716
 	}
717 717
 
718 718
 	/*
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param string|array String or array of strings to check for.
731 731
 	 * @return bool
732 732
      */
733
-    public function has_status( $status ) {
734
-        return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
733
+    public function has_status($status) {
734
+        return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status)));
735 735
 	}
736 736
 
737 737
 	/**
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
      */
742 742
     public function has_trial_period() {
743 743
 		$period = $this->get_trial_period();
744
-        return ! empty( $period );
744
+        return !empty($period);
745 745
 	}
746 746
 
747 747
 	/**
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	 * @return bool
751 751
 	 */
752 752
 	public function is_active() {
753
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
753
+		return $this->has_status('active trialling') && !$this->is_expired();
754 754
 	}
755 755
 
756 756
 	/**
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 * @return bool
760 760
 	 */
761 761
 	public function is_expired() {
762
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
762
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql'));
763 763
 	}
764 764
 
765 765
 	/**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 */
770 770
 	public function is_last_renewal() {
771 771
 		$max_bills = $this->get_bill_times();
772
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
772
+		return !empty($max_bills) && $max_bills <= $this->get_times_billed();
773 773
 	}
774 774
 
775 775
 	/*
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 	/**
785 785
 	 * Backwards compatibilty.
786 786
 	 */
787
-	public function create( $data = array() ) {
787
+	public function create($data = array()) {
788 788
 
789 789
 		// Set the properties.
790
-		if ( is_array( $data ) ) {
791
-			$this->set_props( $data );
790
+		if (is_array($data)) {
791
+			$this->set_props($data);
792 792
 		}
793 793
 
794 794
 		// Save the item.
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	/**
800 800
 	 * Backwards compatibilty.
801 801
 	 */
802
-	public function update( $args = array() ) {
803
-		return $this->create( $args );
802
+	public function update($args = array()) {
803
+		return $this->create($args);
804 804
 	}
805 805
 
806 806
     /**
@@ -809,12 +809,12 @@  discard block
 block discarded – undo
809 809
      * @since  1.0.0
810 810
      * @return WP_Post[]
811 811
      */
812
-    public function get_child_payments( $hide_pending = true ) {
812
+    public function get_child_payments($hide_pending = true) {
813 813
 
814
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
814
+		$statuses = array('publish', 'wpi-processing', 'wpi-renewal');
815 815
 
816
-		if ( ! $hide_pending ) {
817
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
816
+		if (!$hide_pending) {
817
+			$statuses = array_keys(wpinv_get_invoice_statuses());
818 818
 		}
819 819
 
820 820
         return get_posts(
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
      * @return int
837 837
      */
838 838
     public function get_total_payments() {
839
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
839
+		return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id());
840 840
     }
841 841
 
842 842
     /**
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
     public function get_times_billed() {
849 849
         $times_billed = $this->get_total_payments();
850 850
 
851
-        if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) {
851
+        if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) {
852 852
             $times_billed--;
853 853
         }
854 854
 
@@ -863,49 +863,49 @@  discard block
 block discarded – undo
863 863
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
864 864
      * @return bool
865 865
      */
866
-    public function add_payment( $args = array(), $invoice = false ) {
866
+    public function add_payment($args = array(), $invoice = false) {
867 867
 
868 868
 		// Process each payment once.
869
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
869
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
870 870
             return false;
871 871
         }
872 872
 
873 873
 		// Are we creating a new invoice?
874
-		if ( empty( $invoice ) ) {
874
+		if (empty($invoice)) {
875 875
 			$invoice = $this->create_payment();
876 876
 
877
-			if ( empty( $invoice ) ) {
877
+			if (empty($invoice)) {
878 878
 				return false;
879 879
 			}
880 880
 
881 881
 		}
882 882
 
883
-		$invoice->set_status( 'wpi-renewal' );
883
+		$invoice->set_status('wpi-renewal');
884 884
 
885 885
 		// Maybe set a transaction id.
886
-		if ( ! empty( $args['transaction_id'] ) ) {
887
-			$invoice->set_transaction_id( $args['transaction_id'] );
886
+		if (!empty($args['transaction_id'])) {
887
+			$invoice->set_transaction_id($args['transaction_id']);
888 888
 		}
889 889
 
890 890
 		// Set the completed date.
891
-		$invoice->set_completed_date( current_time( 'mysql' ) );
891
+		$invoice->set_completed_date(current_time('mysql'));
892 892
 
893 893
 		// And the gateway.
894
-		if ( ! empty( $args['gateway'] ) ) {
895
-			$invoice->set_gateway( $args['gateway'] );
894
+		if (!empty($args['gateway'])) {
895
+			$invoice->set_gateway($args['gateway']);
896 896
 		}
897 897
 
898 898
 		$invoice->save();
899 899
 
900
-		if ( ! $invoice->exists() ) {
900
+		if (!$invoice->exists()) {
901 901
 			return false;
902 902
 		}
903 903
 
904
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
906
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
904
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
905
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
906
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
907 907
 
908
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
908
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
909 909
 
910 910
         return $invoice->get_id();
911 911
 	}
@@ -920,41 +920,41 @@  discard block
 block discarded – undo
920 920
 
921 921
 		$parent_invoice = $this->get_parent_payment();
922 922
 
923
-		if ( ! $parent_invoice->exists() ) {
923
+		if (!$parent_invoice->exists()) {
924 924
 			return false;
925 925
 		}
926 926
 
927 927
 		// Duplicate the parent invoice.
928
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
929
-		$invoice->set_parent_id( $parent_invoice->get_id() );
930
-		$invoice->set_subscription_id( $this->get_id() );
931
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
928
+		$invoice = getpaid_duplicate_invoice($parent_invoice);
929
+		$invoice->set_parent_id($parent_invoice->get_id());
930
+		$invoice->set_subscription_id($this->get_id());
931
+		$invoice->set_remote_subscription_id($this->get_profile_id());
932 932
 
933 933
 		// Set invoice items.
934
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
934
+		$subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id());
935
+		$allowed_items      = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']);
936 936
 		$invoice_items      = array();
937 937
 
938
-		foreach ( $invoice->get_items() as $item ) {
939
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
938
+		foreach ($invoice->get_items() as $item) {
939
+			if (in_array($item->get_id(), $allowed_items)) {
940 940
 				$invoice_items[] = $item;
941 941
 			}
942 942
 		}
943 943
 
944
-		$invoice->set_items( $invoice_items );
944
+		$invoice->set_items($invoice_items);
945 945
 
946
-		if ( ! empty( $subscription_group['fees'] ) ) {
947
-			$invoice->set_fees( $subscription_group['fees'] );
946
+		if (!empty($subscription_group['fees'])) {
947
+			$invoice->set_fees($subscription_group['fees']);
948 948
 		}
949 949
 
950 950
 		// Maybe recalculate discount (Pre-GetPaid Fix).
951
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
952
-		if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
951
+		$discount = new WPInv_Discount($invoice->get_discount_code());
952
+		if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) {
953
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
954 954
 		}
955 955
 
956 956
 		$invoice->recalculate_total();
957
-		$invoice->set_status( 'wpi-pending' );
957
+		$invoice->set_status('wpi-pending');
958 958
 		$invoice->save();
959 959
 
960 960
 		return $invoice->exists() ? $invoice : false;
@@ -969,20 +969,20 @@  discard block
 block discarded – undo
969 969
 	public function renew() {
970 970
 
971 971
 		// Complete subscription if applicable
972
-		if ( $this->is_last_renewal() ) {
972
+		if ($this->is_last_renewal()) {
973 973
 			return $this->complete();
974 974
 		}
975 975
 
976 976
 		// Calculate new expiration
977 977
 		$frequency      = $this->get_frequency();
978 978
 		$period         = $this->get_period();
979
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
979
+		$new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time());
980 980
 
981
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
-		$this->set_status( 'active' );
981
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
982
+		$this->set_status('active');
983 983
 		$this->save();
984 984
 
985
-		do_action( 'getpaid_subscription_renewed', $this );
985
+		do_action('getpaid_subscription_renewed', $this);
986 986
 
987 987
 		return $this->get_id();
988 988
 	}
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
 	public function complete() {
999 999
 
1000 1000
 		// Only mark a subscription as complete if it's not already cancelled.
1001
-		if ( $this->has_status( 'cancelled' ) ) {
1001
+		if ($this->has_status('cancelled')) {
1002 1002
 			return false;
1003 1003
 		}
1004 1004
 
1005
-		$this->set_status( 'completed' );
1005
+		$this->set_status('completed');
1006 1006
 		return $this->save();
1007 1007
 
1008 1008
 	}
@@ -1014,14 +1014,14 @@  discard block
 block discarded – undo
1014 1014
 	 * @param  bool $check_expiration
1015 1015
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016 1016
 	 */
1017
-	public function expire( $check_expiration = false ) {
1017
+	public function expire($check_expiration = false) {
1018 1018
 
1019
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1019
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
1020 1020
 			// Do not mark as expired since real expiration date is in the future
1021 1021
 			return false;
1022 1022
 		}
1023 1023
 
1024
-		$this->set_status( 'expired' );
1024
+		$this->set_status('expired');
1025 1025
 		return $this->save();
1026 1026
 
1027 1027
 	}
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	 * @return int Subscription id.
1034 1034
 	 */
1035 1035
 	public function failing() {
1036
-		$this->set_status( 'failing' );
1036
+		$this->set_status('failing');
1037 1037
 		return $this->save();
1038 1038
 	}
1039 1039
 
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      * @return int Subscription id.
1045 1045
      */
1046 1046
     public function cancel() {
1047
-		$this->set_status( 'cancelled' );
1047
+		$this->set_status('cancelled');
1048 1048
 		return $this->save();
1049 1049
     }
1050 1050
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	 * @return bool
1056 1056
 	 */
1057 1057
 	public function can_cancel() {
1058
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1058
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1059 1059
 	}
1060 1060
 
1061 1061
     /**
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
      * @return      array
1067 1067
      */
1068 1068
     public function get_cancellable_statuses() {
1069
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1069
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1070 1070
     }
1071 1071
 
1072 1072
 	/**
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 	 * @return string
1077 1077
 	 */
1078 1078
 	public function get_cancel_url() {
1079
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1079
+		$url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url());
1080
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1081 1081
 	}
1082 1082
 
1083 1083
 	/**
@@ -1088,10 +1088,10 @@  discard block
 block discarded – undo
1088 1088
 	 */
1089 1089
 	public function get_view_url() {
1090 1090
 
1091
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1091
+		$url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')));
1092
+		$url = add_query_arg('subscription', $this->get_id(), $url);
1093 1093
 
1094
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1094
+		return apply_filters('getpaid_get_subscription_view_url', $url, $this);
1095 1095
 	}
1096 1096
 
1097 1097
 	/**
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	 * @return bool
1105 1105
 	 */
1106 1106
 	public function can_renew() {
1107
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1107
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1108 1108
 	}
1109 1109
 
1110 1110
 	/**
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 	 * @return string
1115 1115
 	 */
1116 1116
 	public function get_renew_url() {
1117
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1117
+		$url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce');
1118
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1119 1119
 	}
1120 1120
 
1121 1121
 	/**
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 	 * @return bool
1126 1126
 	 */
1127 1127
 	public function can_update() {
1128
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1128
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1129 1129
 	}
1130 1130
 
1131 1131
 	/**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @return string
1136 1136
 	 */
1137 1137
 	public function get_update_url() {
1138
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1138
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id()));
1139
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1140 1140
 	}
1141 1141
 
1142 1142
 	/**
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 	 * @return string
1147 1147
 	 */
1148 1148
 	public function get_status_label() {
1149
-		return getpaid_get_subscription_status_label( $this->get_status() );
1149
+		return getpaid_get_subscription_status_label($this->get_status());
1150 1150
 	}
1151 1151
 
1152 1152
 	/**
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	public function get_status_class() {
1159 1159
 		$statuses = getpaid_get_subscription_status_classes();
1160
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1160
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
1161 1161
 	}
1162 1162
 
1163 1163
     /**
@@ -1168,9 +1168,9 @@  discard block
 block discarded – undo
1168 1168
      */
1169 1169
     public function get_status_label_html() {
1170 1170
 
1171
-		$status_label = sanitize_text_field( $this->get_status_label() );
1172
-		$class        = esc_attr( $this->get_status_class() );
1173
-		$status       = sanitize_html_class( $this->get_status() );
1171
+		$status_label = sanitize_text_field($this->get_status_label());
1172
+		$class        = esc_attr($this->get_status_class());
1173
+		$status       = sanitize_html_class($this->get_status());
1174 1174
 
1175 1175
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1176 1176
     }
@@ -1182,9 +1182,9 @@  discard block
 block discarded – undo
1182 1182
      * @param  string $txn_id The transaction ID from the merchant processor
1183 1183
      * @return bool
1184 1184
      */
1185
-    public function payment_exists( $txn_id = '' ) {
1186
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1187
-        return ! empty( $invoice_id );
1185
+    public function payment_exists($txn_id = '') {
1186
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1187
+        return !empty($invoice_id);
1188 1188
 	}
1189 1189
 
1190 1190
 	/**
@@ -1196,35 +1196,35 @@  discard block
 block discarded – undo
1196 1196
 		// Reset status transition variable.
1197 1197
 		$this->status_transition = false;
1198 1198
 
1199
-		if ( $status_transition ) {
1199
+		if ($status_transition) {
1200 1200
 			try {
1201 1201
 
1202 1202
 				// Fire a hook for the status change.
1203
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1203
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1204
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1205 1205
 
1206
-				if ( ! empty( $status_transition['from'] ) ) {
1206
+				if (!empty($status_transition['from'])) {
1207 1207
 
1208 1208
 					/* translators: 1: old subscription status 2: new subscription status */
1209
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1209
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1210 1210
 
1211 1211
 					// Note the transition occurred.
1212
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1212
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1213 1213
 
1214 1214
 					// Fire another hook.
1215
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1215
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1216
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1217 1217
 
1218 1218
 				} else {
1219 1219
 					/* translators: %s: new invoice status */
1220
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1220
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1221 1221
 
1222 1222
 					// Note the transition occurred.
1223
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1223
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1224 1224
 
1225 1225
 				}
1226
-			} catch ( Exception $e ) {
1227
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1226
+			} catch (Exception $e) {
1227
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1228 1228
 			}
1229 1229
 		}
1230 1230
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 	 */
1251 1251
 	public function activate() {
1252 1252
 		$status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
-		$this->set_status( $status );
1253
+		$this->set_status($status);
1254 1254
 		return $this->save();
1255 1255
 	}
1256 1256
 
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
23
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
23
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
24 24
     }
25 25
 
26 26
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function set_admin_menu_class() {
30 30
 		global $current_screen, $parent_file, $submenu_file;
31 31
 
32
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
32
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
33 33
 			$parent_file = 'wpinv';
34 34
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
35 35
         }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function admin_menu() {
40 40
 
41
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
41
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
42 42
         add_menu_page(
43
-            __( 'GetPaid', 'invoicing' ),
44
-            __( 'GetPaid', 'invoicing' ),
43
+            __('GetPaid', 'invoicing'),
44
+            __('GetPaid', 'invoicing'),
45 45
             $capability,
46 46
             'wpinv',
47 47
             null,
48
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
48
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
49 49
             '54.123460'
50 50
         );
51 51
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     public function add_customers_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Customers', 'invoicing' ),
61
-            __( 'Customers', 'invoicing' ),
60
+            __('Customers', 'invoicing'),
61
+            __('Customers', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-customers',
64
-            array( $this, 'customers_page' )
64
+            array($this, 'customers_page')
65 65
         );
66 66
     }
67 67
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     public function add_subscriptions_menu() {
72 72
         add_submenu_page(
73 73
             'wpinv',
74
-            __( 'Subscriptions', 'invoicing' ),
75
-            __( 'Subscriptions', 'invoicing' ),
74
+            __('Subscriptions', 'invoicing'),
75
+            __('Subscriptions', 'invoicing'),
76 76
             wpinv_get_capability(),
77 77
             'wpinv-subscriptions',
78 78
             'wpinv_subscriptions_page'
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * Displays the customers page.
84 84
      */
85 85
     public function customers_page() {
86
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
86
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
87 87
         ?>
88 88
         <div class="wrap wpi-customers-wrap">
89 89
             <style>
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
                     width: 30%;
92 92
                 }
93 93
             </style>
94
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ); ?>" class="page-title-action"><?php _e( 'Export', 'invoicing' ); ?></a></h1>
94
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce'); ?>" class="page-title-action"><?php _e('Export', 'invoicing'); ?></a></h1>
95 95
             <form method="post">
96 96
             <?php
97 97
                 $table = new WPInv_Customers_Table();
98 98
                 $table->prepare_items();
99
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
99
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
100 100
                 $table->display();
101 101
             ?>
102 102
             </form>
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
     public function add_settings_menu() {
111 111
         add_submenu_page(
112 112
             'wpinv',
113
-            __( 'Invoice Settings', 'invoicing' ),
114
-            __( 'Settings', 'invoicing' ),
115
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
113
+            __('Invoice Settings', 'invoicing'),
114
+            __('Settings', 'invoicing'),
115
+            apply_filters('invoicing_capability', wpinv_get_capability()),
116 116
             'wpinv-settings',
117
-            array( $this, 'options_page' )
117
+            array($this, 'options_page')
118 118
         );
119 119
     }
120 120
 
121
-    public function add_addons_menu(){
122
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
121
+    public function add_addons_menu() {
122
+        if (!apply_filters('wpi_show_addons_page', true)) {
123 123
             return;
124 124
         }
125 125
 
@@ -129,80 +129,80 @@  discard block
 block discarded – undo
129 129
             __('Extensions', 'invoicing'),
130 130
             'manage_options',
131 131
             'wpi-addons',
132
-            array( $this, 'addons_page' )
132
+            array($this, 'addons_page')
133 133
         );
134 134
     }
135 135
 
136
-    public function addons_page(){
136
+    public function addons_page() {
137 137
         $addon_obj = new WPInv_Admin_Addons();
138 138
         $addon_obj->output();
139 139
     }
140 140
 
141 141
     function options_page() {
142
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
142
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
143 143
 
144
-        if ( $page !== 'wpinv-settings' ) {
144
+        if ($page !== 'wpinv-settings') {
145 145
             return;
146 146
         }
147 147
 
148 148
         $settings_tabs = wpinv_get_settings_tabs();
149 149
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
150
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
151
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
150
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
151
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
152 152
         $key           = 'main';
153 153
 
154
-        if ( is_array( $sections ) ) {
155
-            $key = key( $sections );
154
+        if (is_array($sections)) {
155
+            $key = key($sections);
156 156
         }
157 157
 
158 158
         add_thickbox();
159 159
 
160
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
161
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
160
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
161
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
162 162
         ob_start();
163 163
         ?>
164 164
         <div class="wrap">
165 165
             <h1 class="nav-tab-wrapper">
166 166
                 <?php
167
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
168
-                    $tab_url = add_query_arg( array(
167
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
168
+                    $tab_url = add_query_arg(array(
169 169
                         'settings-updated' => false,
170 170
                         'tab' => $tab_id,
171
-                    ) );
171
+                    ));
172 172
 
173 173
                     // Remove the section from the tabs so we always end up at the main section
174
-                    $tab_url = remove_query_arg( 'section', $tab_url );
175
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
174
+                    $tab_url = remove_query_arg('section', $tab_url);
175
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
176 176
 
177 177
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
178 178
 
179
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
180
-                    echo esc_html( $tab_name );
179
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
180
+                    echo esc_html($tab_name);
181 181
                     echo '</a>';
182 182
                 }
183 183
                 ?>
184 184
             </h1>
185 185
             <?php
186
-            $number_of_sections = count( $sections );
186
+            $number_of_sections = count($sections);
187 187
             $number = 0;
188
-            if ( $number_of_sections > 1 ) {
188
+            if ($number_of_sections > 1) {
189 189
                 echo '<div><ul class="subsubsub">';
190
-                foreach( $sections as $section_id => $section_name ) {
190
+                foreach ($sections as $section_id => $section_name) {
191 191
                     echo '<li>';
192 192
                     $number++;
193
-                    $tab_url = add_query_arg( array(
193
+                    $tab_url = add_query_arg(array(
194 194
                         'settings-updated' => false,
195 195
                         'tab' => $active_tab,
196 196
                         'section' => $section_id
197
-                    ) );
198
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
197
+                    ));
198
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
199 199
                     $class = '';
200
-                    if ( $section == $section_id ) {
200
+                    if ($section == $section_id) {
201 201
                         $class = 'current';
202 202
                     }
203
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
203
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
204 204
 
205
-                    if ( $number != $number_of_sections ) {
205
+                    if ($number != $number_of_sections) {
206 206
                         echo ' | ';
207 207
                     }
208 208
                     echo '</li>';
@@ -214,20 +214,20 @@  discard block
 block discarded – undo
214 214
                 <form method="post" action="options.php">
215 215
                     <table class="form-table">
216 216
                         <?php
217
-                        settings_fields( 'wpinv_settings' );
217
+                        settings_fields('wpinv_settings');
218 218
 
219
-                        if ( 'main' === $section ) {
220
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
219
+                        if ('main' === $section) {
220
+                            do_action('wpinv_settings_tab_top', $active_tab);
221 221
                         }
222 222
 
223
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
224
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
225
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
226
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
223
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
224
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
225
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
226
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
227 227
 
228 228
                         // For backwards compatibility
229
-                        if ( 'main' === $section ) {
230
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
229
+                        if ('main' === $section) {
230
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
231 231
                         }
232 232
                         ?>
233 233
                     </table>
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     }
242 242
 
243 243
     public function remove_admin_submenus() {
244
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
244
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
245 245
     }
246 246
 
247 247
     /**
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 
252 252
         add_meta_box(
253 253
             'wpinv_endpoints_nav_link',
254
-            __( 'GetPaid endpoints', 'invoicing' ),
255
-            array( $this, 'nav_menu_links' ),
254
+            __('GetPaid endpoints', 'invoicing'),
255
+            array($this, 'nav_menu_links'),
256 256
             'nav-menus',
257 257
             'side',
258 258
             'low'
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         $endpoints = $this->get_menu_items();
268 268
         ?>
269 269
         <div id="invoicing-endpoints" class="posttypediv">
270
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
270
+            <?php if (!empty($endpoints['pages'])) : ?>
271 271
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
272 272
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
273 273
                         <?php
274
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
275
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
274
+                            $walker = new Walker_Nav_Menu_Checklist(array());
275
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
276 276
                         ?>
277 277
                     </ul>
278 278
                 </div>
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
282 282
                 <span class="list-controls hide-if-no-js">
283 283
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
284
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
284
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
285 285
                 </span>
286 286
 
287 287
                 <span class="add-to-menu">
288
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
288
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
289 289
                     <span class="spinner"></span>
290 290
                 </span>
291 291
             </p>
@@ -298,35 +298,35 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return array.
300 300
      */
301
-    public function get_menu_items(){
301
+    public function get_menu_items() {
302 302
         $items = array();
303 303
 
304 304
         $pages = array(
305 305
             array(
306
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
307
-                'label' => __( 'My Invoices', 'invoicing' ),
306
+                'id'    => wpinv_get_option('invoice_history_page'),
307
+                'label' => __('My Invoices', 'invoicing'),
308 308
             ),
309 309
             array(
310
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
311
-                'label' => __( 'My Subscriptions', 'invoicing' ),
310
+                'id'    => wpinv_get_option('invoice_subscription_page'),
311
+                'label' => __('My Subscriptions', 'invoicing'),
312 312
             )
313 313
         );
314 314
 
315
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
315
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
316 316
 
317
-            if ( (int) $page['id'] > 0 ) {
317
+            if ((int) $page['id'] > 0) {
318 318
 
319 319
                 $item                   = new stdClass();
320 320
                 $item->object_id        = (int) $page['id'];
321 321
                 $item->db_id            = 0;
322
-                $item->object           =  'page';
322
+                $item->object           = 'page';
323 323
                 $item->menu_item_parent = 0;
324 324
                 $item->type             = 'post_type';
325
-                $item->title            = sanitize_text_field( $page['label'] );
326
-                $item->url              = get_permalink( (int) $page['id'] );
325
+                $item->title            = sanitize_text_field($page['label']);
326
+                $item->url              = get_permalink((int) $page['id']);
327 327
                 $item->target           = '';
328 328
                 $item->attr_title       = '';
329
-                $item->classes          = array( 'wpinv-menu-item' );
329
+                $item->classes          = array('wpinv-menu-item');
330 330
                 $item->xfn              = '';
331 331
 
332 332
                 $items['pages'][]       = $item;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
         }
337 337
 
338
-        return apply_filters( 'wpinv_menu_items', $items );
338
+        return apply_filters('wpinv_menu_items', $items);
339 339
     }
340 340
 
341 341
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_unslash($_POST);
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
58
+		if ($this->id != $invoice->get_gateway()) {
59
+			wpinv_error_log('Aborting, Invoice was not paid via PayPal', false);
60
+			wp_die('Invoice not paid via PayPal', 200);
61 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 
98 98
 		}
99 99
 
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
100
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
101
+		wp_die('Could not retrieve the associated invoice.', 200);
102 102
 	}
103 103
 
104 104
 	/**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function validate_ipn() {
108 108
 
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
+		wpinv_error_log('Validating PayPal IPN response', false);
110 110
 
111 111
 		// Retrieve the associated invoice.
112
-		$posted  = wp_unslash( $_POST );
113
-		$invoice = $this->get_ipn_invoice( $posted );
112
+		$posted  = wp_unslash($_POST);
113
+		$invoice = $this->get_ipn_invoice($posted);
114 114
 
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
115
+		if ($this->gateway->is_sandbox($invoice)) {
116
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false);
117 117
 		}
118 118
 
119 119
 		// Validate the IPN.
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		);
131 131
 
132 132
 		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
+		$response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
134 134
 
135 135
 		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
136
+		if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
137
+			wpinv_error_log('Received valid response from PayPal IPN: ' . $response['body'], false);
138 138
 			return true;
139 139
 		}
140 140
 
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
141
+		if (is_wp_error($response)) {
142
+			wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
143 143
 			return false;
144 144
 		}
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
+		wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
147 147
 		return false;
148 148
 
149 149
 	}
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param WPInv_Invoice $invoice          Invoice object.
155 155
 	 * @param string   $currency currency to validate.
156 156
 	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
157
+	protected function validate_ipn_currency($invoice, $currency) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
160 160
 
161 161
 			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
162
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
165 165
 		}
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
+		wpinv_error_log($currency, 'Validated IPN Currency', false);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 	 * @param WPInv_Invoice $invoice          Invoice object.
174 174
 	 * @param float   $amount amount to validate.
175 175
 	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
176
+	protected function validate_ipn_amount($invoice, $amount) {
177
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
178 178
 
179 179
 			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
180
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
183 183
 		}
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
+		wpinv_error_log($amount, 'Validated IPN Amount', false);
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 	 * @param WPInv_Invoice $invoice          Invoice object.
192 192
 	 * @param string   $receiver_email Email to validate.
193 193
 	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
194
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
195
+		$paypal_email = wpinv_get_option('paypal_email');
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
198
+			wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
199 199
 
200 200
 			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
201
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
204 204
 		}
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
206
+		wpinv_error_log('Validated PayPal Email', false);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,70 +212,70 @@  discard block
 block discarded – undo
212 212
 	 * @param WPInv_Invoice $invoice  Invoice object.
213 213
 	 * @param array    $posted Posted data.
214 214
 	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
215
+	protected function ipn_txn_web_accept($invoice, $posted) {
216 216
 
217 217
 		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
218
+		$payment_status = strtolower($posted['payment_status']);
219
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+		$this->validate_ipn_receiver_email($invoice, $business_email);
222
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
223 223
 
224 224
 		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
225
+		if (!empty($posted['txn_id'])) {
226
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
227 227
 			$invoice->save();
228 228
 		}
229 229
 
230
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230
+		$invoice->add_system_note(__('Processing invoice IPN', 'invoicing'));
231 231
 
232 232
 		// Process a refund.
233
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
233
+		if ($payment_status == 'refunded' || $payment_status == 'reversed') {
234 234
 
235
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235
+			update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
236 236
 
237
-			if ( ! $invoice->is_refunded() ) {
238
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
237
+			if (!$invoice->is_refunded()) {
238
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
239 239
 			}
240 240
 
241
-			return wpinv_error_log( $posted['reason_code'], false );
241
+			return wpinv_error_log($posted['reason_code'], false);
242 242
 		}
243 243
 
244 244
 		// Process payments.
245
-		if ( $payment_status == 'completed' ) {
245
+		if ($payment_status == 'completed') {
246 246
 
247
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
247
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
248
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false);
249 249
 			}
250 250
 
251
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
252 252
 
253 253
 			$note = '';
254 254
 
255
-			if ( ! empty( $posted['mc_fee'] ) ) {
256
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
255
+			if (!empty($posted['mc_fee'])) {
256
+				$note = sprintf(__('PayPal Transaction Fee %.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
257 257
 			}
258 258
 
259
-			if ( ! empty( $posted['payer_status'] ) ) {
260
-				$note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
259
+			if (!empty($posted['payer_status'])) {
260
+				$note = ' ' . sprintf(__('Buyer status %.', 'invoicing'), sanitize_text_field($posted['payer_status']));
261 261
 			}
262 262
 
263
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
-			return wpinv_error_log( 'Invoice marked as paid.', false );
263
+			$invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note));
264
+			return wpinv_error_log('Invoice marked as paid.', false);
265 265
 
266 266
 		}
267 267
 
268 268
 		// Pending payments.
269
-		if ( $payment_status == 'pending' ) {
269
+		if ($payment_status == 'pending') {
270 270
 
271 271
 			/* translators: %s: pending reason. */
272
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
272
+			$invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
273 273
 
274
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
+			return wpinv_error_log('Invoice marked as "payment held".', false);
275 275
 		}
276 276
 
277 277
 		/* translators: %s: payment status. */
278
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
278
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status'])));
279 279
 
280 280
 	}
281 281
 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param WPInv_Invoice $invoice  Invoice object.
286 286
 	 * @param array    $posted Posted data.
287 287
 	 */
288
-	protected function ipn_txn_cart( $invoice, $posted ) {
289
-		$this->ipn_txn_web_accept( $invoice, $posted );
288
+	protected function ipn_txn_cart($invoice, $posted) {
289
+		$this->ipn_txn_web_accept($invoice, $posted);
290 290
 	}
291 291
 
292 292
 	/**
@@ -295,43 +295,43 @@  discard block
 block discarded – undo
295 295
 	 * @param WPInv_Invoice $invoice  Invoice object.
296 296
 	 * @param array    $posted Posted data.
297 297
 	 */
298
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
298
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
299 299
 
300
-		wpinv_error_log( 'Processing subscription signup', false );
300
+		wpinv_error_log('Processing subscription signup', false);
301 301
 
302 302
 		// Make sure the invoice has a subscription.
303
-		$subscription = getpaid_get_invoice_subscription( $invoice );
303
+		$subscription = getpaid_get_invoice_subscription($invoice);
304 304
 
305
-		if ( empty( $subscription ) ) {
306
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
305
+		if (empty($subscription)) {
306
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
307 307
 		}
308 308
 
309
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
310 310
 
311 311
 		// Validate the IPN.
312
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
314
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
312
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
313
+		$this->validate_ipn_receiver_email($invoice, $business_email);
314
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
315 315
 
316 316
 		// Activate the subscription.
317
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
-		$subscription->set_date_created( current_time( 'mysql' ) );
319
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
317
+		$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
318
+		$subscription->set_date_created(current_time('mysql'));
319
+		$subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration)));
320
+		$subscription->set_profile_id(sanitize_text_field($posted['subscr_id']));
321 321
 		$subscription->activate();
322 322
 
323 323
 		// Set the transaction id.
324
-		if ( ! empty( $posted['txn_id'] ) ) {
325
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
-			$invoice->set_transaction_id( $posted['txn_id'] );
324
+		if (!empty($posted['txn_id'])) {
325
+			$invoice->add_note(sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
326
+			$invoice->set_transaction_id($posted['txn_id']);
327 327
 		}
328 328
 
329 329
 		// Update the payment status.
330 330
 		$invoice->mark_paid();
331 331
 
332
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
332
+		$invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
333 333
 
334
-		wpinv_error_log( 'Subscription started.', false );
334
+		wpinv_error_log('Subscription started.', false);
335 335
 	}
336 336
 
337 337
 	/**
@@ -340,45 +340,45 @@  discard block
 block discarded – undo
340 340
 	 * @param WPInv_Invoice $invoice  Invoice object.
341 341
 	 * @param array    $posted Posted data.
342 342
 	 */
343
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
343
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
344 344
 
345 345
 		// Make sure the invoice has a subscription.
346
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
346
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
347 347
 
348
-		if ( empty( $subscription ) ) {
349
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
348
+		if (empty($subscription)) {
349
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
350 350
 		}
351 351
 
352
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
353 353
 
354 354
 		// PayPal sends a subscr_payment for the first payment too.
355
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
357
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
359
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
355
+		$date_completed = getpaid_format_date($invoice->get_date_completed());
356
+		$date_created   = getpaid_format_date($invoice->get_date_created());
357
+		$today_date     = getpaid_format_date(current_time('mysql'));
358
+		$payment_date   = getpaid_format_date($posted['payment_date']);
359
+		$subscribe_date = getpaid_format_date($subscription->get_date_created());
360
+		$dates          = array_filter(compact('date_completed', 'date_created', 'subscribe_date'));
361 361
 
362
-		foreach( $dates as $date ) {
362
+		foreach ($dates as $date) {
363 363
 
364
-			if ( $date !== $today_date && $date !== $payment_date ) {
364
+			if ($date !== $today_date && $date !== $payment_date) {
365 365
 				continue;
366 366
 			}
367 367
 
368
-			if ( ! empty( $posted['txn_id'] ) ) {
369
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
368
+			if (!empty($posted['txn_id'])) {
369
+				$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));	
370
+				$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), sanitize_text_field($posted['txn_id'])), false, false, true);
371 371
 			}
372 372
 
373 373
 			return $invoice->mark_paid();
374 374
 
375 375
 		}
376 376
 
377
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
378 378
 
379 379
 		// Abort if the payment is already recorded.
380
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
380
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
381
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false);
382 382
 		}
383 383
 
384 384
 		$args = array(
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
 			'gateway'        => $this->id,
387 387
 		);
388 388
 
389
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
389
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
390 390
 
391
-		if ( empty( $invoice ) ) {
391
+		if (empty($invoice)) {
392 392
 			return;
393 393
 		}
394 394
 
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
395
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
396
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
397 397
 
398 398
 		$subscription->renew();
399
-		wpinv_error_log( 'Subscription renewed.', false );
399
+		wpinv_error_log('Subscription renewed.', false);
400 400
 
401 401
 	}
402 402
 
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @param WPInv_Invoice $invoice  Invoice object.
407 407
 	 */
408
-	protected function ipn_txn_subscr_cancel( $invoice ) {
408
+	protected function ipn_txn_subscr_cancel($invoice) {
409 409
 
410 410
 		// Make sure the invoice has a subscription.
411
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
412 412
 
413
-		if ( empty( $subscription ) ) {
414
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
413
+		if (empty($subscription)) {
414
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415 415
 		}
416 416
 
417
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
418 418
 		$subscription->cancel();
419
-		wpinv_error_log( 'Subscription cancelled.', false );
419
+		wpinv_error_log('Subscription cancelled.', false);
420 420
 
421 421
 	}
422 422
 
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 	 * @param WPInv_Invoice $invoice  Invoice object.
427 427
 	 * @param array    $posted Posted data.
428 428
 	 */
429
-	protected function ipn_txn_subscr_eot( $invoice ) {
429
+	protected function ipn_txn_subscr_eot($invoice) {
430 430
 
431 431
 		// Make sure the invoice has a subscription.
432
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
432
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
433 433
 
434
-		if ( empty( $subscription ) ) {
435
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
434
+		if (empty($subscription)) {
435
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
436 436
 		}
437 437
 
438
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
439 439
 		$subscription->complete();
440
-		wpinv_error_log( 'Subscription completed.', false );
440
+		wpinv_error_log('Subscription completed.', false);
441 441
 
442 442
 	}
443 443
 
@@ -447,18 +447,18 @@  discard block
 block discarded – undo
447 447
 	 * @param WPInv_Invoice $invoice  Invoice object.
448 448
 	 * @param array    $posted Posted data.
449 449
 	 */
450
-	protected function ipn_txn_subscr_failed( $invoice ) {
450
+	protected function ipn_txn_subscr_failed($invoice) {
451 451
 
452 452
 		// Make sure the invoice has a subscription.
453
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
453
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
454 454
 
455
-		if ( empty( $subscription ) ) {
456
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
455
+		if (empty($subscription)) {
456
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
457 457
 		}
458 458
 
459
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
460 460
 		$subscription->failing();
461
-		wpinv_error_log( 'Subscription marked as failing.', false );
461
+		wpinv_error_log('Subscription marked as failing.', false);
462 462
 
463 463
 	}
464 464
 
@@ -468,18 +468,18 @@  discard block
 block discarded – undo
468 468
 	 * @param WPInv_Invoice $invoice  Invoice object.
469 469
 	 * @param array    $posted Posted data.
470 470
 	 */
471
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
471
+	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) {
472 472
 
473 473
 		// Make sure the invoice has a subscription.
474
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
474
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
475 475
 
476
-		if ( empty( $subscription ) ) {
477
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
476
+		if (empty($subscription)) {
477
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
478 478
 		}
479 479
 
480
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
+		wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false);
481 481
 		$subscription->cancel();
482
-		wpinv_error_log( 'Subscription cancelled.', false );
482
+		wpinv_error_log('Subscription cancelled.', false);
483 483
 	}
484 484
 
485 485
 }
Please login to merge, or discard this patch.
includes/data/admin-settings.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -8,99 +8,99 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $getpaid_pages = GetPaid_Installer::get_pages();
14
-$pages         = wpinv_get_pages( true );
14
+$pages         = wpinv_get_pages(true);
15 15
     
16 16
 $currencies = wpinv_get_currencies();
17 17
     
18 18
 $currency_code_options = array();
19
-foreach ( $currencies as $code => $name ) {
20
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
19
+foreach ($currencies as $code => $name) {
20
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
21 21
 }
22 22
 
23 23
 $invoice_number_padd_options = array();
24
-for ( $i = 0; $i <= 20; $i++ ) {
24
+for ($i = 0; $i <= 20; $i++) {
25 25
     $invoice_number_padd_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $currency_symbol = wpinv_currency_symbol();
29 29
     
30 30
 $last_number = $reset_number = '';
31
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
32
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
31
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
32
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
33 33
 
34
-    if ( !empty( $last_invoice_number ) ) {
35
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
34
+    if (!empty($last_invoice_number)) {
35
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
36 36
     }
37 37
 
38 38
     $nonce = wp_create_nonce('reset_invoice_count');
39
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
39
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
40 40
 }
41 41
     
42 42
 $alert_wrapper_start = '<p style="color: #F00">';
43 43
 $alert_wrapper_close = '</p>';
44 44
 
45 45
 return array(
46
-    'general' => apply_filters( 'wpinv_settings_general',
46
+    'general' => apply_filters('wpinv_settings_general',
47 47
         array(
48 48
             'main' => array(
49 49
                 'location_settings' => array(
50 50
                     'id'   => 'location_settings',
51
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
51
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
52 52
                     'desc' => '',
53 53
                     'type' => 'header',
54 54
                 ),
55 55
                 'default_country' => array(
56 56
                     'id'      => 'default_country',
57
-                    'name'    => __( 'Default Country', 'invoicing' ),
58
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
57
+                    'name'    => __('Default Country', 'invoicing'),
58
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
59 59
                     'type'    => 'select',
60 60
                     'options' => wpinv_get_country_list(),
61 61
                     'std'     => 'GB',
62 62
                     'class'   => 'wpi_select2',
63
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
63
+                    'placeholder' => __('Select a country', 'invoicing'),
64 64
                 ),
65 65
                 'default_state' => array(
66 66
                     'id'      => 'default_state',
67
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
68
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
67
+                    'name'    => __('Default State / Province', 'invoicing'),
68
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
69 69
                     'type'    => 'country_states',
70 70
                     'class'   => 'wpi_select2',
71
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
71
+                    'placeholder' => __('Select a state', 'invoicing'),
72 72
                 ),
73 73
                 'store_name' => array(
74 74
                     'id'   => 'store_name',
75
-                    'name' => __( 'Store Name', 'invoicing' ),
76
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
75
+                    'name' => __('Store Name', 'invoicing'),
76
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
77 77
                     'std'     => get_option('blogname'),
78 78
                     'type' => 'text',
79 79
                 ),
80 80
                 'logo' => array(
81 81
                     'id'   => 'logo',
82
-                    'name' => __( 'Logo URL', 'invoicing' ),
83
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
82
+                    'name' => __('Logo URL', 'invoicing'),
83
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
84 84
                     'type' => 'text',
85 85
                 ),
86 86
                 'logo_width'      => array(
87 87
                     'id'          => 'logo_width',
88
-                    'name'        => __( 'Logo width', 'invoicing' ),
89
-                    'desc'        => __( 'Logo width to use in invoice image.', 'invoicing' ),
88
+                    'name'        => __('Logo width', 'invoicing'),
89
+                    'desc'        => __('Logo width to use in invoice image.', 'invoicing'),
90 90
                     'type'        => 'number',
91
-                    'placeholder' => __( 'Auto', 'invoicing' ),
91
+                    'placeholder' => __('Auto', 'invoicing'),
92 92
                 ),
93 93
                 'logo_height'     => array(
94 94
                     'id'          => 'logo_height',
95
-                    'name'        => __( 'Logo height', 'invoicing' ),
96
-                    'desc'        => __( 'Logo height to use in invoice image.', 'invoicing' ),
95
+                    'name'        => __('Logo height', 'invoicing'),
96
+                    'desc'        => __('Logo height to use in invoice image.', 'invoicing'),
97 97
                     'type'        => 'number',
98
-                    'placeholder' => __( 'Auto', 'invoicing' ),
98
+                    'placeholder' => __('Auto', 'invoicing'),
99 99
                 ),
100 100
                 'store_address' => array(
101 101
                     'id'   => 'store_address',
102
-                    'name' => __( 'Store Address', 'invoicing' ),
103
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
102
+                    'name' => __('Store Address', 'invoicing'),
103
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
104 104
                     'type' => 'textarea',
105 105
                 ),
106 106
 
@@ -108,114 +108,114 @@  discard block
 block discarded – undo
108 108
             'page_section' => array(
109 109
                 'page_settings' => array(
110 110
                     'id'   => 'page_settings',
111
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
111
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
112 112
                     'desc' => '',
113 113
                     'type' => 'header',
114 114
                 ),
115 115
                 'checkout_page' => array(
116 116
                     'id'          => 'checkout_page',
117
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
118
-                    'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
117
+                    'name'        => __('Checkout Page', 'invoicing'),
118
+                    'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
119 119
                     'type'        => 'select',
120 120
                     'options'     => $pages,
121 121
                     'class'       => 'wpi_select2',
122
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
123
-                    'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'],
122
+                    'placeholder' => __('Select a page', 'invoicing'),
123
+                    'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'],
124 124
                     'help-tip'    => true,
125 125
                 ),
126 126
                 'success_page' => array(
127 127
                     'id'          => 'success_page',
128
-                    'name'        => __( 'Success Page', 'invoicing' ),
129
-                    'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
128
+                    'name'        => __('Success Page', 'invoicing'),
129
+                    'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
130 130
                     'type'        => 'select',
131 131
                     'options'     => $pages,
132 132
                     'class'       => 'wpi_select2',
133
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
134
-                    'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'],
133
+                    'placeholder' => __('Select a page', 'invoicing'),
134
+                    'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'],
135 135
                     'help-tip'    => true,
136 136
                 ),
137 137
                 'failure_page' => array(
138 138
                     'id'          => 'failure_page',
139
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
140
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
139
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
140
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
141 141
                     'type'        => 'select',
142 142
                     'options'     => $pages,
143 143
                     'class'       => 'wpi_select2',
144
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
145
-                    'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'],
144
+                    'placeholder' => __('Select a page', 'invoicing'),
145
+                    'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'],
146 146
                     'help-tip'    => true,
147 147
                 ),
148 148
                 'invoice_history_page' => array(
149 149
                     'id'          => 'invoice_history_page',
150
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
151
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
150
+                    'name'        => __('Invoice History Page', 'invoicing'),
151
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
152 152
                     'type'        => 'select',
153 153
                     'options'     => $pages,
154 154
                     'class'       => 'wpi_select2',
155
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
156
-                    'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'],
155
+                    'placeholder' => __('Select a page', 'invoicing'),
156
+                    'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'],
157 157
                     'help-tip'    => true,
158 158
                 ),
159 159
                 'invoice_subscription_page' => array(
160 160
                     'id'          => 'invoice_subscription_page',
161
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
162
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
161
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
162
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
163 163
                     'type'        => 'select',
164 164
                     'options'     => $pages,
165 165
                     'class'       => 'wpi_select2',
166
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
167
-                    'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'],
166
+                    'placeholder' => __('Select a page', 'invoicing'),
167
+                    'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'],
168 168
                     'help-tip'    => true,
169 169
                 ),
170 170
             ),
171 171
             'currency_section' => array(
172 172
                 'currency_settings' => array(
173 173
                     'id'   => 'currency_settings',
174
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
174
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
175 175
                     'desc' => '',
176 176
                     'type' => 'header',
177 177
                 ),
178 178
                 'currency' => array(
179 179
                     'id'      => 'currency',
180
-                    'name'    => __( 'Currency', 'invoicing' ),
181
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
180
+                    'name'    => __('Currency', 'invoicing'),
181
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
182 182
                     'type'    => 'select',
183 183
                     'class'       => 'wpi_select2',
184 184
                     'options' => $currency_code_options,
185 185
                 ),
186 186
                 'currency_position' => array(
187 187
                     'id'      => 'currency_position',
188
-                    'name'    => __( 'Currency Position', 'invoicing' ),
189
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
188
+                    'name'    => __('Currency Position', 'invoicing'),
189
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
190 190
                     'type'    => 'select',
191 191
                     'class'   => 'wpi_select2',
192 192
                     'options'  => array(
193
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
194
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
195
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
196
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
193
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
194
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
195
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
196
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
197 197
                     )
198 198
                 ),
199 199
                 'thousands_separator' => array(
200 200
                     'id'   => 'thousands_separator',
201
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
202
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
201
+                    'name' => __('Thousands Separator', 'invoicing'),
202
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'small',
205 205
                     'std'  => ',',
206 206
                 ),
207 207
                 'decimal_separator' => array(
208 208
                     'id'   => 'decimal_separator',
209
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
210
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
209
+                    'name' => __('Decimal Separator', 'invoicing'),
210
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
211 211
                     'type' => 'text',
212 212
                     'size' => 'small',
213 213
                     'std'  => '.',
214 214
                 ),
215 215
                 'decimals' => array(
216 216
                     'id'   => 'decimals',
217
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
218
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
217
+                    'name' => __('Number of Decimals', 'invoicing'),
218
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
219 219
                     'type' => 'number',
220 220
                     'size' => 'small',
221 221
                     'std'  => '2',
@@ -227,21 +227,21 @@  discard block
 block discarded – undo
227 227
             'labels' => array(
228 228
                 'labels' => array(
229 229
                     'id'   => 'labels_settings',
230
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
230
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
231 231
                     'desc' => '',
232 232
                     'type' => 'header',
233 233
                 ),
234 234
                 'vat_invoice_notice_label' => array(
235 235
                     'id' => 'vat_invoice_notice_label',
236
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
237
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
236
+                    'name' => __('Invoice Notice Label', 'invoicing'),
237
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
238 238
                     'type' => 'text',
239 239
                     'size' => 'regular',
240 240
                 ),
241 241
                 'vat_invoice_notice' => array(
242 242
                     'id' => 'vat_invoice_notice',
243
-                    'name' => __( 'Invoice notice', 'invoicing' ),
244
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
243
+                    'name' => __('Invoice notice', 'invoicing'),
244
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
245 245
                     'type' => 'text',
246 246
                     'size' => 'regular',
247 247
                 ),
@@ -253,22 +253,22 @@  discard block
 block discarded – undo
253 253
             'main' => array(
254 254
                 'gateway_settings' => array(
255 255
                     'id'   => 'api_header',
256
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
256
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
257 257
                     'desc' => '',
258 258
                     'type' => 'header',
259 259
                 ),
260 260
                 'gateways' => array(
261 261
                     'id'      => 'gateways',
262
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
263
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
262
+                    'name'    => __('Payment Gateways', 'invoicing'),
263
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
264 264
                     'type'    => 'gateways',
265
-                    'std'     => array( 'manual'=>1 ),
265
+                    'std'     => array('manual'=>1),
266 266
                     'options' => wpinv_get_payment_gateways(),
267 267
                 ),
268 268
                 'default_gateway' => array(
269 269
                     'id'      => 'default_gateway',
270
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
271
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
270
+                    'name'    => __('Default Gateway', 'invoicing'),
271
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
272 272
                     'type'    => 'gateway_select',
273 273
                     'std'     => 'manual',
274 274
                     'class'   => 'wpi_select2',
@@ -283,32 +283,32 @@  discard block
 block discarded – undo
283 283
             'main' => array(
284 284
                 'tax_settings' => array(
285 285
                     'id'   => 'tax_settings',
286
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
286
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
287 287
                     'type' => 'header',
288 288
                 ),
289 289
 
290 290
                 'enable_taxes' => array(
291 291
                     'id'       => 'enable_taxes',
292
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
293
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
292
+                    'name'     => __('Enable Taxes', 'invoicing'),
293
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
294 294
                     'type'     => 'checkbox',
295 295
                     'std'      => 0,
296 296
                 ),
297 297
 
298 298
                 'tax_subtotal_rounding' => array(
299 299
                     'id'                => 'tax_subtotal_rounding',
300
-                    'name'              => __( 'Rounding', 'invoicing' ),
301
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
300
+                    'name'              => __('Rounding', 'invoicing'),
301
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
302 302
                     'type'              => 'checkbox',
303 303
                     'std'               => 1,
304 304
                 ),
305 305
 
306 306
                 'prices_include_tax' => array(
307 307
                     'id'      => 'prices_include_tax',
308
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
308
+                    'name'    => __('Prices entered with tax', 'invoicing'),
309 309
                     'options' => array(
310
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
311
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
310
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
311
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
312 312
                     ),
313 313
                     'type'    => 'select',
314 314
                     'std'     => 'no',
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 
317 317
                 'tax_base'              => array(
318 318
                     'id'                => 'tax_base',
319
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
319
+                    'name'              => __('Calculate tax based on', 'invoicing'),
320 320
                     'options'           => array(
321
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
322
-                        'base'          => __( 'Shop base address', 'invoicing' ),
321
+                        'billing'       => __('Customer billing address', 'invoicing'),
322
+                        'base'          => __('Shop base address', 'invoicing'),
323 323
                     ),
324 324
                     'type'              => 'select',
325 325
                     'std'               => 'billing',
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 
328 328
                 'tax_display_totals'    => array(
329 329
                     'id'                => 'tax_display_totals',
330
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
330
+                    'name'              => __('Display tax totals', 'invoicing'),
331 331
                     'options'           => array(
332
-                        'single'        => __( 'As a single total', 'invoicing' ),
333
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
332
+                        'single'        => __('As a single total', 'invoicing'),
333
+                        'individual'    => __('As individual tax rates', 'invoicing'),
334 334
                     ),
335 335
                     'type'              => 'select',
336 336
                     'std'               => 'individual',
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 
339 339
                 'tax_rate' => array(
340 340
                     'id'   => 'tax_rate',
341
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
342
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
341
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
342
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
343 343
                     'type' => 'number',
344 344
                     'size' => 'small',
345 345
                     'min'  => '0',
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
             'rates' => array(
352 352
                 'tax_rates' => array(
353 353
                     'id'   => 'tax_rates',
354
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
355
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
354
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
355
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
356 356
                     'type' => 'tax_rates',
357 357
                 ),
358 358
             ),
@@ -361,45 +361,45 @@  discard block
 block discarded – undo
361 361
 
362 362
                 'vat_company_name' => array(
363 363
                     'id' => 'vat_company_name',
364
-                    'name' => __( 'Company Name', 'invoicing' ),
365
-                    'desc' => wp_sprintf(__( 'Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
364
+                    'name' => __('Company Name', 'invoicing'),
365
+                    'desc' => wp_sprintf(__('Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
366 366
                     'type' => 'text',
367 367
                     'size' => 'regular',
368 368
                 ),
369 369
 
370 370
                 'vat_number' => array(
371 371
                     'id'   => 'vat_number',
372
-                    'name' => __( 'VAT Number', 'invoicing' ),
373
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
372
+                    'name' => __('VAT Number', 'invoicing'),
373
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
374 374
                     'type' => 'text',
375 375
                     'size' => 'regular',
376 376
                 ),
377 377
 
378 378
                 'vat_prevent_b2c_purchase' => array(
379 379
                     'id' => 'vat_prevent_b2c_purchase',
380
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
381
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
380
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
381
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
382 382
                     'type' => 'checkbox'
383 383
                 ),
384 384
 
385 385
                 'validate_vat_number' => array(
386 386
                     'id'   => 'validate_vat_number',
387
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
388
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
387
+                    'name' => __('Validate VAT Number', 'invoicing'),
388
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
389 389
                     'type' => 'checkbox'
390 390
                 ),
391 391
 
392 392
                 'vat_same_country_rule' => array(
393 393
                     'id'          => 'vat_same_country_rule',
394
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
395
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
394
+                    'name'        => __('Same Country Rule', 'invoicing'),
395
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
396 396
                     'type'        => 'select',
397 397
                     'options'     => array(
398
-                        'no'        => __( 'Do not charge tax', 'invoicing' ),
399
-                        'always'    => __( 'Charge tax unless vat number is validated', 'invoicing' ),
400
-                        'vat_too'   => __( 'Charge tax even if vat number is validated', 'invoicing' )
398
+                        'no'        => __('Do not charge tax', 'invoicing'),
399
+                        'always'    => __('Charge tax unless vat number is validated', 'invoicing'),
400
+                        'vat_too'   => __('Charge tax even if vat number is validated', 'invoicing')
401 401
                     ),
402
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
402
+                    'placeholder' => __('Select an option', 'invoicing'),
403 403
                     'std'         => 'vat_too',
404 404
                 ),
405 405
 
@@ -413,66 +413,66 @@  discard block
 block discarded – undo
413 413
             'main' => array(
414 414
                 'email_settings_header' => array(
415 415
                     'id'   => 'email_settings_header',
416
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
416
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
417 417
                     'type' => 'header',
418 418
                 ),
419 419
                 'email_from_name' => array(
420 420
                     'id'   => 'email_from_name',
421
-                    'name' => __( 'From Name', 'invoicing' ),
422
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
423
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
421
+                    'name' => __('From Name', 'invoicing'),
422
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
423
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
424 424
                     'type' => 'text',
425 425
                 ),
426 426
                 'email_from' => array(
427 427
                     'id'   => 'email_from',
428
-                    'name' => __( 'From Email', 'invoicing' ),
429
-                    'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
430
-                    'std' => get_option( 'admin_email' ),
428
+                    'name' => __('From Email', 'invoicing'),
429
+                    'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
430
+                    'std' => get_option('admin_email'),
431 431
                     'type' => 'text',
432 432
                 ),
433 433
                 'admin_email' => array(
434 434
                     'id'   => 'admin_email',
435
-                    'name' => __( 'Admin Email', 'invoicing' ),
436
-                    'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ),
437
-                    'std' => get_option( 'admin_email' ),
435
+                    'name' => __('Admin Email', 'invoicing'),
436
+                    'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'),
437
+                    'std' => get_option('admin_email'),
438 438
                     'type' => 'text',
439 439
                 ),
440 440
                 'skip_email_free_invoice' => array(
441 441
                     'id'   => 'skip_email_free_invoice',
442
-                    'name' => __( 'Skip Free Invoices', 'invoicing' ),
443
-                    'desc' => __( 'Check this to disable sending emails for free invoices.', 'invoicing' ),
442
+                    'name' => __('Skip Free Invoices', 'invoicing'),
443
+                    'desc' => __('Check this to disable sending emails for free invoices.', 'invoicing'),
444 444
                     'type' => 'checkbox',
445 445
                     'std'  => false,
446 446
                 ),
447 447
                 'overdue_settings_header' => array(
448 448
                     'id'   => 'overdue_settings_header',
449
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
449
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
450 450
                     'type' => 'header',
451 451
                 ),
452 452
                 'overdue_active' => array(
453 453
                     'id'   => 'overdue_active',
454
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
455
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
454
+                    'name' => __('Enable Due Date', 'invoicing'),
455
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
456 456
                     'type' => 'checkbox',
457 457
                     'std'  => false,
458 458
                 ),
459 459
                 'email_template_header' => array(
460 460
                     'id'   => 'email_template_header',
461
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
461
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
462 462
                     'type' => 'header',
463 463
                 ),
464 464
                 'email_header_image' => array(
465 465
                     'id'   => 'email_header_image',
466
-                    'name' => __( 'Header Image', 'invoicing' ),
467
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
466
+                    'name' => __('Header Image', 'invoicing'),
467
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
468 468
                     'std' => '',
469 469
                     'type' => 'text',
470 470
                 ),
471 471
                 'email_footer_text' => array(
472 472
                     'id'   => 'email_footer_text',
473
-                    'name' => __( 'Footer Text', 'invoicing' ),
474
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
475
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ),
473
+                    'name' => __('Footer Text', 'invoicing'),
474
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
475
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'),
476 476
                     'type' => 'textarea',
477 477
                     'class' => 'regular-text',
478 478
                     'rows' => 2,
@@ -480,29 +480,29 @@  discard block
 block discarded – undo
480 480
                 ),
481 481
                 'email_base_color' => array(
482 482
                     'id'   => 'email_base_color',
483
-                    'name' => __( 'Base Color', 'invoicing' ),
484
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
483
+                    'name' => __('Base Color', 'invoicing'),
484
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
485 485
                     'std' => '#557da2',
486 486
                     'type' => 'color',
487 487
                 ),
488 488
                 'email_background_color' => array(
489 489
                     'id'   => 'email_background_color',
490
-                    'name' => __( 'Background Color', 'invoicing' ),
491
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
490
+                    'name' => __('Background Color', 'invoicing'),
491
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
492 492
                     'std' => '#f5f5f5',
493 493
                     'type' => 'color',
494 494
                 ),
495 495
                 'email_body_background_color' => array(
496 496
                     'id'   => 'email_body_background_color',
497
-                    'name' => __( 'Body Background Color', 'invoicing' ),
498
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
497
+                    'name' => __('Body Background Color', 'invoicing'),
498
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
499 499
                     'std' => '#fdfdfd',
500 500
                     'type' => 'color',
501 501
                 ),
502 502
                 'email_text_color' => array(
503 503
                     'id'   => 'email_text_color',
504
-                    'name' => __( 'Body Text Color', 'invoicing' ),
505
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
504
+                    'name' => __('Body Text Color', 'invoicing'),
505
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
506 506
                     'std' => '#505050',
507 507
                     'type' => 'color',
508 508
                 ),
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
     ),
518 518
 
519 519
     // Integrations.
520
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
520
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
521 521
 
522 522
     /** Privacy Settings */
523 523
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -525,17 +525,17 @@  discard block
 block discarded – undo
525 525
             'main' => array(
526 526
                 'invoicing_privacy_policy_settings' => array(
527 527
                     'id'   => 'invoicing_privacy_policy_settings',
528
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
528
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
529 529
                     'type' => 'header',
530 530
                 ),
531 531
                 'privacy_page' => array(
532 532
                     'id'          => 'privacy_page',
533
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
534
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
533
+                    'name'        => __('Privacy Page', 'invoicing'),
534
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
535 535
                     'type'        => 'select',
536
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
536
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
537 537
                     'class'       => 'wpi_select2',
538
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
538
+                    'placeholder' => __('Select a page', 'invoicing'),
539 539
                 ),
540 540
             ),
541 541
         )
@@ -546,19 +546,19 @@  discard block
 block discarded – undo
546 546
             'main' => array(
547 547
                 'invoice_number_format_settings' => array(
548 548
                     'id'   => 'invoice_number_format_settings',
549
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
549
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
550 550
                     'type' => 'header',
551 551
                 ),
552 552
                 'sequential_invoice_number' => array(
553 553
                     'id'   => 'sequential_invoice_number',
554
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
555
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
554
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
555
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
556 556
                     'type' => 'checkbox',
557 557
                 ),
558 558
                 'invoice_sequence_start' => array(
559 559
                     'id'   => 'invoice_sequence_start',
560
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
561
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
560
+                    'name' => __('Sequential Starting Number', 'invoicing'),
561
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
562 562
                     'type' => 'number',
563 563
                     'size' => 'small',
564 564
                     'std'  => '1',
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
                 ),
567 567
                 'invoice_number_padd' => array(
568 568
                     'id'      => 'invoice_number_padd',
569
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
570
-                    'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
569
+                    'name'    => __('Minimum Digits', 'invoicing'),
570
+                    'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
571 571
                     'type'    => 'select',
572 572
                     'options' => $invoice_number_padd_options,
573 573
                     'std'     => 5,
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
                 ),
576 576
                 'invoice_number_prefix' => array(
577 577
                     'id' => 'invoice_number_prefix',
578
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
579
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
578
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
579
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
580 580
                     'type' => 'text',
581 581
                     'size' => 'regular',
582 582
                     'std' => 'INV-',
@@ -584,46 +584,46 @@  discard block
 block discarded – undo
584 584
                 ),
585 585
                 'invoice_number_postfix' => array(
586 586
                     'id' => 'invoice_number_postfix',
587
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
588
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
587
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
588
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
589 589
                     'type' => 'text',
590 590
                     'size' => 'regular',
591 591
                     'std' => ''
592 592
                 ),
593 593
                 'checkout_settings' => array(
594 594
                     'id'   => 'checkout_settings',
595
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
595
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
596 596
                     'type' => 'header',
597 597
                 ),
598 598
                 'disable_new_user_emails' => array(
599 599
                     'id'   => 'disable_new_user_emails',
600
-                    'name' => __( 'Disable new user emails', 'invoicing' ),
601
-                    'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ),
600
+                    'name' => __('Disable new user emails', 'invoicing'),
601
+                    'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'),
602 602
                     'type' => 'checkbox',
603 603
                 ),
604 604
                 'login_to_checkout' => array(
605 605
                     'id'   => 'login_to_checkout',
606
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
607
-                    'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
606
+                    'name' => __('Require Login To Checkout', 'invoicing'),
607
+                    'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
608 608
                     'type' => 'checkbox',
609 609
                 ),
610 610
                 'maxmind_license_key' => array(
611 611
                     'id'   => 'maxmind_license_key',
612
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
612
+                    'name' => __('MaxMind License Key', 'invoicing'),
613 613
                     'type' => 'text',
614 614
                     'size' => 'regular',
615
-                    'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>',
615
+                    'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>',
616 616
                 ),
617 617
 
618 618
                 'uninstall_settings' => array(
619 619
                     'id'   => 'uninstall_settings',
620
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
620
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
621 621
                     'type' => 'header',
622 622
                 ),
623 623
                 'remove_data_on_unistall' => array(
624 624
                     'id'   => 'remove_data_on_unistall',
625
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
626
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
625
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
626
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
627 627
                     'type' => 'checkbox',
628 628
                     'std'  => ''
629 629
                 ),
@@ -632,13 +632,13 @@  discard block
 block discarded – undo
632 632
             'custom-css' => array(
633 633
                 'css_settings' => array(
634 634
                     'id'   => 'css_settings',
635
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
635
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
636 636
                     'type' => 'header',
637 637
                 ),
638 638
                 'template_custom_css' => array(
639 639
                     'id' => 'template_custom_css',
640
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
641
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
640
+                    'name' => __('Invoice Template CSS', 'invoicing'),
641
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
642 642
                     'type' => 'textarea',
643 643
                     'class'=> 'regular-text',
644 644
                     'rows' => 10,
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
             'main' => array(
653 653
                 'tool_settings' => array(
654 654
                     'id'   => 'tool_settings',
655
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
656
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
655
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
656
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
657 657
                     'type' => 'tools',
658 658
                 ),
659 659
             ),
Please login to merge, or discard this patch.