Passed
Pull Request — master (#281)
by Kiran
04:07
created
gateways/authorizenet/anet_php_sdk/lib/shared/AuthorizeNetTypes.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,24 +114,24 @@
 block discarded – undo
114 114
     
115 115
     public function __construct()
116 116
     {
117
-        $this->tax = (object)array();
117
+        $this->tax = (object) array();
118 118
         $this->tax->amount = "";
119 119
         $this->tax->name = "";
120 120
         $this->tax->description = "";
121 121
         
122
-        $this->shipping = (object)array();
122
+        $this->shipping = (object) array();
123 123
         $this->shipping->amount = "";
124 124
         $this->shipping->name = "";
125 125
         $this->shipping->description = "";
126 126
         
127
-        $this->duty = (object)array();
127
+        $this->duty = (object) array();
128 128
         $this->duty->amount = "";
129 129
         $this->duty->name = "";
130 130
         $this->duty->description = "";
131 131
         
132 132
         // line items
133 133
         
134
-        $this->order = (object)array();
134
+        $this->order = (object) array();
135 135
         $this->order->invoiceNumber = "";
136 136
         $this->order->description = "";
137 137
         $this->order->purchaseOrderNumber = "";
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCIM.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
     {
310 310
         $this->_validationMode = $validationMode;
311 311
         $this->_constructXml("validateCustomerPaymentProfileRequest");
312
-        $this->_xml->addChild("customerProfileId",$customerProfileId);
313
-        $this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId);
314
-        $this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId);
315
-        $this->_xml->addChild("cardCode",$cardCode);
312
+        $this->_xml->addChild("customerProfileId", $customerProfileId);
313
+        $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);
314
+        $this->_xml->addChild("customerShippingAddressId", $customerShippingAddressId);
315
+        $this->_xml->addChild("cardCode", $cardCode);
316 316
         return $this->_sendRequest();
317 317
     }
318 318
     
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
      */
342 342
     protected function _setPostString()
