@@ -13,38 +13,38 @@ |
||
13 | 13 | |
14 | 14 | foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) : |
15 | 15 | |
16 | - $class = sanitize_html_class( $column ); |
|
17 | - echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
|
16 | + $class = sanitize_html_class( $column ); |
|
17 | + echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
|
18 | 18 | |
19 | - do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
19 | + do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
20 | 20 | |
21 | - switch( $column ) : |
|
21 | + switch( $column ) : |
|
22 | 22 | |
23 | - case 'subscription': |
|
24 | - $subscription_id = (int) $subscription->get_id(); |
|
25 | - $url = esc_url( $subscription->get_view_url() ); |
|
26 | - echo $widget->add_row_actions( "<a href='$url' class='text-decoration-none'>#$subscription_id</a>", $subscription ); |
|
27 | - break; |
|
23 | + case 'subscription': |
|
24 | + $subscription_id = (int) $subscription->get_id(); |
|
25 | + $url = esc_url( $subscription->get_view_url() ); |
|
26 | + echo $widget->add_row_actions( "<a href='$url' class='text-decoration-none'>#$subscription_id</a>", $subscription ); |
|
27 | + break; |
|
28 | 28 | |
29 | - case 'status': |
|
30 | - echo $subscription->get_status_label(); |
|
31 | - break; |
|
29 | + case 'status': |
|
30 | + echo $subscription->get_status_label(); |
|
31 | + break; |
|
32 | 32 | |
33 | - case 'renewal-date': |
|
34 | - $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
35 | - echo $subscription->is_active() ? $renewal : "—"; |
|
36 | - break; |
|
33 | + case 'renewal-date': |
|
34 | + $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
35 | + echo $subscription->is_active() ? $renewal : "—"; |
|
36 | + break; |
|
37 | 37 | |
38 | - case 'amount': |
|
39 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
40 | - $amount = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
41 | - echo "<strong style='font-weight: 500;'>$amount</strong> / $frequency"; |
|
42 | - break; |
|
38 | + case 'amount': |
|
39 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
40 | + $amount = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
41 | + echo "<strong style='font-weight: 500;'>$amount</strong> / $frequency"; |
|
42 | + break; |
|
43 | 43 | |
44 | - endswitch; |
|
44 | + endswitch; |
|
45 | 45 | |
46 | - do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
46 | + do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
47 | 47 | |
48 | - echo '</td>'; |
|
48 | + echo '</td>'; |
|
49 | 49 | |
50 | 50 | endforeach; |
@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) : |
|
14 | +foreach (array_keys($widget->get_subscriptions_table_columns()) as $column) : |
|
15 | 15 | |
16 | - $class = sanitize_html_class( $column ); |
|
16 | + $class = sanitize_html_class($column); |
|
17 | 17 | echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
18 | 18 | |
19 | - do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
19 | + do_action("getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription); |
|
20 | 20 | |
21 | - switch( $column ) : |
|
21 | + switch ($column) : |
|
22 | 22 | |
23 | 23 | case 'subscription': |
24 | 24 | $subscription_id = (int) $subscription->get_id(); |
25 | - $url = esc_url( $subscription->get_view_url() ); |
|
26 | - echo $widget->add_row_actions( "<a href='$url' class='text-decoration-none'>#$subscription_id</a>", $subscription ); |
|
25 | + $url = esc_url($subscription->get_view_url()); |
|
26 | + echo $widget->add_row_actions("<a href='$url' class='text-decoration-none'>#$subscription_id</a>", $subscription); |
|
27 | 27 | break; |
28 | 28 | |
29 | 29 | case 'status': |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | break; |
32 | 32 | |
33 | 33 | case 'renewal-date': |
34 | - $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
34 | + $renewal = getpaid_format_date_value($subscription->get_next_renewal_date()); |
|
35 | 35 | echo $subscription->is_active() ? $renewal : "—"; |
36 | 36 | break; |
37 | 37 | |
38 | 38 | case 'amount': |
39 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
40 | - $amount = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
39 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
40 | + $amount = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_recurring_amount())), $subscription->get_parent_payment()->get_currency()); |
|
41 | 41 | echo "<strong style='font-weight: 500;'>$amount</strong> / $frequency"; |
42 | 42 | break; |
43 | 43 | |
44 | 44 | endswitch; |
45 | 45 | |
46 | - do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
46 | + do_action("getpaid_subscriptions_frontend_subscription_table_$column", $subscription); |
|
47 | 47 | |
48 | 48 | echo '</td>'; |
49 | 49 |
@@ -15,31 +15,31 @@ discard block |
||
15 | 15 | abstract class GetPaid_Authorize_Net_Legacy_Gateway extends GetPaid_Payment_Gateway { |
16 | 16 | |
17 | 17 | /** |
18 | - * Class constructor. |
|
19 | - */ |
|
20 | - public function __construct() { |
|
18 | + * Class constructor. |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | 21 | parent::__construct(); |
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | - * Returns the API URL. |
|
26 | - * |
|
27 | - * |
|
28 | - * @param WPInv_Invoice $invoice Invoice. |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function get_api_url( $invoice ) { |
|
25 | + * Returns the API URL. |
|
26 | + * |
|
27 | + * |
|
28 | + * @param WPInv_Invoice $invoice Invoice. |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function get_api_url( $invoice ) { |
|
32 | 32 | return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api'; |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * Communicates with authorize.net |
|
37 | - * |
|
38 | - * |
|
39 | - * @param array $post Data to post. |
|
36 | + * Communicates with authorize.net |
|
37 | + * |
|
38 | + * |
|
39 | + * @param array $post Data to post. |
|
40 | 40 | * @param WPInv_Invoice $invoice Invoice. |
41 | - * @return stdClass|WP_Error |
|
42 | - */ |
|
41 | + * @return stdClass|WP_Error |
|
42 | + */ |
|
43 | 43 | public function post( $post, $invoice ){ |
44 | 44 | |
45 | 45 | $url = $this->get_api_url( $invoice ); |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | - * Returns the API authentication params. |
|
85 | - * |
|
86 | - * |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - public function get_auth_params() { |
|
84 | + * Returns the API authentication params. |
|
85 | + * |
|
86 | + * |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + public function get_auth_params() { |
|
90 | 90 | |
91 | 91 | return array( |
92 | 92 | 'name' => $this->get_option( 'login_id' ), |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Cancels a subscription remotely |
|
100 | - * |
|
101 | - * |
|
102 | - * @param WPInv_Subscription $subscription Subscription. |
|
99 | + * Cancels a subscription remotely |
|
100 | + * |
|
101 | + * |
|
102 | + * @param WPInv_Subscription $subscription Subscription. |
|
103 | 103 | * @param WPInv_Invoice $invoice Invoice. |
104 | - */ |
|
105 | - public function cancel_subscription( $subscription, $invoice ) { |
|
104 | + */ |
|
105 | + public function cancel_subscription( $subscription, $invoice ) { |
|
106 | 106 | |
107 | 107 | // Backwards compatibility. New version do not use authorize.net subscriptions. |
108 | 108 | $this->post( |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * Processes ipns. |
|
122 | - * |
|
123 | - * @return void |
|
124 | - */ |
|
125 | - public function verify_ipn() { |
|
121 | + * Processes ipns. |
|
122 | + * |
|
123 | + * @return void |
|
124 | + */ |
|
125 | + public function verify_ipn() { |
|
126 | 126 | |
127 | 127 | $this->maybe_process_old_ipn(); |
128 | 128 | |
129 | 129 | // Validate the IPN. |
130 | 130 | if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
131 | - wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) ); |
|
131 | + wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) ); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // Event type. |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | - * Validates IPN invoices. |
|
171 | - * |
|
170 | + * Validates IPN invoices. |
|
171 | + * |
|
172 | 172 | * @param WPInv_Invoice $invoice |
173 | 173 | * @param object $payload |
174 | - * @return void |
|
175 | - */ |
|
176 | - public function validate_ipn_invoice( $invoice, $payload ) { |
|
174 | + * @return void |
|
175 | + */ |
|
176 | + public function validate_ipn_invoice( $invoice, $payload ) { |
|
177 | 177 | if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) { |
178 | 178 | exit; |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | - * Process subscriptio IPNS. |
|
184 | - * |
|
185 | - * @return void |
|
186 | - */ |
|
187 | - public function maybe_process_old_ipn() { |
|
183 | + * Process subscriptio IPNS. |
|
184 | + * |
|
185 | + * @return void |
|
186 | + */ |
|
187 | + public function maybe_process_old_ipn() { |
|
188 | 188 | |
189 | 189 | $data = wp_unslash( $_POST ); |
190 | 190 | |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | - * Validates the old IPN signature. |
|
229 | + * Validates the old IPN signature. |
|
230 | 230 | * |
231 | 231 | * @param array $posted |
232 | - */ |
|
233 | - public function validate_old_ipn_signature( $posted ) { |
|
232 | + */ |
|
233 | + public function validate_old_ipn_signature( $posted ) { |
|
234 | 234 | |
235 | 235 | $signature = $this->get_option( 'signature_key' ); |
236 | 236 | if ( ! empty( $signature ) ) { |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * Check Authorize.NET IPN validity. |
|
253 | - */ |
|
254 | - public function validate_ipn() { |
|
252 | + * Check Authorize.NET IPN validity. |
|
253 | + */ |
|
254 | + public function validate_ipn() { |
|
255 | 255 | |
256 | 256 | wpinv_error_log( 'Validating Authorize.NET IPN response' ); |
257 | 257 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Legacy Payment Gateway class. |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param WPInv_Invoice $invoice Invoice. |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public function get_api_url( $invoice ) { |
|
32 | - return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api'; |
|
31 | + public function get_api_url($invoice) { |
|
32 | + return $this->is_sandbox($invoice) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -40,40 +40,40 @@ discard block |
||
40 | 40 | * @param WPInv_Invoice $invoice Invoice. |
41 | 41 | * @return stdClass|WP_Error |
42 | 42 | */ |
43 | - public function post( $post, $invoice ){ |
|
43 | + public function post($post, $invoice) { |
|
44 | 44 | |
45 | - $url = $this->get_api_url( $invoice ); |
|
45 | + $url = $this->get_api_url($invoice); |
|
46 | 46 | $response = wp_remote_post( |
47 | 47 | $url, |
48 | 48 | array( |
49 | 49 | 'headers' => array( |
50 | 50 | 'Content-Type' => 'application/json; charset=utf-8' |
51 | 51 | ), |
52 | - 'body' => json_encode( $post ), |
|
52 | + 'body' => json_encode($post), |
|
53 | 53 | 'method' => 'POST' |
54 | 54 | ) |
55 | 55 | ); |
56 | 56 | |
57 | - if ( is_wp_error( $response ) ) { |
|
57 | + if (is_wp_error($response)) { |
|
58 | 58 | return $response; |
59 | 59 | } |
60 | 60 | |
61 | - $response = wp_unslash( wp_remote_retrieve_body( $response ) ); |
|
61 | + $response = wp_unslash(wp_remote_retrieve_body($response)); |
|
62 | 62 | $response = preg_replace('/\xEF\xBB\xBF/', '', $response); // https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851 |
63 | - $response = json_decode( $response ); |
|
63 | + $response = json_decode($response); |
|
64 | 64 | |
65 | - if ( empty( $response ) ) { |
|
66 | - return new WP_Error( 'invalid_reponse', __( 'Invalid gateway response', 'invoicing' ) ); |
|
65 | + if (empty($response)) { |
|
66 | + return new WP_Error('invalid_reponse', __('Invalid gateway response', 'invoicing')); |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( $response->messages->resultCode == 'Error' ) { |
|
69 | + if ($response->messages->resultCode == 'Error') { |
|
70 | 70 | |
71 | - if ( ! empty( $response->transactionResponse ) && ! empty( $response->transactionResponse->errors ) ) { |
|
71 | + if (!empty($response->transactionResponse) && !empty($response->transactionResponse->errors)) { |
|
72 | 72 | $error = $response->transactionResponse->errors[0]; |
73 | - return new WP_Error( $error->errorCode, $error->errorText ); |
|
73 | + return new WP_Error($error->errorCode, $error->errorText); |
|
74 | 74 | } |
75 | 75 | |
76 | - return new WP_Error( $response->messages->message[0]->code, $response->messages->message[0]->text ); |
|
76 | + return new WP_Error($response->messages->message[0]->code, $response->messages->message[0]->text); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $response; |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | public function get_auth_params() { |
90 | 90 | |
91 | 91 | return array( |
92 | - 'name' => $this->get_option( 'login_id' ), |
|
93 | - 'transactionKey' => $this->get_option( 'transaction_key' ), |
|
92 | + 'name' => $this->get_option('login_id'), |
|
93 | + 'transactionKey' => $this->get_option('transaction_key'), |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param WPInv_Subscription $subscription Subscription. |
103 | 103 | * @param WPInv_Invoice $invoice Invoice. |
104 | 104 | */ |
105 | - public function cancel_subscription( $subscription, $invoice ) { |
|
105 | + public function cancel_subscription($subscription, $invoice) { |
|
106 | 106 | |
107 | 107 | // Backwards compatibility. New version do not use authorize.net subscriptions. |
108 | 108 | $this->post( |
@@ -127,38 +127,38 @@ discard block |
||
127 | 127 | $this->maybe_process_old_ipn(); |
128 | 128 | |
129 | 129 | // Validate the IPN. |
130 | - if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
|
131 | - wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) ); |
|
130 | + if (empty($_POST) || !$this->validate_ipn()) { |
|
131 | + wp_die('Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array('response' => 500)); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // Event type. |
135 | - $posted = json_decode( file_get_contents( 'php://input' ) ); |
|
136 | - if ( empty( $posted ) ) { |
|
137 | - wp_die( 'Invalid JSON', 'Authorize.NET IPN', array( 'response' => 500 ) ); |
|
135 | + $posted = json_decode(file_get_contents('php://input')); |
|
136 | + if (empty($posted)) { |
|
137 | + wp_die('Invalid JSON', 'Authorize.NET IPN', array('response' => 500)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Process the IPN. |
141 | - $posted = (object) wp_unslash( $posted ); |
|
141 | + $posted = (object) wp_unslash($posted); |
|
142 | 142 | |
143 | 143 | // Process refunds. |
144 | - if ( 'net.authorize.payment.refund.created' == $posted->eventType ) { |
|
145 | - $invoice = new WPInv_Invoice( $posted->payload->merchantReferenceId ); |
|
146 | - $this->validate_ipn_invoice( $invoice, $posted->payload ); |
|
144 | + if ('net.authorize.payment.refund.created' == $posted->eventType) { |
|
145 | + $invoice = new WPInv_Invoice($posted->payload->merchantReferenceId); |
|
146 | + $this->validate_ipn_invoice($invoice, $posted->payload); |
|
147 | 147 | $invoice->refund(); |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Held funds approved. |
151 | - if ( 'net.authorize.payment.fraud.approved' == $posted->eventType ) { |
|
152 | - $invoice = new WPInv_Invoice( $posted->payload->id ); |
|
153 | - $this->validate_ipn_invoice( $invoice, $posted->payload ); |
|
154 | - $invoice->mark_paid( false, __( 'Payment released', 'invoicing' ) ); |
|
151 | + if ('net.authorize.payment.fraud.approved' == $posted->eventType) { |
|
152 | + $invoice = new WPInv_Invoice($posted->payload->id); |
|
153 | + $this->validate_ipn_invoice($invoice, $posted->payload); |
|
154 | + $invoice->mark_paid(false, __('Payment released', 'invoicing')); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Held funds declined. |
158 | - if ( 'net.authorize.payment.fraud.declined' == $posted->eventType ) { |
|
159 | - $invoice = new WPInv_Invoice( $posted->payload->id ); |
|
160 | - $this->validate_ipn_invoice( $invoice, $posted->payload ); |
|
161 | - $invoice->set_status( 'wpi-failed', __( 'Payment desclined', 'invoicing' ) ); |
|
158 | + if ('net.authorize.payment.fraud.declined' == $posted->eventType) { |
|
159 | + $invoice = new WPInv_Invoice($posted->payload->id); |
|
160 | + $this->validate_ipn_invoice($invoice, $posted->payload); |
|
161 | + $invoice->set_status('wpi-failed', __('Payment desclined', 'invoicing')); |
|
162 | 162 | $invoice->save(); |
163 | 163 | } |
164 | 164 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param object $payload |
174 | 174 | * @return void |
175 | 175 | */ |
176 | - public function validate_ipn_invoice( $invoice, $payload ) { |
|
177 | - if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) { |
|
176 | + public function validate_ipn_invoice($invoice, $payload) { |
|
177 | + if (!$invoice->exists() || $payload->id != $invoice->get_transaction_id()) { |
|
178 | 178 | exit; |
179 | 179 | } |
180 | 180 | } |
@@ -186,32 +186,32 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function maybe_process_old_ipn() { |
188 | 188 | |
189 | - $data = wp_unslash( $_POST ); |
|
189 | + $data = wp_unslash($_POST); |
|
190 | 190 | |
191 | 191 | // Only process subscriptions subscriptions. |
192 | - if ( empty( $_POST['x_subscription_id'] ) ) { |
|
192 | + if (empty($_POST['x_subscription_id'])) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Check validity. |
197 | - $this->validate_old_ipn_signature( $data ); |
|
197 | + $this->validate_old_ipn_signature($data); |
|
198 | 198 | |
199 | 199 | // Fetch the associated subscription. |
200 | - $subscription_id = WPInv_Subscription::get_subscription_id_by_field( $_POST['x_subscription_id'] ); |
|
201 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
200 | + $subscription_id = WPInv_Subscription::get_subscription_id_by_field($_POST['x_subscription_id']); |
|
201 | + $subscription = new WPInv_Subscription($subscription_id); |
|
202 | 202 | |
203 | 203 | // Abort if it is missing or completed. |
204 | - if ( ! $subscription->get_id() || $subscription->has_status( 'completed' ) ) { |
|
204 | + if (!$subscription->get_id() || $subscription->has_status('completed')) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Payment status. |
209 | - if ( 1 == $_POST['x_response_code'] ) { |
|
209 | + if (1 == $_POST['x_response_code']) { |
|
210 | 210 | |
211 | 211 | // Renew the subscription. |
212 | 212 | $subscription->add_payment( |
213 | 213 | array( |
214 | - 'transaction_id' => sanitize_text_field( $data['x_trans_id'] ), |
|
214 | + 'transaction_id' => sanitize_text_field($data['x_trans_id']), |
|
215 | 215 | 'gateway' => $this->id |
216 | 216 | ) |
217 | 217 | ); |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param array $posted |
232 | 232 | */ |
233 | - public function validate_old_ipn_signature( $posted ) { |
|
233 | + public function validate_old_ipn_signature($posted) { |
|
234 | 234 | |
235 | - $signature = $this->get_option( 'signature_key' ); |
|
236 | - if ( ! empty( $signature ) ) { |
|
237 | - $login_id = $this->get_option( 'login_id' ); |
|
235 | + $signature = $this->get_option('signature_key'); |
|
236 | + if (!empty($signature)) { |
|
237 | + $login_id = $this->get_option('login_id'); |
|
238 | 238 | $trans_id = $_POST['x_trans_id']; |
239 | 239 | $amount = $_POST['x_amount']; |
240 | - $hash = hash_hmac ( 'sha512', "^$login_id^$trans_id^$amount^", hex2bin( $signature ) ); |
|
240 | + $hash = hash_hmac('sha512', "^$login_id^$trans_id^$amount^", hex2bin($signature)); |
|
241 | 241 | |
242 | - if ( ! hash_equals( $hash, $posted['x_SHA2_Hash'] ) ) { |
|
243 | - wpinv_error_log( $posted['x_SHA2_Hash'], "Invalid signature. Expected $hash" ); |
|
242 | + if (!hash_equals($hash, $posted['x_SHA2_Hash'])) { |
|
243 | + wpinv_error_log($posted['x_SHA2_Hash'], "Invalid signature. Expected $hash"); |
|
244 | 244 | exit; |
245 | 245 | } |
246 | 246 | |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function validate_ipn() { |
255 | 255 | |
256 | - wpinv_error_log( 'Validating Authorize.NET IPN response' ); |
|
256 | + wpinv_error_log('Validating Authorize.NET IPN response'); |
|
257 | 257 | |
258 | - if ( empty( $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) { |
|
258 | + if (empty($_SERVER['HTTP_X_ANET_SIGNATURE'])) { |
|
259 | 259 | return false; |
260 | 260 | } |
261 | 261 | |
262 | - $signature = $this->get_option( 'signature_key' ); |
|
262 | + $signature = $this->get_option('signature_key'); |
|
263 | 263 | |
264 | - if ( empty( $signature ) ) { |
|
265 | - wpinv_error_log( 'Error: You have not set a signature key' ); |
|
264 | + if (empty($signature)) { |
|
265 | + wpinv_error_log('Error: You have not set a signature key'); |
|
266 | 266 | return false; |
267 | 267 | } |
268 | 268 | |
269 | - $hash = hash_hmac ( 'sha512', file_get_contents( 'php://input' ), hex2bin( $signature ) ); |
|
269 | + $hash = hash_hmac('sha512', file_get_contents('php://input'), hex2bin($signature)); |
|
270 | 270 | |
271 | - if ( hash_equals( $hash, $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) { |
|
272 | - wpinv_error_log( 'Successfully validated the IPN' ); |
|
271 | + if (hash_equals($hash, $_SERVER['HTTP_X_ANET_SIGNATURE'])) { |
|
272 | + wpinv_error_log('Successfully validated the IPN'); |
|
273 | 273 | return true; |
274 | 274 | } |
275 | 275 | |
276 | - wpinv_error_log( 'IPN hash is not valid' ); |
|
277 | - wpinv_error_log( $_SERVER['HTTP_X_ANET_SIGNATURE'] ); |
|
276 | + wpinv_error_log('IPN hash is not valid'); |
|
277 | + wpinv_error_log($_SERVER['HTTP_X_ANET_SIGNATURE']); |
|
278 | 278 | return false; |
279 | 279 | |
280 | 280 | } |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | $css = getpaid_get_email_css(); |
111 | 111 | |
112 | 112 | // include css inliner |
113 | - if ( ! class_exists( 'Emogrifier' ) ) { |
|
114 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
113 | + if ( ! class_exists( 'Emogrifier' ) ) { |
|
114 | + include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // Inline the css. |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $message = wpinv_email_style_body( $message ); |
191 | 191 | $to = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) ); |
192 | 192 | |
193 | - return $mailer->send( |
|
193 | + return $mailer->send( |
|
194 | 194 | $to, |
195 | 195 | $subject, |
196 | 196 | $message, |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * Please use GetPaid_Notification_Email_Sender |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /* |
12 | 12 | |-------------------------------------------------------------------------- |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Generates the email header. |
19 | 19 | */ |
20 | -function wpinv_email_header( $email_heading ) { |
|
21 | - wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) ); |
|
20 | +function wpinv_email_header($email_heading) { |
|
21 | + wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading')); |
|
22 | 22 | } |
23 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
23 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Generates the email footer. |
28 | 28 | */ |
29 | 29 | function wpinv_email_footer() { |
30 | - wpinv_get_template( 'emails/wpinv-email-footer.php' ); |
|
30 | + wpinv_get_template('emails/wpinv-email-footer.php'); |
|
31 | 31 | } |
32 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
32 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param string $email_type |
40 | 40 | * @param bool $sent_to_admin |
41 | 41 | */ |
42 | -function wpinv_email_invoice_details( $invoice, $email_type, $sent_to_admin ) { |
|
42 | +function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) { |
|
43 | 43 | |
44 | - $args = compact( 'invoice', 'email_type', 'sent_to_admin' ); |
|
45 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', $args ); |
|
44 | + $args = compact('invoice', 'email_type', 'sent_to_admin'); |
|
45 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', $args); |
|
46 | 46 | |
47 | 47 | } |
48 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
48 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | /** |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param string $email_type |
56 | 56 | * @param bool $sent_to_admin |
57 | 57 | */ |
58 | -function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) { |
|
58 | +function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) { |
|
59 | 59 | |
60 | 60 | // Prepare line items. |
61 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
62 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
61 | + $columns = getpaid_invoice_item_columns($invoice); |
|
62 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
63 | 63 | |
64 | 64 | // Load the template. |
65 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) ); |
|
65 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin')); |
|
66 | 66 | |
67 | 67 | } |
68 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
68 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | /** |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * @param string $email_type |
76 | 76 | * @param bool $sent_to_admin |
77 | 77 | */ |
78 | -function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) { |
|
78 | +function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) { |
|
79 | 79 | |
80 | - $args = compact( 'invoice', 'email_type', 'sent_to_admin' ); |
|
81 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args ); |
|
80 | + $args = compact('invoice', 'email_type', 'sent_to_admin'); |
|
81 | + wpinv_get_template('emails/wpinv-email-billing-details.php', $args); |
|
82 | 82 | |
83 | 83 | } |
84 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
84 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Returns email css. |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | */ |
90 | 90 | function getpaid_get_email_css() { |
91 | 91 | |
92 | - $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' ); |
|
93 | - return apply_filters( 'wpinv_email_styles', $css ); |
|
92 | + $css = wpinv_get_template_html('emails/wpinv-email-styles.php'); |
|
93 | + return apply_filters('wpinv_email_styles', $css); |
|
94 | 94 | |
95 | 95 | } |
96 | 96 | |
@@ -101,26 +101,26 @@ discard block |
||
101 | 101 | * @return string |
102 | 102 | * |
103 | 103 | */ |
104 | -function wpinv_email_style_body( $content ) { |
|
104 | +function wpinv_email_style_body($content) { |
|
105 | 105 | |
106 | - if ( ! class_exists( 'DOMDocument' ) ) { |
|
106 | + if (!class_exists('DOMDocument')) { |
|
107 | 107 | return $content; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $css = getpaid_get_email_css(); |
111 | 111 | |
112 | 112 | // include css inliner |
113 | - if ( ! class_exists( 'Emogrifier' ) ) { |
|
114 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
113 | + if (!class_exists('Emogrifier')) { |
|
114 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // Inline the css. |
118 | 118 | try { |
119 | - $emogrifier = new Emogrifier( $content, $css ); |
|
119 | + $emogrifier = new Emogrifier($content, $css); |
|
120 | 120 | $_content = $emogrifier->emogrify(); |
121 | 121 | $content = $_content; |
122 | - } catch ( Exception $e ) { |
|
123 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
122 | + } catch (Exception $e) { |
|
123 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | return $content; |
@@ -129,37 +129,37 @@ discard block |
||
129 | 129 | |
130 | 130 | // Backwards compatibility. |
131 | 131 | function wpinv_init_transactional_emails() { |
132 | - foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) { |
|
133 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
132 | + foreach (apply_filters('wpinv_email_actions', array()) as $action) { |
|
133 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
134 | 134 | } |
135 | 135 | } |
136 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
136 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
137 | 137 | |
138 | 138 | function wpinv_send_transactional_email() { |
139 | 139 | $args = func_get_args(); |
140 | 140 | $function = current_filter() . '_notification'; |
141 | - do_action_ref_array( $function, $args ); |
|
141 | + do_action_ref_array($function, $args); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | function wpinv_mail_get_from_address() { |
145 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
146 | - return sanitize_email( $from_address ); |
|
145 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
146 | + return sanitize_email($from_address); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | function wpinv_mail_get_from_name() { |
150 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
151 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
150 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
151 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
152 | 152 | } |
153 | 153 | |
154 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
155 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
156 | - return ( $active ? true : false ); |
|
154 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
155 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
156 | + return ($active ? true : false); |
|
157 | 157 | } |
158 | 158 | |
159 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
160 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
159 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
160 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
161 | 161 | |
162 | - switch ( $email_type ) { |
|
162 | + switch ($email_type) { |
|
163 | 163 | case 'html' : |
164 | 164 | $content_type = 'text/html'; |
165 | 165 | break; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @param array $attachments Any files to attach to the email. |
185 | 185 | * @param string|array $cc An email or array of extra emails to send a copy of the email to. |
186 | 186 | */ |
187 | -function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) { |
|
187 | +function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) { |
|
188 | 188 | |
189 | 189 | $mailer = new GetPaid_Notification_Email_Sender(); |
190 | - $message = wpinv_email_style_body( $message ); |
|
191 | - $to = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) ); |
|
190 | + $message = wpinv_email_style_body($message); |
|
191 | + $to = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc)); |
|
192 | 192 | |
193 | 193 | return $mailer->send( |
194 | 194 | $to, |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @return array |
206 | 206 | */ |
207 | 207 | function wpinv_get_emails() { |
208 | - return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) ); |
|
208 | + return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings')); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -214,172 +214,172 @@ discard block |
||
214 | 214 | * @param array $settings |
215 | 215 | * @return array |
216 | 216 | */ |
217 | -function wpinv_settings_emails( $settings = array() ) { |
|
218 | - $settings = array_merge( $settings, wpinv_get_emails() ); |
|
219 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
217 | +function wpinv_settings_emails($settings = array()) { |
|
218 | + $settings = array_merge($settings, wpinv_get_emails()); |
|
219 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
220 | 220 | } |
221 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
221 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Filter email section names. |
225 | 225 | * |
226 | 226 | */ |
227 | -function wpinv_settings_sections_emails( $settings ) { |
|
228 | - foreach ( wpinv_get_emails() as $key => $email) { |
|
229 | - $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key ); |
|
227 | +function wpinv_settings_sections_emails($settings) { |
|
228 | + foreach (wpinv_get_emails() as $key => $email) { |
|
229 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return $settings; |
233 | 233 | } |
234 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
234 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
235 | 235 | |
236 | -function wpinv_email_is_enabled( $email_type ) { |
|
236 | +function wpinv_email_is_enabled($email_type) { |
|
237 | 237 | $emails = wpinv_get_emails(); |
238 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
238 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
239 | 239 | |
240 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
240 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
241 | 241 | } |
242 | 242 | |
243 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
244 | - switch ( $email_type ) { |
|
243 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
244 | + switch ($email_type) { |
|
245 | 245 | case 'new_invoice': |
246 | 246 | case 'cancelled_invoice': |
247 | 247 | case 'failed_invoice': |
248 | 248 | $recipient = wpinv_get_admin_email(); |
249 | 249 | break; |
250 | 250 | default: |
251 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
252 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
251 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
252 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
253 | 253 | break; |
254 | 254 | } |
255 | 255 | |
256 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
256 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Returns invoice CC recipients |
261 | 261 | */ |
262 | -function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
263 | - switch ( $email_type ) { |
|
262 | +function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
263 | + switch ($email_type) { |
|
264 | 264 | case 'new_invoice': |
265 | 265 | case 'cancelled_invoice': |
266 | 266 | case 'failed_invoice': |
267 | 267 | return array(); |
268 | 268 | break; |
269 | 269 | default: |
270 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
271 | - $recipient = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true ); |
|
272 | - if ( empty( $recipient ) ) { |
|
270 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
271 | + $recipient = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true); |
|
272 | + if (empty($recipient)) { |
|
273 | 273 | return array(); |
274 | 274 | } |
275 | - return array_filter( array_map( 'trim', explode( ',', $recipient ) ) ); |
|
275 | + return array_filter(array_map('trim', explode(',', $recipient))); |
|
276 | 276 | break; |
277 | 277 | } |
278 | 278 | |
279 | 279 | } |
280 | 280 | |
281 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
282 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
283 | - $subject = __( $subject, 'invoicing' ); |
|
281 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
282 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
283 | + $subject = __($subject, 'invoicing'); |
|
284 | 284 | |
285 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
285 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
286 | 286 | |
287 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
287 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
288 | 288 | } |
289 | 289 | |
290 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
291 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
292 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
290 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
291 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
292 | + $email_heading = __($email_heading, 'invoicing'); |
|
293 | 293 | |
294 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
294 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
295 | 295 | |
296 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
296 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
297 | 297 | } |
298 | 298 | |
299 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
300 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
301 | - $content = __( $content, 'invoicing' ); |
|
299 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
300 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
301 | + $content = __($content, 'invoicing'); |
|
302 | 302 | |
303 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
303 | + $content = wpinv_email_format_text($content, $invoice); |
|
304 | 304 | |
305 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
305 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
306 | 306 | } |
307 | 307 | |
308 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
308 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
309 | 309 | $from_name = wpinv_mail_get_from_address(); |
310 | 310 | $from_email = wpinv_mail_get_from_address(); |
311 | 311 | |
312 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
312 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
313 | 313 | |
314 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
315 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
314 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
315 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
316 | 316 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
317 | 317 | |
318 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
318 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
319 | 319 | } |
320 | 320 | |
321 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
321 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
322 | 322 | $attachments = array(); |
323 | 323 | |
324 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
324 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Searches for and replaces certain placeholders in an email. |
329 | 329 | */ |
330 | -function wpinv_email_format_text( $content, $invoice ) { |
|
330 | +function wpinv_email_format_text($content, $invoice) { |
|
331 | 331 | |
332 | 332 | $replace_array = array( |
333 | 333 | '{site_title}' => wpinv_get_blogname(), |
334 | - '{date}' => getpaid_format_date( current_time( 'mysql' ) ), |
|
334 | + '{date}' => getpaid_format_date(current_time('mysql')), |
|
335 | 335 | ); |
336 | 336 | |
337 | - $invoice = new WPInv_Invoice( $invoice ); |
|
337 | + $invoice = new WPInv_Invoice($invoice); |
|
338 | 338 | |
339 | - if ( $invoice->get_id() ) { |
|
339 | + if ($invoice->get_id()) { |
|
340 | 340 | |
341 | 341 | $replace_array = array_merge( |
342 | 342 | $replace_array, |
343 | 343 | array( |
344 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
345 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
346 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
347 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
348 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
349 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
350 | - '{invoice_total}' => wpinv_price( wpinv_format_amount( $invoice->get_total( true ) ) ), |
|
351 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
352 | - '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ), |
|
353 | - '{invoice_date}' => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ), |
|
354 | - '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ), |
|
355 | - '{invoice_quote}' => sanitize_text_field( $invoice->get_type() ), |
|
356 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_type() ) ), |
|
357 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
344 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
345 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
346 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
347 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
348 | + '{email}' => sanitize_email($invoice->get_email()), |
|
349 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
350 | + '{invoice_total}' => wpinv_price(wpinv_format_amount($invoice->get_total(true))), |
|
351 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
352 | + '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()), |
|
353 | + '{invoice_date}' => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))), |
|
354 | + '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))), |
|
355 | + '{invoice_quote}' => sanitize_text_field($invoice->get_type()), |
|
356 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_type())), |
|
357 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
358 | 358 | ) |
359 | 359 | ); |
360 | 360 | |
361 | 361 | } |
362 | 362 | |
363 | 363 | // Let third party plugins filter the arra. |
364 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
364 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
365 | 365 | |
366 | - foreach ( $replace_array as $key => $value ) { |
|
367 | - $content = str_replace( $key, $value, $content ); |
|
366 | + foreach ($replace_array as $key => $value) { |
|
367 | + $content = str_replace($key, $value, $content); |
|
368 | 368 | } |
369 | 369 | |
370 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
370 | + return apply_filters('wpinv_email_content_replace', $content); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
374 | -function wpinv_email_wrap_message( $message ) { |
|
374 | +function wpinv_email_wrap_message($message) { |
|
375 | 375 | // Buffer |
376 | 376 | ob_start(); |
377 | 377 | |
378 | - do_action( 'wpinv_email_header' ); |
|
378 | + do_action('wpinv_email_header'); |
|
379 | 379 | |
380 | - echo wpautop( wptexturize( $message ) ); |
|
380 | + echo wpautop(wptexturize($message)); |
|
381 | 381 | |
382 | - do_action( 'wpinv_email_footer' ); |
|
382 | + do_action('wpinv_email_footer'); |
|
383 | 383 | |
384 | 384 | // Get contents |
385 | 385 | $message = ob_get_clean(); |
@@ -387,21 +387,21 @@ discard block |
||
387 | 387 | return $message; |
388 | 388 | } |
389 | 389 | |
390 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) { |
|
391 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
392 | - $date_format = get_option( 'date_format' ); |
|
393 | - $time_format = get_option( 'time_format' ); |
|
390 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type) { |
|
391 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
392 | + $date_format = get_option('date_format'); |
|
393 | + $time_format = get_option('time_format'); |
|
394 | 394 | ?> |
395 | 395 | <div id="wpinv-email-notes"> |
396 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
396 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
397 | 397 | <ol class="wpinv-notes-lists"> |
398 | 398 | <?php |
399 | - foreach ( $invoice_notes as $note ) { |
|
400 | - $note_time = strtotime( $note->comment_date ); |
|
399 | + foreach ($invoice_notes as $note) { |
|
400 | + $note_time = strtotime($note->comment_date); |
|
401 | 401 | ?> |
402 | 402 | <li class="comment wpinv-note"> |
403 | - <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> |
|
404 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
403 | + <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> |
|
404 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
405 | 405 | </li> |
406 | 406 | <?php |
407 | 407 | } |
@@ -410,4 +410,4 @@ discard block |
||
410 | 410 | <?php |
411 | 411 | } |
412 | 412 | } |
413 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
413 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
@@ -229,7 +229,7 @@ |
||
229 | 229 | */ |
230 | 230 | function wpinv_send_back_to_checkout() { |
231 | 231 | |
232 | - // Do we have any errors? |
|
232 | + // Do we have any errors? |
|
233 | 233 | if ( wpinv_get_errors() ) { |
234 | 234 | wp_send_json_error( getpaid_get_errors_html() ); |
235 | 235 | } |
@@ -1,155 +1,155 @@ discard block |
||
1 | 1 | <?php |
2 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
3 | - if ( empty( $invoice ) ) { |
|
2 | +function wpinv_is_subscription_payment($invoice = '') { |
|
3 | + if (empty($invoice)) { |
|
4 | 4 | return false; |
5 | 5 | } |
6 | 6 | |
7 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
8 | - $invoice = wpinv_get_invoice( $invoice ); |
|
7 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
8 | + $invoice = wpinv_get_invoice($invoice); |
|
9 | 9 | } |
10 | 10 | |
11 | - if ( empty( $invoice ) ) { |
|
11 | + if (empty($invoice)) { |
|
12 | 12 | return false; |
13 | 13 | } |
14 | 14 | |
15 | - if ( $invoice->is_renewal() ) { |
|
15 | + if ($invoice->is_renewal()) { |
|
16 | 16 | return true; |
17 | 17 | } |
18 | 18 | |
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
23 | - if ( empty( $invoice ) ) { |
|
22 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
23 | + if (empty($invoice)) { |
|
24 | 24 | return false; |
25 | 25 | } |
26 | 26 | |
27 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
28 | - $invoice = wpinv_get_invoice( $invoice ); |
|
27 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
28 | + $invoice = wpinv_get_invoice($invoice); |
|
29 | 29 | } |
30 | 30 | |
31 | - if ( empty( $invoice ) ) { |
|
31 | + if (empty($invoice)) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | |
35 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
35 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
36 | 36 | } |
37 | 37 | |
38 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
39 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
38 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
39 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
40 | 40 | |
41 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
42 | - $amount = __( 'Free', 'invoicing' ); |
|
41 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
42 | + $amount = __('Free', 'invoicing'); |
|
43 | 43 | $interval = $trial_interval; |
44 | 44 | $period = $trial_period; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $description = ''; |
48 | - switch ( $period ) { |
|
48 | + switch ($period) { |
|
49 | 49 | case 'D' : |
50 | 50 | case 'day' : |
51 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
51 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
52 | 52 | break; |
53 | 53 | case 'W' : |
54 | 54 | case 'week' : |
55 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
55 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
56 | 56 | break; |
57 | 57 | case 'M' : |
58 | 58 | case 'month' : |
59 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
59 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
60 | 60 | break; |
61 | 61 | case 'Y' : |
62 | 62 | case 'year' : |
63 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
63 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
67 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
71 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
72 | - $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
|
70 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
71 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
72 | + $bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0; |
|
73 | 73 | |
74 | 74 | $description = ''; |
75 | - switch ( $period ) { |
|
75 | + switch ($period) { |
|
76 | 76 | case 'D' : |
77 | 77 | case 'day' : |
78 | - if ( (int)$bill_times > 0 ) { |
|
79 | - if ( $interval > 1 ) { |
|
80 | - if ( $bill_times > 1 ) { |
|
81 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
78 | + if ((int) $bill_times > 0) { |
|
79 | + if ($interval > 1) { |
|
80 | + if ($bill_times > 1) { |
|
81 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
82 | 82 | } else { |
83 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
83 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
84 | 84 | } |
85 | 85 | } else { |
86 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
86 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
87 | 87 | } |
88 | 88 | } else { |
89 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
89 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
90 | 90 | } |
91 | 91 | break; |
92 | 92 | case 'W' : |
93 | 93 | case 'week' : |
94 | - if ( (int)$bill_times > 0 ) { |
|
95 | - if ( $interval > 1 ) { |
|
96 | - if ( $bill_times > 1 ) { |
|
97 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
94 | + if ((int) $bill_times > 0) { |
|
95 | + if ($interval > 1) { |
|
96 | + if ($bill_times > 1) { |
|
97 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
98 | 98 | } else { |
99 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
99 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
100 | 100 | } |
101 | 101 | } else { |
102 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
102 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
105 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
106 | 106 | } |
107 | 107 | break; |
108 | 108 | case 'M' : |
109 | 109 | case 'month' : |
110 | - if ( (int)$bill_times > 0 ) { |
|
111 | - if ( $interval > 1 ) { |
|
112 | - if ( $bill_times > 1 ) { |
|
113 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
110 | + if ((int) $bill_times > 0) { |
|
111 | + if ($interval > 1) { |
|
112 | + if ($bill_times > 1) { |
|
113 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
114 | 114 | } else { |
115 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
115 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
116 | 116 | } |
117 | 117 | } else { |
118 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
118 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
121 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
122 | 122 | } |
123 | 123 | break; |
124 | 124 | case 'Y' : |
125 | 125 | case 'year' : |
126 | - if ( (int)$bill_times > 0 ) { |
|
127 | - if ( $interval > 1 ) { |
|
128 | - if ( $bill_times > 1 ) { |
|
129 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
126 | + if ((int) $bill_times > 0) { |
|
127 | + if ($interval > 1) { |
|
128 | + if ($bill_times > 1) { |
|
129 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
130 | 130 | } else { |
131 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
131 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
134 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
135 | 135 | } |
136 | 136 | } else { |
137 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
137 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
138 | 138 | } |
139 | 139 | break; |
140 | 140 | } |
141 | 141 | |
142 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
142 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
146 | - if ( empty( $invoice ) ) { |
|
145 | +function wpinv_subscription_payment_desc($invoice) { |
|
146 | + if (empty($invoice)) { |
|
147 | 147 | return NULL; |
148 | 148 | } |
149 | 149 | |
150 | 150 | $description = ''; |
151 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
152 | - if ( $item->has_free_trial() ) { |
|
151 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
152 | + if ($item->has_free_trial()) { |
|
153 | 153 | $trial_period = $item->get_trial_period(); |
154 | 154 | $trial_interval = $item->get_trial_interval(); |
155 | 155 | } else { |
@@ -157,40 +157,40 @@ discard block |
||
157 | 157 | $trial_interval = 0; |
158 | 158 | } |
159 | 159 | |
160 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
160 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
161 | 161 | } |
162 | 162 | |
163 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
163 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
164 | 164 | } |
165 | 165 | |
166 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
167 | - $initial_total = wpinv_round_amount( $initial ); |
|
168 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
166 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
167 | + $initial_total = wpinv_round_amount($initial); |
|
168 | + $recurring_total = wpinv_round_amount($recurring); |
|
169 | 169 | |
170 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
170 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
171 | 171 | // Free trial |
172 | 172 | } else { |
173 | - if ( $bill_times == 1 ) { |
|
173 | + if ($bill_times == 1) { |
|
174 | 174 | $recurring_total = $initial_total; |
175 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
175 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
176 | 176 | $bill_times--; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - $initial_amount = wpinv_price( wpinv_format_amount( $initial_total ), $currency ); |
|
181 | - $recurring_amount = wpinv_price( wpinv_format_amount( $recurring_total ), $currency ); |
|
180 | + $initial_amount = wpinv_price(wpinv_format_amount($initial_total), $currency); |
|
181 | + $recurring_amount = wpinv_price(wpinv_format_amount($recurring_total), $currency); |
|
182 | 182 | |
183 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
183 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
184 | 184 | |
185 | - if ( $initial_total != $recurring_total ) { |
|
186 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
185 | + if ($initial_total != $recurring_total) { |
|
186 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
187 | 187 | |
188 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
188 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
189 | 189 | } else { |
190 | 190 | $description = $recurring; |
191 | 191 | } |
192 | 192 | |
193 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
193 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * @param string $card_number Card number. |
201 | 201 | * @return string |
202 | 202 | */ |
203 | -function getpaid_get_card_name( $card_number ) { |
|
203 | +function getpaid_get_card_name($card_number) { |
|
204 | 204 | |
205 | 205 | // Known regexes. |
206 | 206 | $regexes = array( |
207 | - '/^4/' => __( 'Visa', 'invoicing' ), |
|
208 | - '/^5[1-5]/' => __( 'Mastercard', 'invoicing' ), |
|
209 | - '/^3[47]/' => __( 'Amex', 'invoicing' ), |
|
210 | - '/^3(?:0[0-5]|[68])/' => __( 'Diners Club', 'invoicing' ), |
|
211 | - '/^6(?:011|5)/' => __( 'Discover', 'invoicing' ), |
|
212 | - '/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ), |
|
207 | + '/^4/' => __('Visa', 'invoicing'), |
|
208 | + '/^5[1-5]/' => __('Mastercard', 'invoicing'), |
|
209 | + '/^3[47]/' => __('Amex', 'invoicing'), |
|
210 | + '/^3(?:0[0-5]|[68])/' => __('Diners Club', 'invoicing'), |
|
211 | + '/^6(?:011|5)/' => __('Discover', 'invoicing'), |
|
212 | + '/^(?:2131|1800|35\d{3})/' => __('JCB', 'invoicing'), |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | // Confirm if one matches. |
216 | - foreach ( $regexes as $regex => $card ) { |
|
217 | - if ( preg_match ( $regex, $card_number ) >= 1 ) { |
|
216 | + foreach ($regexes as $regex => $card) { |
|
217 | + if (preg_match($regex, $card_number) >= 1) { |
|
218 | 218 | return $card; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | // None matched. |
223 | - return __( 'Card', 'invoicing' ); |
|
223 | + return __('Card', 'invoicing'); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | function wpinv_send_back_to_checkout() { |
231 | 231 | |
232 | 232 | // Do we have any errors? |
233 | - if ( wpinv_get_errors() ) { |
|
234 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
233 | + if (wpinv_get_errors()) { |
|
234 | + wp_send_json_error(getpaid_get_errors_html()); |
|
235 | 235 | } |
236 | 236 | |
237 | - wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) ); |
|
237 | + wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing')); |
|
238 | 238 | } |
@@ -31,36 +31,36 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | - $can_checkout = true; // Always true for now |
|
34 | + $can_checkout = true; // Always true for now |
|
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | + $page_id = absint( $page_id ); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | + $page_id = absint( $page_id ); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | + $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | + $ret = $ret ? is_page( $ret ) : false; |
|
63 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
@@ -103,55 +103,55 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
110 | - // Check for backward compatibility |
|
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
109 | + if ( !empty( $args ) ) { |
|
110 | + // Check for backward compatibility |
|
111 | + if ( is_string( $args ) ) |
|
112 | + $args = str_replace( '?', '', $args ); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args( $args ); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
117 | - } |
|
116 | + $uri = add_query_arg( $args, $uri ); |
|
117 | + } |
|
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | - } |
|
123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | + } |
|
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function wpinv_get_success_page_url( $query_string = null ) { |
131 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | - $success_page = get_permalink( $success_page ); |
|
131 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | + $success_page = get_permalink( $success_page ); |
|
133 | 133 | |
134 | - if ( $query_string ) |
|
135 | - $success_page .= $query_string; |
|
134 | + if ( $query_string ) |
|
135 | + $success_page .= $query_string; |
|
136 | 136 | |
137 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
137 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
141 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
141 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
143 | 143 | |
144 | - if ( $extras ) |
|
145 | - $uri .= $extras; |
|
144 | + if ( $extras ) |
|
145 | + $uri .= $extras; |
|
146 | 146 | |
147 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
147 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function wpinv_is_failed_transaction_page() { |
151 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
151 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
154 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -226,36 +226,36 @@ discard block |
||
226 | 226 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
227 | 227 | |
228 | 228 | if ( $require_billing_details ) { |
229 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
230 | - $required_fields['first_name'] = array( |
|
231 | - 'error_id' => 'invalid_first_name', |
|
232 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
233 | - ); |
|
234 | - } |
|
235 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
236 | - $required_fields['address'] = array( |
|
237 | - 'error_id' => 'invalid_address', |
|
238 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
239 | - ); |
|
240 | - } |
|
241 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
242 | - $required_fields['city'] = array( |
|
243 | - 'error_id' => 'invalid_city', |
|
244 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
245 | - ); |
|
246 | - } |
|
247 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
248 | - $required_fields['state'] = array( |
|
249 | - 'error_id' => 'invalid_state', |
|
250 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
251 | - ); |
|
252 | - } |
|
253 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
254 | - $required_fields['country'] = array( |
|
255 | - 'error_id' => 'invalid_country', |
|
256 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
257 | - ); |
|
258 | - } |
|
229 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
230 | + $required_fields['first_name'] = array( |
|
231 | + 'error_id' => 'invalid_first_name', |
|
232 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
233 | + ); |
|
234 | + } |
|
235 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
236 | + $required_fields['address'] = array( |
|
237 | + 'error_id' => 'invalid_address', |
|
238 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
239 | + ); |
|
240 | + } |
|
241 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
242 | + $required_fields['city'] = array( |
|
243 | + 'error_id' => 'invalid_city', |
|
244 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
245 | + ); |
|
246 | + } |
|
247 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
248 | + $required_fields['state'] = array( |
|
249 | + 'error_id' => 'invalid_state', |
|
250 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
251 | + ); |
|
252 | + } |
|
253 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
254 | + $required_fields['country'] = array( |
|
255 | + 'error_id' => 'invalid_country', |
|
256 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
257 | + ); |
|
258 | + } |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -87,8 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if ( is_string( $args ) ) { |
|
91 | + $args = str_replace( '?', '', $args ); |
|
92 | + } |
|
92 | 93 | |
93 | 94 | $args = wp_parse_args( $args ); |
94 | 95 | |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | |
109 | 110 | if ( !empty( $args ) ) { |
110 | 111 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
112 | + if ( is_string( $args ) ) { |
|
113 | + $args = str_replace( '?', '', $args ); |
|
114 | + } |
|
113 | 115 | |
114 | 116 | $args = wp_parse_args( $args ); |
115 | 117 | |
@@ -131,8 +133,9 @@ discard block |
||
131 | 133 | $success_page = wpinv_get_option( 'success_page', 0 ); |
132 | 134 | $success_page = get_permalink( $success_page ); |
133 | 135 | |
134 | - if ( $query_string ) |
|
135 | - $success_page .= $query_string; |
|
136 | + if ( $query_string ) { |
|
137 | + $success_page .= $query_string; |
|
138 | + } |
|
136 | 139 | |
137 | 140 | return apply_filters( 'wpinv_success_page_url', $success_page ); |
138 | 141 | } |
@@ -141,8 +144,9 @@ discard block |
||
141 | 144 | $uri = wpinv_get_option( 'failure_page', '' ); |
142 | 145 | $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
143 | 146 | |
144 | - if ( $extras ) |
|
145 | - $uri .= $extras; |
|
147 | + if ( $extras ) { |
|
148 | + $uri .= $extras; |
|
149 | + } |
|
146 | 150 | |
147 | 151 | return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
148 | 152 | } |
@@ -7,172 +7,172 @@ 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 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
48 | + $page_id = absint($page_id); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option('success_page', false); |
|
55 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
62 | + $ret = $ret ? is_page($ret) : false; |
|
63 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Redirects a user the success page. |
74 | 74 | */ |
75 | -function wpinv_send_to_success_page( $args = array() ) { |
|
75 | +function wpinv_send_to_success_page($args = array()) { |
|
76 | 76 | $redirect = add_query_arg( |
77 | - wp_parse_args( $args ), |
|
77 | + wp_parse_args($args), |
|
78 | 78 | wpinv_get_success_page_uri() |
79 | 79 | ); |
80 | 80 | |
81 | - wp_redirect( $redirect ); |
|
81 | + wp_redirect($redirect); |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
85 | +function wpinv_send_to_failed_page($args = null) { |
|
86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
87 | 87 | |
88 | - if ( !empty( $args ) ) { |
|
88 | + if (!empty($args)) { |
|
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if (is_string($args)) |
|
91 | + $args = str_replace('?', '', $args); |
|
92 | 92 | |
93 | - $args = wp_parse_args( $args ); |
|
93 | + $args = wp_parse_args($args); |
|
94 | 94 | |
95 | - $redirect = add_query_arg( $args, $redirect ); |
|
95 | + $redirect = add_query_arg($args, $redirect); |
|
96 | 96 | } |
97 | 97 | |
98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
99 | 99 | |
100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
101 | - wp_redirect( $redirect ); |
|
100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
101 | + wp_redirect($redirect); |
|
102 | 102 | exit; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
105 | +function wpinv_get_checkout_uri($args = array()) { |
|
106 | + $uri = wpinv_get_option('checkout_page', false); |
|
107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
109 | + if (!empty($args)) { |
|
110 | 110 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
111 | + if (is_string($args)) |
|
112 | + $args = str_replace('?', '', $args); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args($args); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
116 | + $uri = add_query_arg($args, $uri); |
|
117 | 117 | } |
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
131 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | - $success_page = get_permalink( $success_page ); |
|
130 | +function wpinv_get_success_page_url($query_string = null) { |
|
131 | + $success_page = wpinv_get_option('success_page', 0); |
|
132 | + $success_page = get_permalink($success_page); |
|
133 | 133 | |
134 | - if ( $query_string ) |
|
134 | + if ($query_string) |
|
135 | 135 | $success_page .= $query_string; |
136 | 136 | |
137 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
137 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
141 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
140 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
141 | + $uri = wpinv_get_option('failure_page', ''); |
|
142 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
143 | 143 | |
144 | - if ( $extras ) |
|
144 | + if ($extras) |
|
145 | 145 | $uri .= $extras; |
146 | 146 | |
147 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
147 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function wpinv_is_failed_transaction_page() { |
151 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
151 | + $ret = wpinv_get_option('failure_page', false); |
|
152 | + $ret = isset($ret) ? is_page($ret) : false; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
154 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_transaction_query( $type = 'start' ) { |
|
157 | +function wpinv_transaction_query($type = 'start') { |
|
158 | 158 | global $wpdb; |
159 | 159 | |
160 | 160 | $wpdb->hide_errors(); |
161 | 161 | |
162 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
163 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
162 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
163 | + define('WPINV_USE_TRANSACTIONS', true); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
167 | - switch ( $type ) { |
|
166 | + if (WPINV_USE_TRANSACTIONS) { |
|
167 | + switch ($type) { |
|
168 | 168 | case 'commit' : |
169 | - $wpdb->query( 'COMMIT' ); |
|
169 | + $wpdb->query('COMMIT'); |
|
170 | 170 | break; |
171 | 171 | case 'rollback' : |
172 | - $wpdb->query( 'ROLLBACK' ); |
|
172 | + $wpdb->query('ROLLBACK'); |
|
173 | 173 | break; |
174 | 174 | default : |
175 | - $wpdb->query( 'START TRANSACTION' ); |
|
175 | + $wpdb->query('START TRANSACTION'); |
|
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
@@ -181,141 +181,141 @@ discard block |
||
181 | 181 | function wpinv_get_prefix() { |
182 | 182 | $invoice_prefix = 'INV-'; |
183 | 183 | |
184 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
184 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | function wpinv_get_business_logo() { |
188 | - $business_logo = wpinv_get_option( 'logo' ); |
|
189 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
188 | + $business_logo = wpinv_get_option('logo'); |
|
189 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | function wpinv_get_business_name() { |
193 | 193 | $business_name = wpinv_get_option('store_name'); |
194 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
194 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | function wpinv_get_blogname() { |
198 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
198 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | function wpinv_get_admin_email() { |
202 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
203 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
202 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
203 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | function wpinv_get_business_website() { |
207 | - $business_website = home_url( '/' ); |
|
208 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
207 | + $business_website = home_url('/'); |
|
208 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
209 | 209 | } |
210 | 210 | |
211 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
211 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
212 | 212 | $terms_text = ''; |
213 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
213 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | function wpinv_get_business_footer() { |
217 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
218 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
219 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
217 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
218 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
219 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | function wpinv_checkout_required_fields() { |
223 | 223 | $required_fields = array(); |
224 | 224 | |
225 | 225 | // Let payment gateways and other extensions determine if address fields should be required |
226 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
226 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
227 | 227 | |
228 | - if ( $require_billing_details ) { |
|
229 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
228 | + if ($require_billing_details) { |
|
229 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
230 | 230 | $required_fields['first_name'] = array( |
231 | 231 | 'error_id' => 'invalid_first_name', |
232 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
232 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
233 | 233 | ); |
234 | 234 | } |
235 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
235 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
236 | 236 | $required_fields['address'] = array( |
237 | 237 | 'error_id' => 'invalid_address', |
238 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
238 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
239 | 239 | ); |
240 | 240 | } |
241 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
241 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
242 | 242 | $required_fields['city'] = array( |
243 | 243 | 'error_id' => 'invalid_city', |
244 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
244 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
245 | 245 | ); |
246 | 246 | } |
247 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
247 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
248 | 248 | $required_fields['state'] = array( |
249 | 249 | 'error_id' => 'invalid_state', |
250 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
250 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
251 | 251 | ); |
252 | 252 | } |
253 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
253 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
254 | 254 | $required_fields['country'] = array( |
255 | 255 | 'error_id' => 'invalid_country', |
256 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
256 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
257 | 257 | ); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
261 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | function wpinv_is_ssl_enforced() { |
265 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
266 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
265 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
266 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | function wpinv_schedule_event_twicedaily() { |
270 | 270 | wpinv_email_payment_reminders(); |
271 | 271 | } |
272 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
272 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
273 | 273 | |
274 | 274 | function wpinv_require_login_to_checkout() { |
275 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
276 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
275 | + $return = wpinv_get_option('login_to_checkout', false); |
|
276 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
277 | 277 | } |
278 | 278 | |
279 | -function wpinv_sequential_number_active( $type = '' ) { |
|
280 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
281 | - if ( null !== $check ) { |
|
279 | +function wpinv_sequential_number_active($type = '') { |
|
280 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
281 | + if (null !== $check) { |
|
282 | 282 | return $check; |
283 | 283 | } |
284 | 284 | |
285 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
285 | + return wpinv_get_option('sequential_invoice_number'); |
|
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
288 | +function wpinv_switch_to_locale($locale = NULL) { |
|
289 | 289 | global $invoicing, $wpi_switch_locale; |
290 | 290 | |
291 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
292 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
291 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
292 | + $locale = empty($locale) ? get_locale() : $locale; |
|
293 | 293 | |
294 | - switch_to_locale( $locale ); |
|
294 | + switch_to_locale($locale); |
|
295 | 295 | |
296 | 296 | $wpi_switch_locale = $locale; |
297 | 297 | |
298 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
298 | + add_filter('plugin_locale', 'get_locale'); |
|
299 | 299 | |
300 | 300 | $invoicing->load_textdomain(); |
301 | 301 | |
302 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
302 | + do_action('wpinv_switch_to_locale', $locale); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | 306 | function wpinv_restore_locale() { |
307 | 307 | global $invoicing, $wpi_switch_locale; |
308 | 308 | |
309 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
309 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
310 | 310 | restore_previous_locale(); |
311 | 311 | |
312 | 312 | $wpi_switch_locale = NULL; |
313 | 313 | |
314 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
314 | + remove_filter('plugin_locale', 'get_locale'); |
|
315 | 315 | |
316 | 316 | $invoicing->load_textdomain(); |
317 | 317 | |
318 | - do_action( 'wpinv_restore_locale' ); |
|
318 | + do_action('wpinv_restore_locale'); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,22 +323,22 @@ discard block |
||
323 | 323 | * Returns the default form's id. |
324 | 324 | */ |
325 | 325 | function wpinv_get_default_payment_form() { |
326 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
326 | + $form = get_option('wpinv_default_payment_form'); |
|
327 | 327 | |
328 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
328 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
329 | 329 | $form = wp_insert_post( |
330 | 330 | array( |
331 | 331 | 'post_type' => 'wpi_payment_form', |
332 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
332 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
333 | 333 | 'post_status' => 'publish', |
334 | 334 | 'meta_input' => array( |
335 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
335 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
336 | 336 | 'wpinv_form_items' => array(), |
337 | 337 | ) |
338 | 338 | ) |
339 | 339 | ); |
340 | 340 | |
341 | - update_option( 'wpinv_default_payment_form', $form ); |
|
341 | + update_option('wpinv_default_payment_form', $form); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return $form; |
@@ -349,19 +349,19 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @param int $payment_form |
351 | 351 | */ |
352 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
352 | +function getpaid_get_payment_form_elements($payment_form) { |
|
353 | 353 | |
354 | - if ( empty( $payment_form ) ) { |
|
355 | - return wpinv_get_data( 'sample-payment-form' ); |
|
354 | + if (empty($payment_form)) { |
|
355 | + return wpinv_get_data('sample-payment-form'); |
|
356 | 356 | } |
357 | 357 | |
358 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
358 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
359 | 359 | |
360 | - if ( is_array( $form_elements ) ) { |
|
360 | + if (is_array($form_elements)) { |
|
361 | 361 | return $form_elements; |
362 | 362 | } |
363 | 363 | |
364 | - return wpinv_get_data( 'sample-payment-form' ); |
|
364 | + return wpinv_get_data('sample-payment-form'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param int $payment_form |
372 | 372 | */ |
373 | -function gepaid_get_form_items( $id ) { |
|
374 | - $form = new GetPaid_Payment_Form( $id ); |
|
373 | +function gepaid_get_form_items($id) { |
|
374 | + $form = new GetPaid_Payment_Form($id); |
|
375 | 375 | |
376 | 376 | // Is this a default form? |
377 | - if ( $form->is_default() ) { |
|
377 | + if ($form->is_default()) { |
|
378 | 378 | return array(); |
379 | 379 | } |
380 | 380 | |
381 | - return $form->get_items( 'view', 'arrays' ); |
|
381 | + return $form->get_items('view', 'arrays'); |
|
382 | 382 | } |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @return array |
78 | 78 | */ |
79 | 79 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
80 | - $invoice_statuses = array( |
|
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
80 | + $invoice_statuses = array( |
|
81 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | 82 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
83 | 83 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
84 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | 87 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
88 | 88 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
89 | 89 | ); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | function wpinv_status_nicename( $status ) { |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @return string |
209 | 209 | */ |
210 | 210 | function getpaid_get_price_format() { |
211 | - $currency_pos = wpinv_currency_position(); |
|
212 | - $format = '%1$s%2$s'; |
|
211 | + $currency_pos = wpinv_currency_position(); |
|
212 | + $format = '%1$s%2$s'; |
|
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
215 | - case 'left': |
|
216 | - $format = '%1$s%2$s'; |
|
217 | - break; |
|
218 | - case 'right': |
|
219 | - $format = '%2$s%1$s'; |
|
220 | - break; |
|
221 | - case 'left_space': |
|
222 | - $format = '%1$s %2$s'; |
|
223 | - break; |
|
224 | - case 'right_space': |
|
225 | - $format = '%2$s %1$s'; |
|
226 | - break; |
|
227 | - } |
|
214 | + switch ( $currency_pos ) { |
|
215 | + case 'left': |
|
216 | + $format = '%1$s%2$s'; |
|
217 | + break; |
|
218 | + case 'right': |
|
219 | + $format = '%2$s%1$s'; |
|
220 | + break; |
|
221 | + case 'left_space': |
|
222 | + $format = '%1$s %2$s'; |
|
223 | + break; |
|
224 | + case 'right_space': |
|
225 | + $format = '%2$s %1$s'; |
|
226 | + break; |
|
227 | + } |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | 331 | function getpaid_maybe_define_constant( $name, $value ) { |
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
334 | - } |
|
332 | + if ( ! defined( $name ) ) { |
|
333 | + define( $name, $value ); |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get( 'arg_separator.output' ); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | function wpinv_rgb_from_hex( $color ) { |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | - } |
|
687 | + if ( ! is_array( $list ) ) { |
|
688 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | + } |
|
690 | 690 | |
691 | - return $list; |
|
691 | + return $list; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | } |
709 | 709 | |
710 | 710 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
711 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
712 | 712 | |
713 | - return $data; |
|
713 | + return $data; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -739,17 +739,17 @@ discard block |
||
739 | 739 | */ |
740 | 740 | function wpinv_clean( $var ) { |
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if ( is_array( $var ) ) { |
|
743 | + return array_map( 'wpinv_clean', $var ); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | if ( is_object( $var ) ) { |
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
747 | + $object_vars = get_object_vars( $var ); |
|
748 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | + $var->$property_name = wpinv_clean( $property_value ); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | 754 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
755 | 755 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | */ |
763 | 763 | function getpaid_convert_price_string_to_options( $str ) { |
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
765 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | 766 | $options = array(); |
767 | 767 | |
768 | 768 | foreach ( $raw_options as $option ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -862,15 +862,15 @@ discard block |
||
862 | 862 | function getpaid_limit_length( $string, $limit ) { |
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | - } |
|
869 | - } else { |
|
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | - } |
|
873 | - } |
|
865 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | + if ( mb_strlen( $string ) > $limit ) { |
|
867 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | + } |
|
869 | + } else { |
|
870 | + if ( strlen( $string ) > $limit ) { |
|
871 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | + } |
|
873 | + } |
|
874 | 874 | return $string; |
875 | 875 | |
876 | 876 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | function wpinv_get_ip() { |
22 | 22 | $ip = $_SERVER['REMOTE_ADDR']; |
23 | 23 | |
24 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
25 | 25 | //Check ip from share internet. |
26 | 26 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
27 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | //Check ip is pass from proxy. |
29 | 29 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
30 | 30 | } |
31 | 31 | |
32 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
32 | + return apply_filters('wpinv_get_ip', $ip); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | function wpinv_get_user_agent() { |
36 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
37 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
36 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
37 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
38 | 38 | } else { |
39 | 39 | $user_agent = ''; |
40 | 40 | } |
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
42 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -47,27 +47,27 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $amount The amount to sanitize. |
49 | 49 | */ |
50 | -function wpinv_sanitize_amount( $amount ) { |
|
50 | +function wpinv_sanitize_amount($amount) { |
|
51 | 51 | |
52 | 52 | // Format decimals. |
53 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
53 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
54 | 54 | |
55 | 55 | // Remove thousands. |
56 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
56 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
57 | 57 | |
58 | 58 | // Cast the remaining to a float. |
59 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
59 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
64 | - if ( $decimals === NULL ) { |
|
63 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
64 | + if ($decimals === NULL) { |
|
65 | 65 | $decimals = wpinv_decimals(); |
66 | 66 | } |
67 | 67 | |
68 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
68 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
69 | 69 | |
70 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
70 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | * @since 1.0.19 |
77 | 77 | * @return array |
78 | 78 | */ |
79 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
79 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
80 | 80 | $invoice_statuses = array( |
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
83 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
88 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
81 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
82 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
83 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
84 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
85 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
86 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
87 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
88 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
89 | 89 | ); |
90 | 90 | |
91 | - if ( $draft ) { |
|
92 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
91 | + if ($draft) { |
|
92 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( $trashed ) { |
|
96 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
95 | + if ($trashed) { |
|
96 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
100 | 100 | } |
101 | 101 | |
102 | -function wpinv_status_nicename( $status ) { |
|
103 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
104 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
102 | +function wpinv_status_nicename($status) { |
|
103 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
104 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
105 | 105 | |
106 | 106 | return $status; |
107 | 107 | } |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param string $current |
113 | 113 | */ |
114 | -function wpinv_get_currency( $current = '' ) { |
|
114 | +function wpinv_get_currency($current = '') { |
|
115 | 115 | |
116 | - if ( empty( $current ) ) { |
|
117 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
116 | + if (empty($current)) { |
|
117 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
118 | 118 | } |
119 | 119 | |
120 | - return trim( strtoupper( $current ) ); |
|
120 | + return trim(strtoupper($current)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,25 +125,25 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param string|null $currency The currency code. Defaults to the default currency. |
127 | 127 | */ |
128 | -function wpinv_currency_symbol( $currency = null ) { |
|
128 | +function wpinv_currency_symbol($currency = null) { |
|
129 | 129 | |
130 | 130 | // Prepare the currency. |
131 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
131 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
132 | 132 | |
133 | 133 | // Fetch all symbols. |
134 | 134 | $symbols = wpinv_get_currency_symbols(); |
135 | 135 | |
136 | 136 | // Fetch this currencies symbol. |
137 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
137 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
138 | 138 | |
139 | 139 | // Filter the symbol. |
140 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
140 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | function wpinv_currency_position() { |
144 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
144 | + $position = wpinv_get_option('currency_position', 'left'); |
|
145 | 145 | |
146 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
146 | + return apply_filters('wpinv_currency_position', $position); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param $string|null $current |
153 | 153 | */ |
154 | -function wpinv_thousands_separator( $current = null ) { |
|
154 | +function wpinv_thousands_separator($current = null) { |
|
155 | 155 | |
156 | - if ( null == $current ) { |
|
157 | - $current = wpinv_get_option( 'thousands_separator', '.' ); |
|
156 | + if (null == $current) { |
|
157 | + $current = wpinv_get_option('thousands_separator', '.'); |
|
158 | 158 | } |
159 | 159 | |
160 | - return trim( $current ); |
|
160 | + return trim($current); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param $string|null $current |
167 | 167 | */ |
168 | -function wpinv_decimal_separator( $current = null ) { |
|
168 | +function wpinv_decimal_separator($current = null) { |
|
169 | 169 | |
170 | - if ( null == $current ) { |
|
171 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
170 | + if (null == $current) { |
|
171 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
172 | 172 | } |
173 | 173 | |
174 | - return trim( $current ); |
|
174 | + return trim($current); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,27 +179,27 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param $string|null $current |
181 | 181 | */ |
182 | -function wpinv_decimals( $current = null ) { |
|
182 | +function wpinv_decimals($current = null) { |
|
183 | 183 | |
184 | - if ( null == $current ) { |
|
185 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
184 | + if (null == $current) { |
|
185 | + $current = wpinv_get_option('decimals', 2); |
|
186 | 186 | } |
187 | 187 | |
188 | - return absint( $current ); |
|
188 | + return absint($current); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Retrieves a list of all supported currencies. |
193 | 193 | */ |
194 | 194 | function wpinv_get_currencies() { |
195 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
195 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Retrieves a list of all currency symbols. |
200 | 200 | */ |
201 | 201 | function wpinv_get_currency_symbols() { |
202 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
202 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $currency_pos = wpinv_currency_position(); |
212 | 212 | $format = '%1$s%2$s'; |
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
214 | + switch ($currency_pos) { |
|
215 | 215 | case 'left': |
216 | 216 | $format = '%1$s%2$s'; |
217 | 217 | break; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | break; |
227 | 227 | } |
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -236,25 +236,25 @@ discard block |
||
236 | 236 | * @param string $currency Currency. |
237 | 237 | * @return string |
238 | 238 | */ |
239 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
239 | +function wpinv_price($amount = 0, $currency = '') { |
|
240 | 240 | |
241 | 241 | // Backwards compatibility. |
242 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
242 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
243 | 243 | |
244 | 244 | // Prepare variables. |
245 | - $currency = wpinv_get_currency( $currency ); |
|
245 | + $currency = wpinv_get_currency($currency); |
|
246 | 246 | $amount = (float) $amount; |
247 | 247 | $unformatted_amount = $amount; |
248 | 248 | $negative = $amount < 0; |
249 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
250 | - $amount = wpinv_format_amount( $amount ); |
|
249 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
250 | + $amount = wpinv_format_amount($amount); |
|
251 | 251 | |
252 | 252 | // Format the amount. |
253 | 253 | $format = getpaid_get_price_format(); |
254 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
254 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
255 | 255 | |
256 | 256 | // Filter the formatting. |
257 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
257 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -265,33 +265,33 @@ discard block |
||
265 | 265 | * @param bool $calculate Whether or not to apply separators. |
266 | 266 | * @return string |
267 | 267 | */ |
268 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
268 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
269 | 269 | $thousands_sep = wpinv_thousands_separator(); |
270 | 270 | $decimal_sep = wpinv_decimal_separator(); |
271 | - $decimals = wpinv_decimals( $decimals ); |
|
271 | + $decimals = wpinv_decimals($decimals); |
|
272 | 272 | |
273 | 273 | // Format decimals. |
274 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
274 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
275 | 275 | |
276 | 276 | // Remove thousands. |
277 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
277 | + $amount = str_replace($thousands_sep, '', $amount); |
|
278 | 278 | |
279 | 279 | // Cast the remaining to a float. |
280 | - $amount = floatval( $amount ); |
|
280 | + $amount = floatval($amount); |
|
281 | 281 | |
282 | - if ( $calculate ) { |
|
282 | + if ($calculate) { |
|
283 | 283 | return $amount; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Fomart the amount. |
287 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
287 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
288 | 288 | } |
289 | 289 | |
290 | -function wpinv_sanitize_key( $key ) { |
|
290 | +function wpinv_sanitize_key($key) { |
|
291 | 291 | $raw_key = $key; |
292 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
292 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
293 | 293 | |
294 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
294 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param $str the file whose extension should be retrieved. |
301 | 301 | */ |
302 | -function wpinv_get_file_extension( $str ) { |
|
303 | - $filetype = wp_check_filetype( $str ); |
|
302 | +function wpinv_get_file_extension($str) { |
|
303 | + $filetype = wp_check_filetype($str); |
|
304 | 304 | return $filetype['ext']; |
305 | 305 | } |
306 | 306 | |
@@ -309,16 +309,16 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @param string $string |
311 | 311 | */ |
312 | -function wpinv_string_is_image_url( $string ) { |
|
313 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
314 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
312 | +function wpinv_string_is_image_url($string) { |
|
313 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
314 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | 318 | * Returns the current URL. |
319 | 319 | */ |
320 | 320 | function wpinv_get_current_page_url() { |
321 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
321 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -328,46 +328,46 @@ discard block |
||
328 | 328 | * @param string $name Constant name. |
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
331 | +function getpaid_maybe_define_constant($name, $value) { |
|
332 | + if (!defined($name)) { |
|
333 | + define($name, $value); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get('arg_separator.output'); |
|
339 | 339 | } |
340 | 340 | |
341 | -function wpinv_rgb_from_hex( $color ) { |
|
342 | - $color = str_replace( '#', '', $color ); |
|
341 | +function wpinv_rgb_from_hex($color) { |
|
342 | + $color = str_replace('#', '', $color); |
|
343 | 343 | |
344 | 344 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
345 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
346 | - if ( empty( $color ) ) { |
|
345 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
346 | + if (empty($color)) { |
|
347 | 347 | return NULL; |
348 | 348 | } |
349 | 349 | |
350 | - $color = str_split( $color ); |
|
350 | + $color = str_split($color); |
|
351 | 351 | |
352 | 352 | $rgb = array(); |
353 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
354 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
355 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
353 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
354 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
355 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
356 | 356 | |
357 | 357 | return $rgb; |
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
361 | - $base = wpinv_rgb_from_hex( $color ); |
|
360 | +function wpinv_hex_darker($color, $factor = 30) { |
|
361 | + $base = wpinv_rgb_from_hex($color); |
|
362 | 362 | $color = '#'; |
363 | 363 | |
364 | - foreach ( $base as $k => $v ) { |
|
364 | + foreach ($base as $k => $v) { |
|
365 | 365 | $amount = $v / 100; |
366 | - $amount = round( $amount * $factor ); |
|
366 | + $amount = round($amount * $factor); |
|
367 | 367 | $new_decimal = $v - $amount; |
368 | 368 | |
369 | - $new_hex_component = dechex( $new_decimal ); |
|
370 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
369 | + $new_hex_component = dechex($new_decimal); |
|
370 | + if (strlen($new_hex_component) < 2) { |
|
371 | 371 | $new_hex_component = "0" . $new_hex_component; |
372 | 372 | } |
373 | 373 | $color .= $new_hex_component; |
@@ -376,18 +376,18 @@ discard block |
||
376 | 376 | return $color; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
380 | - $base = wpinv_rgb_from_hex( $color ); |
|
379 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
380 | + $base = wpinv_rgb_from_hex($color); |
|
381 | 381 | $color = '#'; |
382 | 382 | |
383 | - foreach ( $base as $k => $v ) { |
|
383 | + foreach ($base as $k => $v) { |
|
384 | 384 | $amount = 255 - $v; |
385 | 385 | $amount = $amount / 100; |
386 | - $amount = round( $amount * $factor ); |
|
386 | + $amount = round($amount * $factor); |
|
387 | 387 | $new_decimal = $v + $amount; |
388 | 388 | |
389 | - $new_hex_component = dechex( $new_decimal ); |
|
390 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
389 | + $new_hex_component = dechex($new_decimal); |
|
390 | + if (strlen($new_hex_component) < 2) { |
|
391 | 391 | $new_hex_component = "0" . $new_hex_component; |
392 | 392 | } |
393 | 393 | $color .= $new_hex_component; |
@@ -396,22 +396,22 @@ discard block |
||
396 | 396 | return $color; |
397 | 397 | } |
398 | 398 | |
399 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
400 | - $hex = str_replace( '#', '', $color ); |
|
399 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
400 | + $hex = str_replace('#', '', $color); |
|
401 | 401 | |
402 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
403 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
404 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
402 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
403 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
404 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
405 | 405 | |
406 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
406 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
407 | 407 | |
408 | 408 | return $brightness > 155 ? $dark : $light; |
409 | 409 | } |
410 | 410 | |
411 | -function wpinv_format_hex( $hex ) { |
|
412 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
411 | +function wpinv_format_hex($hex) { |
|
412 | + $hex = trim(str_replace('#', '', $hex)); |
|
413 | 413 | |
414 | - if ( strlen( $hex ) == 3 ) { |
|
414 | + if (strlen($hex) == 3) { |
|
415 | 415 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
416 | 416 | } |
417 | 417 | |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
432 | 432 | * @return string |
433 | 433 | */ |
434 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
435 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
436 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
434 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
435 | + if (function_exists('mb_strimwidth')) { |
|
436 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
437 | 437 | } |
438 | 438 | |
439 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
439 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -448,28 +448,28 @@ discard block |
||
448 | 448 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
449 | 449 | * @return int Returns the number of characters in string. |
450 | 450 | */ |
451 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
452 | - if ( function_exists( 'mb_strlen' ) ) { |
|
453 | - return mb_strlen( $str, $encoding ); |
|
451 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
452 | + if (function_exists('mb_strlen')) { |
|
453 | + return mb_strlen($str, $encoding); |
|
454 | 454 | } |
455 | 455 | |
456 | - return strlen( $str ); |
|
456 | + return strlen($str); |
|
457 | 457 | } |
458 | 458 | |
459 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
460 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
461 | - return mb_strtolower( $str, $encoding ); |
|
459 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
460 | + if (function_exists('mb_strtolower')) { |
|
461 | + return mb_strtolower($str, $encoding); |
|
462 | 462 | } |
463 | 463 | |
464 | - return strtolower( $str ); |
|
464 | + return strtolower($str); |
|
465 | 465 | } |
466 | 466 | |
467 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
468 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
469 | - return mb_strtoupper( $str, $encoding ); |
|
467 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
468 | + if (function_exists('mb_strtoupper')) { |
|
469 | + return mb_strtoupper($str, $encoding); |
|
470 | 470 | } |
471 | 471 | |
472 | - return strtoupper( $str ); |
|
472 | + return strtoupper($str); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
484 | 484 | * @return int Returns the position of the first occurrence of search in the string. |
485 | 485 | */ |
486 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
487 | - if ( function_exists( 'mb_strpos' ) ) { |
|
488 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
486 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
487 | + if (function_exists('mb_strpos')) { |
|
488 | + return mb_strpos($str, $find, $offset, $encoding); |
|
489 | 489 | } |
490 | 490 | |
491 | - return strpos( $str, $find, $offset ); |
|
491 | + return strpos($str, $find, $offset); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
503 | 503 | * @return int Returns the position of the last occurrence of search. |
504 | 504 | */ |
505 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
506 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
507 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
505 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
506 | + if (function_exists('mb_strrpos')) { |
|
507 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
508 | 508 | } |
509 | 509 | |
510 | - return strrpos( $str, $find, $offset ); |
|
510 | + return strrpos($str, $find, $offset); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -522,16 +522,16 @@ discard block |
||
522 | 522 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
523 | 523 | * @return string |
524 | 524 | */ |
525 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
526 | - if ( function_exists( 'mb_substr' ) ) { |
|
527 | - if ( $length === null ) { |
|
528 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
525 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
526 | + if (function_exists('mb_substr')) { |
|
527 | + if ($length === null) { |
|
528 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
529 | 529 | } else { |
530 | - return mb_substr( $str, $start, $length, $encoding ); |
|
530 | + return mb_substr($str, $start, $length, $encoding); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - return substr( $str, $start, $length ); |
|
534 | + return substr($str, $start, $length); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -543,48 +543,48 @@ discard block |
||
543 | 543 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
544 | 544 | * @return string The width of string. |
545 | 545 | */ |
546 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
547 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
548 | - return mb_strwidth( $str, $encoding ); |
|
546 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
547 | + if (function_exists('mb_strwidth')) { |
|
548 | + return mb_strwidth($str, $encoding); |
|
549 | 549 | } |
550 | 550 | |
551 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
551 | + return wpinv_utf8_strlen($str, $encoding); |
|
552 | 552 | } |
553 | 553 | |
554 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
555 | - if ( function_exists( 'mb_strlen' ) ) { |
|
556 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
554 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
555 | + if (function_exists('mb_strlen')) { |
|
556 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
557 | 557 | $str_end = ""; |
558 | 558 | |
559 | - if ( $lower_str_end ) { |
|
560 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
559 | + if ($lower_str_end) { |
|
560 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
561 | 561 | } else { |
562 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
562 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | return $first_letter . $str_end; |
566 | 566 | } |
567 | 567 | |
568 | - return ucfirst( $str ); |
|
568 | + return ucfirst($str); |
|
569 | 569 | } |
570 | 570 | |
571 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
572 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
573 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
571 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
572 | + if (function_exists('mb_convert_case')) { |
|
573 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
574 | 574 | } |
575 | 575 | |
576 | - return ucwords( $str ); |
|
576 | + return ucwords($str); |
|
577 | 577 | } |
578 | 578 | |
579 | -function wpinv_period_in_days( $period, $unit ) { |
|
580 | - $period = absint( $period ); |
|
579 | +function wpinv_period_in_days($period, $unit) { |
|
580 | + $period = absint($period); |
|
581 | 581 | |
582 | - if ( $period > 0 ) { |
|
583 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
582 | + if ($period > 0) { |
|
583 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
584 | 584 | $period = $period * 7; |
585 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
585 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
586 | 586 | $period = $period * 30; |
587 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
587 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
588 | 588 | $period = $period * 365; |
589 | 589 | } |
590 | 590 | } |
@@ -592,14 +592,14 @@ discard block |
||
592 | 592 | return $period; |
593 | 593 | } |
594 | 594 | |
595 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
596 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
597 | - return cal_days_in_month( $calendar, $month, $year ); |
|
595 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
596 | + if (function_exists('cal_days_in_month')) { |
|
597 | + return cal_days_in_month($calendar, $month, $year); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | // Fallback in case the calendar extension is not loaded in PHP |
601 | 601 | // Only supports Gregorian calendar |
602 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
602 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return string |
612 | 612 | */ |
613 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
614 | - if ( $allow_html ) { |
|
615 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
613 | +function wpi_help_tip($tip, $allow_html = false) { |
|
614 | + if ($allow_html) { |
|
615 | + $tip = wpi_sanitize_tooltip($tip); |
|
616 | 616 | } else { |
617 | - $tip = esc_attr( $tip ); |
|
617 | + $tip = esc_attr($tip); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | * @param string $var |
629 | 629 | * @return string |
630 | 630 | */ |
631 | -function wpi_sanitize_tooltip( $var ) { |
|
632 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
631 | +function wpi_sanitize_tooltip($var) { |
|
632 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
633 | 633 | 'br' => array(), |
634 | 634 | 'em' => array(), |
635 | 635 | 'strong' => array(), |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | 'li' => array(), |
640 | 640 | 'ol' => array(), |
641 | 641 | 'p' => array(), |
642 | - ) ) ); |
|
642 | + ))); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function wpinv_get_screen_ids() { |
651 | 651 | |
652 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
652 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
653 | 653 | |
654 | 654 | $screen_ids = array( |
655 | 655 | 'toplevel_page_' . $screen_id, |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | 'invoicing_page_wpi-addons', |
668 | 668 | ); |
669 | 669 | |
670 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
670 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * @param array|string $list List of values. |
679 | 679 | * @return array Sanitized array of values. |
680 | 680 | */ |
681 | -function wpinv_parse_list( $list ) { |
|
681 | +function wpinv_parse_list($list) { |
|
682 | 682 | |
683 | - if ( empty( $list ) ) { |
|
683 | + if (empty($list)) { |
|
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
687 | + if (!is_array($list)) { |
|
688 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | return $list; |
@@ -699,16 +699,16 @@ discard block |
||
699 | 699 | * @param string $key Type of data to fetch. |
700 | 700 | * @return mixed Fetched data. |
701 | 701 | */ |
702 | -function wpinv_get_data( $key ) { |
|
702 | +function wpinv_get_data($key) { |
|
703 | 703 | |
704 | 704 | // Try fetching it from the cache. |
705 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
706 | - if( $data ) { |
|
705 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
706 | + if ($data) { |
|
707 | 707 | return $data; |
708 | 708 | } |
709 | 709 | |
710 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
710 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
711 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
712 | 712 | |
713 | 713 | return $data; |
714 | 714 | } |
@@ -722,10 +722,10 @@ discard block |
||
722 | 722 | * @param bool $first_empty Whether or not the first item in the list should be empty |
723 | 723 | * @return mixed Fetched data. |
724 | 724 | */ |
725 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
725 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
726 | 726 | |
727 | - if ( ! empty( $options ) && $first_empty ) { |
|
728 | - return array_merge( array( '' => '' ), $options ); |
|
727 | + if (!empty($options) && $first_empty) { |
|
728 | + return array_merge(array('' => ''), $options); |
|
729 | 729 | } |
730 | 730 | return $options; |
731 | 731 | |
@@ -737,21 +737,21 @@ discard block |
||
737 | 737 | * @param mixed $var Data to sanitize. |
738 | 738 | * @return string|array |
739 | 739 | */ |
740 | -function wpinv_clean( $var ) { |
|
740 | +function wpinv_clean($var) { |
|
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if (is_array($var)) { |
|
743 | + return array_map('wpinv_clean', $var); |
|
744 | 744 | } |
745 | 745 | |
746 | - if ( is_object( $var ) ) { |
|
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
746 | + if (is_object($var)) { |
|
747 | + $object_vars = get_object_vars($var); |
|
748 | + foreach ($object_vars as $property_name => $property_value) { |
|
749 | + $var->$property_name = wpinv_clean($property_value); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | 752 | } |
753 | 753 | |
754 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
754 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -760,43 +760,43 @@ discard block |
||
760 | 760 | * @param string $str Data to convert. |
761 | 761 | * @return string|array |
762 | 762 | */ |
763 | -function getpaid_convert_price_string_to_options( $str ) { |
|
763 | +function getpaid_convert_price_string_to_options($str) { |
|
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | - $options = array(); |
|
765 | + $raw_options = array_map('trim', explode(',', $str)); |
|
766 | + $options = array(); |
|
767 | 767 | |
768 | - foreach ( $raw_options as $option ) { |
|
768 | + foreach ($raw_options as $option) { |
|
769 | 769 | |
770 | - if ( '' == $option ) { |
|
770 | + if ('' == $option) { |
|
771 | 771 | continue; |
772 | 772 | } |
773 | 773 | |
774 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
774 | + $option = array_map('trim', explode('|', $option)); |
|
775 | 775 | |
776 | 776 | $price = null; |
777 | 777 | $label = null; |
778 | 778 | |
779 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
780 | - $label = $option[0]; |
|
779 | + if (isset($option[0]) && '' != $option[0]) { |
|
780 | + $label = $option[0]; |
|
781 | 781 | } |
782 | 782 | |
783 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
783 | + if (isset($option[1]) && '' != $option[1]) { |
|
784 | 784 | $price = $option[1]; |
785 | 785 | } |
786 | 786 | |
787 | - if ( ! isset( $price ) ) { |
|
787 | + if (!isset($price)) { |
|
788 | 788 | $price = $label; |
789 | 789 | } |
790 | 790 | |
791 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
791 | + if (!isset($price) || !is_numeric($price)) { |
|
792 | 792 | continue; |
793 | 793 | } |
794 | 794 | |
795 | - if ( ! isset( $label ) ) { |
|
795 | + if (!isset($label)) { |
|
796 | 796 | $label = $price; |
797 | 797 | } |
798 | 798 | |
799 | - $options[ $price ] = $label; |
|
799 | + $options[$price] = $label; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | return $options; |
@@ -805,22 +805,22 @@ discard block |
||
805 | 805 | /** |
806 | 806 | * Returns the help tip. |
807 | 807 | */ |
808 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
809 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
810 | - $tip = esc_attr__( $tip ); |
|
808 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
809 | + $additional_classes = sanitize_html_class($additional_classes); |
|
810 | + $tip = esc_attr__($tip); |
|
811 | 811 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
815 | 815 | * Formats a date |
816 | 816 | */ |
817 | -function getpaid_format_date( $date ) { |
|
817 | +function getpaid_format_date($date) { |
|
818 | 818 | |
819 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
819 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
820 | 820 | return ''; |
821 | 821 | } |
822 | 822 | |
823 | - return date_i18n( getpaid_date_format(), strtotime( $date ) ); |
|
823 | + return date_i18n(getpaid_date_format(), strtotime($date)); |
|
824 | 824 | |
825 | 825 | } |
826 | 826 | |
@@ -829,9 +829,9 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @return string |
831 | 831 | */ |
832 | -function getpaid_format_date_value( $date, $default = "—" ) { |
|
833 | - $date = getpaid_format_date( $date ); |
|
834 | - return empty( $date ) ? $default : $date; |
|
832 | +function getpaid_format_date_value($date, $default = "—") { |
|
833 | + $date = getpaid_format_date($date); |
|
834 | + return empty($date) ? $default : $date; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -859,16 +859,16 @@ discard block |
||
859 | 859 | * @param integer $limit Limit size in characters. |
860 | 860 | * @return string |
861 | 861 | */ |
862 | -function getpaid_limit_length( $string, $limit ) { |
|
862 | +function getpaid_limit_length($string, $limit) { |
|
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
865 | + if (function_exists('mb_strimwidth')) { |
|
866 | + if (mb_strlen($string) > $limit) { |
|
867 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
868 | 868 | } |
869 | 869 | } else { |
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
870 | + if (strlen($string) > $limit) { |
|
871 | + $string = substr($string, 0, $str_limit) . '...'; |
|
872 | 872 | } |
873 | 873 | } |
874 | 874 | return $string; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * @since 1.0.19 |
883 | 883 | */ |
884 | 884 | function getpaid_api() { |
885 | - return getpaid()->get( 'api' ); |
|
885 | + return getpaid()->get('api'); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @since 1.0.19 |
893 | 893 | */ |
894 | 894 | function getpaid_post_types() { |
895 | - return getpaid()->get( 'post_types' ); |
|
895 | + return getpaid()->get('post_types'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @since 1.0.19 |
903 | 903 | */ |
904 | 904 | function getpaid_session() { |
905 | - return getpaid()->get( 'session' ); |
|
905 | + return getpaid()->get('session'); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | * @since 1.0.19 |
913 | 913 | */ |
914 | 914 | function getpaid_notes() { |
915 | - return getpaid()->get( 'notes' ); |
|
915 | + return getpaid()->get('notes'); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * @return GetPaid_Admin |
922 | 922 | */ |
923 | 923 | function getpaid_admin() { |
924 | - return getpaid()->get( 'admin' ); |
|
924 | + return getpaid()->get('admin'); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -931,6 +931,6 @@ discard block |
||
931 | 931 | * @param string $base the base url |
932 | 932 | * @return string |
933 | 933 | */ |
934 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
935 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
934 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
935 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
936 | 936 | } |
@@ -117,14 +117,14 @@ |
||
117 | 117 | */ |
118 | 118 | function getpaid_doing_it_wrong( $function, $message, $version ) { |
119 | 119 | |
120 | - $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | - |
|
122 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | - } else { |
|
126 | - _doing_it_wrong( $function, $message, $version ); |
|
127 | - } |
|
120 | + $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | + |
|
122 | + if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | + do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | + error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | + } else { |
|
126 | + _doing_it_wrong( $function, $message, $version ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Returns the errors as html |
@@ -14,27 +14,27 @@ discard block |
||
14 | 14 | * @param clear whether or not to clear the errors. |
15 | 15 | * @since 1.0.19 |
16 | 16 | */ |
17 | -function getpaid_get_errors_html( $clear = true ) { |
|
17 | +function getpaid_get_errors_html($clear = true) { |
|
18 | 18 | |
19 | 19 | $errors = ''; |
20 | - foreach ( wpinv_get_errors() as $error ) { |
|
21 | - $type = 'error'; |
|
20 | + foreach (wpinv_get_errors() as $error) { |
|
21 | + $type = 'error'; |
|
22 | 22 | |
23 | - if ( is_array( $error ) ) { |
|
23 | + if (is_array($error)) { |
|
24 | 24 | $type = $error['type']; |
25 | 25 | $error = $error['text']; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $errors .= aui()->alert( |
29 | 29 | array( |
30 | - 'content' => wp_kses_post( $error ), |
|
30 | + 'content' => wp_kses_post($error), |
|
31 | 31 | 'type' => $type, |
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | - if ( $clear ){ |
|
37 | + if ($clear) { |
|
38 | 38 | wpinv_clear_errors(); |
39 | 39 | } |
40 | 40 | |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @return array |
56 | 56 | */ |
57 | 57 | function wpinv_get_errors() { |
58 | - $errors = getpaid_session()->get( 'wpinv_errors' ); |
|
59 | - return is_array( $errors ) ? $errors : array(); |
|
58 | + $errors = getpaid_session()->get('wpinv_errors'); |
|
59 | + return is_array($errors) ? $errors : array(); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | * @param string $error_message The error message. |
67 | 67 | * @param string $type Either error, info, warning, primary, dark, light or success. |
68 | 68 | */ |
69 | -function wpinv_set_error( $error_id, $error_message, $type = 'error' ) { |
|
69 | +function wpinv_set_error($error_id, $error_message, $type = 'error') { |
|
70 | 70 | |
71 | 71 | $errors = wpinv_get_errors(); |
72 | - $errors[ $error_id ] = array( |
|
72 | + $errors[$error_id] = array( |
|
73 | 73 | 'type' => $type, |
74 | 74 | 'text' => $error_message, |
75 | 75 | ); |
76 | 76 | |
77 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
77 | + getpaid_session()->set('wpinv_errors', $errors); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | */ |
84 | 84 | function wpinv_has_errors() { |
85 | - return count( wpinv_get_errors() ) > 0; |
|
85 | + return count(wpinv_get_errors()) > 0; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,21 +90,21 @@ discard block |
||
90 | 90 | * |
91 | 91 | */ |
92 | 92 | function wpinv_clear_errors() { |
93 | - getpaid_session()->set( 'wpinv_errors', null ); |
|
93 | + getpaid_session()->set('wpinv_errors', null); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Clears a single error. |
98 | 98 | * |
99 | 99 | */ |
100 | -function wpinv_unset_error( $error_id ) { |
|
100 | +function wpinv_unset_error($error_id) { |
|
101 | 101 | $errors = wpinv_get_errors(); |
102 | 102 | |
103 | - if ( isset( $errors[ $error_id ] ) ) { |
|
104 | - unset( $errors[ $error_id ] ); |
|
103 | + if (isset($errors[$error_id])) { |
|
104 | + unset($errors[$error_id]); |
|
105 | 105 | } |
106 | 106 | |
107 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
107 | + getpaid_session()->set('wpinv_errors', $errors); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | * @param string $message Message to log. |
116 | 116 | * @param string $version Version the message was added in. |
117 | 117 | */ |
118 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
118 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
119 | 119 | |
120 | 120 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
121 | 121 | |
122 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
122 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
123 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
124 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
125 | 125 | } else { |
126 | - _doing_it_wrong( $function, $message, $version ); |
|
126 | + _doing_it_wrong($function, $message, $version); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | } |
@@ -137,38 +137,38 @@ discard block |
||
137 | 137 | * @param string $line The line that contains the error. |
138 | 138 | * @param bool $exit Whether or not to exit function execution. |
139 | 139 | */ |
140 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
140 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
141 | 141 | |
142 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
142 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
143 | 143 | |
144 | 144 | // Ensure the log is a scalar. |
145 | - if ( ! is_scalar( $log ) ) { |
|
146 | - $log = print_r( $log, true ); |
|
145 | + if (!is_scalar($log)) { |
|
146 | + $log = print_r($log, true); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Add title. |
150 | - if ( ! empty( $title ) ) { |
|
151 | - $log = $title . ' ' . trim( $log ); |
|
150 | + if (!empty($title)) { |
|
151 | + $log = $title . ' ' . trim($log); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Add the file to the label. |
155 | - if ( ! empty( $file ) ) { |
|
155 | + if (!empty($file)) { |
|
156 | 156 | $log .= ' in ' . $file; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Add the line number to the label. |
160 | - if ( ! empty( $line ) ) { |
|
160 | + if (!empty($line)) { |
|
161 | 161 | $log .= ' on line ' . $line; |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Log the message. |
165 | - error_log( trim ( $log ) ); |
|
165 | + error_log(trim($log)); |
|
166 | 166 | |
167 | 167 | // ... and a backtrace. |
168 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
168 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
169 | 169 | |
170 | 170 | // Maybe exit. |
171 | - if ( $exit ) { |
|
171 | + if ($exit) { |
|
172 | 172 | exit; |
173 | 173 | } |
174 | 174 |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false |
39 | - ), |
|
39 | + ), |
|
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | - 'type' => 'text', |
|
45 | - 'desc_tip' => true, |
|
46 | - 'default' => '', |
|
47 | - 'placeholder' => __('1','invoicing'), |
|
48 | - 'advanced' => false |
|
49 | - ), |
|
50 | - |
|
51 | - 'item' => array( |
|
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | - 'type' => 'text', |
|
55 | - 'desc_tip' => true, |
|
56 | - 'default' => '', |
|
57 | - 'placeholder' => __('1','invoicing'), |
|
58 | - 'advanced' => false |
|
59 | - ), |
|
42 | + 'title' => __( 'Form', 'invoicing' ), |
|
43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | + 'type' => 'text', |
|
45 | + 'desc_tip' => true, |
|
46 | + 'default' => '', |
|
47 | + 'placeholder' => __('1','invoicing'), |
|
48 | + 'advanced' => false |
|
49 | + ), |
|
50 | + |
|
51 | + 'item' => array( |
|
52 | + 'title' => __( 'Items', 'invoicing' ), |
|
53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | + 'type' => 'text', |
|
55 | + 'desc_tip' => true, |
|
56 | + 'default' => '', |
|
57 | + 'placeholder' => __('1','invoicing'), |
|
58 | + 'advanced' => false |
|
59 | + ), |
|
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | - 'type' => 'text', |
|
65 | - 'desc_tip' => true, |
|
66 | - 'default' => '', |
|
67 | - 'advanced' => false |
|
68 | - ) |
|
62 | + 'title' => __( 'Button', 'invoicing' ), |
|
63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | + 'type' => 'text', |
|
65 | + 'desc_tip' => true, |
|
66 | + 'default' => '', |
|
67 | + 'advanced' => false |
|
68 | + ) |
|
69 | 69 | |
70 | 70 | ) |
71 | 71 | |
@@ -75,95 +75,95 @@ discard block |
||
75 | 75 | parent::__construct( $options ); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * The Super block output function. |
|
80 | - * |
|
81 | - * @param array $args |
|
82 | - * @param array $widget_args |
|
83 | - * @param string $content |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
78 | + /** |
|
79 | + * The Super block output function. |
|
80 | + * |
|
81 | + * @param array $args |
|
82 | + * @param array $widget_args |
|
83 | + * @param string $content |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
88 | 88 | |
89 | - // Is the shortcode set up correctly? |
|
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | - return aui()->alert( |
|
92 | - array( |
|
93 | - 'type' => 'warning', |
|
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - // Payment form or button? |
|
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
102 | - } else { |
|
103 | - return $this->handle_buy_item( $args ); |
|
104 | - } |
|
105 | - |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Displaying a payment form |
|
110 | - * |
|
111 | - * @return string |
|
112 | - */ |
|
89 | + // Is the shortcode set up correctly? |
|
90 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | + return aui()->alert( |
|
92 | + array( |
|
93 | + 'type' => 'warning', |
|
94 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + // Payment form or button? |
|
100 | + if ( ! empty( $args['form'] ) ) { |
|
101 | + return $this->handle_payment_form( $args ); |
|
102 | + } else { |
|
103 | + return $this->handle_buy_item( $args ); |
|
104 | + } |
|
105 | + |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Displaying a payment form |
|
110 | + * |
|
111 | + * @return string |
|
112 | + */ |
|
113 | 113 | protected function handle_payment_form( $args = array() ) { |
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
116 | - ob_start(); |
|
117 | - getpaid_display_payment_form( $args['form'] ); |
|
118 | - return ob_get_clean(); |
|
119 | - } |
|
115 | + if ( empty( $args['button'] ) ) { |
|
116 | + ob_start(); |
|
117 | + getpaid_display_payment_form( $args['form'] ); |
|
118 | + return ob_get_clean(); |
|
119 | + } |
|
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | - } |
|
121 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Displays a payment form button. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Displays a payment form button. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | protected function payment_form_button( $form, $button ) { |
130 | - return getpaid_get_payment_button( $button, $form ); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Selling an item |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
130 | + return getpaid_get_payment_button( $button, $form ); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Selling an item |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | 138 | protected function handle_buy_item( $args = array() ) { |
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
142 | - } |
|
140 | + if ( empty( $args['button'] ) ) { |
|
141 | + return $this->buy_item_form( $args['item'] ); |
|
142 | + } |
|
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Displays a buy item form. |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Displays a buy item form. |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | 153 | protected function buy_item_form( $item ) { |
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
155 | - ob_start(); |
|
156 | - getpaid_display_item_payment_form( $items ); |
|
157 | - return ob_get_clean(); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Displays a buy item button. |
|
162 | - * |
|
163 | - * @return string |
|
164 | - */ |
|
154 | + $items = getpaid_convert_items_to_array( $item ); |
|
155 | + ob_start(); |
|
156 | + getpaid_display_item_payment_form( $items ); |
|
157 | + return ob_get_clean(); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Displays a buy item button. |
|
162 | + * |
|
163 | + * @return string |
|
164 | + */ |
|
165 | 165 | protected function buy_item_button( $item, $button ) { |
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
166 | + return getpaid_get_payment_button( $button, null, $item ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'form']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'getpaid', |
25 | - 'name' => __('GetPaid','invoicing'), |
|
25 | + 'name' => __('GetPaid', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'getpaid bsui', |
28 | - 'description' => esc_html__('Show payment forms or buttons.','invoicing'), |
|
28 | + 'description' => esc_html__('Show payment forms or buttons.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | |
32 | 32 | 'title' => array( |
33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
33 | + 'title' => __('Widget title', 'invoicing'), |
|
34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
35 | 35 | 'type' => 'text', |
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | ), |
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
42 | + 'title' => __('Form', 'invoicing'), |
|
43 | + 'desc' => __('Enter a form id in case you want to display a specific payment form', 'invoicing'), |
|
44 | 44 | 'type' => 'text', |
45 | 45 | 'desc_tip' => true, |
46 | 46 | 'default' => '', |
47 | - 'placeholder' => __('1','invoicing'), |
|
47 | + 'placeholder' => __('1', 'invoicing'), |
|
48 | 48 | 'advanced' => false |
49 | 49 | ), |
50 | 50 | |
51 | 51 | 'item' => array( |
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
52 | + 'title' => __('Items', 'invoicing'), |
|
53 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing'), |
|
54 | 54 | 'type' => 'text', |
55 | 55 | 'desc_tip' => true, |
56 | 56 | 'default' => '', |
57 | - 'placeholder' => __('1','invoicing'), |
|
57 | + 'placeholder' => __('1', 'invoicing'), |
|
58 | 58 | 'advanced' => false |
59 | 59 | ), |
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
62 | + 'title' => __('Button', 'invoicing'), |
|
63 | + 'desc' => __('Enter button label in case you would like to display the forms in a popup.', 'invoicing'), |
|
64 | 64 | 'type' => 'text', |
65 | 65 | 'desc_tip' => true, |
66 | 66 | 'default' => '', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ); |
73 | 73 | |
74 | 74 | |
75 | - parent::__construct( $options ); |
|
75 | + parent::__construct($options); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
87 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
88 | 88 | |
89 | 89 | // Is the shortcode set up correctly? |
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
90 | + if (empty($args['form']) && empty($args['item'])) { |
|
91 | 91 | return aui()->alert( |
92 | 92 | array( |
93 | 93 | 'type' => 'warning', |
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
94 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
95 | 95 | ) |
96 | 96 | ); |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Payment form or button? |
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
100 | + if (!empty($args['form'])) { |
|
101 | + return $this->handle_payment_form($args); |
|
102 | 102 | } else { |
103 | - return $this->handle_buy_item( $args ); |
|
103 | + return $this->handle_buy_item($args); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - protected function handle_payment_form( $args = array() ) { |
|
113 | + protected function handle_payment_form($args = array()) { |
|
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
115 | + if (empty($args['button'])) { |
|
116 | 116 | ob_start(); |
117 | - getpaid_display_payment_form( $args['form'] ); |
|
117 | + getpaid_display_payment_form($args['form']); |
|
118 | 118 | return ob_get_clean(); |
119 | 119 | } |
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
121 | + return $this->payment_form_button($args['form'], $args['button']); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected function payment_form_button( $form, $button ) { |
|
130 | - return getpaid_get_payment_button( $button, $form ); |
|
129 | + protected function payment_form_button($form, $button) { |
|
130 | + return getpaid_get_payment_button($button, $form); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - protected function handle_buy_item( $args = array() ) { |
|
138 | + protected function handle_buy_item($args = array()) { |
|
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
140 | + if (empty($args['button'])) { |
|
141 | + return $this->buy_item_form($args['item']); |
|
142 | 142 | } |
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button($args['item'], $args['button']); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - protected function buy_item_form( $item ) { |
|
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
153 | + protected function buy_item_form($item) { |
|
154 | + $items = getpaid_convert_items_to_array($item); |
|
155 | 155 | ob_start(); |
156 | - getpaid_display_item_payment_form( $items ); |
|
156 | + getpaid_display_item_payment_form($items); |
|
157 | 157 | return ob_get_clean(); |
158 | 158 | } |
159 | 159 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - protected function buy_item_button( $item, $button ) { |
|
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
165 | + protected function buy_item_button($item, $button) { |
|
166 | + return getpaid_get_payment_button($button, null, $item); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -7,52 +7,52 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <small class='form-text text-muted mb-2'> |
15 | - <?php esc_html_e( 'This amount will be added to the total amount for this form', 'invoicing' ); ?> |
|
15 | + <?php esc_html_e('This amount will be added to the total amount for this form', 'invoicing'); ?> |
|
16 | 16 | </small> |
17 | 17 | |
18 | 18 | <div class='form-group'> |
19 | 19 | <label class="d-block"> |
20 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
20 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
21 | 21 | <input v-model='active_form_element.label' class='form-control' /> |
22 | 22 | </label> |
23 | 23 | </div> |
24 | 24 | |
25 | 25 | <div class='form-group' v-if="active_form_element.select_type=='select'"> |
26 | 26 | <label class="d-block"> |
27 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
27 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
28 | 28 | <input v-model='active_form_element.placeholder' class='form-control' /> |
29 | 29 | </label> |
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <div class='form-group'> |
33 | 33 | <label class="d-block"> |
34 | - <span><?php esc_html_e( 'Select Type', 'invoicing' ); ?></span> |
|
34 | + <span><?php esc_html_e('Select Type', 'invoicing'); ?></span> |
|
35 | 35 | <select class='form-control custom-select' v-model='active_form_element.select_type'> |
36 | - <option value='select'><?php esc_html_e( 'Dropdown', 'invoicing' ) ?></option> |
|
37 | - <option value='checkboxes'><?php esc_html_e( 'Checkboxes', 'invoicing' ) ?></option> |
|
38 | - <option value='radios'><?php esc_html_e( 'Radio Buttons', 'invoicing' ) ?></option> |
|
39 | - <option value='buttons'><?php esc_html_e( 'Buttons', 'invoicing' ) ?></option> |
|
40 | - <option value='circles'><?php esc_html_e( 'Circles', 'invoicing' ) ?></option> |
|
36 | + <option value='select'><?php esc_html_e('Dropdown', 'invoicing') ?></option> |
|
37 | + <option value='checkboxes'><?php esc_html_e('Checkboxes', 'invoicing') ?></option> |
|
38 | + <option value='radios'><?php esc_html_e('Radio Buttons', 'invoicing') ?></option> |
|
39 | + <option value='buttons'><?php esc_html_e('Buttons', 'invoicing') ?></option> |
|
40 | + <option value='circles'><?php esc_html_e('Circles', 'invoicing') ?></option> |
|
41 | 41 | </select> |
42 | 42 | </label> |
43 | 43 | </div> |
44 | 44 | |
45 | 45 | <div class='form-group'> |
46 | 46 | <label class="d-block"> |
47 | - <span><?php esc_html_e( 'Options', 'invoicing' ); ?></span> |
|
47 | + <span><?php esc_html_e('Options', 'invoicing'); ?></span> |
|
48 | 48 | <textarea placeholder='Basic|10,Pro|99,Business|199' v-model='active_form_element.options' class='form-control' rows='3'></textarea> |
49 | - <small class='form-text text-muted mb-2'><?php esc_html_e( 'Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing' ); ?></small> |
|
49 | + <small class='form-text text-muted mb-2'><?php esc_html_e('Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing'); ?></small> |
|
50 | 50 | </label> |
51 | 51 | </div> |
52 | 52 | |
53 | 53 | <div class='form-group'> |
54 | 54 | <label class="d-block"> |
55 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
56 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
55 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
56 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
57 | 57 | </label> |
58 | 58 | </div> |