@@ -116,7 +116,7 @@ |
||
116 | 116 | */ |
117 | 117 | protected function _setPostString() |
118 | 118 | { |
119 | - $this->_post_string =<<<XML |
|
119 | + $this->_post_string = <<<XML |
|
120 | 120 | <?xml version="1.0" encoding="utf-8"?> |
121 | 121 | <ARB{$this->_request_type} xmlns= "AnetApi/xml/v1/schema/AnetApiSchema.xsd"> |
122 | 122 | <merchantAuthentication> |
@@ -309,10 +309,10 @@ discard block |
||
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 |
||
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 |
||
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 | /** |
@@ -387,7 +387,7 @@ discard block |
||
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); |
@@ -116,7 +116,7 @@ discard block |
||
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)); |
|
119 | + $this->version = array_pop(array_slice(explode('"', $response), 1, 1)); |
|
120 | 120 | $this->response_code = (string)$this->xml->ResponseCode; |
121 | 121 | |
122 | 122 | if ($this->response_code == 1) { |
@@ -144,7 +144,7 @@ discard block |
||
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 |
||
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 |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | { |
65 | 65 | $month = ($month ? $month : date('m')); |
66 | 66 | $year = ($year ? $year : date('Y')); |
67 | - $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6); |
|
68 | - $lastSettlementDate = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6); |
|
67 | + $firstSettlementDate = substr(date('c', mktime(0, 0, 0, $month, 1, $year)), 0, -6); |
|
68 | + $lastSettlementDate = substr(date('c', mktime(0, 0, 0, $month + 1, 0, $year)), 0, -6); |
|
69 | 69 | return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); |
70 | 70 | } |
71 | 71 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $month = ($month ? $month : date('m')); |
99 | 99 | $day = ($day ? $day : date('d')); |
100 | 100 | $year = ($year ? $year : date('Y')); |
101 | - $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); |
|
102 | - $lastSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); |
|
101 | + $firstSettlementDate = substr(date('c', mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)), 0, -6); |
|
102 | + $lastSettlementDate = substr(date('c', mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)), 0, -6); |
|
103 | 103 | $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); |
104 | 104 | $batches = $response->xpath("batchList/batch"); |
105 | 105 | foreach ($batches as $batch) { |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | */ |
188 | 188 | private function _constructXml($request_type) |
189 | 189 | { |
190 | - $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>'; |
|
190 | + $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>'; |
|
191 | 191 | $this->_xml = @new SimpleXMLElement($string); |
192 | 192 | $merchant = $this->_xml->addChild('merchantAuthentication'); |
193 | - $merchant->addChild('name',$this->_api_login); |
|
194 | - $merchant->addChild('transactionKey',$this->_transaction_key); |
|
193 | + $merchant->addChild('name', $this->_api_login); |
|
194 | + $merchant->addChild('transactionKey', $this->_transaction_key); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | $string = ""; |
52 | 52 | $types = $this->__getTypes(); |
53 | 53 | foreach ($types as $type) { |
54 | - if (preg_match("/struct /",$type)) { |
|
55 | - $type = preg_replace("/struct /","class ",$type); |
|
56 | - $type = preg_replace("/ (\w+) (\w+);/"," // $1\n public \$$2;",$type); |
|
57 | - $string .= $type ."\n"; |
|
54 | + if (preg_match("/struct /", $type)) { |
|
55 | + $type = preg_replace("/struct /", "class ", $type); |
|
56 | + $type = preg_replace("/ (\w+) (\w+);/", " // $1\n public \$$2;", $type); |
|
57 | + $string .= $type . "\n"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | return $string; |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function saveSoapDocumentation($path) |
86 | 86 | { |
87 | - $string = "<?php\n"; |
|
87 | + $string = "<?php\n"; |
|
88 | 88 | $string .= "/**\n"; |
89 | 89 | $string .= " * Auto generated documentation for the AuthorizeNetSOAP API.\n"; |
90 | 90 | $string .= " * Generated " . date("m/d/Y") . "\n"; |
91 | 91 | $string .= " */\n"; |
92 | 92 | $string .= "class AuthorizeNetSOAP\n"; |
93 | - $string .= "{\n" . $this->getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() ."\n\n ?>"; |
|
93 | + $string .= "{\n" . $this->getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() . "\n\n ?>"; |
|
94 | 94 | return file_put_contents($path, $string); |
95 | 95 | } |
96 | 96 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | else |
58 | 58 | { |
59 | 59 | // Redirect to error page. |
60 | - $redirect_url = $url . '?response_code='.$response->response_code . '&response_reason_text=' . $response->response_reason_text; |
|
60 | + $redirect_url = $url . '?response_code=' . $response->response_code . '&response_reason_text=' . $response->response_reason_text; |
|
61 | 61 | } |
62 | 62 | // Send the Javascript back to AuthorizeNet, which will redirect user back to your site. |
63 | 63 | echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url); |
@@ -179,54 +179,54 @@ discard block |
||
179 | 179 | -moz-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); |
180 | 180 | box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); } |
181 | 181 | </style> |
182 | - <form method="post" action="'.$post_url.'"> |
|
183 | - '.$hidden_fields.' |
|
182 | + <form method="post" action="'.$post_url . '"> |
|
183 | + '.$hidden_fields . ' |
|
184 | 184 | <fieldset> |
185 | 185 | <div> |
186 | 186 | <label>Credit Card Number</label> |
187 | - <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '').'"></input> |
|
187 | + <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '') . '"></input> |
|
188 | 188 | </div> |
189 | 189 | <div> |
190 | 190 | <label>Exp.</label> |
191 | - <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '').'"></input> |
|
191 | + <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '') . '"></input> |
|
192 | 192 | </div> |
193 | 193 | <div> |
194 | 194 | <label>CCV</label> |
195 | - <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '').'"></input> |
|
195 | + <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '') . '"></input> |
|
196 | 196 | </div> |
197 | 197 | </fieldset> |
198 | 198 | <fieldset> |
199 | 199 | <div> |
200 | 200 | <label>First Name</label> |
201 | - <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '').'"></input> |
|
201 | + <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '') . '"></input> |
|
202 | 202 | </div> |
203 | 203 | <div> |
204 | 204 | <label>Last Name</label> |
205 | - <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '').'"></input> |
|
205 | + <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '') . '"></input> |
|
206 | 206 | </div> |
207 | 207 | </fieldset> |
208 | 208 | <fieldset> |
209 | 209 | <div> |
210 | 210 | <label>Address</label> |
211 | - <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '').'"></input> |
|
211 | + <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '') . '"></input> |
|
212 | 212 | </div> |
213 | 213 | <div> |
214 | 214 | <label>City</label> |
215 | - <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '').'"></input> |
|
215 | + <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '') . '"></input> |
|
216 | 216 | </div> |
217 | 217 | </fieldset> |
218 | 218 | <fieldset> |
219 | 219 | <div> |
220 | 220 | <label>State</label> |
221 | - <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '').'"></input> |
|
221 | + <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '') . '"></input> |
|
222 | 222 | </div> |
223 | 223 | <div> |
224 | 224 | <label>Zip Code</label> |
225 | - <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '').'"></input> |
|
225 | + <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '') . '"></input> |
|
226 | 226 | </div> |
227 | 227 | <div> |
228 | 228 | <label>Country</label> |
229 | - <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '').'"></input> |
|
229 | + <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '') . '"></input> |
|
230 | 230 | </div> |
231 | 231 | </fieldset> |
232 | 232 | <input type="submit" value="BUY" class="submit buy"> |
@@ -1,41 +1,41 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | global $post; |
6 | 6 | $invoice_id = $post->ID; |
7 | -$invoice = wpinv_get_invoice( $invoice_id ); |
|
8 | -if ( empty( $invoice ) ) { |
|
7 | +$invoice = wpinv_get_invoice($invoice_id); |
|
8 | +if (empty($invoice)) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | -$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' ); |
|
12 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html> |
|
11 | +$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing'); |
|
12 | +do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html> |
|
13 | 13 | <html <?php language_attributes(); ?>> |
14 | 14 | <head> |
15 | 15 | <meta charset="UTF-8"> |
16 | 16 | <title><?php wp_title() ?></title> |
17 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
17 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
18 | 18 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
19 | 19 | <meta name="robots" content="noindex,nofollow"> |
20 | 20 | |
21 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
21 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
22 | 22 | </head> |
23 | 23 | <body class="body wpinv wpinv-print"> |
24 | - <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?> |
|
24 | + <?php do_action('wpinv_invoice_print_body_start', $invoice); ?> |
|
25 | 25 | <div class="container wpinv-wrap"> |
26 | - <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?> |
|
27 | - <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div> |
|
26 | + <?php if ($watermark = wpinv_watermark($invoice_id)) { ?> |
|
27 | + <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div> |
|
28 | 28 | <?php } ?> |
29 | 29 | <!-- ///// Start PDF header --> |
30 | 30 | <htmlpageheader name="wpinv-pdf-header"> |
31 | - <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?> |
|
31 | + <?php do_action('wpinv_invoice_print_before_header', $invoice); ?> |
|
32 | 32 | <div class="row wpinv-header"> |
33 | 33 | <div class="col-xs-6 wpinv-business"> |
34 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
35 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
36 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
34 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
35 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
36 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
37 | 37 | <?php } else { ?> |
38 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
38 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
39 | 39 | <?php } ?> |
40 | 40 | </a> |
41 | 41 | </div> |
@@ -44,56 +44,56 @@ discard block |
||
44 | 44 | <h2><?php echo $type; ?></h2> |
45 | 45 | </div> |
46 | 46 | </div> |
47 | - <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?> |
|
47 | + <?php do_action('wpinv_invoice_print_after_header', $invoice); ?> |
|
48 | 48 | </htmlpageheader> |
49 | 49 | <!-- End PDF header ///// --> |
50 | 50 | |
51 | - <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?> |
|
51 | + <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?> |
|
52 | 52 | <div class="row wpinv-top-content"> |
53 | 53 | <div class="col-xs-12 col-sm-6 wpinv-addresses"> |
54 | 54 | <div class="col-xs-12 wpinv-address wpinv-from-address"> |
55 | 55 | <?php wpinv_display_from_address(); ?> |
56 | 56 | </div> |
57 | 57 | <div class="col-xs-12 wpinv-address wpinv-to-address"> |
58 | - <?php wpinv_display_to_address( $invoice_id ); ?> |
|
58 | + <?php wpinv_display_to_address($invoice_id); ?> |
|
59 | 59 | </div> |
60 | 60 | </div> |
61 | 61 | <div class="col-xs-12 col-sm-6 wpinv-details"> |
62 | 62 | <div class="col-xs-12 wpinv-line-details"> |
63 | - <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?> |
|
64 | - <?php wpinv_display_invoice_details( $invoice ); ?> |
|
65 | - <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?> |
|
63 | + <?php do_action('wpinv_invoice_print_before_details', $invoice); ?> |
|
64 | + <?php wpinv_display_invoice_details($invoice); ?> |
|
65 | + <?php do_action('wpinv_invoice_print_after_details', $invoice); ?> |
|
66 | 66 | </div> |
67 | 67 | </div> |
68 | 68 | </div> |
69 | - <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?> |
|
69 | + <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?> |
|
70 | 70 | |
71 | - <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?> |
|
71 | + <?php do_action('wpinv_invoice_print_middle', $invoice); ?> |
|
72 | 72 | |
73 | - <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?> |
|
73 | + <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?> |
|
74 | 74 | <div class="row wpinv-items"> |
75 | 75 | <div class="col-sm-12 wpinv-line-items"> |
76 | - <?php wpinv_display_line_items( $invoice_id ); ?> |
|
76 | + <?php wpinv_display_line_items($invoice_id); ?> |
|
77 | 77 | </div> |
78 | 78 | </div> |
79 | - <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?> |
|
79 | + <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?> |
|
80 | 80 | |
81 | 81 | <!-- ///// Start PDF footer --> |
82 | 82 | <htmlpagefooter name="wpinv-pdf-footer"> |
83 | - <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?> |
|
83 | + <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?> |
|
84 | 84 | <div class="row wpinv-footer"> |
85 | 85 | <div class="col-sm-12"> |
86 | - <?php if ( $term_text = wpinv_get_terms_text() ) { ?> |
|
87 | - <div class="terms-text"><?php echo wpautop( $term_text ); ?></div> |
|
86 | + <?php if ($term_text = wpinv_get_terms_text()) { ?> |
|
87 | + <div class="terms-text"><?php echo wpautop($term_text); ?></div> |
|
88 | 88 | <?php } ?> |
89 | 89 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
90 | - <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div> |
|
90 | + <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div> |
|
91 | 91 | </div> |
92 | 92 | </div> |
93 | - <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?> |
|
93 | + <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?> |
|
94 | 94 | </htmlpagefooter> |
95 | 95 | <!-- End PDF footer ///// --> |
96 | 96 | </div><!-- END wpinv-wrap --> |
97 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
97 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
98 | 98 | </body> |
99 | 99 | </html> |
100 | 100 | \ No newline at end of file |
@@ -7,51 +7,51 @@ discard block |
||
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 | class WPInv_API { |
15 | 15 | protected $post_type = 'wpi_invoice'; |
16 | 16 | |
17 | - public function __construct( $params = array() ) { |
|
17 | + public function __construct($params = array()) { |
|
18 | 18 | } |
19 | - public function insert_invoice( $data ) { |
|
19 | + public function insert_invoice($data) { |
|
20 | 20 | global $wpdb; |
21 | 21 | //wpinv_transaction_query( 'start' ); |
22 | 22 | |
23 | 23 | try { |
24 | - if ( empty( $data['invoice'] ) ) { |
|
25 | - throw new WPInv_API_Exception( 'wpinv_api_missing_invoice_data', sprintf( __( 'No %1$s data specified to create %1$s', 'invoicing' ), 'invoice' ), 400 ); |
|
24 | + if (empty($data['invoice'])) { |
|
25 | + throw new WPInv_API_Exception('wpinv_api_missing_invoice_data', sprintf(__('No %1$s data specified to create %1$s', 'invoicing'), 'invoice'), 400); |
|
26 | 26 | } |
27 | 27 | |
28 | - $data = apply_filters( 'wpinv_api_create_invoice_data', $data['invoice'], $this ); |
|
28 | + $data = apply_filters('wpinv_api_create_invoice_data', $data['invoice'], $this); |
|
29 | 29 | |
30 | - $invoice = wpinv_insert_invoice( $data, true ); |
|
31 | - if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) { |
|
32 | - throw new WPInv_API_Exception( 'wpinv_api_cannot_create_invoice', sprintf( __( 'Cannot create invoice: %s', 'invoicing' ), implode( ', ', $invoice->get_error_messages() ) ), 400 ); |
|
30 | + $invoice = wpinv_insert_invoice($data, true); |
|
31 | + if (empty($invoice->ID) || is_wp_error($invoice)) { |
|
32 | + throw new WPInv_API_Exception('wpinv_api_cannot_create_invoice', sprintf(__('Cannot create invoice: %s', 'invoicing'), implode(', ', $invoice->get_error_messages())), 400); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // HTTP 201 Created |
36 | - $this->send_status( 201 ); |
|
36 | + $this->send_status(201); |
|
37 | 37 | |
38 | - do_action( 'wpinv_api_create_invoice', $invoice->ID, $data, $this ); |
|
38 | + do_action('wpinv_api_create_invoice', $invoice->ID, $data, $this); |
|
39 | 39 | |
40 | 40 | //wpinv_transaction_query( 'commit' ); |
41 | 41 | |
42 | - return wpinv_get_invoice( $invoice->ID ); |
|
43 | - } catch ( WPInv_API_Exception $e ) { |
|
42 | + return wpinv_get_invoice($invoice->ID); |
|
43 | + } catch (WPInv_API_Exception $e) { |
|
44 | 44 | //wpinv_transaction_query( 'rollback' ); |
45 | 45 | |
46 | - return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); |
|
46 | + return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode())); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public function send_status( $code ) { |
|
51 | - status_header( $code ); |
|
50 | + public function send_status($code) { |
|
51 | + status_header($code); |
|
52 | 52 | } |
53 | 53 | |
54 | - protected function set_billing_details( $invoice, $data ) { |
|
54 | + protected function set_billing_details($invoice, $data) { |
|
55 | 55 | $address_fields = array( |
56 | 56 | 'user_id', |
57 | 57 | 'first_name', |
@@ -70,66 +70,66 @@ discard block |
||
70 | 70 | $billing_details = array(); |
71 | 71 | $user_id = $invoice->get_user_id(); |
72 | 72 | |
73 | - foreach ( $address_fields as $field ) { |
|
74 | - if ( isset( $data['billing_details'][ $field ] ) ) { |
|
75 | - $value = sanitize_text_field( $data['billing_details'][ $field ] ); |
|
73 | + foreach ($address_fields as $field) { |
|
74 | + if (isset($data['billing_details'][$field])) { |
|
75 | + $value = sanitize_text_field($data['billing_details'][$field]); |
|
76 | 76 | |
77 | - if ( $field == 'country' && empty( $value ) ) { |
|
78 | - if ( !empty( $invoice->country ) ) { |
|
77 | + if ($field == 'country' && empty($value)) { |
|
78 | + if (!empty($invoice->country)) { |
|
79 | 79 | $value = $invoice->country; |
80 | 80 | } else { |
81 | - $value = wpinv_default_billing_country( '', $user_id ); |
|
81 | + $value = wpinv_default_billing_country('', $user_id); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - if ( $field == 'state' && empty( $value ) ) { |
|
86 | - if ( !empty( $invoice->state ) ) { |
|
85 | + if ($field == 'state' && empty($value)) { |
|
86 | + if (!empty($invoice->state)) { |
|
87 | 87 | $value = $invoice->state; |
88 | 88 | } else { |
89 | 89 | $value = wpinv_get_default_state(); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $invoice->set( $field, $value ); |
|
93 | + $invoice->set($field, $value); |
|
94 | 94 | |
95 | - update_post_meta( $invoice->ID, '_wpinv_' . $field, $value ); |
|
95 | + update_post_meta($invoice->ID, '_wpinv_' . $field, $value); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | return $invoice; |
100 | 100 | } |
101 | 101 | |
102 | - protected function set_discount( $invoice, $data ) { |
|
103 | - if ( isset( $data['discount'] ) ) { |
|
104 | - $invoice->set( 'discount', wpinv_round_amount( $data['discount'] ) ); |
|
102 | + protected function set_discount($invoice, $data) { |
|
103 | + if (isset($data['discount'])) { |
|
104 | + $invoice->set('discount', wpinv_round_amount($data['discount'])); |
|
105 | 105 | |
106 | - update_post_meta( $invoice->ID, '_wpinv_discount', wpinv_round_amount( $data['discount'] ) ); |
|
106 | + update_post_meta($invoice->ID, '_wpinv_discount', wpinv_round_amount($data['discount'])); |
|
107 | 107 | |
108 | - if ( isset( $data['discount_code'] ) ) { |
|
109 | - $invoice->set( 'discount_code', $data['discount_code'] ); |
|
108 | + if (isset($data['discount_code'])) { |
|
109 | + $invoice->set('discount_code', $data['discount_code']); |
|
110 | 110 | |
111 | - update_post_meta( $invoice->ID, '_wpinv_discount_code', $data['discount_code'] ); |
|
111 | + update_post_meta($invoice->ID, '_wpinv_discount_code', $data['discount_code']); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | 115 | return $invoice; |
116 | 116 | } |
117 | 117 | |
118 | - protected function set_items( $invoice, $data ) { |
|
119 | - if ( !empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
118 | + protected function set_items($invoice, $data) { |
|
119 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
120 | 120 | $items_array = array(); |
121 | 121 | |
122 | - if ( !empty( $invoice->country ) ) { |
|
122 | + if (!empty($invoice->country)) { |
|
123 | 123 | $country = $invoice->country; |
124 | - } else if ( !empty( $data['billing_details']['country'] ) ) { |
|
124 | + } else if (!empty($data['billing_details']['country'])) { |
|
125 | 125 | $country = $data['billing_details']['country']; |
126 | 126 | } else { |
127 | - $country = wpinv_default_billing_country( '', $invoice->get_user_id() ); |
|
127 | + $country = wpinv_default_billing_country('', $invoice->get_user_id()); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( !empty( $invoice->state ) ) { |
|
130 | + if (!empty($invoice->state)) { |
|
131 | 131 | $state = $invoice->state; |
132 | - } else if ( !empty( $data['billing_details']['state'] ) ) { |
|
132 | + } else if (!empty($data['billing_details']['state'])) { |
|
133 | 133 | $state = $data['billing_details']['state']; |
134 | 134 | } else { |
135 | 135 | $state = wpinv_get_default_state(); |
@@ -138,54 +138,54 @@ discard block |
||
138 | 138 | $_POST['country'] = $country; |
139 | 139 | $_POST['state'] = $state; |
140 | 140 | |
141 | - $rate = wpinv_get_tax_rate( $country, $state, 'global' ); |
|
141 | + $rate = wpinv_get_tax_rate($country, $state, 'global'); |
|
142 | 142 | |
143 | 143 | $total_tax = 0; |
144 | - foreach ( $data['items'] as $item ) { |
|
145 | - $id = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : ''; |
|
146 | - $title = isset( $item['title'] ) ? sanitize_text_field( $item['title'] ) : ''; |
|
147 | - $desc = isset( $item['description'] ) ? sanitize_text_field( $item['description'] ) : ''; |
|
148 | - $amount = isset( $item['amount'] ) ? wpinv_round_amount( $item['amount'] ) : 0; |
|
144 | + foreach ($data['items'] as $item) { |
|
145 | + $id = isset($item['id']) ? sanitize_text_field($item['id']) : ''; |
|
146 | + $title = isset($item['title']) ? sanitize_text_field($item['title']) : ''; |
|
147 | + $desc = isset($item['description']) ? sanitize_text_field($item['description']) : ''; |
|
148 | + $amount = isset($item['amount']) ? wpinv_round_amount($item['amount']) : 0; |
|
149 | 149 | |
150 | - if ( !empty( $item['vat_rates_class'] ) ) { |
|
150 | + if (!empty($item['vat_rates_class'])) { |
|
151 | 151 | $vat_rates_class = $item['vat_rates_class']; |
152 | 152 | } else { |
153 | 153 | $vat_rates_class = '_standard'; |
154 | 154 | } |
155 | - $vat_rate = wpinv_get_tax_rate( $country, $state, $id ); |
|
155 | + $vat_rate = wpinv_get_tax_rate($country, $state, $id); |
|
156 | 156 | |
157 | - $tax = $amount > 0 ? ( $amount * 0.01 * (float)$vat_rate ) : 0; |
|
157 | + $tax = $amount > 0 ? ($amount * 0.01 * (float)$vat_rate) : 0; |
|
158 | 158 | $total_tax += $tax; |
159 | 159 | |
160 | 160 | $items_array[] = array( |
161 | 161 | 'id' => $id, |
162 | - 'title' => esc_html( $title ), |
|
163 | - 'description' => esc_html( $desc ), |
|
164 | - 'amount' => $amount > 0 ? wpinv_round_amount( $amount ) : 0, |
|
165 | - 'subtotal' => $amount > 0 ? wpinv_round_amount( $amount ) : 0, |
|
162 | + 'title' => esc_html($title), |
|
163 | + 'description' => esc_html($desc), |
|
164 | + 'amount' => $amount > 0 ? wpinv_round_amount($amount) : 0, |
|
165 | + 'subtotal' => $amount > 0 ? wpinv_round_amount($amount) : 0, |
|
166 | 166 | 'vat_rates_class' => $vat_rates_class, |
167 | 167 | 'vat_rate' => $vat_rate, |
168 | - 'tax' => $tax > 0 ? wpinv_round_amount( $tax ) : 0, |
|
168 | + 'tax' => $tax > 0 ? wpinv_round_amount($tax) : 0, |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
172 | - update_post_meta( $invoice->ID, '_wpinv_tax', wpinv_round_amount( $total_tax ) ); |
|
173 | - $invoice->set( 'tax', wpinv_round_amount( $total_tax ) ); |
|
172 | + update_post_meta($invoice->ID, '_wpinv_tax', wpinv_round_amount($total_tax)); |
|
173 | + $invoice->set('tax', wpinv_round_amount($total_tax)); |
|
174 | 174 | |
175 | - $items_array = apply_filters( 'wpinv_save_invoice_items', $items_array, $data['items'], $invoice ); |
|
175 | + $items_array = apply_filters('wpinv_save_invoice_items', $items_array, $data['items'], $invoice); |
|
176 | 176 | |
177 | - $invoice->set( 'items', $items_array ); |
|
178 | - update_post_meta( $invoice->ID, '_wpinv_items', $items_array ); |
|
177 | + $invoice->set('items', $items_array); |
|
178 | + update_post_meta($invoice->ID, '_wpinv_items', $items_array); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $invoice; |
182 | 182 | } |
183 | 183 | |
184 | - protected function set_invoice_meta( $invoice_id, $invoice_meta ) { |
|
185 | - foreach ( $invoice_meta as $meta_key => $meta_value ) { |
|
184 | + protected function set_invoice_meta($invoice_id, $invoice_meta) { |
|
185 | + foreach ($invoice_meta as $meta_key => $meta_value) { |
|
186 | 186 | |
187 | - if ( is_string( $meta_key) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) { |
|
188 | - update_post_meta( $invoice_id, $meta_key, $meta_value ); |
|
187 | + if (is_string($meta_key) && !is_protected_meta($meta_key) && is_scalar($meta_value)) { |
|
188 | + update_post_meta($invoice_id, $meta_key, $meta_value); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | class WPInv_API_Exception extends Exception { |
196 | 196 | protected $error_code; |
197 | 197 | |
198 | - public function __construct( $error_code, $error_message, $http_status_code ) { |
|
198 | + public function __construct($error_code, $error_message, $http_status_code) { |
|
199 | 199 | $this->error_code = $error_code; |
200 | - parent::__construct( $error_message, $http_status_code ); |
|
200 | + parent::__construct($error_message, $http_status_code); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | public function getErrorCode() { |
@@ -1,56 +1,56 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | -do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html> |
|
5 | +do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html> |
|
6 | 6 | <html <?php language_attributes(); ?>> |
7 | 7 | <head> |
8 | 8 | <meta charset="UTF-8"> |
9 | 9 | <title><?php wp_title() ?></title> |
10 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
10 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
11 | 11 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
12 | 12 | <meta name="robots" content="noindex,nofollow"> |
13 | - <?php do_action( 'wpinv_invalid_invoice_head' ); ?> |
|
13 | + <?php do_action('wpinv_invalid_invoice_head'); ?> |
|
14 | 14 | </head> |
15 | 15 | <body class="body wpinv wpinv-print wpinv-invalid-invoice"> |
16 | - <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?> |
|
16 | + <?php do_action('wpinv_invalid_invoice_body_start'); ?> |
|
17 | 17 | <div class="container wpinv-wrap"> |
18 | 18 | <!-- ///// Start Header --> |
19 | 19 | <htmlpageheader name="wpinv-pdf-header"> |
20 | - <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?> |
|
20 | + <?php do_action('wpinv_invalid_invoice_before_header'); ?> |
|
21 | 21 | <div class="row wpinv-header"> |
22 | 22 | <div class="col-xs-12 wpinv-business"> |
23 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
24 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
25 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
23 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
24 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
25 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
26 | 26 | <?php } else { ?> |
27 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
27 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
28 | 28 | <?php } ?> |
29 | 29 | </a> |
30 | 30 | </div> |
31 | 31 | </div> |
32 | - <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?> |
|
32 | + <?php do_action('wpinv_invalid_invoice_after_header'); ?> |
|
33 | 33 | </htmlpageheader> |
34 | 34 | <!-- End Header ///// --> |
35 | 35 | |
36 | - <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?> |
|
36 | + <?php do_action('wpinv_invalid_invoice_before_content'); ?> |
|
37 | 37 | |
38 | - <?php do_action( 'wpinv_invalid_invoice_content' ); ?> |
|
38 | + <?php do_action('wpinv_invalid_invoice_content'); ?> |
|
39 | 39 | |
40 | - <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?> |
|
40 | + <?php do_action('wpinv_invalid_invoice_after_content'); ?> |
|
41 | 41 | |
42 | 42 | <!-- ///// Start Footer --> |
43 | 43 | <htmlpagefooter name="wpinv-pdf-footer"> |
44 | - <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?> |
|
44 | + <?php do_action('wpinv_invalid_invoice_before_footer'); ?> |
|
45 | 45 | <div class="row wpinv-footer"> |
46 | 46 | <div class="col-sm-12"> |
47 | 47 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | - <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?> |
|
50 | + <?php do_action('wpinv_invalid_invoice_after_footer'); ?> |
|
51 | 51 | </htmlpagefooter> |
52 | 52 | <!-- End Footer ///// --> |
53 | 53 | </div> |
54 | - <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?> |
|
54 | + <?php do_action('wpinv_invalid_invoice_body_end'); ?> |
|
55 | 55 | </body> |
56 | 56 | </html> |
57 | 57 | \ No newline at end of file |