343 343
     {
344
-        ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode',$this->_validationMode) : "");
344
+        ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode', $this->_validationMode) : "");
345 345
         $this->_post_string = $this->_xml->asXML();
346 346
         
347 347
         // Add extraOptions CDATA
348 348
         if ($this->_extraOptions) {
349 349
             $this->_xml->addChild("extraOptions");
350
-            $this->_post_string = str_replace("<extraOptions></extraOptions>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
350
+            $this->_post_string = str_replace("<extraOptions></extraOptions>", '<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
351 351
             $this->_extraOptions = false;
352 352
         }
353 353
         // Blank out our validation mode, so that we don't include it in calls that
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
      */
363 363
     private function _constructXml($request_type)
364 364
     {
365
-        $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
365
+        $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>';
366 366
         $this->_xml = @new SimpleXMLElement($string);
367 367
         $merchant = $this->_xml->addChild('merchantAuthentication');
368
-        $merchant->addChild('name',$this->_api_login);
369
-        $merchant->addChild('transactionKey',$this->_transaction_key);
370
-        ($this->_refId ? $this->_xml->addChild('refId',$this->_refId) : "");
368
+        $merchant->addChild('name', $this->_api_login);
369
+        $merchant->addChild('transactionKey', $this->_transaction_key);
370
+        ($this->_refId ? $this->_xml->addChild('refId', $this->_refId) : "");
371 371
     }
372 372
     
373 373
     /**
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     private function _addObject($destination, $object)
380 380
     {
381
-        $array = (array)$object;
381
+        $array = (array) $object;
382 382
         foreach ($array as $key => $value) {
383 383
             if ($value && !is_object($value)) {
384 384
                 if (is_array($value) && count($value)) {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                         $this->_addObject($items, $item);
388 388
                     }
389 389
                 } else {
390
-                    $destination->addChild($key,$value);
390
+                    $destination->addChild($key, $value);
391 391
                 }
392 392
             } elseif (is_object($value) && self::_notEmpty($value)) {
393 393
                 $dest = $destination->addChild($key);
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     private static function _notEmpty($object)
407 407
     {
408
-        $array = (array)$object;
408
+        $array = (array) $object;
409 409
         foreach ($array as $key => $value) {
410 410
             if ($value && !is_object($value)) {
411 411
                 return true;
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public function getValidationResponses()
443 443
     {
444
-        $responses = (array)$this->xml->validationDirectResponseList;
444
+        $responses = (array) $this->xml->validationDirectResponseList;
445 445
         $return = array();
446
-        foreach ((array)$responses["string"] as $response) {
446
+        foreach ((array) $responses["string"] as $response) {
447 447
             $return[] = new AuthorizeNetAIM_Response($response, ",", "", array());
448 448
         }
449 449
         return $return;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
      */
463 463
     public function getCustomerProfileIds()
464 464
     {
465
-        $ids = (array)$this->xml->ids;
465
+        $ids = (array) $this->xml->ids;
466 466
         return $ids["numericString"];
467 467
     }
468 468
     
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
      */
472 472
     public function getCustomerPaymentProfileIds()
473 473
     {
474
-        $ids = (array)$this->xml->customerPaymentProfileIdList;
474
+        $ids = (array) $this->xml->customerPaymentProfileIdList;
475 475
         return $ids["numericString"];
476 476
     }
477 477
     
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      */
481 481
     public function getCustomerShippingAddressIds()
482 482
     {
483
-        $ids = (array)$this->xml->customerShippingAddressIdList;
483
+        $ids = (array) $this->xml->customerShippingAddressIdList;
484 484
         return $ids["numericString"];
485 485
     }
486 486
     
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetAIM.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
      * A list of all fields in the AIM API.
78 78
      * Used to warn user if they try to set a field not offered in the API.
79 79
      */
80
-    private $_all_aim_fields = array("address","allow_partial_auth","amount",
81
-        "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name",
82
-        "bank_acct_num","bank_acct_type","bank_check_number","bank_name",
83
-        "card_code","card_num","cardholder_authentication_value","city","company",
84
-        "country","cust_id","customer_ip","delim_char","delim_data","description",
85
-        "duplicate_window","duty","echeck_type","email","email_customer",
86
-        "encap_char","exp_date","fax","first_name","footer_email_receipt",
87
-        "freight","header_email_receipt","invoice_num","last_name","line_item",
88
-        "login","method","phone","po_num","recurring_billing","relay_response",
89
-        "ship_to_address","ship_to_city","ship_to_company","ship_to_country",
90
-        "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip",
91
-        "split_tender_id","state","tax","tax_exempt","test_request","tran_key",
92
-        "trans_id","type","version","zip"
80
+    private $_all_aim_fields = array("address", "allow_partial_auth", "amount",
81
+        "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name",
82
+        "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name",
83
+        "card_code", "card_num", "cardholder_authentication_value", "city", "company",
84
+        "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description",
85
+        "duplicate_window", "duty", "echeck_type", "email", "email_customer",
86
+        "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt",
87
+        "freight", "header_email_receipt", "invoice_num", "last_name", "line_item",
88
+        "login", "method", "phone", "po_num", "recurring_billing", "relay_response",
89
+        "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country",
90
+        "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip",
91
+        "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key",
92
+        "trans_id", "type", "version", "zip"
93 93
         );
94 94
     
95 95
     /**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public function setFields($fields)
236 236
     {
237
-        $array = (array)$fields;
237
+        $array = (array) $fields;
238 238
         foreach ($array as $key => $value) {
239 239
             $this->setField($key, $value);
240 240
         }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function setCustomFields($fields)
249 249
     {
250
-        $array = (array)$fields;
250
+        $array = (array) $fields;
251 251
         foreach ($array as $key => $value) {
252 252
             $this->setCustomField($key, $value);
253 253
         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             // Split Array
404 404
             $this->response = $response;
405 405
             if ($encap_char) {
406
-                $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
406
+                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
407 407
             } else {
408 408
                 $this->_response_array = explode($delimiter, $response);
409 409
             }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             $this->duty                 = $this->_response_array[33];
458 458
             $this->freight              = $this->_response_array[34];
459 459
             $this->tax_exempt           = $this->_response_array[35];
460
-            $this->purchase_order_number= $this->_response_array[36];
460
+            $this->purchase_order_number = $this->_response_array[36];
461 461
             $this->md5_hash             = $this->_response_array[37];
462 462
             $this->card_code_response   = $this->_response_array[38];
463 463
             $this->cavv_response        = $this->_response_array[39];
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
             
485 485
             if ($this->error) {
486 486
                 $this->error_message = "AuthorizeNet Error:
487
-                Response Code: ".$this->response_code."
488
-                Response Subcode: ".$this->response_subcode."
489
-                Response Reason Code: ".$this->response_reason_code."
490
-                Response Reason Text: ".$this->response_reason_text."
487
+                Response Code: ".$this->response_code . "
488
+                Response Subcode: ".$this->response_subcode . "
489
+                Response Reason Code: ".$this->response_reason_code . "
490
+                Response Reason Text: ".$this->response_reason_text . "
491 491
                 ";
492 492
             }
493 493
         } else {
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCP.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -116,27 +116,27 @@  discard block
 block discarded – undo
116 116
                 
117 117
                 $this->xml = @simplexml_load_string($response);
118 118
                 // Set all fields
119
-                $this->version              = array_pop(array_slice(explode('"', $response), 1,1));
120
-                $this->response_code        = (string)$this->xml->ResponseCode;
119
+                $this->version              = array_pop(array_slice(explode('"', $response), 1, 1));
120
+                $this->response_code        = (string) $this->xml->ResponseCode;
121 121
                 
122 122
                 if ($this->response_code == 1) {
123
-                    $this->response_reason_code = (string)$this->xml->Messages->Message->Code;
124
-                    $this->response_reason_text = (string)$this->xml->Messages->Message->Description;
123
+                    $this->response_reason_code = (string) $this->xml->Messages->Message->Code;
124
+                    $this->response_reason_text = (string) $this->xml->Messages->Message->Description;
125 125
                 } else {
126
-                    $this->response_reason_code = (string)$this->xml->Errors->Error->ErrorCode;
127
-                    $this->response_reason_text = (string)$this->xml->Errors->Error->ErrorText;
126
+                    $this->response_reason_code = (string) $this->xml->Errors->Error->ErrorCode;
127
+                    $this->response_reason_text = (string) $this->xml->Errors->Error->ErrorText;
128 128
                 }
129 129
                 
130
-                $this->authorization_code   = (string)$this->xml->AuthCode;
131
-                $this->avs_code             = (string)$this->xml->AVSResultCode;
132
-                $this->card_code_response   = (string)$this->xml->CVVResultCode;
133
-                $this->transaction_id       = (string)$this->xml->TransID;
134
-                $this->md5_hash             = (string)$this->xml->TransHash;
135
-                $this->user_ref             = (string)$this->xml->UserRef;
136
-                $this->card_num             = (string)$this->xml->AccountNumber;
137
-                $this->card_type            = (string)$this->xml->AccountType;
138
-                $this->test_mode            = (string)$this->xml->TestMode;
139
-                $this->ref_trans_id         = (string)$this->xml->RefTransID;
130
+                $this->authorization_code   = (string) $this->xml->AuthCode;
131
+                $this->avs_code             = (string) $this->xml->AVSResultCode;
132
+                $this->card_code_response   = (string) $this->xml->CVVResultCode;
133
+                $this->transaction_id       = (string) $this->xml->TransID;
134
+                $this->md5_hash             = (string) $this->xml->TransHash;
135
+                $this->user_ref             = (string) $this->xml->UserRef;
136
+                $this->card_num             = (string) $this->xml->AccountNumber;
137
+                $this->card_type            = (string) $this->xml->AccountType;
138
+                $this->test_mode            = (string) $this->xml->TestMode;
139
+                $this->ref_trans_id         = (string) $this->xml->RefTransID;
140 140
                 
141 141
                 
142 142
             } else { // If it's an NVP response
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 // Split Array
145 145
                 $this->response = $response;
146 146
                 if ($encap_char) {
147
-                    $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
147
+                    $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
148 148
                 } else {
149 149
                     $this->_response_array = explode($delimiter, $response);
150 150
                 }
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
             
191 191
             if ($this->error) {
192 192
                 $this->error_message = "AuthorizeNet Error:
193
-                Response Code: ".$this->response_code."
194
-                Response Reason Code: ".$this->response_reason_code."
195
-                Response Reason Text: ".$this->response_reason_text."
193
+                Response Code: ".$this->response_code . "
194
+                Response Reason Code: ".$this->response_reason_code . "
195
+                Response Reason Text: ".$this->response_reason_text . "
196 196
                 ";
197 197
             }
198 198
             
Please login to merge, or discard this patch.
includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 	public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER)
52 52
 	{
53
-		$login    = trim($login);
53
+		$login = trim($login);
54 54
         $transkey = trim($transkey);
55 55
         if (empty($login) || empty($transkey))
56 56
         {
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
     private function removeResponseXMLNS($input)
74 74
     {
75 75
         // why remove them one at a time? all three aren't consistantly used in the response
76
-        $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"','',$input);
77
-        $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','',$input);
78
-        return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input);
76
+        $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $input);
77
+        $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', '', $input);
78
+        return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"', '', $input);
79 79
     }
80 80
 
81 81
 	public function __toString()
82 82
 	{
83
-	    $output  = '';
83
+	    $output = '';
84 84
         $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n";
85 85
         $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n";
86 86
         $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n";
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
             {
160 160
                 if (is_array($value))
161 161
                 {
162
-                    if(is_numeric($key))
162
+                    if (is_numeric($key))
163 163
                     {
164
-                        if($first === true)
164
+                        if ($first === true)
165 165
                         {
166 166
                             $xmlx  = $xml;
167 167
                             $first = false;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     	curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2);
201 201
     	curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem');
202 202
 
203
-        if(($this->response = curl_exec($this->ch)) !== false)
203
+        if (($this->response = curl_exec($this->ch)) !== false)
204 204
         {
205 205
             $this->response_xml = @new SimpleXMLElement($this->response);
206 206
 
Please login to merge, or discard this patch.
includes/class-wpinv-addons.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * All Invoicing extensions screen related functions can be found here.
6 6
  *
7 7
  */
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array of tabs.
22 22
 	 */
23
-	public function get_tabs(){
23
+	public function get_tabs() {
24 24
 		$tabs = array(
25 25
 			'addons' => __("Addons", "invoicing"),
26 26
             'gateways' => __("Payment Gateways", "invoicing"),
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return array
40 40
 	 */
41
-	public function get_section_data( $section_id ) {
42
-		$section      = self::get_tab( $section_id );
41
+	public function get_section_data($section_id) {
42
+		$section      = self::get_tab($section_id);
43 43
 		$api_url = "https://wpinvoicing.com/edd-api/v2/products/";
44 44
 		$section_data = new stdClass();
45 45
 
46
-		if($section_id=='recommended_plugins'){
46
+		if ($section_id == 'recommended_plugins') {
47 47
 			$section_data->products = self::get_recommend_wp_plugins_edd_formatted();
48 48
 		}
49
-		elseif ( ! empty( $section ) ) {
50
-			if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing
49
+		elseif (!empty($section)) {
50
+			if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing
51 51
 			//if ( 1==1) {
52 52
 
53
-				$query_args = array( 'category' => $section_id, 'number' => 100);
54
-				$query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id);
53
+				$query_args = array('category' => $section_id, 'number' => 100);
54
+				$query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id);
55 55
 
56
-				$raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout'     => 15, ) );
56
+				$raw_section = wp_safe_remote_get(esc_url_raw(add_query_arg($query_args, $api_url)), array('user-agent' => 'Invoicing Addons Page', 'timeout'     => 15,));
57 57
 
58
-				if ( ! is_wp_error( $raw_section ) ) {
59
-					$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
58
+				if (!is_wp_error($raw_section)) {
59
+					$section_data = json_decode(wp_remote_retrieve_body($raw_section));
60 60
 
61
-					if ( ! empty( $section_data->products ) ) {
62
-						set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS );
61
+					if (!empty($section_data->products)) {
62
+						set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS);
63 63
 					}
64 64
 				}
65 65
 			}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$products = isset($section_data->products) ? $section_data->products : '';
69 69
 
70
-		return apply_filters( 'wpi_addons_section_data', $products, $section_id );
70
+		return apply_filters('wpi_addons_section_data', $products, $section_id);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param string $theme
79 79
 	 * @param string $plugin
80 80
 	 */
81
-	public function output_button( $addon ) {
82
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
81
+	public function output_button($addon) {
82
+		$current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
83 83
 //		$button_text = __('Free','invoicing');
84 84
 //		$licensing = false;
85 85
 //		$installed = false;
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 //		$install_status = 'get';
92 92
 //		$onclick = '';
93 93
 
94
-		$wp_org_themes = array('supreme-directory','directory-starter');
94
+		$wp_org_themes = array('supreme-directory', 'directory-starter');
95 95
 
96 96
 		$button_args = array(
97
-			'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab,
97
+			'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab,
98 98
 			'id' => isset($addon->info->id) ? absint($addon->info->id) : '',
99 99
 			'title' => isset($addon->info->title) ? $addon->info->title : '',
100
-			'button_text' => __('Free','invoicing'),
101
-			'price_text' => __('Free','invoicing'),
100
+			'button_text' => __('Free', 'invoicing'),
101
+			'price_text' => __('Free', 'invoicing'),
102 102
 			'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product
103 103
 			'url' => isset($addon->info->link) ? $addon->info->link : '', // button url
104 104
 			'class' => 'button-primary',
@@ -114,83 +114,83 @@  discard block
 block discarded – undo
114 114
 			'update_url' => '',
115 115
 		);
116 116
 
117
-		if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
118
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
119
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
117
+		if (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) {
118
+			include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
119
+			if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; }
120 120
 			$status = self::install_plugin_install_status($addon);
121 121
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
122
-			if(isset($status['status'])){$button_args['install_status'] = $status['status'];}
122
+			if (isset($status['status'])) {$button_args['install_status'] = $status['status']; }
123 123
 			$button_args['update_url'] = "https://wpinvoicing.com";
124
-		}elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
125
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
124
+		}elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
125
+			if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; }
126 126
 			$button_args['installed'] = self::is_theme_installed($addon);
127
-			if(!in_array($button_args['slug'],$wp_org_themes)){
127
+			if (!in_array($button_args['slug'], $wp_org_themes)) {
128 128
 				$button_args['update_url'] = "https://wpinvoicing.com";
129 129
 			}
130
-		}elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){
131
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
132
-			$status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>""));
130
+		}elseif ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug) {
131
+			include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
132
+			$status = install_plugin_install_status(array("slug"=>$button_args['slug'], "version"=>""));
133 133
 			$button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install';
134 134
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
135 135
 		}
136 136
 
137 137
 		// set price
138
-		if(isset($addon->pricing) && !empty($addon->pricing)){
139
-			if(is_object($addon->pricing)){
140
-				$prices = (Array)$addon->pricing;
138
+		if (isset($addon->pricing) && !empty($addon->pricing)) {
139
+			if (is_object($addon->pricing)) {
140
+				$prices = (Array) $addon->pricing;
141 141
 				$button_args['price'] = reset($prices);
142
-			}elseif(isset($addon->pricing)){
142
+			}elseif (isset($addon->pricing)) {
143 143
 				$button_args['price'] = $addon->pricing;
144 144
 			}
145 145
 		}
146 146
 
147 147
 		// set price text
148
-		if( $button_args['price'] && $button_args['price'] != '0.00' ){
149
-			$button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']);
148
+		if ($button_args['price'] && $button_args['price'] != '0.00') {
149
+			$button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']);
150 150
 		}
151 151
 
152 152
 
153 153
 		// set if installed
154
-		if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){
154
+		if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) {
155 155
 			$button_args['installed'] = true;
156 156
 		}
157 157
 
158 158
 //		print_r($button_args);
159 159
 		// set if active
160
-		if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){
161
-			if($button_args['type'] != 'themes'){
160
+		if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) {
161
+			if ($button_args['type'] != 'themes') {
162 162
 				$button_args['active'] = is_plugin_active($button_args['file']);
163
-			}else{
163
+			} else {
164 164
 				$button_args['active'] = self::is_theme_active($addon);
165 165
 			}
166 166
 		}
167 167
 
168 168
 		// set button text and class
169
-		if($button_args['active']){
170
-			$button_args['button_text'] = __('Active','invoicing');
169
+		if ($button_args['active']) {
170
+			$button_args['button_text'] = __('Active', 'invoicing');
171 171
 			$button_args['class'] = ' button-secondary disabled ';
172
-		}elseif($button_args['installed']){
173
-			$button_args['button_text'] = __('Activate','invoicing');
172
+		}elseif ($button_args['installed']) {
173
+			$button_args['button_text'] = __('Activate', 'invoicing');
174 174
 
175
-			if($button_args['type'] != 'themes'){
176
-				if ( current_user_can( 'manage_options' ) ) {
177
-					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']);
178
-				}else{
175
+			if ($button_args['type'] != 'themes') {
176
+				if (current_user_can('manage_options')) {
177
+					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']);
178
+				} else {
179 179
 					$button_args['url'] = '#';
180 180
 				}
181
-			}else{
182
-				if ( current_user_can( 'switch_themes' ) ) {
181
+			} else {
182
+				if (current_user_can('switch_themes')) {
183 183
 					$button_args['url'] = self::get_theme_activation_url($addon);
184
-				}else{
184
+				} else {
185 185
 					$button_args['url'] = '#';
186 186
 				}
187 187
 			}
188 188
 
189
-		}else{
190
-			if($button_args['type'] == 'recommended_plugins'){
191
-				$button_args['button_text'] = __('Install','invoicing');
192
-			}else{
193
-				$button_args['button_text'] = __('Get it','invoicing');
189
+		} else {
190
+			if ($button_args['type'] == 'recommended_plugins') {
191
+				$button_args['button_text'] = __('Install', 'invoicing');
192
+			} else {
193
+				$button_args['button_text'] = __('Get it', 'invoicing');
194 194
 
195 195
 				/*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){
196 196
 					$button_args['button_text'] = __('Install','invoicing');
@@ -203,45 +203,45 @@  discard block
 block discarded – undo
203 203
 
204 204
 		
205 205
 		// filter the button arguments
206
-		$button_args = apply_filters('edd_api_button_args',$button_args);
206
+		$button_args = apply_filters('edd_api_button_args', $button_args);
207 207
 //		print_r($button_args);
208 208
 		// set price text
209
-		if(isset($button_args['price_text'])){
209
+		if (isset($button_args['price_text'])) {
210 210
 			?>
211 211
 			<a
212 212
 				target="_blank"
213 213
 				class="addons-price-text"
214
-				href="<?php echo esc_url( $button_args['link'] ); ?>">
215
-				<?php echo esc_html( $button_args['price_text'] ); ?>
214
+				href="<?php echo esc_url($button_args['link']); ?>">
215
+				<?php echo esc_html($button_args['price_text']); ?>
216 216
 			</a>
217 217
 			<?php
218 218
 		}
219 219
 
220 220
 
221 221
 		$target = '';
222
-		if ( ! empty( $button_args['url'] ) ) {
222
+		if (!empty($button_args['url'])) {
223 223
 			$target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" ';
224 224
 		}
225 225
 
226 226
 		?>
227 227
 		<a
228
-			data-licence="<?php echo esc_attr($button_args['license']);?>"
229
-			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>"
230
-			data-title="<?php echo esc_attr($button_args['title']);?>"
231
-			data-type="<?php echo esc_attr($button_args['type']);?>"
232
-			data-text-error-message="<?php _e('Something went wrong!','invoicing');?>"
233
-			data-text-activate="<?php _e('Activate','invoicing');?>"
234
-			data-text-activating="<?php _e('Activating','invoicing');?>"
235
-			data-text-deactivate="<?php _e('Deactivate','invoicing');?>"
236
-			data-text-installed="<?php _e('Installed','invoicing');?>"
237
-			data-text-install="<?php _e('Install','invoicing');?>"
238
-			data-text-installing="<?php _e('Installing','invoicing');?>"
239
-			data-text-error="<?php _e('Error','invoicing');?>"
240
-			<?php if(!empty($button_args['onclick'])){echo " onclick='".$button_args['onclick']."' ";}?>
241
-			<?php echo $target;?>
242
-			class="addons-button  <?php echo esc_attr( $button_args['class'] ); ?>"
243
-			href="<?php echo esc_url( $button_args['url'] ); ?>">
244
-			<?php echo esc_html( $button_args['button_text'] ); ?>
228
+			data-licence="<?php echo esc_attr($button_args['license']); ?>"
229
+			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>"
230
+			data-title="<?php echo esc_attr($button_args['title']); ?>"
231
+			data-type="<?php echo esc_attr($button_args['type']); ?>"
232
+			data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>"
233
+			data-text-activate="<?php _e('Activate', 'invoicing'); ?>"
234
+			data-text-activating="<?php _e('Activating', 'invoicing'); ?>"
235
+			data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>"
236
+			data-text-installed="<?php _e('Installed', 'invoicing'); ?>"
237
+			data-text-install="<?php _e('Install', 'invoicing'); ?>"
238
+			data-text-installing="<?php _e('Installing', 'invoicing'); ?>"
239
+			data-text-error="<?php _e('Error', 'invoicing'); ?>"
240
+			<?php if (!empty($button_args['onclick'])) {echo " onclick='" . $button_args['onclick'] . "' "; }?>
241
+			<?php echo $target; ?>
242
+			class="addons-button  <?php echo esc_attr($button_args['class']); ?>"
243
+			href="<?php echo esc_url($button_args['url']); ?>">
244
+			<?php echo esc_html($button_args['button_text']); ?>
245 245
 		</a>
246 246
 		<?php
247 247
 
@@ -256,35 +256,35 @@  discard block
 block discarded – undo
256 256
 		$tabs            = self::get_tabs();
257 257
 		$sections        = self::get_sections();
258 258
 		$theme           = wp_get_theme();
259
-		$section_keys    = array_keys( $sections );
260
-		$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
261
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
262
-		include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
259
+		$section_keys    = array_keys($sections);
260
+		$current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys);
261
+		$current_tab     = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
262
+		include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php');
263 263
 	}
264 264
 
265 265
 	/**
266 266
 	 * A list of recommended wp.org plugins.
267 267
 	 * @return array
268 268
 	 */
269
-	public function get_recommend_wp_plugins(){
269
+	public function get_recommend_wp_plugins() {
270 270
 		$plugins = array(
271 271
             'invoicing-quotes' => array(
272 272
                 'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
273 273
                 'slug'   => 'invoicing-quotes',
274 274
                 'name'   => 'Quotes',
275
-                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'),
275
+                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'),
276 276
             ),
277 277
             'geodirectory' => array(
278 278
                 'url'   => 'https://wordpress.org/plugins/geodirectory/',
279 279
                 'slug'   => 'geodirectory',
280 280
                 'name'   => 'GeoDirectory',
281
-                'desc'   => __('Turn any WordPress theme into a global business directory portal.','invoicing'),
281
+                'desc'   => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'),
282 282
             ),
283 283
             'userswp' => array(
284 284
                 'url'   => 'https://wordpress.org/plugins/userswp/',
285 285
                 'slug'   => 'userswp',
286 286
                 'name'   => 'UsersWP',
287
-                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'),
287
+                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'),
288 288
             ),
289 289
 		);
290 290
 
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +582 added lines, -582 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -30,381 +30,381 @@  discard block
 block discarded – undo
30 30
         'wpinv_fully_refunded',
31 31
         'wpinv_partially_refunded',
32 32
         'wpinv_new_invoice_note'
33
-    ) );
33
+    ));
34 34
 
35
-    foreach ( $email_actions as $action ) {
36
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
35
+    foreach ($email_actions as $action) {
36
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
37 37
     }
38 38
 }
39
-add_action( 'init', 'wpinv_init_transactional_emails' );
39
+add_action('init', 'wpinv_init_transactional_emails');
40 40
 
41 41
 // New invoice email
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
46
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
47
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
42
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
46
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
47
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
48 48
 
49 49
 // Cancelled invoice email
50
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
51
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
50
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
51
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
52 52
 
53 53
 // Failed invoice email
54
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
55
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
54
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
55
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
56 56
 
57 57
 // On hold invoice email
58
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
59
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
58
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
59
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
60 60
 
61 61
 // Processing invoice email
62
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
62
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
63 63
 
64 64
 // Paid invoice email
65
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
65
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
66 66
 
67 67
 // Refunded invoice email
68
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
69
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
70
-add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
71
-add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
68
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
69
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
70
+add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
71
+add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
72 72
 
73 73
 // Invoice note
74
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
74
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
75 75
 
76
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
77
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
78
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
79
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
80
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
76
+add_action('wpinv_email_header', 'wpinv_email_header');
77
+add_action('wpinv_email_footer', 'wpinv_email_footer');
78
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
79
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
80
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
81 81
 
82 82
 function wpinv_send_transactional_email() {
83 83
     $args       = func_get_args();
84 84
     $function   = current_filter() . '_notification';
85
-    do_action_ref_array( $function, $args );
85
+    do_action_ref_array($function, $args);
86 86
 }
87 87
 
88
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
88
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
89 89
     $email_type = 'new_invoice';
90
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
90
+    if (!wpinv_email_is_enabled($email_type)) {
91 91
         return false;
92 92
     }
93 93
 
94
-    $invoice = wpinv_get_invoice( $invoice_id );
95
-    if ( empty( $invoice ) ) {
94
+    $invoice = wpinv_get_invoice($invoice_id);
95
+    if (empty($invoice)) {
96 96
         return false;
97 97
     }
98 98
 
99
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
99
+    if (!("wpi_invoice" === $invoice->post_type)) {
100 100
         return false;
101 101
     }
102 102
 
103
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
104
-    if ( !is_email( $recipient ) ) {
103
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
104
+    if (!is_email($recipient)) {
105 105
         return false;
106 106
     }
107 107
 
108
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
108
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
109 109
 
110
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
111
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
112
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
113
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
114
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
110
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
111
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
112
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
113
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
114
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
115 115
 
116
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
116
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
117 117
             'invoice'       => $invoice,
118 118
             'email_type'    => $email_type,
119 119
             'email_heading' => $email_heading,
120 120
             'sent_to_admin' => true,
121 121
             'plain_text'    => false,
122 122
             'message_body'  => $message_body,
123
-        ) );
123
+        ));
124 124
 
125
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
125
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
126 126
 
127
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
127
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
128 128
 
129 129
     return $sent;
130 130
 }
131 131
 
132
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
132
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
133 133
     $email_type = 'cancelled_invoice';
134
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
134
+    if (!wpinv_email_is_enabled($email_type)) {
135 135
         return false;
136 136
     }
137 137
 
138
-    $invoice = wpinv_get_invoice( $invoice_id );
139
-    if ( empty( $invoice ) ) {
138
+    $invoice = wpinv_get_invoice($invoice_id);
139
+    if (empty($invoice)) {
140 140
         return false;
141 141
     }
142 142
 
143
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
143
+    if (!("wpi_invoice" === $invoice->post_type)) {
144 144
         return false;
145 145
     }
146 146
 
147
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
148
-    if ( !is_email( $recipient ) ) {
147
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
148
+    if (!is_email($recipient)) {
149 149
         return false;
150 150
     }
151 151
 
152
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
152
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
153 153
 
154
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
155
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
156
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
157
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
158
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
154
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
155
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
156
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
157
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
158
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
159 159
 
160
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
160
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
161 161
             'invoice'       => $invoice,
162 162
             'email_type'    => $email_type,
163 163
             'email_heading' => $email_heading,
164 164
             'sent_to_admin' => true,
165 165
             'plain_text'    => false,
166 166
             'message_body'  => $message_body,
167
-        ) );
167
+        ));
168 168
 
169
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
169
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
170 170
 
171
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
171
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
172 172
 
173 173
     return $sent;
174 174
 }
175 175
 
176
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
176
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
177 177
     $email_type = 'failed_invoice';
178
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
178
+    if (!wpinv_email_is_enabled($email_type)) {
179 179
         return false;
180 180
     }
181 181
     
182
-    $invoice = wpinv_get_invoice( $invoice_id );
183
-    if ( empty( $invoice ) ) {
182
+    $invoice = wpinv_get_invoice($invoice_id);
183
+    if (empty($invoice)) {
184 184
         return false;
185 185
     }
186 186
 
187
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
187
+    if (!("wpi_invoice" === $invoice->post_type)) {
188 188
         return false;
189 189
     }
190 190
 
191
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
192
-    if ( !is_email( $recipient ) ) {
191
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
192
+    if (!is_email($recipient)) {
193 193
         return false;
194 194
     }
195 195
 
196
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
196
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
197 197
 
198
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
199
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
200
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
201
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
202
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
198
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
199
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
200
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
201
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
202
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
203 203
     
204
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
204
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
205 205
             'invoice'       => $invoice,
206 206
             'email_type'    => $email_type,
207 207
             'email_heading' => $email_heading,
208 208
             'sent_to_admin' => true,
209 209
             'plain_text'    => false,
210 210
             'message_body'  => $message_body,
211
-        ) );
211
+        ));
212 212
 
213
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
213
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
214 214
 
215
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
215
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
216 216
 
217 217
     return $sent;
218 218
 }
219 219
 
220
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
220
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
221 221
     $email_type = 'onhold_invoice';
222
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
222
+    if (!wpinv_email_is_enabled($email_type)) {
223 223
         return false;
224 224
     }
225 225
 
226
-    $invoice = wpinv_get_invoice( $invoice_id );
227
-    if ( empty( $invoice ) ) {
226
+    $invoice = wpinv_get_invoice($invoice_id);
227
+    if (empty($invoice)) {
228 228
         return false;
229 229
     }
230 230
 
231
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
231
+    if (!("wpi_invoice" === $invoice->post_type)) {
232 232
         return false;
233 233
     }
234 234
 
235
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
236
-    if ( !is_email( $recipient ) ) {
235
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
236
+    if (!is_email($recipient)) {
237 237
         return false;
238 238
     }
239 239
 
240
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
240
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
241 241
 
242
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
243
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
244
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
245
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
246
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
242
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
243
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
244
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
245
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
246
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
247 247
     
248
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
248
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
249 249
             'invoice'       => $invoice,
250 250
             'email_type'    => $email_type,
251 251
             'email_heading' => $email_heading,
252 252
             'sent_to_admin' => false,
253 253
             'plain_text'    => false,
254 254
             'message_body'  => $message_body,
255
-        ) );
255
+        ));
256 256
     
257
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
257
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
258 258
     
259
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
260
-        $recipient  = wpinv_get_admin_email();
261
-        $subject    .= ' - ADMIN BCC COPY';
262
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
259
+    if (wpinv_mail_admin_bcc_active($email_type)) {
260
+        $recipient = wpinv_get_admin_email();
261
+        $subject .= ' - ADMIN BCC COPY';
262
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
263 263
     }
264 264
 
265
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
265
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
266 266
 
267 267
     return $sent;
268 268
 }
269 269
 
270
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
270
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
271 271
     $email_type = 'processing_invoice';
272
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
272
+    if (!wpinv_email_is_enabled($email_type)) {
273 273
         return false;
274 274
     }
275 275
 
276
-    $invoice = wpinv_get_invoice( $invoice_id );
277
-    if ( empty( $invoice ) ) {
276
+    $invoice = wpinv_get_invoice($invoice_id);
277
+    if (empty($invoice)) {
278 278
         return false;
279 279
     }
280 280
 
281
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
281
+    if (!("wpi_invoice" === $invoice->post_type)) {
282 282
         return false;
283 283
     }
284 284
 
285
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
286
-    if ( !is_email( $recipient ) ) {
285
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
286
+    if (!is_email($recipient)) {
287 287
         return false;
288 288
     }
289 289
 
290
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
290
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
291 291
 
292 292
     $search                     = array();
293 293
     $search['invoice_number']   = '{invoice_number}';
294 294
     $search['invoice_date']     = '{invoice_date}';
295 295
     $search['name']             = '{name}';
296 296
 
297
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
298
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
299
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
300
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
301
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
297
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
298
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
299
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
300
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
301
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
302 302
     
303
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
303
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
304 304
             'invoice'       => $invoice,
305 305
             'email_type'    => $email_type,
306 306
             'email_heading' => $email_heading,
307 307
             'sent_to_admin' => false,
308 308
             'plain_text'    => false,
309 309
             'message_body'  => $message_body,
310
-        ) );
310
+        ));
311 311
 
312
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
312
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
313 313
 
314
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
315
-        $recipient  = wpinv_get_admin_email();
316
-        $subject    .= ' - ADMIN BCC COPY';
317
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
314
+    if (wpinv_mail_admin_bcc_active($email_type)) {
315
+        $recipient = wpinv_get_admin_email();
316
+        $subject .= ' - ADMIN BCC COPY';
317
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
318 318
     }
319 319
 
320
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
320
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
321 321
 
322 322
     return $sent;
323 323
 }
324 324
 
325
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
325
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
326 326
     $email_type = 'completed_invoice';
327
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
327
+    if (!wpinv_email_is_enabled($email_type)) {
328 328
         return false;
329 329
     }
330 330
 
331
-    $invoice = wpinv_get_invoice( $invoice_id );
332
-    if ( empty( $invoice ) ) {
331
+    $invoice = wpinv_get_invoice($invoice_id);
332
+    if (empty($invoice)) {
333 333
         return false;
334 334
     }
335 335
 
336
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
336
+    if (!("wpi_invoice" === $invoice->post_type)) {
337 337
         return false;
338 338
     }
339 339
 
340
-    if($invoice->is_renewal() && wpinv_email_is_enabled( 'completed_invoice_renewal' )){
340
+    if ($invoice->is_renewal() && wpinv_email_is_enabled('completed_invoice_renewal')) {
341 341
         return false;
342 342
     }
343 343
 
344
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
345
-    if ( !is_email( $recipient ) ) {
344
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
345
+    if (!is_email($recipient)) {
346 346
         return false;
347 347
     }
348 348
 
349
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
349
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
350 350
 
351
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
352
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
353
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
354
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
355
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
351
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
352
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
353
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
354
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
355
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
356 356
 
357
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
357
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
358 358
             'invoice'       => $invoice,
359 359
             'email_type'    => $email_type,
360 360
             'email_heading' => $email_heading,
361 361
             'sent_to_admin' => false,
362 362
             'plain_text'    => false,
363 363
             'message_body'  => $message_body,
364
-        ) );
364
+        ));
365 365
 
366
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
366
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
367 367
 
368
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
369
-        $recipient  = wpinv_get_admin_email();
370
-        $subject    .= ' - ADMIN BCC COPY';
371
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
368
+    if (wpinv_mail_admin_bcc_active($email_type)) {
369
+        $recipient = wpinv_get_admin_email();
370
+        $subject .= ' - ADMIN BCC COPY';
371
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
372 372
     }
373 373
 
374
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
374
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
375 375
 
376 376
     return $sent;
377 377
 }
378 378
 
379
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
379
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
380 380
     $email_type = 'refunded_invoice';
381
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
381
+    if (!wpinv_email_is_enabled($email_type)) {
382 382
         return false;
383 383
     }
384 384
 
385
-    $invoice = wpinv_get_invoice( $invoice_id );
386
-    if ( empty( $invoice ) ) {
385
+    $invoice = wpinv_get_invoice($invoice_id);
386
+    if (empty($invoice)) {
387 387
         return false;
388 388
     }
389 389
 
390
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
390
+    if (!("wpi_invoice" === $invoice->post_type)) {
391 391
         return false;
392 392
     }
393 393
 
394
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
395
-    if ( !is_email( $recipient ) ) {
394
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
395
+    if (!is_email($recipient)) {
396 396
         return false;
397 397
     }
398 398
 
399
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
399
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
400 400
 
401
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
402
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
403
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
404
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
405
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
401
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
402
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
403
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
404
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
405
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
406 406
 
407
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
407
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
408 408
             'invoice'           => $invoice,
409 409
             'email_type'        => $email_type,
410 410
             'email_heading'     => $email_heading,
@@ -412,50 +412,50 @@  discard block
 block discarded – undo
412 412
             'plain_text'        => false,
413 413
             'partial_refund'    => false,
414 414
             'message_body'      => $message_body,
415
-        ) );
415
+        ));
416 416
 
417
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
417
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
418 418
 
419
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
420
-        $recipient  = wpinv_get_admin_email();
421
-        $subject    .= ' - ADMIN BCC COPY';
422
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
419
+    if (wpinv_mail_admin_bcc_active($email_type)) {
420
+        $recipient = wpinv_get_admin_email();
421
+        $subject .= ' - ADMIN BCC COPY';
422
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
423 423
     }
424 424
 
425
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
425
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
426 426
 
427 427
     return $sent;
428 428
 }
429 429
 
430
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
430
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
431 431
     $email_type = 'refunded_invoice';
432
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
432
+    if (!wpinv_email_is_enabled($email_type)) {
433 433
         return false;
434 434
     }
435 435
 
436
-    $invoice = wpinv_get_invoice( $invoice_id );
437
-    if ( empty( $invoice ) ) {
436
+    $invoice = wpinv_get_invoice($invoice_id);
437
+    if (empty($invoice)) {
438 438
         return false;
439 439
     }
440 440
 
441
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
441
+    if (!("wpi_invoice" === $invoice->post_type)) {
442 442
         return false;
443 443
     }
444 444
 
445
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
446
-    if ( !is_email( $recipient ) ) {
445
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
446
+    if (!is_email($recipient)) {
447 447
         return false;
448 448
     }
449 449
 
450
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
450
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
451 451
 
452
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
453
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
454
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
455
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
456
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
452
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
453
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
454
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
455
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
456
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
457 457
 
458
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
458
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
459 459
             'invoice'           => $invoice,
460 460
             'email_type'        => $email_type,
461 461
             'email_heading'     => $email_heading,
@@ -463,95 +463,95 @@  discard block
 block discarded – undo
463 463
             'plain_text'        => false,
464 464
             'partial_refund'    => true,
465 465
             'message_body'      => $message_body,
466
-        ) );
466
+        ));
467 467
 
468
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
468
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
469 469
 
470
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
471
-        $recipient  = wpinv_get_admin_email();
472
-        $subject    .= ' - ADMIN BCC COPY';
473
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
470
+    if (wpinv_mail_admin_bcc_active($email_type)) {
471
+        $recipient = wpinv_get_admin_email();
472
+        $subject .= ' - ADMIN BCC COPY';
473
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
474 474
     }
475 475
 
476
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
476
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
477 477
 
478 478
     return $sent;
479 479
 }
480 480
 
481
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
481
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
482 482
 }
483 483
 
484
-function wpinv_user_invoice_notification( $invoice_id ) {
484
+function wpinv_user_invoice_notification($invoice_id) {
485 485
     $email_type = 'user_invoice';
486
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
486
+    if (!wpinv_email_is_enabled($email_type)) {
487 487
         return -1;
488 488
     }
489 489
 
490
-    $invoice = wpinv_get_invoice( $invoice_id );
491
-    if ( empty( $invoice ) ) {
490
+    $invoice = wpinv_get_invoice($invoice_id);
491
+    if (empty($invoice)) {
492 492
         return false;
493 493
     }
494 494
 
495
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
495
+    if (!("wpi_invoice" === $invoice->post_type)) {
496 496
         return false;
497 497
     }
498 498
 
499
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
500
-    if ( !is_email( $recipient ) ) {
499
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
500
+    if (!is_email($recipient)) {
501 501
         return false;
502 502
     }
503 503
 
504
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
504
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
505 505
 
506
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
507
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
508
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
509
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
510
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
506
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
507
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
508
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
509
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
510
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
511 511
     
512
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
512
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
513 513
             'invoice'       => $invoice,
514 514
             'email_type'    => $email_type,
515 515
             'email_heading' => $email_heading,
516 516
             'sent_to_admin' => false,
517 517
             'plain_text'    => false,
518 518
             'message_body'  => $message_body,
519
-        ) );
519
+        ));
520 520
 
521
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
521
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
522 522
 
523
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
524
-        $recipient  = wpinv_get_admin_email();
525
-        $subject    .= ' - ADMIN BCC COPY';
526
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
523
+    if (wpinv_mail_admin_bcc_active($email_type)) {
524
+        $recipient = wpinv_get_admin_email();
525
+        $subject .= ' - ADMIN BCC COPY';
526
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
527 527
     }
528 528
 
529
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
529
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
530 530
 
531
-    if ( $sent ) {
532
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
531
+    if ($sent) {
532
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
533 533
     } else {
534
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
534
+        $note = __('Fail to send invoice to the user!', 'invoicing');
535 535
     }
536 536
 
537
-    $invoice->add_note( $note, '', '', true ); // Add system note.
537
+    $invoice->add_note($note, '', '', true); // Add system note.
538 538
 
539 539
     return $sent;
540 540
 }
541 541
 
542
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
542
+function wpinv_user_note_notification($invoice_id, $args = array()) {
543 543
     $email_type = 'user_note';
544
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
544
+    if (!wpinv_email_is_enabled($email_type)) {
545 545
         return false;
546 546
     }
547 547
 
548
-    $invoice = wpinv_get_invoice( $invoice_id );
549
-    if ( empty( $invoice ) ) {
548
+    $invoice = wpinv_get_invoice($invoice_id);
549
+    if (empty($invoice)) {
550 550
         return false;
551 551
     }
552 552
 
553
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
554
-    if ( !is_email( $recipient ) ) {
553
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
554
+    if (!is_email($recipient)) {
555 555
         return false;
556 556
     }
557 557
 
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
         'user_note' => ''
560 560
     );
561 561
 
562
-    $args = wp_parse_args( $args, $defaults );
562
+    $args = wp_parse_args($args, $defaults);
563 563
 
564
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
564
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
565 565
 
566
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
567
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
568
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
569
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
570
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
566
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
567
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
568
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
569
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
570
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
571 571
 
572
-    $message_body   = str_replace( '{customer_note}', $args['user_note'], $message_body );
572
+    $message_body   = str_replace('{customer_note}', $args['user_note'], $message_body);
573 573
 
574
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
574
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
575 575
             'invoice'       => $invoice,
576 576
             'email_type'    => $email_type,
577 577
             'email_heading' => $email_heading,
@@ -579,36 +579,36 @@  discard block
 block discarded – undo
579 579
             'plain_text'    => false,
580 580
             'message_body'  => $message_body,
581 581
             'customer_note' => $args['user_note']
582
-        ) );
582
+        ));
583 583
 
584
-    $content        = wpinv_email_format_text( $content, $invoice );
584
+    $content = wpinv_email_format_text($content, $invoice);
585 585
 
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
 
588
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
588
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
589 589
 
590 590
     return $sent;
591 591
 }
592 592
 
593 593
 function wpinv_mail_get_from_address() {
594
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
595
-    return sanitize_email( $from_address );
594
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
595
+    return sanitize_email($from_address);
596 596
 }
597 597
 
598 598
 function wpinv_mail_get_from_name() {
599
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
600
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
599
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
600
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
601 601
 }
602 602
 
603
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
604
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
605
-    return ( $active ? true : false );
603
+function wpinv_mail_admin_bcc_active($mail_type = '') {
604
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
605
+    return ($active ? true : false);
606 606
 }
607 607
     
608
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
609
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
608
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
609
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
610 610
 
611
-    switch ( $email_type ) {
611
+    switch ($email_type) {
612 612
         case 'html' :
613 613
             $content_type = 'text/html';
614 614
             break;
@@ -623,35 +623,35 @@  discard block
 block discarded – undo
623 623
     return $content_type;
624 624
 }
625 625
     
626
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
627
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
628
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
629
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
626
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
627
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
628
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
629
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
630 630
 
631
-    $message = wpinv_email_style_body( $message );
632
-    $message = apply_filters( 'wpinv_mail_content', $message );
631
+    $message = wpinv_email_style_body($message);
632
+    $message = apply_filters('wpinv_mail_content', $message);
633 633
 
634
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
634
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
635 635
 
636
-    if ( !$sent ) {
637
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
638
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
636
+    if (!$sent) {
637
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
638
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
639 639
     }
640 640
 
641
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
642
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
643
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
641
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
642
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
643
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
644 644
 
645 645
     return $sent;
646 646
 }
647 647
     
648 648
 function wpinv_get_emails() {
649 649
     $overdue_days_options       = array();
650
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
651
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
650
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
651
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
652 652
 
653
-    for ( $i = 2; $i <= 10; $i++ ) {
654
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
653
+    for ($i = 2; $i <= 10; $i++) {
654
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
655 655
     }
656 656
 
657 657
     // Default, built-in gateways
@@ -659,39 +659,39 @@  discard block
 block discarded – undo
659 659
             'new_invoice' => array(
660 660
             'email_new_invoice_header' => array(
661 661
                 'id'   => 'email_new_invoice_header',
662
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
663
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
662
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
663
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
664 664
                 'type' => 'header',
665 665
             ),
666 666
             'email_new_invoice_active' => array(
667 667
                 'id'   => 'email_new_invoice_active',
668
-                'name' => __( 'Enable/Disable', 'invoicing' ),
669
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
668
+                'name' => __('Enable/Disable', 'invoicing'),
669
+                'desc' => __('Enable this email notification', 'invoicing'),
670 670
                 'type' => 'checkbox',
671 671
                 'std'  => 1
672 672
             ),
673 673
             'email_new_invoice_subject' => array(
674 674
                 'id'   => 'email_new_invoice_subject',
675
-                'name' => __( 'Subject', 'invoicing' ),
676
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
675
+                'name' => __('Subject', 'invoicing'),
676
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
677 677
                 'type' => 'text',
678
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
678
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
679 679
                 'size' => 'large'
680 680
             ),
681 681
             'email_new_invoice_heading' => array(
682 682
                 'id'   => 'email_new_invoice_heading',
683
-                'name' => __( 'Email Heading', 'invoicing' ),
684
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
683
+                'name' => __('Email Heading', 'invoicing'),
684
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
685 685
                 'type' => 'text',
686
-                'std'  => __( 'New payment invoice', 'invoicing' ),
686
+                'std'  => __('New payment invoice', 'invoicing'),
687 687
                 'size' => 'large'
688 688
             ),
689 689
             'email_new_invoice_body' => array(
690 690
                 'id'   => 'email_new_invoice_body',
691
-                'name' => __( 'Email Content', 'invoicing' ),
692
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
691
+                'name' => __('Email Content', 'invoicing'),
692
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
693 693
                 'type' => 'rich_editor',
694
-                'std'  => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
694
+                'std'  => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
695 695
                 'class' => 'large',
696 696
                 'size' => '10'
697 697
             ),
@@ -699,39 +699,39 @@  discard block
 block discarded – undo
699 699
         'cancelled_invoice' => array(
700 700
             'email_cancelled_invoice_header' => array(
701 701
                 'id'   => 'email_cancelled_invoice_header',
702
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
703
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
702
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
703
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
704 704
                 'type' => 'header',
705 705
             ),
706 706
             'email_cancelled_invoice_active' => array(
707 707
                 'id'   => 'email_cancelled_invoice_active',
708
-                'name' => __( 'Enable/Disable', 'invoicing' ),
709
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
708
+                'name' => __('Enable/Disable', 'invoicing'),
709
+                'desc' => __('Enable this email notification', 'invoicing'),
710 710
                 'type' => 'checkbox',
711 711
                 'std'  => 1
712 712
             ),
713 713
             'email_cancelled_invoice_subject' => array(
714 714
                 'id'   => 'email_cancelled_invoice_subject',
715
-                'name' => __( 'Subject', 'invoicing' ),
716
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
715
+                'name' => __('Subject', 'invoicing'),
716
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
717 717
                 'type' => 'text',
718
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
718
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
719 719
                 'size' => 'large'
720 720
             ),
721 721
             'email_cancelled_invoice_heading' => array(
722 722
                 'id'   => 'email_cancelled_invoice_heading',
723
-                'name' => __( 'Email Heading', 'invoicing' ),
724
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
723
+                'name' => __('Email Heading', 'invoicing'),
724
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
725 725
                 'type' => 'text',
726
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
726
+                'std'  => __('Cancelled invoice', 'invoicing'),
727 727
                 'size' => 'large'
728 728
             ),
729 729
             'email_cancelled_invoice_body' => array(
730 730
                 'id'   => 'email_cancelled_invoice_body',
731
-                'name' => __( 'Email Content', 'invoicing' ),
732
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
731
+                'name' => __('Email Content', 'invoicing'),
732
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
733 733
                 'type' => 'rich_editor',
734
-                'std'  => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
734
+                'std'  => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
735 735
                 'class' => 'large',
736 736
                 'size' => '10'
737 737
             ),
@@ -739,39 +739,39 @@  discard block
 block discarded – undo
739 739
         'failed_invoice' => array(
740 740
             'email_failed_invoice_header' => array(
741 741
                 'id'   => 'email_failed_invoice_header',
742
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
743
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
742
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
743
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
744 744
                 'type' => 'header',
745 745
             ),
746 746
             'email_failed_invoice_active' => array(
747 747
                 'id'   => 'email_failed_invoice_active',
748
-                'name' => __( 'Enable/Disable', 'invoicing' ),
749
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
748
+                'name' => __('Enable/Disable', 'invoicing'),
749
+                'desc' => __('Enable this email notification', 'invoicing'),
750 750
                 'type' => 'checkbox',
751 751
                 'std'  => 1
752 752
             ),
753 753
             'email_failed_invoice_subject' => array(
754 754
                 'id'   => 'email_failed_invoice_subject',
755
-                'name' => __( 'Subject', 'invoicing' ),
756
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
755
+                'name' => __('Subject', 'invoicing'),
756
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
757 757
                 'type' => 'text',
758
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
758
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
759 759
                 'size' => 'large'
760 760
             ),
761 761
             'email_failed_invoice_heading' => array(
762 762
                 'id'   => 'email_failed_invoice_heading',
763
-                'name' => __( 'Email Heading', 'invoicing' ),
764
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
763
+                'name' => __('Email Heading', 'invoicing'),
764
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
765 765
                 'type' => 'text',
766
-                'std'  => __( 'Failed invoice', 'invoicing' ),
766
+                'std'  => __('Failed invoice', 'invoicing'),
767 767
                 'size' => 'large'
768 768
             ),
769 769
             'email_failed_invoice_body' => array(
770 770
                 'id'   => 'email_failed_invoice_body',
771
-                'name' => __( 'Email Content', 'invoicing' ),
772
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
771
+                'name' => __('Email Content', 'invoicing'),
772
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
773 773
                 'type' => 'rich_editor',
774
-                'std'  => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
774
+                'std'  => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
775 775
                 'class' => 'large',
776 776
                 'size' => '10'
777 777
             ),
@@ -779,46 +779,46 @@  discard block
 block discarded – undo
779 779
         'onhold_invoice' => array(
780 780
             'email_onhold_invoice_header' => array(
781 781
                 'id'   => 'email_onhold_invoice_header',
782
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
783
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
782
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
783
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
784 784
                 'type' => 'header',
785 785
             ),
786 786
             'email_onhold_invoice_active' => array(
787 787
                 'id'   => 'email_onhold_invoice_active',
788
-                'name' => __( 'Enable/Disable', 'invoicing' ),
789
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
788
+                'name' => __('Enable/Disable', 'invoicing'),
789
+                'desc' => __('Enable this email notification', 'invoicing'),
790 790
                 'type' => 'checkbox',
791 791
                 'std'  => 1
792 792
             ),
793 793
             'email_onhold_invoice_subject' => array(
794 794
                 'id'   => 'email_onhold_invoice_subject',
795
-                'name' => __( 'Subject', 'invoicing' ),
796
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
795
+                'name' => __('Subject', 'invoicing'),
796
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
797 797
                 'type' => 'text',
798
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
798
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
799 799
                 'size' => 'large'
800 800
             ),
801 801
             'email_onhold_invoice_heading' => array(
802 802
                 'id'   => 'email_onhold_invoice_heading',
803
-                'name' => __( 'Email Heading', 'invoicing' ),
804
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
803
+                'name' => __('Email Heading', 'invoicing'),
804
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
805 805
                 'type' => 'text',
806
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
806
+                'std'  => __('Thank you for your invoice', 'invoicing'),
807 807
                 'size' => 'large'
808 808
             ),
809 809
             'email_onhold_invoice_admin_bcc' => array(
810 810
                 'id'   => 'email_onhold_invoice_admin_bcc',
811
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
812
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
811
+                'name' => __('Enable Admin BCC', 'invoicing'),
812
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
813 813
                 'type' => 'checkbox',
814 814
                 'std'  => 1
815 815
             ),
816 816
             'email_onhold_invoice_body' => array(
817 817
                 'id'   => 'email_onhold_invoice_body',
818
-                'name' => __( 'Email Content', 'invoicing' ),
819
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
818
+                'name' => __('Email Content', 'invoicing'),
819
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
820 820
                 'type' => 'rich_editor',
821
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
821
+                'std'  => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
822 822
                 'class' => 'large',
823 823
                 'size' => '10'
824 824
             ),
@@ -826,46 +826,46 @@  discard block
 block discarded – undo
826 826
         'processing_invoice' => array(
827 827
             'email_processing_invoice_header' => array(
828 828
                 'id'   => 'email_processing_invoice_header',
829
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
829
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_processing_invoice_active' => array(
834 834
                 'id'   => 'email_processing_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_processing_invoice_subject' => array(
841 841
                 'id'   => 'email_processing_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_processing_invoice_heading' => array(
849 849
                 'id'   => 'email_processing_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_processing_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_processing_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
863 863
             'email_processing_invoice_body' => array(
864 864
                 'id'   => 'email_processing_invoice_body',
865
-                'name' => __( 'Email Content', 'invoicing' ),
866
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
865
+                'name' => __('Email Content', 'invoicing'),
866
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
867 867
                 'type' => 'rich_editor',
868
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
868
+                'std'  => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
869 869
                 'class' => 'large',
870 870
                 'size' => '10'
871 871
             ),
@@ -873,52 +873,52 @@  discard block
 block discarded – undo
873 873
         'completed_invoice' => array(
874 874
             'email_completed_invoice_header' => array(
875 875
                 'id'   => 'email_completed_invoice_header',
876
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
877
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
876
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
877
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
878 878
                 'type' => 'header',
879 879
             ),
880 880
             'email_completed_invoice_active' => array(
881 881
                 'id'   => 'email_completed_invoice_active',
882
-                'name' => __( 'Enable/Disable', 'invoicing' ),
883
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
882
+                'name' => __('Enable/Disable', 'invoicing'),
883
+                'desc' => __('Enable this email notification', 'invoicing'),
884 884
                 'type' => 'checkbox',
885 885
                 'std'  => 1
886 886
             ),
887 887
             'email_completed_invoice_renewal_active' => array(
888 888
                 'id'   => 'email_completed_invoice_renewal_active',
889
-                'name' => __( 'Enable renewal notification', 'invoicing' ),
890
-                'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ),
889
+                'name' => __('Enable renewal notification', 'invoicing'),
890
+                'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'),
891 891
                 'type' => 'checkbox',
892 892
                 'std'  => 0
893 893
             ),
894 894
             'email_completed_invoice_subject' => array(
895 895
                 'id'   => 'email_completed_invoice_subject',
896
-                'name' => __( 'Subject', 'invoicing' ),
897
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
896
+                'name' => __('Subject', 'invoicing'),
897
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
898 898
                 'type' => 'text',
899
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
899
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
900 900
                 'size' => 'large'
901 901
             ),
902 902
             'email_completed_invoice_heading' => array(
903 903
                 'id'   => 'email_completed_invoice_heading',
904
-                'name' => __( 'Email Heading', 'invoicing' ),
905
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
904
+                'name' => __('Email Heading', 'invoicing'),
905
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
906 906
                 'type' => 'text',
907
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
907
+                'std'  => __('Your invoice has been paid', 'invoicing'),
908 908
                 'size' => 'large'
909 909
             ),
910 910
             'email_completed_invoice_admin_bcc' => array(
911 911
                 'id'   => 'email_completed_invoice_admin_bcc',
912
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
913
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
912
+                'name' => __('Enable Admin BCC', 'invoicing'),
913
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
914 914
                 'type' => 'checkbox',
915 915
             ),
916 916
             'email_completed_invoice_body' => array(
917 917
                 'id'   => 'email_completed_invoice_body',
918
-                'name' => __( 'Email Content', 'invoicing' ),
919
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
918
+                'name' => __('Email Content', 'invoicing'),
919
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
920 920
                 'type' => 'rich_editor',
921
-                'std'  => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ),
921
+                'std'  => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'),
922 922
                 'class' => 'large',
923 923
                 'size' => '10'
924 924
             ),
@@ -927,46 +927,46 @@  discard block
 block discarded – undo
927 927
         'refunded_invoice' => array(
928 928
             'email_refunded_invoice_header' => array(
929 929
                 'id'   => 'email_refunded_invoice_header',
930
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
931
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
930
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
931
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
932 932
                 'type' => 'header',
933 933
             ),
934 934
             'email_refunded_invoice_active' => array(
935 935
                 'id'   => 'email_refunded_invoice_active',
936
-                'name' => __( 'Enable/Disable', 'invoicing' ),
937
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
936
+                'name' => __('Enable/Disable', 'invoicing'),
937
+                'desc' => __('Enable this email notification', 'invoicing'),
938 938
                 'type' => 'checkbox',
939 939
                 'std'  => 1
940 940
             ),
941 941
             'email_refunded_invoice_subject' => array(
942 942
                 'id'   => 'email_refunded_invoice_subject',
943
-                'name' => __( 'Subject', 'invoicing' ),
944
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
943
+                'name' => __('Subject', 'invoicing'),
944
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
945 945
                 'type' => 'text',
946
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
946
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
947 947
                 'size' => 'large'
948 948
             ),
949 949
             'email_refunded_invoice_heading' => array(
950 950
                 'id'   => 'email_refunded_invoice_heading',
951
-                'name' => __( 'Email Heading', 'invoicing' ),
952
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
951
+                'name' => __('Email Heading', 'invoicing'),
952
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
953 953
                 'type' => 'text',
954
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
954
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
955 955
                 'size' => 'large'
956 956
             ),
957 957
             'email_refunded_invoice_admin_bcc' => array(
958 958
                 'id'   => 'email_refunded_invoice_admin_bcc',
959
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
960
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
959
+                'name' => __('Enable Admin BCC', 'invoicing'),
960
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
961 961
                 'type' => 'checkbox',
962 962
                 'std'  => 1
963 963
             ),
964 964
             'email_refunded_invoice_body' => array(
965 965
                 'id'   => 'email_refunded_invoice_body',
966
-                'name' => __( 'Email Content', 'invoicing' ),
967
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
966
+                'name' => __('Email Content', 'invoicing'),
967
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
968 968
                 'type' => 'rich_editor',
969
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
969
+                'std'  => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
970 970
                 'class' => 'large',
971 971
                 'size' => '10'
972 972
             ),
@@ -974,46 +974,46 @@  discard block
 block discarded – undo
974 974
         'user_invoice' => array(
975 975
             'email_user_invoice_header' => array(
976 976
                 'id'   => 'email_user_invoice_header',
977
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
978
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
977
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
978
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
979 979
                 'type' => 'header',
980 980
             ),
981 981
             'email_user_invoice_active' => array(
982 982
                 'id'   => 'email_user_invoice_active',
983
-                'name' => __( 'Enable/Disable', 'invoicing' ),
984
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
983
+                'name' => __('Enable/Disable', 'invoicing'),
984
+                'desc' => __('Enable this email notification', 'invoicing'),
985 985
                 'type' => 'checkbox',
986 986
                 'std'  => 1
987 987
             ),
988 988
             'email_user_invoice_subject' => array(
989 989
                 'id'   => 'email_user_invoice_subject',
990
-                'name' => __( 'Subject', 'invoicing' ),
991
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
990
+                'name' => __('Subject', 'invoicing'),
991
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
992 992
                 'type' => 'text',
993
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
993
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
994 994
                 'size' => 'large'
995 995
             ),
996 996
             'email_user_invoice_heading' => array(
997 997
                 'id'   => 'email_user_invoice_heading',
998
-                'name' => __( 'Email Heading', 'invoicing' ),
999
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
998
+                'name' => __('Email Heading', 'invoicing'),
999
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1000 1000
                 'type' => 'text',
1001
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1001
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1002 1002
                 'size' => 'large'
1003 1003
             ),
1004 1004
             'email_user_invoice_admin_bcc' => array(
1005 1005
                 'id'   => 'email_user_invoice_admin_bcc',
1006
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1007
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1006
+                'name' => __('Enable Admin BCC', 'invoicing'),
1007
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1008 1008
                 'type' => 'checkbox',
1009 1009
                 'std'  => 1
1010 1010
             ),
1011 1011
             'email_user_invoice_body' => array(
1012 1012
                 'id'   => 'email_user_invoice_body',
1013
-                'name' => __( 'Email Content', 'invoicing' ),
1014
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1013
+                'name' => __('Email Content', 'invoicing'),
1014
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1015 1015
                 'type' => 'rich_editor',
1016
-                'std'  => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1016
+                'std'  => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1017 1017
                 'class' => 'large',
1018 1018
                 'size' => '10'
1019 1019
             ),
@@ -1021,39 +1021,39 @@  discard block
 block discarded – undo
1021 1021
         'user_note' => array(
1022 1022
             'email_user_note_header' => array(
1023 1023
                 'id'   => 'email_user_note_header',
1024
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1025
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1024
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1025
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1026 1026
                 'type' => 'header',
1027 1027
             ),
1028 1028
             'email_user_note_active' => array(
1029 1029
                 'id'   => 'email_user_note_active',
1030
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1031
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1030
+                'name' => __('Enable/Disable', 'invoicing'),
1031
+                'desc' => __('Enable this email notification', 'invoicing'),
1032 1032
                 'type' => 'checkbox',
1033 1033
                 'std'  => 1
1034 1034
             ),
1035 1035
             'email_user_note_subject' => array(
1036 1036
                 'id'   => 'email_user_note_subject',
1037
-                'name' => __( 'Subject', 'invoicing' ),
1038
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1037
+                'name' => __('Subject', 'invoicing'),
1038
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1039 1039
                 'type' => 'text',
1040
-                'std'  => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
1040
+                'std'  => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
1041 1041
                 'size' => 'large'
1042 1042
             ),
1043 1043
             'email_user_note_heading' => array(
1044 1044
                 'id'   => 'email_user_note_heading',
1045
-                'name' => __( 'Email Heading', 'invoicing' ),
1046
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1045
+                'name' => __('Email Heading', 'invoicing'),
1046
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1047 1047
                 'type' => 'text',
1048
-                'std'  => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
1048
+                'std'  => __('A note has been added to your {invoice_label}', 'invoicing'),
1049 1049
                 'size' => 'large'
1050 1050
             ),
1051 1051
             'email_user_note_body' => array(
1052 1052
                 'id'   => 'email_user_note_body',
1053
-                'name' => __( 'Email Content', 'invoicing' ),
1054
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1053
+                'name' => __('Email Content', 'invoicing'),
1054
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1055 1055
                 'type' => 'rich_editor',
1056
-                'std'  => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
1056
+                'std'  => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
1057 1057
                 'class' => 'large',
1058 1058
                 'size' => '10'
1059 1059
             ),
@@ -1061,158 +1061,158 @@  discard block
 block discarded – undo
1061 1061
         'overdue' => array(
1062 1062
             'email_overdue_header' => array(
1063 1063
                 'id'   => 'email_overdue_header',
1064
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1065
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1064
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1065
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1066 1066
                 'type' => 'header',
1067 1067
             ),
1068 1068
             'email_overdue_active' => array(
1069 1069
                 'id'   => 'email_overdue_active',
1070
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1071
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1070
+                'name' => __('Enable/Disable', 'invoicing'),
1071
+                'desc' => __('Enable this email notification', 'invoicing'),
1072 1072
                 'type' => 'checkbox',
1073 1073
                 'std'  => 1
1074 1074
             ),
1075 1075
             'email_due_reminder_days' => array(
1076 1076
                 'id'        => 'email_due_reminder_days',
1077
-                'name'      => __( 'When to Send', 'invoicing' ),
1078
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1077
+                'name'      => __('When to Send', 'invoicing'),
1078
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1079 1079
                 'default'   => '',
1080 1080
                 'type'      => 'multicheck',
1081 1081
                 'options'   => $overdue_days_options,
1082 1082
             ),
1083 1083
             'email_overdue_subject' => array(
1084 1084
                 'id'   => 'email_overdue_subject',
1085
-                'name' => __( 'Subject', 'invoicing' ),
1086
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1085
+                'name' => __('Subject', 'invoicing'),
1086
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1087 1087
                 'type' => 'text',
1088
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1088
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1089 1089
                 'size' => 'large'
1090 1090
             ),
1091 1091
             'email_overdue_heading' => array(
1092 1092
                 'id'   => 'email_overdue_heading',
1093
-                'name' => __( 'Email Heading', 'invoicing' ),
1094
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1093
+                'name' => __('Email Heading', 'invoicing'),
1094
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1095 1095
                 'type' => 'text',
1096
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1096
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1097 1097
                 'size' => 'large'
1098 1098
             ),
1099 1099
             'email_overdue_body' => array(
1100 1100
                 'id'   => 'email_overdue_body',
1101
-                'name' => __( 'Email Content', 'invoicing' ),
1102
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1101
+                'name' => __('Email Content', 'invoicing'),
1102
+                'desc' => __('The content of the email.', 'invoicing'),
1103 1103
                 'type' => 'rich_editor',
1104
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1104
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1105 1105
                 'class' => 'large',
1106 1106
                 'size'  => 10,
1107 1107
             ),
1108 1108
         ),
1109 1109
     );
1110 1110
 
1111
-    return apply_filters( 'wpinv_get_emails', $emails );
1111
+    return apply_filters('wpinv_get_emails', $emails);
1112 1112
 }
1113 1113
 
1114
-function wpinv_settings_emails( $settings = array() ) {
1114
+function wpinv_settings_emails($settings = array()) {
1115 1115
     $emails = wpinv_get_emails();
1116 1116
 
1117
-    if ( !empty( $emails ) ) {
1118
-        foreach ( $emails as $key => $email ) {
1117
+    if (!empty($emails)) {
1118
+        foreach ($emails as $key => $email) {
1119 1119
             $settings[$key] = $email;
1120 1120
         }
1121 1121
     }
1122 1122
 
1123
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1123
+    return apply_filters('wpinv_settings_get_emails', $settings);
1124 1124
 }
1125
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1125
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1126 1126
 
1127
-function wpinv_settings_sections_emails( $settings ) {
1127
+function wpinv_settings_sections_emails($settings) {
1128 1128
     $emails = wpinv_get_emails();
1129 1129
 
1130 1130
     if (!empty($emails)) {
1131
-        foreach  ($emails as $key => $email) {
1132
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1131
+        foreach ($emails as $key => $email) {
1132
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1133 1133
         }
1134 1134
     }
1135 1135
 
1136 1136
     return $settings;    
1137 1137
 }
1138
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1138
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1139 1139
 
1140
-function wpinv_email_is_enabled( $email_type ) {
1140
+function wpinv_email_is_enabled($email_type) {
1141 1141
     $emails = wpinv_get_emails();
1142
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1142
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1143 1143
 
1144
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1144
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1145 1145
 }
1146 1146
 
1147
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1148
-    switch ( $email_type ) {
1147
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1148
+    switch ($email_type) {
1149 1149
         case 'new_invoice':
1150 1150
         case 'cancelled_invoice':
1151 1151
         case 'failed_invoice':
1152 1152
             $recipient  = wpinv_get_admin_email();
1153 1153
         break;
1154 1154
         default:
1155
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1156
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1155
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1156
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1157 1157
         break;
1158 1158
     }
1159 1159
 
1160
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1160
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1161 1161
 }
1162 1162
 
1163
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1164
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1165
-    $subject    = __( $subject, 'invoicing' );
1163
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1164
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1165
+    $subject    = __($subject, 'invoicing');
1166 1166
 
1167
-    $subject    = wpinv_email_format_text( $subject, $invoice );
1167
+    $subject    = wpinv_email_format_text($subject, $invoice);
1168 1168
 
1169
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1169
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1170 1170
 }
1171 1171
 
1172
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1173
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1174
-    $email_heading = __( $email_heading, 'invoicing' );
1172
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1173
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1174
+    $email_heading = __($email_heading, 'invoicing');
1175 1175
 
1176
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
1176
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
1177 1177
 
1178
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1178
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1179 1179
 }
1180 1180
 
1181
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1182
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1183
-    $content    = __( $content, 'invoicing' );
1181
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1182
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1183
+    $content    = __($content, 'invoicing');
1184 1184
 
1185
-    $content    = wpinv_email_format_text( $content, $invoice );
1185
+    $content    = wpinv_email_format_text($content, $invoice);
1186 1186
 
1187
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1187
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1188 1188
 }
1189 1189
 
1190
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1190
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1191 1191
     $from_name = wpinv_mail_get_from_address();
1192 1192
     $from_email = wpinv_mail_get_from_address();
1193 1193
     
1194
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1194
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1195 1195
     
1196
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1197
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1196
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1197
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1198 1198
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1199 1199
     
1200
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1200
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1201 1201
 }
1202 1202
 
1203
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1203
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1204 1204
     $attachments = array();
1205 1205
     
1206
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1206
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1207 1207
 }
1208 1208
 
1209
-function wpinv_email_format_text( $content, $invoice ) {
1209
+function wpinv_email_format_text($content, $invoice) {
1210 1210
     $replace_array = array(
1211 1211
         '{site_title}'      => wpinv_get_blogname(),
1212
-        '{date}'            => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ),
1212
+        '{date}'            => date_i18n(get_option('date_format'), (int) current_time('timestamp')),
1213 1213
     );
1214 1214
     
1215
-    if ( !empty( $invoice->ID ) ) {
1215
+    if (!empty($invoice->ID)) {
1216 1216
         $replace_array = array_merge(
1217 1217
             $replace_array, 
1218 1218
             array(
@@ -1222,65 +1222,65 @@  discard block
 block discarded – undo
1222 1222
                 '{last_name}'       => $invoice->get_last_name(),
1223 1223
                 '{email}'           => $invoice->get_email(),
1224 1224
                 '{invoice_number}'  => $invoice->get_number(),
1225
-                '{invoice_total}'   => $invoice->get_total( true ),
1226
-                '{invoice_link}'    => $invoice->get_view_url( true ),
1227
-                '{invoice_pay_link}'=> $invoice->get_view_url( true ),
1228
-                '{invoice_date}'    => $invoice->get_invoice_date( true ),
1229
-                '{invoice_due_date}'=> $invoice->get_due_date( true ),
1230
-                '{invoice_quote}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1231
-                '{invoice_label}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1232
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
1225
+                '{invoice_total}'   => $invoice->get_total(true),
1226
+                '{invoice_link}'    => $invoice->get_view_url(true),
1227
+                '{invoice_pay_link}'=> $invoice->get_view_url(true),
1228
+                '{invoice_date}'    => $invoice->get_invoice_date(true),
1229
+                '{invoice_due_date}'=> $invoice->get_due_date(true),
1230
+                '{invoice_quote}'   => $invoice->get_invoice_quote_type($invoice->ID),
1231
+                '{invoice_label}'   => $invoice->get_invoice_quote_type($invoice->ID),
1232
+                '{is_was}'          => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'),
1233 1233
             )
1234 1234
         );
1235 1235
     }
1236 1236
 
1237
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
1237
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
1238 1238
 
1239
-    foreach ( $replace_array as $key => $value ) {
1240
-        $content = str_replace( $key, $value, $content );
1239
+    foreach ($replace_array as $key => $value) {
1240
+        $content = str_replace($key, $value, $content);
1241 1241
     }
1242 1242
 
1243
-    return apply_filters( 'wpinv_email_content_replace', $content );
1243
+    return apply_filters('wpinv_email_content_replace', $content);
1244 1244
 }
1245 1245
 
1246
-function wpinv_email_style_body( $content ) {
1246
+function wpinv_email_style_body($content) {
1247 1247
     // make sure we only inline CSS for html emails
1248
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1248
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1249 1249
         ob_start();
1250
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1251
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1250
+        wpinv_get_template('emails/wpinv-email-styles.php');
1251
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1252 1252
 
1253 1253
         // apply CSS styles inline for picky email clients
1254 1254
         try {
1255
-            $emogrifier = new Emogrifier( $content, $css );
1255
+            $emogrifier = new Emogrifier($content, $css);
1256 1256
             $content    = $emogrifier->emogrify();
1257
-        } catch ( Exception $e ) {
1258
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1257
+        } catch (Exception $e) {
1258
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1259 1259
         }
1260 1260
     }
1261 1261
     return $content;
1262 1262
 }
1263 1263
 
1264
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1265
-    wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1264
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1265
+    wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1266 1266
 }
1267 1267
 
1268 1268
 /**
1269 1269
  * Get the email footer.
1270 1270
  */
1271
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1272
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1271
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1272
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1273 1273
 }
1274 1274
 
1275
-function wpinv_email_wrap_message( $message ) {
1275
+function wpinv_email_wrap_message($message) {
1276 1276
     // Buffer
1277 1277
     ob_start();
1278 1278
 
1279
-    do_action( 'wpinv_email_header' );
1279
+    do_action('wpinv_email_header');
1280 1280
 
1281
-    echo wpautop( wptexturize( $message ) );
1281
+    echo wpautop(wptexturize($message));
1282 1282
 
1283
-    do_action( 'wpinv_email_footer' );
1283
+    do_action('wpinv_email_footer');
1284 1284
 
1285 1285
     // Get contents
1286 1286
     $message = ob_get_clean();
@@ -1288,92 +1288,92 @@  discard block
 block discarded – undo
1288 1288
     return $message;
1289 1289
 }
1290 1290
 
1291
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1292
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1291
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1292
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1293 1293
 }
1294 1294
 
1295
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1296
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1295
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1296
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1297 1297
 }
1298 1298
 
1299
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1300
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1299
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1300
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1301 1301
 }
1302 1302
 
1303
-function wpinv_send_customer_invoice( $data = array() ) {
1304
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1303
+function wpinv_send_customer_invoice($data = array()) {
1304
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1305 1305
 
1306
-    if ( empty( $invoice_id ) ) {
1306
+    if (empty($invoice_id)) {
1307 1307
         return;
1308 1308
     }
1309 1309
 
1310
-    if ( !wpinv_current_user_can_manage_invoicing() ) {
1311
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1310
+    if (!wpinv_current_user_can_manage_invoicing()) {
1311
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1312 1312
     }
1313 1313
     
1314
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1314
+    $sent = wpinv_user_invoice_notification($invoice_id);
1315 1315
 
1316 1316
     if ( -1 === $sent ) {
1317 1317
         $status = 'email_disabled';
1318
-    } elseif ( $sent ) {
1318
+    } elseif ($sent) {
1319 1319
         $status = 'email_sent';
1320 1320
     } else {
1321 1321
         $status = 'email_fail';
1322 1322
     }
1323 1323
 
1324
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1325
-    wp_redirect( $redirect );
1324
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1325
+    wp_redirect($redirect);
1326 1326
     exit;
1327 1327
 }
1328
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1328
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1329 1329
 
1330
-function wpinv_send_overdue_reminder( $data = array() ) {
1331
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1330
+function wpinv_send_overdue_reminder($data = array()) {
1331
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1332 1332
 
1333
-    if ( empty( $invoice_id ) ) {
1333
+    if (empty($invoice_id)) {
1334 1334
         return;
1335 1335
     }
1336 1336
 
1337
-    if ( !wpinv_current_user_can_manage_invoicing() ) {
1338
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1337
+    if (!wpinv_current_user_can_manage_invoicing()) {
1338
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1339 1339
     }
1340 1340
 
1341
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1341
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1342 1342
     
1343 1343
     $status = $sent ? 'email_sent' : 'email_fail';
1344 1344
 
1345
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1346
-    wp_redirect( $redirect );
1345
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1346
+    wp_redirect($redirect);
1347 1347
     exit;
1348 1348
 }
1349
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1349
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1350 1350
 
1351
-function wpinv_send_customer_note_email( $data ) {
1352
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1351
+function wpinv_send_customer_note_email($data) {
1352
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1353 1353
 
1354
-    if ( empty( $invoice_id ) ) {
1354
+    if (empty($invoice_id)) {
1355 1355
         return;
1356 1356
     }
1357 1357
 
1358
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1358
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1359 1359
 }
1360
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1360
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1361 1361
 
1362
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1363
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1364
-        $date_format = get_option( 'date_format' );
1365
-        $time_format = get_option( 'time_format' );
1362
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1363
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1364
+        $date_format = get_option('date_format');
1365
+        $time_format = get_option('time_format');
1366 1366
         ?>
1367 1367
         <div id="wpinv-email-notes">
1368
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1368
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1369 1369
             <ol class="wpinv-notes-lists">
1370 1370
         <?php
1371
-        foreach ( $invoice_notes as $note ) {
1372
-            $note_time = strtotime( $note->comment_date );
1371
+        foreach ($invoice_notes as $note) {
1372
+            $note_time = strtotime($note->comment_date);
1373 1373
             ?>
1374 1374
             <li class="comment wpinv-note">
1375
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
1376
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1375
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
1376
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1377 1377
             </li>
1378 1378
             <?php
1379 1379
         }
@@ -1382,21 +1382,21 @@  discard block
 block discarded – undo
1382 1382
         <?php
1383 1383
     }
1384 1384
 }
1385
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1385
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1386 1386
 
1387 1387
 function wpinv_email_payment_reminders() {
1388 1388
     global $wpi_auto_reminder;
1389
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1389
+    if (!wpinv_get_option('email_overdue_active')) {
1390 1390
         return;
1391 1391
     }
1392 1392
 
1393
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1394
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1393
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1394
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1395 1395
 
1396
-        if ( empty( $reminder_days ) ) {
1396
+        if (empty($reminder_days)) {
1397 1397
             return;
1398 1398
         }
1399
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1399
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1400 1400
 
1401 1401
         $args = array(
1402 1402
             'post_type'     => 'wpi_invoice',
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
             'meta_query'    => array(
1407 1407
                 array(
1408 1408
                     'key'       =>  '_wpinv_due_date',
1409
-                    'value'     =>  array( '', 'none' ),
1409
+                    'value'     =>  array('', 'none'),
1410 1410
                     'compare'   =>  'NOT IN',
1411 1411
                 )
1412 1412
             ),
@@ -1415,143 +1415,143 @@  discard block
 block discarded – undo
1415 1415
             'order'         => 'ASC',
1416 1416
         );
1417 1417
 
1418
-        $invoices = get_posts( $args );
1418
+        $invoices = get_posts($args);
1419 1419
 
1420
-        if ( empty( $invoices ) ) {
1420
+        if (empty($invoices)) {
1421 1421
             return;
1422 1422
         }
1423 1423
 
1424
-        $date_to_send   = array();
1424
+        $date_to_send = array();
1425 1425
 
1426
-        foreach ( $invoices as $id ) {
1427
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1426
+        foreach ($invoices as $id) {
1427
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1428 1428
 
1429
-            foreach ( $reminder_days as $key => $days ) {
1430
-                if ( $days !== '' ) {
1431
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1429
+            foreach ($reminder_days as $key => $days) {
1430
+                if ($days !== '') {
1431
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1432 1432
                 }
1433 1433
             }
1434 1434
         }
1435 1435
 
1436
-        $today              = date_i18n( 'Y-m-d' );
1436
+        $today              = date_i18n('Y-m-d');
1437 1437
         $wpi_auto_reminder  = true;
1438 1438
 
1439
-        foreach ( $date_to_send as $id => $values ) {
1440
-            if ( in_array( $today, $values ) ) {
1441
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1439
+        foreach ($date_to_send as $id => $values) {
1440
+            if (in_array($today, $values)) {
1441
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1442 1442
 
1443
-                if ( isset( $sent ) && !empty( $sent ) ) {
1444
-                    if ( !in_array( $today, $sent ) ) {
1445
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1443
+                if (isset($sent) && !empty($sent)) {
1444
+                    if (!in_array($today, $sent)) {
1445
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1446 1446
                     }
1447 1447
                 } else {
1448
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1448
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1449 1449
                 }
1450 1450
             }
1451 1451
         }
1452 1452
 
1453
-        $wpi_auto_reminder  = false;
1453
+        $wpi_auto_reminder = false;
1454 1454
     }
1455 1455
 }
1456 1456
 
1457
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1457
+function wpinv_send_payment_reminder_notification($invoice_id) {
1458 1458
     $email_type = 'overdue';
1459
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1459
+    if (!wpinv_email_is_enabled($email_type)) {
1460 1460
         return false;
1461 1461
     }
1462 1462
 
1463
-    $invoice    = wpinv_get_invoice( $invoice_id );
1464
-    if ( empty( $invoice ) ) {
1463
+    $invoice = wpinv_get_invoice($invoice_id);
1464
+    if (empty($invoice)) {
1465 1465
         return false;
1466 1466
     }
1467 1467
 
1468
-    if ( !$invoice->needs_payment() ) {
1468
+    if (!$invoice->needs_payment()) {
1469 1469
         return false;
1470 1470
     }
1471 1471
 
1472
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1473
-    if ( !is_email( $recipient ) ) {
1472
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1473
+    if (!is_email($recipient)) {
1474 1474
         return false;
1475 1475
     }
1476 1476
 
1477
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
1477
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
1478 1478
 
1479
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1480
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1481
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1482
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1483
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1479
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1480
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1481
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1482
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1483
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1484 1484
 
1485
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1485
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1486 1486
             'invoice'       => $invoice,
1487 1487
             'email_type'    => $email_type,
1488 1488
             'email_heading' => $email_heading,
1489 1489
             'sent_to_admin' => false,
1490 1490
             'plain_text'    => false,
1491 1491
             'message_body'  => $message_body
1492
-        ) );
1492
+        ));
1493 1493
 
1494
-    $content        = wpinv_email_format_text( $content, $invoice );
1494
+    $content = wpinv_email_format_text($content, $invoice);
1495 1495
 
1496
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1497
-    if ( $sent ) {
1498
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1496
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1497
+    if ($sent) {
1498
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1499 1499
     }
1500 1500
 
1501
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
1501
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
1502 1502
 
1503 1503
     return $sent;
1504 1504
 }
1505
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1505
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1506 1506
 
1507
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1507
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1508 1508
     global $wpi_auto_reminder;
1509 1509
 
1510
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1510
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1511 1511
 
1512
-    if ( empty( $sent ) ) {
1512
+    if (empty($sent)) {
1513 1513
         $sent = array();
1514 1514
     }
1515
-    $sent[] = date_i18n( 'Y-m-d' );
1515
+    $sent[] = date_i18n('Y-m-d');
1516 1516
 
1517
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1517
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1518 1518
 
1519
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1520
-        $note = __( 'Automated reminder sent to the user.', 'invoicing' );
1521
-        $invoice->add_note( $note, false, false, true );
1519
+    if ($wpi_auto_reminder) { // Auto reminder note.
1520
+        $note = __('Automated reminder sent to the user.', 'invoicing');
1521
+        $invoice->add_note($note, false, false, true);
1522 1522
     } else { // Menual reminder note.
1523
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1524
-        $invoice->add_note( $note );
1523
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1524
+        $invoice->add_note($note);
1525 1525
     }
1526 1526
 }
1527
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1527
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1528 1528
 
1529
-function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) {
1530
-    if ( empty( $invoice ) ) {
1529
+function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) {
1530
+    if (empty($invoice)) {
1531 1531
         return;
1532 1532
     }
1533 1533
 
1534
-    if ( is_int( $invoice ) ) {
1535
-        $invoice = wpinv_get_invoice( $invoice );
1534
+    if (is_int($invoice)) {
1535
+        $invoice = wpinv_get_invoice($invoice);
1536 1536
     }
1537 1537
 
1538
-    if ( ! empty( $invoice ) && is_object( $invoice ) ) {
1539
-        if ( ! $site && function_exists( 'get_user_locale' ) ) {
1540
-            $locale = get_user_locale( $invoice->get_user_id() );
1538
+    if (!empty($invoice) && is_object($invoice)) {
1539
+        if (!$site && function_exists('get_user_locale')) {
1540
+            $locale = get_user_locale($invoice->get_user_id());
1541 1541
         } else {
1542 1542
             $locale = get_locale();
1543 1543
         }
1544 1544
 
1545
-        wpinv_switch_to_locale( $locale );
1545
+        wpinv_switch_to_locale($locale);
1546 1546
     }
1547 1547
 }
1548
-add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 );
1548
+add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3);
1549 1549
 
1550
-function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) {
1551
-    if ( empty( $invoice ) ) {
1550
+function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) {
1551
+    if (empty($invoice)) {
1552 1552
         return;
1553 1553
     }
1554 1554
 
1555 1555
     wpinv_restore_locale();
1556 1556
 }
1557
-add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 );
1557
+add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3);
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function wpinv_subscriptions_page() {
10 10
 
11
-	if ( ! empty( $_GET['id'] ) ) {
11
+	if (!empty($_GET['id'])) {
12 12
 
13 13
         wpinv_recurring_subscription_details();
14 14
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	<div class="wrap">
20 20
 
21 21
 		<h1>
22
-			<?php _e( 'Subscriptions', 'invoicing' ); ?>
22
+			<?php _e('Subscriptions', 'invoicing'); ?>
23 23
 		</h1>
24 24
 		<?php
25 25
 		$subscribers_table = new WPInv_Subscription_Reports_Table();
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			<input type="hidden" name="post_type" value="download" />
32 32
 			<input type="hidden" name="page" value="wpinv-subscriptions" />
33 33
 			<?php $subscribers_table->views(); ?>
34
-			<?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?>
34
+			<?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?>
35 35
 			<?php $subscribers_table->display(); ?>
36 36
 
37 37
 		</form>
@@ -49,34 +49,34 @@  discard block
 block discarded – undo
49 49
 
50 50
 	$render = true;
51 51
 
52
-	if ( ! current_user_can( 'manage_invoicing' ) ) {
53
-		die( __( 'You are not permitted to view this data.', 'invoicing' ) );
52
+	if (!current_user_can('manage_invoicing')) {
53
+		die(__('You are not permitted to view this data.', 'invoicing'));
54 54
 	}
55 55
 
56
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
57
-        die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
56
+	if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
57
+        die(__('Invalid subscription ID Provided.', 'invoicing'));
58 58
 	}
59 59
 
60 60
 	$sub_id  = (int) $_GET['id'];
61
-	$sub     = new WPInv_Subscription( $sub_id );
61
+	$sub     = new WPInv_Subscription($sub_id);
62 62
 
63
-	if ( empty( $sub ) ) {
64
-		die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
63
+	if (empty($sub)) {
64
+		die(__('Invalid subscription ID Provided.', 'invoicing'));
65 65
 	}
66 66
 
67 67
 	?>
68 68
 	<div class="wrap">
69
-		<h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2>
69
+		<h2><?php _e('Subscription Details', 'invoicing'); ?></h2>
70 70
 
71
-		<?php if ( $sub ) : ?>
71
+		<?php if ($sub) : ?>
72 72
 
73 73
 			<div id="wpinv-item-card-wrapper">
74 74
 
75
-				<?php do_action( 'wpinv_subscription_card_top', $sub ); ?>
75
+				<?php do_action('wpinv_subscription_card_top', $sub); ?>
76 76
 
77 77
 				<div class="info-wrapper item-section">
78 78
 
79
-					<form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>">
79
+					<form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>">
80 80
 
81 81
 						<div class="item-info">
82 82
 
@@ -84,124 +84,124 @@  discard block
 block discarded – undo
84 84
 								<tbody>
85 85
 									<tr>
86 86
 										<td class="row-title">
87
-											<label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label>
87
+											<label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label>
88 88
 										</td>
89 89
 										<td>
90 90
 											<?php
91
-											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency );
92
-											$billing   = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency;
93
-											$initial   = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) );
94
-											printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing );
91
+											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency);
92
+											$billing   = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency;
93
+											$initial   = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id));
94
+											printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing);
95 95
 											?>
96 96
 										</td>
97 97
 									</tr>
98 98
 									<tr>
99 99
 										<td class="row-title">
100
-											<label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label>
100
+											<label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label>
101 101
 										</td>
102
-										<td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td>
102
+										<td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td>
103 103
 									</tr>
104 104
 									<tr>
105 105
 										<td class="row-title">
106
-											<label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label>
106
+											<label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label>
107 107
 										</td>
108 108
 										<td>
109
-											<?php $subscriber = get_userdata( $sub->customer_id ); ?>
110
-											<a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a>
109
+											<?php $subscriber = get_userdata($sub->customer_id); ?>
110
+											<a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a>
111 111
 										</td>
112 112
 									</tr>
113 113
 									<tr>
114 114
 										<td class="row-title">
115
-											<label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label>
115
+											<label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label>
116 116
 										</td>
117 117
 										<td>
118
-                                            <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a>&nbsp;&nbsp;&nbsp;<?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td>
118
+                                            <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a>&nbsp;&nbsp;&nbsp;<?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td>
119 119
 									</tr>
120 120
 									<tr>
121 121
 										<td class="row-title">
122
-											<label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label>
122
+											<label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label>
123 123
 										</td>
124 124
 										<td>
125 125
 											<?php
126
-                                            echo wpinv_item_dropdown( array(
126
+                                            echo wpinv_item_dropdown(array(
127 127
                                                 'name'              => 'product_id',
128 128
                                                 'id'                => 'wpinv_invoice_item',
129 129
                                                 'with_packages'     => false,
130 130
                                                 'show_recurring'    => true,
131 131
                                                 'selected'          => $sub->product_id,
132 132
                                                 'class'             => 'wpinv-sub-product-id wpi_select2',
133
-                                            ) );
133
+                                            ));
134 134
 
135 135
                                             ?>
136
-											<a href="<?php echo esc_url( add_query_arg( array(
136
+											<a href="<?php echo esc_url(add_query_arg(array(
137 137
 													'post'   => $sub->product_id,
138 138
 													'action' => 'edit'
139
-												), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a>
139
+												), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a>
140 140
 										</td>
141 141
 									</tr>
142 142
 									<tr>
143 143
 										<td class="row-title">
144
-											<label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label>
144
+											<label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label>
145 145
 										</td>
146
-										<td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td>
146
+										<td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td>
147 147
 									</tr>
148 148
 									<tr>
149 149
 										<td class="row-title">
150
-											<label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label>
150
+											<label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label>
151 151
 										</td>
152 152
 										<td>
153 153
 											<span class="wpinv-sub-profile-id">
154
-												<?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?>
154
+												<?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?>
155 155
 											</span>
156
-											<input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" />
156
+											<input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" />
157 157
 											<span>&nbsp;&ndash;&nbsp;</span>
158
-											<a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a>
158
+											<a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a>
159 159
 										</td>
160 160
 									</tr>
161 161
 									<tr>
162 162
 										<td class="row-title">
163
-											<label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label>
163
+											<label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label>
164 164
 										</td>
165 165
 										<td>
166
-											<span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span>
167
-											<input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" />
166
+											<span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span>
167
+											<input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" />
168 168
 											<span>&nbsp;&ndash;&nbsp;</span>
169
-											<a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a>
169
+											<a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a>
170 170
 										</td>
171 171
 									</tr>
172 172
 									<tr>
173 173
 										<td class="row-title">
174
-											<label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label>
174
+											<label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label>
175 175
 										</td>
176
-										<td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td>
176
+										<td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td>
177 177
 									</tr>
178 178
 									<tr>
179 179
 										<td class="row-title">
180 180
 											<label for="tablecell">
181
-												<?php if( 'trialling' == $sub->status ) : ?>
182
-													<?php _e( 'Trialling Until:', 'invoicing' ); ?>
181
+												<?php if ('trialling' == $sub->status) : ?>
182
+													<?php _e('Trialling Until:', 'invoicing'); ?>
183 183
 												<?php else: ?>
184
-													<?php _e( 'Expiration Date:', 'invoicing' ); ?>
184
+													<?php _e('Expiration Date:', 'invoicing'); ?>
185 185
 												<?php endif; ?>
186 186
 											</label>
187 187
 										</td>
188 188
 										<td>
189
-											<span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span>
189
+											<span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span>
190 190
 										</td>
191 191
 									</tr>
192 192
 									<tr>
193 193
 										<td class="row-title">
194
-											<label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label>
194
+											<label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label>
195 195
 										</td>
196 196
 										<td>
197 197
 											<select name="status" class="wpi_select2">
198
-												<option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option>
199
-												<option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option>
200
-												<option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option>
201
-												<option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option>
202
-												<option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option>
203
-												<option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option>
204
-												<option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option>
198
+												<option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option>
199
+												<option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option>
200
+												<option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option>
201
+												<option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option>
202
+												<option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option>
203
+												<option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option>
204
+												<option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option>
205 205
 											</select>
206 206
 										</td>
207 207
 									</tr>
@@ -209,79 +209,79 @@  discard block
 block discarded – undo
209 209
 							</table>
210 210
 						</div>
211 211
 						<div id="wpinv-sub-notices">
212
-							<div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div>
213
-							<div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div>
212
+							<div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div>
213
+							<div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div>
214 214
 						</div>
215 215
 						<div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;">
216
-							<?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?>
217
-							<input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/>
218
-							<input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" />
219
-							<?php if( $sub->can_cancel() ) : ?>
220
-								<a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a>
216
+							<?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?>
217
+							<input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/>
218
+							<input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" />
219
+							<?php if ($sub->can_cancel()) : ?>
220
+								<a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a>
221 221
 							<?php endif; ?>
222
-							&nbsp;<input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/>
222
+							&nbsp;<input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/>
223 223
 						</div>
224 224
 
225 225
 					</form>
226 226
 				</div>
227 227
 
228
-				<?php do_action( 'wpinv_subscription_before_stats', $sub ); ?>
228
+				<?php do_action('wpinv_subscription_before_stats', $sub); ?>
229 229
 
230
-				<?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?>
230
+				<?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?>
231 231
 
232 232
 				<div id="item-tables-wrapper" class="item-section">
233 233
 
234
-					<?php do_action( 'wpinv_subscription_before_tables', $sub ); ?>
234
+					<?php do_action('wpinv_subscription_before_tables', $sub); ?>
235 235
 
236
-					<h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3>
236
+					<h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3>
237 237
 					<?php $payments = $sub->get_child_payments(); ?>
238
-					<?php if ( 'manual' == $sub->gateway ) : ?>
239
-						<p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p>
238
+					<?php if ('manual' == $sub->gateway) : ?>
239
+						<p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p>
240 240
 					<?php endif; ?>
241 241
 					<table class="wp-list-table widefat striped payments">
242 242
 						<thead>
243 243
 						<tr>
244
-							<th><?php _e( 'ID', 'invoicing' ); ?></th>
245
-							<th><?php _e( 'Amount', 'invoicing' ); ?></th>
246
-							<th><?php _e( 'Date', 'invoicing' ); ?></th>
247
-							<th><?php _e( 'Status', 'invoicing' ); ?></th>
248
-                            <th><?php _e( 'Invoice', 'invoicing' ); ?></th>
249
-							<th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th>
244
+							<th><?php _e('ID', 'invoicing'); ?></th>
245
+							<th><?php _e('Amount', 'invoicing'); ?></th>
246
+							<th><?php _e('Date', 'invoicing'); ?></th>
247
+							<th><?php _e('Status', 'invoicing'); ?></th>
248
+                            <th><?php _e('Invoice', 'invoicing'); ?></th>
249
+							<th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th>
250 250
 						</tr>
251 251
 						</thead>
252 252
 						<tbody>
253
-						<?php if ( ! empty( $payments ) ) : ?>
254
-							<?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?>
253
+						<?php if (!empty($payments)) : ?>
254
+							<?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?>
255 255
 								<tr>
256 256
 									<td><?php echo $payment->ID; ?></td>
257
-									<td><?php echo $invoice->get_total( true ); ?></td>
257
+									<td><?php echo $invoice->get_total(true); ?></td>
258 258
 									<td><?php echo $invoice->get_invoice_date(); ?></td>
259
-									<td><?php echo $invoice->get_status( true ); ?></td>
259
+									<td><?php echo $invoice->get_status(true); ?></td>
260 260
 									<td>
261
-										<a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a>
262
-										<?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?>
261
+										<a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a>
262
+										<?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?>
263 263
 									</td>
264 264
 									<td class="column-wpi_actions">
265
-										<a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?>
265
+										<a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?>
266 266
 										</a>
267
-										<?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?>
267
+										<?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?>
268 268
 									</td>
269 269
 								</tr>
270 270
 							<?php endforeach; ?>
271 271
 						<?php else: ?>
272 272
 							<tr>
273
-								<td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td>
273
+								<td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td>
274 274
 							</tr>
275 275
 						<?php endif; ?>
276 276
 						</tbody>
277 277
 						<tfoot></tfoot>
278 278
 					</table>
279 279
 
280
-					<?php do_action( 'wpinv_subscription_after_tables', $sub ); ?>
280
+					<?php do_action('wpinv_subscription_after_tables', $sub); ?>
281 281
 
282 282
 				</div>
283 283
 
284
-				<?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?>
284
+				<?php do_action('wpinv_subscription_card_bottom', $sub); ?>
285 285
 			</div>
286 286
 
287 287
 		<?php endif; ?>
@@ -299,36 +299,36 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function wpinv_recurring_process_subscription_update() {
301 301
 
302
-	if( empty( $_POST['sub_id'] ) ) {
302
+	if (empty($_POST['sub_id'])) {
303 303
 		return;
304 304
 	}
305 305
 
306
-	if( empty( $_POST['wpinv_update_subscription'] ) ) {
306
+	if (empty($_POST['wpinv_update_subscription'])) {
307 307
 		return;
308 308
 	}
309 309
 
310
-	if( ! current_user_can( 'manage_invoicing') ) {
310
+	if (!current_user_can('manage_invoicing')) {
311 311
 		return;
312 312
 	}
313 313
 
314
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
315
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
314
+	if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) {
315
+		wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
316 316
 	}
317 317
 
318
-	$profile_id      = sanitize_text_field( $_POST['profile_id'] );
319
-	$transaction_id  = sanitize_text_field( $_POST['transaction_id'] );
320
-	$product_id      = absint( $_POST['product_id'] );
321
-	$subscription    = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
322
-	$subscription->update( array(
323
-		'status'         => sanitize_text_field( $_POST['status'] ),
318
+	$profile_id      = sanitize_text_field($_POST['profile_id']);
319
+	$transaction_id  = sanitize_text_field($_POST['transaction_id']);
320
+	$product_id      = absint($_POST['product_id']);
321
+	$subscription    = new WPInv_Subscription(absint($_POST['sub_id']));
322
+	$subscription->update(array(
323
+		'status'         => sanitize_text_field($_POST['status']),
324 324
 		'profile_id'     => $profile_id,
325 325
 		'product_id'     => $product_id,
326 326
 		'transaction_id' => $transaction_id,
327
-	) );
327
+	));
328 328
 
329
-	$status = sanitize_text_field( $_POST['status'] );
329
+	$status = sanitize_text_field($_POST['status']);
330 330
 
331
-	switch( $status ) {
331
+	switch ($status) {
332 332
 
333 333
 		case 'cancelled' :
334 334
 
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 
348 348
 	}
349 349
 
350
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) );
350
+	wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id));
351 351
 	exit;
352 352
 
353 353
 }
354
-add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 );
354
+add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1);
355 355
 
356 356
 /**
357 357
  * Handles subscription deletion
@@ -362,30 +362,30 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function wpinv_recurring_process_subscription_deletion() {
364 364
 
365
-	if( empty( $_POST['sub_id'] ) ) {
365
+	if (empty($_POST['sub_id'])) {
366 366
 		return;
367 367
 	}
368 368
 
369
-	if( empty( $_POST['wpinv_delete_subscription'] ) ) {
369
+	if (empty($_POST['wpinv_delete_subscription'])) {
370 370
 		return;
371 371
 	}
372 372
 
373
-	if( ! current_user_can( 'manage_invoicing') ) {
373
+	if (!current_user_can('manage_invoicing')) {
374 374
 		return;
375 375
 	}
376 376
 
377
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
378
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
377
+	if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) {
378
+		wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
379 379
 	}
380 380
 
381
-	$subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
381
+	$subscription = new WPInv_Subscription(absint($_POST['sub_id']));
382 382
 
383
-	delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' );
383
+	delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment');
384 384
 
385 385
 	$subscription->delete();
386 386
 
387
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) );
387
+	wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted'));
388 388
 	exit;
389 389
 
390 390
 }
391
-add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 );
391
+add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2);
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
8
-function wpinv_discount_columns( $existing_columns ) {
7
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
8
+function wpinv_discount_columns($existing_columns) {
9 9
     $columns                = array();
10 10
     $columns['cb']          = $existing_columns['cb'];
11
-    $columns['name']        = __( 'Name', 'invoicing' );
12
-    $columns['code']        = __( 'Code', 'invoicing' );
13
-    $columns['amount']      = __( 'Amount', 'invoicing' );
14
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
15
-    $columns['start_date']  = __( 'Start Date', 'invoicing' );
16
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
17
-    $columns['status']      = __( 'Status', 'invoicing' );
11
+    $columns['name']        = __('Name', 'invoicing');
12
+    $columns['code']        = __('Code', 'invoicing');
13
+    $columns['amount']      = __('Amount', 'invoicing');
14
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
15
+    $columns['start_date']  = __('Start Date', 'invoicing');
16
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
17
+    $columns['status']      = __('Status', 'invoicing');
18 18
 
19 19
     return $columns;
20 20
 }
21 21
 
22
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
23
-function wpinv_discount_custom_column( $column ) {
22
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
23
+function wpinv_discount_custom_column($column) {
24 24
     global $post;
25 25
     
26 26
     $discount = $post;
27 27
 
28
-    switch ( $column ) {
28
+    switch ($column) {
29 29
         case 'name' :
30
-            echo get_the_title( $discount->ID );
30
+            echo get_the_title($discount->ID);
31 31
         break;
32 32
         case 'code' :
33
-            echo wpinv_get_discount_code( $discount->ID );
33
+            echo wpinv_get_discount_code($discount->ID);
34 34
         break;
35 35
         case 'amount' :
36
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
36
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
37 37
         break;
38 38
         case 'usage_limit' :
39
-            echo wpinv_get_discount_uses( $discount->ID );
39
+            echo wpinv_get_discount_uses($discount->ID);
40 40
         break;
41 41
         case 'usage' :
42
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
43
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
44
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
42
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
43
+            if (wpinv_get_discount_max_uses($discount->ID)) {
44
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
45 45
             } else {
46 46
                 $usage .= ' &infin;';
47 47
             }
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
             echo $usage;
50 50
         break;
51 51
         case 'start_date' :
52
-            if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) {
53
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) );
52
+            if ($start_date = wpinv_get_discount_start_date($discount->ID)) {
53
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date));
54 54
             } else {
55 55
                 $value = '-';
56 56
             }
@@ -58,163 +58,163 @@  discard block
 block discarded – undo
58 58
             echo $value;
59 59
         break;
60 60
         case 'expiry_date' :
61
-            if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) {
62
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) );
61
+            if ($expiration = wpinv_get_discount_expiration($discount->ID)) {
62
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration));
63 63
             } else {
64
-                $value = __( 'Never', 'invoicing' );
64
+                $value = __('Never', 'invoicing');
65 65
             }
66 66
                 
67 67
             echo $value;
68 68
         break;
69 69
         break;
70 70
         case 'description' :
71
-            echo wp_kses_post( $post->post_excerpt );
71
+            echo wp_kses_post($post->post_excerpt);
72 72
         break;
73 73
         case 'status' :
74
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
74
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
75 75
             
76
-            echo wpinv_discount_status( $status );
76
+            echo wpinv_discount_status($status);
77 77
         break;
78 78
     }
79 79
 }
80 80
 
81
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
82
-function wpinv_post_row_actions( $actions, $post ) {
83
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
81
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
82
+function wpinv_post_row_actions($actions, $post) {
83
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
84 84
     
85
-    if ( $post_type == 'wpi_invoice' ) {
85
+    if ($post_type == 'wpi_invoice') {
86 86
         $actions = array();
87 87
     }
88 88
     
89
-    if ( $post_type == 'wpi_discount' ) {
90
-        $actions = wpinv_discount_row_actions( $post, $actions );
89
+    if ($post_type == 'wpi_discount') {
90
+        $actions = wpinv_discount_row_actions($post, $actions);
91 91
     }
92 92
     
93 93
     return $actions;
94 94
 }
95 95
 
96
-function wpinv_discount_row_actions( $discount, $row_actions ) {
97
-    $row_actions  = array();
98
-    $edit_link = get_edit_post_link( $discount->ID );
99
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
96
+function wpinv_discount_row_actions($discount, $row_actions) {
97
+    $row_actions = array();
98
+    $edit_link = get_edit_post_link($discount->ID);
99
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
100 100
 
101
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
102
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
103
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
104
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
101
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
102
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
103
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
104
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
105 105
     }
106 106
 
107
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
108
-        if ( isset( $row_actions['delete'] ) ) {
109
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
107
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
108
+        if (isset($row_actions['delete'])) {
109
+            unset($row_actions['delete']); // Don't delete used discounts.
110 110
         }
111 111
     } else {
112
-        $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>';
112
+        $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>';
113 113
     }
114 114
     
115 115
 
116
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
116
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
117 117
 
118 118
     return $row_actions;
119 119
 }
120 120
 
121
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
122
-function wpinv_table_primary_column( $default, $screen_id ) {
123
-    if ( 'edit-wpi_invoice' === $screen_id ) {
121
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
122
+function wpinv_table_primary_column($default, $screen_id) {
123
+    if ('edit-wpi_invoice' === $screen_id) {
124 124
         return 'name';
125 125
     }
126 126
     
127 127
     return $default;
128 128
 }
129 129
 
130
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
131
-    if ( !$display ) {
130
+function wpinv_discount_bulk_actions($actions, $display = false) {    
131
+    if (!$display) {
132 132
         return array();
133 133
     }
134 134
     
135 135
     $actions = array(
136
-        'activate'   => __( 'Activate', 'invoicing' ),
137
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
138
-        'delete'     => __( 'Delete', 'invoicing' ),
136
+        'activate'   => __('Activate', 'invoicing'),
137
+        'deactivate' => __('Deactivate', 'invoicing'),
138
+        'delete'     => __('Delete', 'invoicing'),
139 139
     );
140 140
     $two = '';
141 141
     $which = 'top';
142 142
     echo '</div><div class="alignleft actions bulkactions">';
143
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
144
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
145
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
143
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
144
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
145
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
146 146
 
147
-    foreach ( $actions as $name => $title ) {
147
+    foreach ($actions as $name => $title) {
148 148
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
149 149
 
150 150
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
151 151
     }
152 152
     echo "</select>";
153 153
 
154
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
154
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
155 155
     
156 156
     echo '</div><div class="alignleft actions">';
157 157
 }
158
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
158
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
159 159
 
160
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
161
-    if ( $post_type == 'wpi_discount' ) {
160
+function wpinv_disable_months_dropdown($disable, $post_type) {
161
+    if ($post_type == 'wpi_discount') {
162 162
         $disable = true;
163 163
     }
164 164
     
165 165
     return $disable;
166 166
 }
167
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
167
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
168 168
 
169 169
 function wpinv_restrict_manage_posts() {
170 170
     global $typenow;
171 171
 
172
-    if( 'wpi_discount' == $typenow ) {
172
+    if ('wpi_discount' == $typenow) {
173 173
         wpinv_discount_filters();
174 174
     }
175 175
 }
176
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
176
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
177 177
 
178 178
 function wpinv_discount_filters() {
179
-    echo wpinv_discount_bulk_actions( array(), true );
179
+    echo wpinv_discount_bulk_actions(array(), true);
180 180
     
181 181
     ?>
182 182
     <select name="discount_type" id="dropdown_wpinv_discount_type">
183
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
183
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
184 184
         <?php
185 185
             $types = wpinv_get_discount_types();
186 186
 
187
-            foreach ( $types as $name => $type ) {
188
-                echo '<option value="' . esc_attr( $name ) . '"';
187
+            foreach ($types as $name => $type) {
188
+                echo '<option value="' . esc_attr($name) . '"';
189 189
 
190
-                if ( isset( $_GET['discount_type'] ) )
191
-                    selected( $name, $_GET['discount_type'] );
190
+                if (isset($_GET['discount_type']))
191
+                    selected($name, $_GET['discount_type']);
192 192
 
193
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
193
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
194 194
             }
195 195
         ?>
196 196
     </select>
197 197
     <?php
198 198
 }
199 199
 
200
-function wpinv_request( $vars ) {
200
+function wpinv_request($vars) {
201 201
     global $typenow, $wp_query, $wp_post_statuses;
202 202
 
203
-    if ( 'wpi_invoice' === $typenow ) {
204
-        if ( !isset( $vars['post_status'] ) ) {
203
+    if ('wpi_invoice' === $typenow) {
204
+        if (!isset($vars['post_status'])) {
205 205
             $post_statuses = wpinv_get_invoice_statuses();
206 206
 
207
-            foreach ( $post_statuses as $status => $value ) {
208
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
209
-                    unset( $post_statuses[ $status ] );
207
+            foreach ($post_statuses as $status => $value) {
208
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
209
+                    unset($post_statuses[$status]);
210 210
                 }
211 211
             }
212 212
 
213
-            $vars['post_status'] = array_keys( $post_statuses );
213
+            $vars['post_status'] = array_keys($post_statuses);
214 214
         }
215 215
         
216
-        if ( isset( $vars['orderby'] ) ) {
217
-            if ( 'amount' == $vars['orderby'] ) {
216
+        if (isset($vars['orderby'])) {
217
+            if ('amount' == $vars['orderby']) {
218 218
                 $vars = array_merge(
219 219
                     $vars,
220 220
                     array(
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                         'orderby'  => 'meta_value_num'
223 223
                     )
224 224
                 );
225
-            } else if ( 'customer' == $vars['orderby'] ) {
225
+            } else if ('customer' == $vars['orderby']) {
226 226
                 $vars = array_merge(
227 227
                     $vars,
228 228
                     array(
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                         'orderby'  => 'meta_value'
231 231
                     )
232 232
                 );
233
-            } else if ( 'number' == $vars['orderby'] ) {
233
+            } else if ('number' == $vars['orderby']) {
234 234
                 $vars = array_merge(
235 235
                     $vars,
236 236
                     array(
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                         'orderby'  => 'meta_value'
239 239
                     )
240 240
                 );
241
-            } else if ( 'payment_date' == $vars['orderby'] ) {
241
+            } else if ('payment_date' == $vars['orderby']) {
242 242
                 $vars = array_merge(
243 243
                     $vars,
244 244
                     array(
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
                 );
249 249
             }
250 250
         }
251
-    } else if ( 'wpi_item' == $typenow ) {
251
+    } else if ('wpi_item' == $typenow) {
252 252
         // Check if 'orderby' is set to "price"
253
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
253
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
254 254
             $vars = array_merge(
255 255
                 $vars,
256 256
                 array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         // Check if "orderby" is set to "vat_rule"
264
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
264
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
265 265
             $vars = array_merge(
266 266
                 $vars,
267 267
                 array(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
 
274 274
         // Check if "orderby" is set to "vat_class"
275
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
275
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
276 276
             $vars = array_merge(
277 277
                 $vars,
278 278
                 array(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         }
284 284
         
285 285
         // Check if "orderby" is set to "type"
286
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
286
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
287 287
             $vars = array_merge(
288 288
                 $vars,
289 289
                 array(
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         }
295 295
         
296 296
         // Check if "orderby" is set to "recurring"
297
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
297
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
298 298
             $vars = array_merge(
299 299
                 $vars,
300 300
                 array(
@@ -304,104 +304,104 @@  discard block
 block discarded – undo
304 304
             );
305 305
         }
306 306
 
307
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
307
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
308 308
         // Filter vat rule type
309
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
309
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
310 310
             $meta_query[] = array(
311 311
                     'key'   => '_wpinv_vat_rule',
312
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
312
+                    'value' => sanitize_text_field($_GET['vat_rule']),
313 313
                     'compare' => '='
314 314
                 );
315 315
         }
316 316
         
317 317
         // Filter vat class
318
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
318
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
319 319
             $meta_query[] = array(
320 320
                     'key'   => '_wpinv_vat_class',
321
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
321
+                    'value' => sanitize_text_field($_GET['vat_class']),
322 322
                     'compare' => '='
323 323
                 );
324 324
         }
325 325
         
326 326
         // Filter item type
327
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
327
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
328 328
             $meta_query[] = array(
329 329
                     'key'   => '_wpinv_type',
330
-                    'value' => sanitize_text_field( $_GET['type'] ),
330
+                    'value' => sanitize_text_field($_GET['type']),
331 331
                     'compare' => '='
332 332
                 );
333 333
         }
334 334
         
335
-        if ( !empty( $meta_query ) ) {
335
+        if (!empty($meta_query)) {
336 336
             $vars['meta_query'] = $meta_query;
337 337
         }
338
-    } else if ( 'wpi_discount' == $typenow ) {
339
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
338
+    } else if ('wpi_discount' == $typenow) {
339
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
340 340
         // Filter vat rule type
341
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
341
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
342 342
             $meta_query[] = array(
343 343
                     'key'   => '_wpi_discount_type',
344
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
344
+                    'value' => sanitize_text_field($_GET['discount_type']),
345 345
                     'compare' => '='
346 346
                 );
347 347
         }
348 348
         
349
-        if ( !empty( $meta_query ) ) {
349
+        if (!empty($meta_query)) {
350 350
             $vars['meta_query'] = $meta_query;
351 351
         }
352 352
     }
353 353
 
354 354
     return $vars;
355 355
 }
356
-add_filter( 'request', 'wpinv_request' );
356
+add_filter('request', 'wpinv_request');
357 357
 
358
-function wpinv_item_type_class( $classes, $class, $post_id ) {
358
+function wpinv_item_type_class($classes, $class, $post_id) {
359 359
     global $pagenow, $typenow;
360 360
 
361
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
362
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
363
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
361
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
362
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
363
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
364 364
         }
365 365
         
366
-        if ( !wpinv_item_is_editable( $post_id ) ) {
366
+        if (!wpinv_item_is_editable($post_id)) {
367 367
             $classes[] = 'wpi-editable-n';
368 368
         }
369 369
     }
370 370
     return $classes;
371 371
 }
372
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
372
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
373 373
 
374 374
 function wpinv_check_quick_edit() {
375 375
     global $pagenow, $current_screen, $wpinv_item_screen;
376 376
 
377
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
378
-        if ( empty( $wpinv_item_screen ) ) {
379
-            if ( $current_screen->post_type == 'wpi_item' ) {
377
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
378
+        if (empty($wpinv_item_screen)) {
379
+            if ($current_screen->post_type == 'wpi_item') {
380 380
                 $wpinv_item_screen = 'y';
381 381
             } else {
382 382
                 $wpinv_item_screen = 'n';
383 383
             }
384 384
         }
385 385
 
386
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
387
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
388
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
386
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
387
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
388
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
389 389
         }
390 390
     }
391 391
 }
392
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
392
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
393 393
 
394
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
395
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
396
-        unset( $actions['inline hide-if-no-js'] );
394
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
395
+    if (isset($actions['inline hide-if-no-js'])) {
396
+        unset($actions['inline hide-if-no-js']);
397 397
     }
398 398
     
399
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
400
-        if ( isset( $actions['trash'] ) ) {
401
-            unset( $actions['trash'] );
399
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
400
+        if (isset($actions['trash'])) {
401
+            unset($actions['trash']);
402 402
         }
403
-        if ( isset( $actions['delete'] ) ) {
404
-            unset( $actions['delete'] );
403
+        if (isset($actions['delete'])) {
404
+            unset($actions['delete']);
405 405
         }
406 406
     }
407 407
 
@@ -418,19 +418,19 @@  discard block
 block discarded – undo
418 418
  * @param int $post_parent (default: 0) Parent for the new page
419 419
  * @return int page ID
420 420
  */
421
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
421
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
422 422
     global $wpdb;
423 423
 
424
-    $option_value = wpinv_get_option( $option );
424
+    $option_value = wpinv_get_option($option);
425 425
 
426
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
427
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
426
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
427
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
428 428
             // Valid page is already in place
429 429
             return $page_object->ID;
430 430
         }
431 431
     }
432 432
 
433
-    if(!empty($post_parent)){
433
+    if (!empty($post_parent)) {
434 434
         $page = get_page_by_path($post_parent);
435 435
         if ($page) {
436 436
             $post_parent = $page->ID;
@@ -439,40 +439,40 @@  discard block
 block discarded – undo
439 439
         }
440 440
     }
441 441
 
442
-    if ( strlen( $page_content ) > 0 ) {
442
+    if (strlen($page_content) > 0) {
443 443
         // Search for an existing page with the specified page content (typically a shortcode)
444
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
444
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
445 445
     } else {
446 446
         // Search for an existing page with the specified page slug
447
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
447
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
448 448
     }
449 449
 
450
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
450
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
451 451
 
452
-    if ( $valid_page_found ) {
453
-        if ( $option ) {
454
-            wpinv_update_option( $option, $valid_page_found );
452
+    if ($valid_page_found) {
453
+        if ($option) {
454
+            wpinv_update_option($option, $valid_page_found);
455 455
         }
456 456
         return $valid_page_found;
457 457
     }
458 458
 
459 459
     // Search for a matching valid trashed page
460
-    if ( strlen( $page_content ) > 0 ) {
460
+    if (strlen($page_content) > 0) {
461 461
         // Search for an existing page with the specified page content (typically a shortcode)
462
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
462
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
463 463
     } else {
464 464
         // Search for an existing page with the specified page slug
465
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
465
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
466 466
     }
467 467
 
468
-    if ( $trashed_page_found ) {
468
+    if ($trashed_page_found) {
469 469
         $page_id   = $trashed_page_found;
470 470
         $page_data = array(
471 471
             'ID'             => $page_id,
472 472
             'post_status'    => 'publish',
473 473
             'post_parent'    => $post_parent,
474 474
         );
475
-        wp_update_post( $page_data );
475
+        wp_update_post($page_data);
476 476
     } else {
477 477
         $page_data = array(
478 478
             'post_status'    => 'publish',
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
             'post_parent'    => $post_parent,
485 485
             'comment_status' => 'closed',
486 486
         );
487
-        $page_id = wp_insert_post( $page_data );
487
+        $page_id = wp_insert_post($page_data);
488 488
     }
489 489
 
490
-    if ( $option ) {
491
-        wpinv_update_option( $option, (int)$page_id );
490
+    if ($option) {
491
+        wpinv_update_option($option, (int) $page_id);
492 492
     }
493 493
 
494 494
     return $page_id;
Please login to merge, or discard this patch.