@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | 'id' => 'wpinv_key', |
48 | 48 | 'name' => 'wpinv_key', |
49 | 49 | 'label' => sprintf( |
50 | - __( '%s Key:', 'invoicing' ), |
|
51 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
50 | + __('%s Key:', 'invoicing'), |
|
51 | + ucfirst($invoice->get_invoice_quote_type()) |
|
52 | 52 | ), |
53 | 53 | 'label_type' => 'vertical', |
54 | 54 | 'class' => 'form-control-sm', |
55 | - 'value' => $invoice->get_key( 'edit' ), |
|
55 | + 'value' => $invoice->get_key('edit'), |
|
56 | 56 | 'extra_attributes' => array( |
57 | 57 | 'onclick' => 'this.select();', |
58 | 58 | 'readonly' => 'true', |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | 'id' => 'wpinv_view_url', |
68 | 68 | 'name' => 'wpinv_view_url', |
69 | 69 | 'label' => sprintf( |
70 | - __( '%s URL:', 'invoicing' ), |
|
71 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
72 | - ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
70 | + __('%s URL:', 'invoicing'), |
|
71 | + ucfirst($invoice->get_invoice_quote_type()) |
|
72 | + ) . ' <a href="' . esc_url_raw($invoice->get_view_url()) . '" title="' . __('View invoice', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
73 | 73 | 'label_type' => 'vertical', |
74 | 74 | 'class' => 'form-control-sm', |
75 | 75 | 'value' => $invoice->get_view_url(), |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | // If the invoice is paid... |
84 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
84 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
85 | 85 | |
86 | 86 | // Gateway. |
87 | 87 | echo aui()->input( |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | 'type' => 'text', |
90 | 90 | 'id' => 'wpinv_gateway', |
91 | 91 | 'name' => '', |
92 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
92 | + 'label' => __('Gateway:', 'invoicing'), |
|
93 | 93 | 'label_type' => 'vertical', |
94 | 94 | 'class' => 'form-control-sm', |
95 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
95 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
96 | 96 | 'extra_attributes' => array( |
97 | 97 | 'onclick' => 'this.select();', |
98 | 98 | 'readonly' => 'true', |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | 'type' => 'text', |
107 | 107 | 'id' => 'wpinv_transaction_id', |
108 | 108 | 'name' => 'wpinv_transaction_id', |
109 | - 'label' => __( 'Transaction ID:', 'invoicing' ), |
|
109 | + 'label' => __('Transaction ID:', 'invoicing'), |
|
110 | 110 | 'label_type' => 'vertical', |
111 | 111 | 'class' => 'form-control-sm', |
112 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
113 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
112 | + 'value' => $invoice->get_transaction_id('edit'), |
|
113 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
114 | 114 | 'extra_attributes' => array( |
115 | 115 | 'onclick' => 'this.select();', |
116 | 116 | 'readonly' => 'true', |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | 'type' => 'text', |
125 | 125 | 'id' => 'wpinv_currency', |
126 | 126 | 'name' => 'wpinv_currency', |
127 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
127 | + 'label' => __('Currency:', 'invoicing'), |
|
128 | 128 | 'label_type' => 'vertical', |
129 | 129 | 'class' => 'form-control-sm', |
130 | - 'value' => $invoice->get_currency( 'edit' ), |
|
130 | + 'value' => $invoice->get_currency('edit'), |
|
131 | 131 | 'extra_attributes' => array( |
132 | 132 | 'onclick' => 'this.select();', |
133 | 133 | 'readonly' => 'true', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | } else { |
139 | 139 | |
140 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
140 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
141 | 141 | |
142 | 142 | // Payment URL. |
143 | 143 | echo aui()->input( |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'type' => 'text', |
146 | 146 | 'id' => 'wpinv_payment_url', |
147 | 147 | 'name' => 'wpinv_payment_url', |
148 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
148 | + 'label' => __('Payment URL:', 'invoicing'), |
|
149 | 149 | 'label_type' => 'vertical', |
150 | 150 | 'class' => 'form-control-sm', |
151 | 151 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | array( |
162 | 162 | 'id' => 'wpinv_gateway', |
163 | 163 | 'name' => 'wpinv_gateway', |
164 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
164 | + 'label' => __('Gateway:', 'invoicing'), |
|
165 | 165 | 'label_type' => 'vertical', |
166 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
167 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
166 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
167 | + 'value' => $invoice->get_gateway('edit'), |
|
168 | 168 | 'select2' => true, |
169 | 169 | 'data-allow-clear' => 'false', |
170 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
170 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
171 | 171 | ) |
172 | 172 | ); |
173 | 173 |
@@ -7,44 +7,44 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Make sure that the form is active. |
13 | -if ( ! $form->is_active() ) { |
|
13 | +if (!$form->is_active()) { |
|
14 | 14 | echo aui()->alert( |
15 | 15 | array( |
16 | 16 | 'type' => 'warning', |
17 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
17 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
18 | 18 | ) |
19 | 19 | ); |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | 23 | // Fires before displaying a payment form. |
24 | -do_action( 'getpaid_before_payment_form', $form ); |
|
24 | +do_action('getpaid_before_payment_form', $form); |
|
25 | 25 | ?> |
26 | 26 | |
27 | -<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>' data-currency='<?php echo esc_attr( empty( $form->invoice ) ? wpinv_get_currency() : $form->invoice->get_currency() ); ?>'> |
|
27 | +<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>' data-currency='<?php echo esc_attr(empty($form->invoice) ? wpinv_get_currency() : $form->invoice->get_currency()); ?>'> |
|
28 | 28 | |
29 | 29 | |
30 | 30 | <?php |
31 | 31 | |
32 | 32 | // Fires when printing the top of a payment form. |
33 | - do_action( 'getpaid_payment_form_top', $form ); |
|
33 | + do_action('getpaid_payment_form_top', $form); |
|
34 | 34 | |
35 | 35 | // And the optional invoice id. |
36 | - if ( ! empty( $form->invoice ) ) { |
|
37 | - echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
36 | + if (!empty($form->invoice)) { |
|
37 | + echo getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // We also want to include the form id. |
41 | - echo getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
41 | + echo getpaid_hidden_field('form_id', $form->get_id()); |
|
42 | 42 | |
43 | 43 | // And an indication that this is a payment form submission. |
44 | - echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
44 | + echo getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
45 | 45 | |
46 | 46 | // Fires before displaying payment form elements. |
47 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
47 | + do_action('getpaid_payment_form_before_elements', $form); |
|
48 | 48 | |
49 | 49 | // Display the elements. |
50 | 50 | ?> |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | <div class="row"> |
53 | 53 | <?php |
54 | 54 | |
55 | - foreach ( $form->get_elements() as $element ) { |
|
55 | + foreach ($form->get_elements() as $element) { |
|
56 | 56 | |
57 | - if ( isset( $element['type'] ) ) { |
|
58 | - $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) ); |
|
57 | + if (isset($element['type'])) { |
|
58 | + $grid_class = esc_attr(getpaid_get_form_element_grid_class($element)); |
|
59 | 59 | echo "<div class='$grid_class'>"; |
60 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
61 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
60 | + do_action('getpaid_payment_form_element', $element, $form); |
|
61 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
62 | 62 | echo "</div>"; |
63 | 63 | } |
64 | 64 | |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | // Fires after displaying payment form elements. |
73 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
73 | + do_action('getpaid_payment_form_after_elements', $form); |
|
74 | 74 | |
75 | 75 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
76 | 76 | |
77 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
77 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
78 | 78 | |
79 | 79 | edit_post_link( |
80 | - __( 'Edit this form.', 'invoicing' ), |
|
80 | + __('Edit this form.', 'invoicing'), |
|
81 | 81 | '<small class="form-text text-muted">', |
82 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
82 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
83 | 83 | $form->get_id(), |
84 | 84 | 'text-danger' |
85 | 85 | ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;"> |
93 | 93 | <div class="spinner-border mx-auto align-self-center text-white" role="status"> |
94 | - <span class="sr-only"><?php _e( 'Loading...', 'invoicing' );?></span> |
|
94 | + <span class="sr-only"><?php _e('Loading...', 'invoicing'); ?></span> |
|
95 | 95 | </div> |
96 | 96 | </div> |
97 | 97 | |
@@ -100,4 +100,4 @@ discard block |
||
100 | 100 | <?php |
101 | 101 | |
102 | 102 | // Fires after displaying a payment form. |
103 | -do_action( 'getpaid_after_payment_form', $form ); |
|
103 | +do_action('getpaid_after_payment_form', $form); |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -139,49 +139,49 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Invoice addons. |
152 | - if ( $this->supports( 'addons' ) ) { |
|
153 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
152 | + if ($this->supports('addons')) { |
|
153 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // Gateway settings. |
157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
157 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
158 | 158 | |
159 | 159 | |
160 | 160 | // Gateway checkout fiellds. |
161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
161 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
162 | 162 | |
163 | 163 | // Process payment. |
164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
164 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
165 | 165 | |
166 | 166 | // Change the checkout button text. |
167 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
168 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
167 | + if (!empty($this->checkout_button_text)) { |
|
168 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Check if a gateway is valid for a given currency. |
172 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
172 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
173 | 173 | |
174 | 174 | // Generate the transaction url. |
175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
175 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
176 | 176 | |
177 | 177 | // Generate the subscription url. |
178 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
178 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
179 | 179 | |
180 | 180 | // Confirm payments. |
181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
181 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
182 | 182 | |
183 | 183 | // Verify IPNs. |
184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
184 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @since 1.0.19 |
192 | 192 | * @return bool |
193 | 193 | */ |
194 | - public function is( $gateway ) { |
|
194 | + public function is($gateway) { |
|
195 | 195 | return $gateway == $this->id; |
196 | 196 | } |
197 | 197 | |
@@ -201,24 +201,24 @@ discard block |
||
201 | 201 | * @since 1.0.19 |
202 | 202 | * @return array |
203 | 203 | */ |
204 | - public function get_tokens( $sandbox = null ) { |
|
204 | + public function get_tokens($sandbox = null) { |
|
205 | 205 | |
206 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
207 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
206 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
207 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
208 | 208 | |
209 | - if ( is_array( $tokens ) ) { |
|
209 | + if (is_array($tokens)) { |
|
210 | 210 | $this->tokens = $tokens; |
211 | 211 | } |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Filter tokens. |
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
220 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
221 | + return wp_list_filter($this->tokens, $args); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0.19 |
229 | 229 | */ |
230 | - public function save_token( $token ) { |
|
230 | + public function save_token($token) { |
|
231 | 231 | |
232 | 232 | $tokens = $this->get_tokens(); |
233 | 233 | $tokens[] = $token; |
234 | 234 | |
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
235 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
236 | 236 | |
237 | 237 | $this->tokens = $tokens; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | */ |
246 | 246 | public function get_method_title() { |
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
247 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return string |
254 | 254 | */ |
255 | 255 | public function get_method_description() { |
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
256 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Invoice $invoice Invoice object. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_return_url( $invoice ) { |
|
265 | + public function get_return_url($invoice) { |
|
266 | 266 | |
267 | 267 | // Payment success url |
268 | 268 | $return_url = add_query_arg( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | wpinv_get_success_page_uri() |
275 | 275 | ); |
276 | 276 | |
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
277 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | * @param string $content Success page content. |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function confirm_payment( $content ) { |
|
286 | + public function confirm_payment($content) { |
|
287 | 287 | |
288 | 288 | // Retrieve the invoice. |
289 | 289 | $invoice_id = getpaid_get_current_invoice_id(); |
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
291 | 291 | |
292 | 292 | // Ensure that it exists and that it is pending payment. |
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
293 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
294 | 294 | return $content; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Can the user view this invoice?? |
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
298 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
299 | 299 | return $content; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Show payment processing indicator. |
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
303 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param GetPaid_Form_Item[] $items |
318 | 318 | * @return WPInv_Invoice |
319 | 319 | */ |
320 | - public function process_addons( $invoice, $items ) { |
|
320 | + public function process_addons($invoice, $items) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param WPInv_Invoice $invoice Invoice object. |
329 | 329 | * @return string transaction URL, or empty string. |
330 | 330 | */ |
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
331 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
332 | 332 | |
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | 334 | |
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
335 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
336 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
337 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $transaction_url; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param WPInv_Subscription $subscription Subscription objectt. |
349 | 349 | * @return string subscription URL, or empty string. |
350 | 350 | */ |
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
351 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
352 | 352 | |
353 | - $profile_id = $subscription->get_profile_id(); |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | 354 | |
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
355 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
356 | 356 | |
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
357 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
358 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | public function is_available() { |
372 | - return ! empty( $this->enabled ); |
|
372 | + return !empty($this->enabled); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return string |
379 | 379 | */ |
380 | 380 | public function get_title() { |
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
381 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function get_description() { |
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
390 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
400 | 400 | * @return void |
401 | 401 | */ |
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
402 | + public function process_payment($invoice, $submission_data, $submission) { |
|
403 | 403 | // Process the payment then either redirect to the success page or the gateway. |
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
404 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $reason Refund reason. |
416 | 416 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
417 | 417 | */ |
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
418 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
419 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param int $invoice_id 0 or invoice id. |
426 | 426 | * @param GetPaid_Payment_Form $form Current payment form. |
427 | 427 | */ |
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
428 | + public function payment_fields($invoice_id, $form) { |
|
429 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param array $admin_settings |
436 | 436 | */ |
437 | - public function admin_settings( $admin_settings ) { |
|
437 | + public function admin_settings($admin_settings) { |
|
438 | 438 | return $admin_settings; |
439 | 439 | } |
440 | 440 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param string $option |
445 | 445 | */ |
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
446 | + public function get_option($option, $default = false) { |
|
447 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return bool True if the gateway supports the feature, false otherwise. |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
460 | + public function supports($feature) { |
|
461 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -466,36 +466,36 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param bool $save whether or not to display the save button. |
468 | 468 | */ |
469 | - public function get_cc_form( $save = false ) { |
|
469 | + public function get_cc_form($save = false) { |
|
470 | 470 | |
471 | 471 | ob_start(); |
472 | 472 | |
473 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
473 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
474 | 474 | |
475 | 475 | $months = array( |
476 | - '01' => __( 'January', 'invoicing' ), |
|
477 | - '02' => __( 'February', 'invoicing' ), |
|
478 | - '03' => __( 'March', 'invoicing' ), |
|
479 | - '04' => __( 'April', 'invoicing' ), |
|
480 | - '05' => __( 'May', 'invoicing' ), |
|
481 | - '06' => __( 'June', 'invoicing' ), |
|
482 | - '07' => __( 'July', 'invoicing' ), |
|
483 | - '08' => __( 'August', 'invoicing' ), |
|
484 | - '09' => __( 'September', 'invoicing' ), |
|
485 | - '10' => __( 'October', 'invoicing' ), |
|
486 | - '11' => __( 'November', 'invoicing' ), |
|
487 | - '12' => __( 'December', 'invoicing' ), |
|
476 | + '01' => __('January', 'invoicing'), |
|
477 | + '02' => __('February', 'invoicing'), |
|
478 | + '03' => __('March', 'invoicing'), |
|
479 | + '04' => __('April', 'invoicing'), |
|
480 | + '05' => __('May', 'invoicing'), |
|
481 | + '06' => __('June', 'invoicing'), |
|
482 | + '07' => __('July', 'invoicing'), |
|
483 | + '08' => __('August', 'invoicing'), |
|
484 | + '09' => __('September', 'invoicing'), |
|
485 | + '10' => __('October', 'invoicing'), |
|
486 | + '11' => __('November', 'invoicing'), |
|
487 | + '12' => __('December', 'invoicing'), |
|
488 | 488 | ); |
489 | 489 | |
490 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
490 | + $year = (int) date('Y', current_time('timestamp')); |
|
491 | 491 | $years = array(); |
492 | 492 | |
493 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
494 | - $years[ $year + $i ] = $year + $i; |
|
493 | + for ($i = 0; $i <= 10; $i++) { |
|
494 | + $years[$year + $i] = $year + $i; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | ?> |
498 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
498 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
499 | 499 | |
500 | 500 | |
501 | 501 | <div class="getpaid-cc-card-inner"> |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | <div class="col-12"> |
505 | 505 | |
506 | 506 | <div class="form-group"> |
507 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
507 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
508 | 508 | <div class="input-group input-group-sm"> |
509 | 509 | <div class="input-group-prepend "> |
510 | 510 | <span class="input-group-text"> |
511 | 511 | <i class="fa fa-credit-card"></i> |
512 | 512 | </span> |
513 | 513 | </div> |
514 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
514 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
515 | 515 | </div> |
516 | 516 | </div> |
517 | 517 | |
@@ -519,17 +519,17 @@ discard block |
||
519 | 519 | |
520 | 520 | <div class="col-12"> |
521 | 521 | <div class="form-group"> |
522 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
522 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
523 | 523 | <div class="form-row"> |
524 | 524 | |
525 | 525 | <div class="col"> |
526 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
527 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
526 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
527 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
528 | 528 | |
529 | 529 | <?php |
530 | - foreach ( $months as $key => $month ) { |
|
531 | - $key = esc_attr( $key ); |
|
532 | - $month = wpinv_clean( $month ); |
|
530 | + foreach ($months as $key => $month) { |
|
531 | + $key = esc_attr($key); |
|
532 | + $month = wpinv_clean($month); |
|
533 | 533 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
534 | 534 | } |
535 | 535 | ?> |
@@ -538,13 +538,13 @@ discard block |
||
538 | 538 | </div> |
539 | 539 | |
540 | 540 | <div class="col"> |
541 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
542 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
541 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
542 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
543 | 543 | |
544 | 544 | <?php |
545 | - foreach ( $years as $key => $year ) { |
|
546 | - $key = esc_attr( $key ); |
|
547 | - $year = wpinv_clean( $year ); |
|
545 | + foreach ($years as $key => $year) { |
|
546 | + $key = esc_attr($key); |
|
547 | + $year = wpinv_clean($year); |
|
548 | 548 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
549 | 549 | } |
550 | 550 | ?> |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | array( |
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | - 'label' => __( 'CCV', 'invoicing' ), |
|
565 | + 'label' => __('CCV', 'invoicing'), |
|
566 | 566 | 'label_type' => 'vertical', |
567 | 567 | 'class' => 'form-control-sm', |
568 | 568 | 'extra_attributes' => array( |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
580 | + if ($save) { |
|
581 | 581 | echo $this->save_payment_method_checkbox(); |
582 | 582 | } |
583 | 583 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @since 1.0.19 |
598 | 598 | */ |
599 | - public function new_payment_method_entry( $form ) { |
|
599 | + public function new_payment_method_entry($form) { |
|
600 | 600 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
601 | 601 | } |
602 | 602 | |
@@ -606,16 +606,16 @@ discard block |
||
606 | 606 | * @since 1.0.19 |
607 | 607 | */ |
608 | 608 | public function saved_payment_methods() { |
609 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
609 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
610 | 610 | |
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
611 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
612 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $html .= $this->get_new_payment_method_option_html(); |
616 | 616 | $html .= '</ul>'; |
617 | 617 | |
618 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
618 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param array $token Payment Token. |
626 | 626 | * @return string Generated payment method HTML |
627 | 627 | */ |
628 | - public function get_saved_payment_method_option_html( $token ) { |
|
628 | + public function get_saved_payment_method_option_html($token) { |
|
629 | 629 | |
630 | 630 | return sprintf( |
631 | 631 | '<li class="getpaid-payment-method form-group"> |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | <span>%3$s</span> |
635 | 635 | </label> |
636 | 636 | </li>', |
637 | - esc_attr( $this->id ), |
|
638 | - esc_attr( $token['id'] ), |
|
639 | - esc_html( $token['name'] ), |
|
640 | - checked( empty( $token['default'] ), false, false ), |
|
641 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
637 | + esc_attr($this->id), |
|
638 | + esc_attr($token['id']), |
|
639 | + esc_html($token['name']), |
|
640 | + checked(empty($token['default']), false, false), |
|
641 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
642 | 642 | ); |
643 | 643 | |
644 | 644 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | */ |
651 | 651 | public function get_new_payment_method_option_html() { |
652 | 652 | |
653 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
653 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
654 | 654 | |
655 | 655 | return sprintf( |
656 | 656 | '<li class="getpaid-new-payment-method"> |
@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | <span>%2$s</span> |
660 | 660 | </label> |
661 | 661 | </li>', |
662 | - esc_attr( $this->id ), |
|
663 | - esc_html( $label ) |
|
662 | + esc_attr($this->id), |
|
663 | + esc_html($label) |
|
664 | 664 | ); |
665 | 665 | |
666 | 666 | } |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | return aui()->input( |
676 | 676 | array( |
677 | 677 | 'type' => 'checkbox', |
678 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
678 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
679 | + 'id' => esc_attr(uniqid($this->id)), |
|
680 | 680 | 'required' => false, |
681 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
681 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
682 | 682 | 'value' => 'true', |
683 | 683 | 'checked' => true, |
684 | 684 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return array |
694 | 694 | */ |
695 | - public function register_gateway( $gateways ) { |
|
695 | + public function register_gateway($gateways) { |
|
696 | 696 | |
697 | - $gateways[ $this->id ] = array( |
|
697 | + $gateways[$this->id] = array( |
|
698 | 698 | |
699 | 699 | 'admin_label' => $this->method_title, |
700 | 700 | 'checkout_label' => $this->title, |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function is_sandbox( $invoice = null ) { |
|
715 | + public function is_sandbox($invoice = null) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
717 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
718 | 718 | return $invoice->get_mode() == 'test'; |
719 | 719 | } |
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode($this->id); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -736,15 +736,15 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function validate_currency( $validation, $currency ) { |
|
739 | + public function validate_currency($validation, $currency) { |
|
740 | 740 | |
741 | 741 | // Required currencies. |
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
742 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
743 | 743 | return false; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Excluded currencies. |
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
747 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
@@ -755,13 +755,13 @@ discard block |
||
755 | 755 | * Displays an error |
756 | 756 | * |
757 | 757 | */ |
758 | - public function show_error( $code, $message, $type ) { |
|
758 | + public function show_error($code, $message, $type) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
760 | + if (is_admin()) { |
|
761 | + getpaid_admin()->{"show_$type"}($message); |
|
762 | 762 | } |
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error($code, $message, $type); |
|
765 | 765 | |
766 | 766 | } |
767 | 767 |
@@ -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 Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
27 | + protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct() { |
68 | 68 | |
69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
71 | - $this->notify_url = getpaid_get_non_query_string_ipn_url( $this->id ); |
|
69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
71 | + $this->notify_url = getpaid_get_non_query_string_ipn_url($this->id); |
|
72 | 72 | |
73 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
74 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
73 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
74 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
75 | 75 | parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * @param int $invoice_id 0 or invoice id. |
82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
83 | 83 | */ |
84 | - public function payment_fields( $invoice_id, $form ) { |
|
84 | + public function payment_fields($invoice_id, $form) { |
|
85 | 85 | |
86 | 86 | // Let the user select a payment method. |
87 | 87 | echo $this->saved_payment_methods(); |
88 | 88 | |
89 | 89 | // Show the credit card entry form. |
90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,64 +100,64 @@ discard block |
||
100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
101 | 101 | * @return string|WP_Error Payment profile id. |
102 | 102 | */ |
103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
104 | 104 | |
105 | 105 | // Remove non-digits from the number |
106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
107 | 107 | |
108 | 108 | // Generate args. |
109 | 109 | $args = array( |
110 | 110 | 'createCustomerProfileRequest' => array( |
111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
112 | 112 | 'profile' => array( |
113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
116 | 116 | 'paymentProfiles' => array( |
117 | 117 | 'customerType' => 'individual', |
118 | 118 | |
119 | 119 | // Billing information. |
120 | 120 | 'billTo' => array( |
121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
123 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
123 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
128 | 128 | ), |
129 | 129 | |
130 | 130 | // Payment information. |
131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
132 | 132 | ) |
133 | 133 | ), |
134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | |
138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
139 | 139 | |
140 | - if ( is_wp_error( $response ) ) { |
|
140 | + if (is_wp_error($response)) { |
|
141 | 141 | return $response; |
142 | 142 | } |
143 | 143 | |
144 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
144 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
145 | 145 | |
146 | 146 | // Save the payment token. |
147 | - if ( $save ) { |
|
147 | + if ($save) { |
|
148 | 148 | $this->save_token( |
149 | 149 | array( |
150 | 150 | 'id' => $response->customerPaymentProfileIdList[0], |
151 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
151 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
152 | 152 | 'default' => true, |
153 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
153 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
154 | 154 | ) |
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add a note about the validation response. |
159 | 159 | $invoice->add_note( |
160 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
160 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
161 | 161 | false, |
162 | 162 | false, |
163 | 163 | true |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return string|WP_Error Profile id. |
175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
176 | 176 | */ |
177 | - public function get_customer_profile( $profile_id ) { |
|
177 | + public function get_customer_profile($profile_id) { |
|
178 | 178 | |
179 | 179 | // Generate args. |
180 | 180 | $args = array( |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | |
187 | - return $this->post( $args, false ); |
|
187 | + return $this->post($args, false); |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -199,18 +199,18 @@ discard block |
||
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
200 | 200 | * @return string|WP_Error Profile id. |
201 | 201 | */ |
202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
202 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
203 | 203 | |
204 | 204 | // Remove non-digits from the number |
205 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
205 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
206 | 206 | |
207 | 207 | // Prepare card details. |
208 | - $payment_information = $this->get_payment_information( $submission_data['authorizenet'] ); |
|
208 | + $payment_information = $this->get_payment_information($submission_data['authorizenet']); |
|
209 | 209 | |
210 | 210 | // Authorize.NET does not support saving the same card twice. |
211 | - $cached_information = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice ); |
|
211 | + $cached_information = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice); |
|
212 | 212 | |
213 | - if ( $cached_information ) { |
|
213 | + if ($cached_information) { |
|
214 | 214 | return $cached_information; |
215 | 215 | } |
216 | 216 | |
@@ -223,46 +223,46 @@ discard block |
||
223 | 223 | |
224 | 224 | // Billing information. |
225 | 225 | 'billTo' => array( |
226 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
227 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
228 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
229 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
230 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
231 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
232 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
226 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
227 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
228 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
229 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
230 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
231 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
232 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
233 | 233 | ), |
234 | 234 | |
235 | 235 | // Payment information. |
236 | 236 | 'payment' => $payment_information |
237 | 237 | ), |
238 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
238 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
239 | 239 | ) |
240 | 240 | ); |
241 | 241 | |
242 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
242 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
243 | 243 | |
244 | - if ( is_wp_error( $response ) ) { |
|
244 | + if (is_wp_error($response)) { |
|
245 | 245 | return $response; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Save the payment token. |
249 | - if ( $save ) { |
|
249 | + if ($save) { |
|
250 | 250 | $this->save_token( |
251 | 251 | array( |
252 | 252 | 'id' => $response->customerPaymentProfileId, |
253 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
253 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
254 | 254 | 'default' => true, |
255 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
255 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
256 | 256 | ) |
257 | 257 | ); |
258 | 258 | } |
259 | 259 | |
260 | 260 | // Cache payment profile id. |
261 | - $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId ); |
|
261 | + $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId); |
|
262 | 262 | |
263 | 263 | // Add a note about the validation response. |
264 | 264 | $invoice->add_note( |
265 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
265 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
266 | 266 | false, |
267 | 267 | false, |
268 | 268 | true |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * @param array $payment_details. |
280 | 280 | * @return array|false Profile id. |
281 | 281 | */ |
282 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
282 | + public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) { |
|
283 | 283 | |
284 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
285 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
284 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
285 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
286 | 286 | |
287 | - if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) { |
|
287 | + if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) { |
|
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | 'getCustomerPaymentProfileRequest' => array( |
294 | 294 | 'merchantAuthentication' => $this->get_auth_params(), |
295 | 295 | 'customerProfileId' => $customer_profile, |
296 | - 'customerPaymentProfileId' => $cached_information[ $payment_details ], |
|
296 | + 'customerPaymentProfileId' => $cached_information[$payment_details], |
|
297 | 297 | ) |
298 | 298 | ); |
299 | 299 | |
300 | - $response = $this->post( $args, $invoice ); |
|
300 | + $response = $this->post($args, $invoice); |
|
301 | 301 | |
302 | - return is_wp_error( $response ) ? false : $cached_information[ $payment_details ]; |
|
302 | + return is_wp_error($response) ? false : $cached_information[$payment_details]; |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | * @param array $payment_details. |
311 | 311 | * @param string $payment_profile_id. |
312 | 312 | */ |
313 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
313 | + public function add_payment_profile_to_cache($payment_details, $payment_profile_id) { |
|
314 | 314 | |
315 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
316 | - $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
|
317 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
315 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
316 | + $cached_information = is_array($cached_information) ? $cached_information : array(); |
|
317 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
318 | 318 | |
319 | - $cached_information[ $payment_details ] = $payment_profile_id; |
|
320 | - update_option( 'getpaid_authorize_net_cached_profiles', $cached_information ); |
|
319 | + $cached_information[$payment_details] = $payment_profile_id; |
|
320 | + update_option('getpaid_authorize_net_cached_profiles', $cached_information); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return string|WP_Error Profile id. |
331 | 331 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
332 | 332 | */ |
333 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
333 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
334 | 334 | |
335 | 335 | // Generate args. |
336 | 336 | $args = array( |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | ) |
342 | 342 | ); |
343 | 343 | |
344 | - return $this->post( $args, false ); |
|
344 | + return $this->post($args, false); |
|
345 | 345 | |
346 | 346 | } |
347 | 347 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
355 | 355 | * @return WP_Error|object |
356 | 356 | */ |
357 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
357 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
358 | 358 | |
359 | 359 | // Generate args. |
360 | 360 | $args = array( |
@@ -374,28 +374,28 @@ discard block |
||
374 | 374 | ) |
375 | 375 | ), |
376 | 376 | 'order' => array( |
377 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
377 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
378 | 378 | ), |
379 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
379 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
380 | 380 | 'tax' => array( |
381 | 381 | 'amount' => $invoice->get_total_tax(), |
382 | - 'name' => __( 'TAX', 'invoicing' ), |
|
382 | + 'name' => __('TAX', 'invoicing'), |
|
383 | 383 | ), |
384 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
384 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
385 | 385 | 'customer' => array( |
386 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
387 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
386 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
387 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
388 | 388 | ), |
389 | 389 | 'customerIP' => $invoice->get_ip(), |
390 | 390 | ) |
391 | 391 | ) |
392 | 392 | ); |
393 | 393 | |
394 | - if ( 0 == $invoice->get_total_tax() ) { |
|
395 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
394 | + if (0 == $invoice->get_total_tax()) { |
|
395 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
396 | 396 | } |
397 | 397 | |
398 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
398 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
399 | 399 | |
400 | 400 | } |
401 | 401 | |
@@ -405,29 +405,29 @@ discard block |
||
405 | 405 | * @param stdClass $result Api response. |
406 | 406 | * @param WPInv_Invoice $invoice Invoice. |
407 | 407 | */ |
408 | - public function process_charge_response( $result, $invoice ) { |
|
408 | + public function process_charge_response($result, $invoice) { |
|
409 | 409 | |
410 | 410 | wpinv_clear_errors(); |
411 | 411 | $response_code = (int) $result->transactionResponse->responseCode; |
412 | 412 | |
413 | 413 | // Succeeded. |
414 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
414 | + if (1 == $response_code || 4 == $response_code) { |
|
415 | 415 | |
416 | 416 | // Maybe set a transaction id. |
417 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
418 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
417 | + if (!empty($result->transactionResponse->transId)) { |
|
418 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
419 | 419 | } |
420 | 420 | |
421 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
421 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
422 | 422 | |
423 | - if ( 1 == $response_code ) { |
|
423 | + if (1 == $response_code) { |
|
424 | 424 | return $invoice->mark_paid(); |
425 | 425 | } |
426 | 426 | |
427 | - $invoice->set_status( 'wpi-onhold' ); |
|
427 | + $invoice->set_status('wpi-onhold'); |
|
428 | 428 | $invoice->add_note( |
429 | 429 | sprintf( |
430 | - __( 'Held for review: %s', 'invoicing' ), |
|
430 | + __('Held for review: %s', 'invoicing'), |
|
431 | 431 | $result->transactionResponse->messages->message[0]->description |
432 | 432 | ) |
433 | 433 | ); |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | |
437 | 437 | } |
438 | 438 | |
439 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
439 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
440 | 440 | |
441 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
441 | + if (!empty($result->transactionResponse->errors)) { |
|
442 | 442 | $errors = (object) $result->transactionResponse->errors; |
443 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
443 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | } |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | * @param array $card Card details. |
453 | 453 | * @return array |
454 | 454 | */ |
455 | - public function get_payment_information( $card ) { |
|
455 | + public function get_payment_information($card) { |
|
456 | 456 | return array( |
457 | 457 | |
458 | - 'creditCard' => array ( |
|
458 | + 'creditCard' => array( |
|
459 | 459 | 'cardNumber' => $card['cc_number'], |
460 | 460 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
461 | 461 | 'cardCode' => $card['cc_cvv2'], |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param WPInv_Invoice $invoice Invoice. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_customer_profile_meta_name( $invoice ) { |
|
475 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
474 | + public function get_customer_profile_meta_name($invoice) { |
|
475 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -483,34 +483,34 @@ discard block |
||
483 | 483 | * @param WPInv_Invoice $invoice |
484 | 484 | * @return WP_Error|string The payment profile id |
485 | 485 | */ |
486 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
486 | + public function validate_submission_data($submission_data, $invoice) { |
|
487 | 487 | |
488 | 488 | // Validate authentication details. |
489 | 489 | $auth = $this->get_auth_params(); |
490 | 490 | |
491 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
492 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
491 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
492 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // Validate the payment method. |
496 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
497 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
496 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
497 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // Are we adding a new payment method? |
501 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
501 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
502 | 502 | return $submission_data['getpaid-authorizenet-payment-method']; |
503 | 503 | } |
504 | 504 | |
505 | 505 | // Retrieve the customer profile id. |
506 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
506 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
507 | 507 | |
508 | 508 | // Create payment method. |
509 | - if ( empty( $profile_id ) ) { |
|
510 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
509 | + if (empty($profile_id)) { |
|
510 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
511 | 511 | } |
512 | 512 | |
513 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
513 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 | |
@@ -521,32 +521,32 @@ discard block |
||
521 | 521 | * @param WPInv_Invoice $invoice Invoice. |
522 | 522 | * @return array |
523 | 523 | */ |
524 | - public function get_line_items( $invoice ) { |
|
524 | + public function get_line_items($invoice) { |
|
525 | 525 | $items = array(); |
526 | 526 | |
527 | - foreach ( $invoice->get_items() as $item ) { |
|
527 | + foreach ($invoice->get_items() as $item) { |
|
528 | 528 | |
529 | 529 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
530 | 530 | $items[] = array( |
531 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
532 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
533 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
534 | - 'quantity' => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ), |
|
531 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
532 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
533 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
534 | + 'quantity' => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()), |
|
535 | 535 | 'unitPrice' => (float) $amount, |
536 | 536 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
537 | 537 | ); |
538 | 538 | |
539 | 539 | } |
540 | 540 | |
541 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
541 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
542 | 542 | |
543 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
543 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
544 | 544 | |
545 | - if ( $amount > 0 ) { |
|
545 | + if ($amount > 0) { |
|
546 | 546 | $items[] = array( |
547 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
548 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
549 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
547 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
548 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
549 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
550 | 550 | 'quantity' => '1', |
551 | 551 | 'unitPrice' => (float) $amount, |
552 | 552 | 'taxable' => false, |
@@ -567,36 +567,36 @@ discard block |
||
567 | 567 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
568 | 568 | * @return array |
569 | 569 | */ |
570 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
570 | + public function process_payment($invoice, $submission_data, $submission) { |
|
571 | 571 | |
572 | 572 | // Validate the submitted data. |
573 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
573 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
574 | 574 | |
575 | 575 | // Do we have an error? |
576 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
577 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
578 | - wpinv_send_back_to_checkout( $invoice ); |
|
576 | + if (is_wp_error($payment_profile_id)) { |
|
577 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
578 | + wpinv_send_back_to_checkout($invoice); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | // Save the payment method to the order. |
582 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
582 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
583 | 583 | |
584 | 584 | // Check if this is a subscription or not. |
585 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
586 | - if ( ! empty( $subscriptions ) ) { |
|
587 | - $this->process_subscription( $invoice, $subscriptions ); |
|
585 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
586 | + if (!empty($subscriptions)) { |
|
587 | + $this->process_subscription($invoice, $subscriptions); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | // If it is free, send to the success page. |
591 | - if ( ! $invoice->needs_payment() ) { |
|
591 | + if (!$invoice->needs_payment()) { |
|
592 | 592 | $invoice->mark_paid(); |
593 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
593 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | // Charge the payment profile. |
597 | - $this->process_initial_payment( $invoice ); |
|
597 | + $this->process_initial_payment($invoice); |
|
598 | 598 | |
599 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
599 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
600 | 600 | |
601 | 601 | exit; |
602 | 602 | |
@@ -607,23 +607,23 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @param WPInv_Invoice $invoice Invoice. |
609 | 609 | */ |
610 | - protected function process_initial_payment( $invoice ) { |
|
610 | + protected function process_initial_payment($invoice) { |
|
611 | 611 | |
612 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
613 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
614 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
612 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
613 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
614 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
615 | 615 | |
616 | 616 | // Do we have an error? |
617 | - if ( is_wp_error( $result ) ) { |
|
618 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
619 | - wpinv_send_back_to_checkout( $invoice ); |
|
617 | + if (is_wp_error($result)) { |
|
618 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
619 | + wpinv_send_back_to_checkout($invoice); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | // Process the response. |
623 | - $this->process_charge_response( $result, $invoice ); |
|
623 | + $this->process_charge_response($result, $invoice); |
|
624 | 624 | |
625 | - if ( wpinv_get_errors() ) { |
|
626 | - wpinv_send_back_to_checkout( $invoice ); |
|
625 | + if (wpinv_get_errors()) { |
|
626 | + wpinv_send_back_to_checkout($invoice); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | } |
@@ -634,30 +634,30 @@ discard block |
||
634 | 634 | * @param WPInv_Invoice $invoice Invoice. |
635 | 635 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
636 | 636 | */ |
637 | - public function process_subscription( $invoice, $subscriptions ) { |
|
637 | + public function process_subscription($invoice, $subscriptions) { |
|
638 | 638 | |
639 | 639 | // Check if there is an initial amount to charge. |
640 | - if ( (float) $invoice->get_total() > 0 ) { |
|
641 | - $this->process_initial_payment( $invoice ); |
|
640 | + if ((float) $invoice->get_total() > 0) { |
|
641 | + $this->process_initial_payment($invoice); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | // Activate the subscriptions. |
645 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
645 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
646 | 646 | |
647 | - foreach ( $subscriptions as $subscription ) { |
|
648 | - if ( $subscription->exists() ) { |
|
649 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
650 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
647 | + foreach ($subscriptions as $subscription) { |
|
648 | + if ($subscription->exists()) { |
|
649 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
650 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
651 | 651 | |
652 | - $subscription->set_next_renewal_date( $expiry ); |
|
653 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
654 | - $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
652 | + $subscription->set_next_renewal_date($expiry); |
|
653 | + $subscription->set_date_created(current_time('mysql')); |
|
654 | + $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
655 | 655 | $subscription->activate(); |
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
659 | 659 | // Redirect to the success page. |
660 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
660 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
661 | 661 | |
662 | 662 | } |
663 | 663 | |
@@ -668,20 +668,20 @@ discard block |
||
668 | 668 | * @param bool $should_expire |
669 | 669 | * @param WPInv_Subscription $subscription |
670 | 670 | */ |
671 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
671 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
672 | 672 | |
673 | 673 | // Ensure its our subscription && it's active. |
674 | - if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
674 | + if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
675 | 675 | return $should_expire; |
676 | 676 | } |
677 | 677 | |
678 | 678 | // If this is the last renewal, complete the subscription. |
679 | - if ( $subscription->is_last_renewal() ) { |
|
679 | + if ($subscription->is_last_renewal()) { |
|
680 | 680 | $subscription->complete(); |
681 | 681 | return false; |
682 | 682 | } |
683 | 683 | |
684 | - $this->renew_subscription( $subscription ); |
|
684 | + $this->renew_subscription($subscription); |
|
685 | 685 | |
686 | 686 | return false; |
687 | 687 | |
@@ -692,28 +692,28 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @param WPInv_Subscription $subscription |
694 | 694 | */ |
695 | - public function renew_subscription( $subscription ) { |
|
695 | + public function renew_subscription($subscription) { |
|
696 | 696 | |
697 | 697 | // Generate the renewal invoice. |
698 | 698 | $new_invoice = $subscription->create_payment(); |
699 | 699 | $old_invoice = $subscription->get_parent_payment(); |
700 | 700 | |
701 | - if ( empty( $new_invoice ) ) { |
|
702 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
701 | + if (empty($new_invoice)) { |
|
702 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
703 | 703 | $subscription->failing(); |
704 | 704 | return; |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Charge the payment method. |
708 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
709 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
710 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
708 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
709 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
710 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
711 | 711 | |
712 | 712 | // Do we have an error? |
713 | - if ( is_wp_error( $result ) ) { |
|
713 | + if (is_wp_error($result)) { |
|
714 | 714 | |
715 | 715 | $old_invoice->add_note( |
716 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
716 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
717 | 717 | true, |
718 | 718 | false, |
719 | 719 | true |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | } |
725 | 725 | |
726 | 726 | // Process the response. |
727 | - $this->process_charge_response( $result, $new_invoice ); |
|
727 | + $this->process_charge_response($result, $new_invoice); |
|
728 | 728 | |
729 | - if ( wpinv_get_errors() ) { |
|
729 | + if (wpinv_get_errors()) { |
|
730 | 730 | |
731 | 731 | $old_invoice->add_note( |
732 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
732 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
733 | 733 | true, |
734 | 734 | false, |
735 | 735 | true |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | |
740 | 740 | } |
741 | 741 | |
742 | - $subscription->add_payment( array(), $new_invoice ); |
|
742 | + $subscription->add_payment(array(), $new_invoice); |
|
743 | 743 | $subscription->renew(); |
744 | 744 | } |
745 | 745 | |
@@ -750,34 +750,34 @@ discard block |
||
750 | 750 | * @param GetPaid_Form_Item[] $items |
751 | 751 | * @return WPInv_Invoice |
752 | 752 | */ |
753 | - public function process_addons( $invoice, $items ) { |
|
753 | + public function process_addons($invoice, $items) { |
|
754 | 754 | |
755 | 755 | global $getpaid_authorize_addons; |
756 | 756 | |
757 | 757 | $getpaid_authorize_addons = array(); |
758 | - foreach ( $items as $item ) { |
|
758 | + foreach ($items as $item) { |
|
759 | 759 | |
760 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
760 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
761 | 761 | $getpaid_authorize_addons[] = $item; |
762 | 762 | } |
763 | 763 | |
764 | 764 | } |
765 | 765 | |
766 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
766 | + if (empty($getpaid_authorize_addons)) { |
|
767 | 767 | return; |
768 | 768 | } |
769 | 769 | |
770 | 770 | $invoice->recalculate_total(); |
771 | 771 | |
772 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
773 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
772 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
773 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
774 | 774 | |
775 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
776 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
777 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
775 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
776 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
777 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
778 | 778 | |
779 | - if ( is_wp_error( $result ) ) { |
|
780 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
779 | + if (is_wp_error($result)) { |
|
780 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
@@ -790,19 +790,19 @@ discard block |
||
790 | 790 | * @param array $args |
791 | 791 | * @return array |
792 | 792 | */ |
793 | - public function filter_addons_request( $args ) { |
|
793 | + public function filter_addons_request($args) { |
|
794 | 794 | |
795 | 795 | global $getpaid_authorize_addons; |
796 | 796 | $total = 0; |
797 | 797 | |
798 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
798 | + foreach ($getpaid_authorize_addons as $addon) { |
|
799 | 799 | $total += $addon->get_sub_total(); |
800 | 800 | } |
801 | 801 | |
802 | 802 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
803 | 803 | |
804 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
805 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
804 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
805 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | return $args; |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | public function sandbox_notice() { |
816 | 816 | |
817 | 817 | return sprintf( |
818 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
818 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
819 | 819 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
820 | 820 | '</a>' |
821 | 821 | ); |
@@ -827,42 +827,42 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @param array $admin_settings |
829 | 829 | */ |
830 | - public function admin_settings( $admin_settings ) { |
|
830 | + public function admin_settings($admin_settings) { |
|
831 | 831 | |
832 | 832 | $currencies = sprintf( |
833 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
834 | - implode( ', ', $this->currencies ) |
|
833 | + __('Supported Currencies: %s', 'invoicing'), |
|
834 | + implode(', ', $this->currencies) |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
838 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
838 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
839 | 839 | |
840 | 840 | $admin_settings['authorizenet_login_id'] = array( |
841 | 841 | 'type' => 'text', |
842 | 842 | 'id' => 'authorizenet_login_id', |
843 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
844 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
843 | + 'name' => __('API Login ID', 'invoicing'), |
|
844 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
845 | 845 | ); |
846 | 846 | |
847 | 847 | $admin_settings['authorizenet_transaction_key'] = array( |
848 | 848 | 'type' => 'text', |
849 | 849 | 'id' => 'authorizenet_transaction_key', |
850 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
850 | + 'name' => __('Transaction Key', 'invoicing'), |
|
851 | 851 | ); |
852 | 852 | |
853 | 853 | $admin_settings['authorizenet_signature_key'] = array( |
854 | 854 | 'type' => 'text', |
855 | 855 | 'id' => 'authorizenet_signature_key', |
856 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
857 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
856 | + 'name' => __('Signature Key', 'invoicing'), |
|
857 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
858 | 858 | ); |
859 | 859 | |
860 | 860 | $admin_settings['authorizenet_ipn_url'] = array( |
861 | 861 | 'type' => 'ipn_url', |
862 | 862 | 'id' => 'authorizenet_ipn_url', |
863 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
863 | + 'name' => __('Webhook URL', 'invoicing'), |
|
864 | 864 | 'std' => $this->notify_url, |
865 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
865 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
866 | 866 | 'custom' => 'authorizenet', |
867 | 867 | 'readonly' => true, |
868 | 868 | ); |
@@ -7,27 +7,27 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Cart table columns. |
13 | 13 | $columns = array( |
14 | - 'name' => __( 'Item', 'invoicing' ), |
|
15 | - 'price' => __( 'Price', 'invoicing' ), |
|
16 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
14 | + 'name' => __('Item', 'invoicing'), |
|
15 | + 'price' => __('Price', 'invoicing'), |
|
16 | + 'quantity' => __('Quantity', 'invoicing'), |
|
17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
18 | 18 | ); |
19 | 19 | |
20 | -if ( ! empty( $form->invoice ) ) { |
|
21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
20 | +if (!empty($form->invoice)) { |
|
21 | + $columns = getpaid_invoice_item_columns($form->invoice); |
|
22 | 22 | } |
23 | 23 | |
24 | -if ( isset( $columns['tax_rate'] ) ) { |
|
25 | - unset( $columns['tax_rate'] ); |
|
24 | +if (isset($columns['tax_rate'])) { |
|
25 | + unset($columns['tax_rate']); |
|
26 | 26 | } |
27 | 27 | |
28 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
28 | +$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form); |
|
29 | 29 | |
30 | -do_action( 'getpaid_before_payment_form_cart', $form ); |
|
30 | +do_action('getpaid_before_payment_form_cart', $form); |
|
31 | 31 | |
32 | 32 | ?> |
33 | 33 | <div class="getpaid-payment-form-items-cart border form-group"> |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | |
36 | 36 | <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3"> |
37 | 37 | <div class="form-row"> |
38 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
39 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>"> |
|
40 | - <?php echo sanitize_text_field( $label ); ?> |
|
38 | + <?php foreach ($columns as $key => $label) : ?> |
|
39 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>"> |
|
40 | + <?php echo sanitize_text_field($label); ?> |
|
41 | 41 | </div> |
42 | 42 | <?php endforeach; ?> |
43 | 43 | </div> |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | <?php |
47 | 47 | |
48 | 48 | // Display the item totals. |
49 | - foreach ( $form->get_items() as $item ) { |
|
50 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
49 | + foreach ($form->get_items() as $item) { |
|
50 | + wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Display the cart totals. |
54 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
54 | + wpinv_get_template('payment-forms/cart-totals.php', compact('form')); |
|
55 | 55 | |
56 | 56 | ?> |
57 | 57 | </div> |
58 | 58 | |
59 | 59 | <?php |
60 | 60 | |
61 | -do_action( 'getpaid_after_payment_form_cart', $form ); |
|
61 | +do_action('getpaid_after_payment_form_cart', $form); |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
99 | 99 | */ |
100 | 100 | public static function instance() { |
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
102 | 102 | |
103 | 103 | self::$instance = new AyeCode_UI_Settings; |
104 | 104 | |
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
106 | 106 | |
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
107 | + if (is_admin()) { |
|
108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
110 | 110 | |
111 | 111 | // Maybe show example page |
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
113 | 113 | } |
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
116 | 116 | |
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
117 | + do_action('ayecode_ui_settings_loaded'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * Setup some constants. |
125 | 125 | */ |
126 | - public function constants(){ |
|
126 | + public function constants() { |
|
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
143 | 143 | * |
144 | 144 | * We load super early in case there is a theme version that might change the colors |
145 | 145 | */ |
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
146 | + if ($this->settings['css']) { |
|
147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
148 | 148 | } |
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // maybe load JS |
154 | - if ( $this->settings['js'] ) { |
|
154 | + if ($this->settings['js']) { |
|
155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
157 | 157 | } |
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Maybe set the HTML font size |
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
163 | + if ($this->settings['html_font_size']) { |
|
164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function load_admin_scripts(){ |
|
175 | + public function load_admin_scripts() { |
|
176 | 176 | $result = true; |
177 | 177 | |
178 | 178 | // check if specifically disabled |
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
179 | + if (!empty($this->settings['disable_admin'])) { |
|
180 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
181 | + foreach ($url_parts as $part) { |
|
182 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
183 | 183 | return false; // return early, no point checking further |
184 | 184 | } |
185 | 185 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * Add a html font size to the footer. |
193 | 193 | */ |
194 | - public function html_font_size(){ |
|
194 | + public function html_font_size() { |
|
195 | 195 | $this->settings = $this->get_settings(); |
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return bool |
203 | 203 | */ |
204 | - public function is_aui_screen(){ |
|
204 | + public function is_aui_screen() { |
|
205 | 205 | $load = false; |
206 | 206 | // check if we should load or not |
207 | - if ( is_admin() ) { |
|
207 | + if (is_admin()) { |
|
208 | 208 | // Only enable on set pages |
209 | 209 | $aui_screens = array( |
210 | 210 | 'page', |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | 'settings_page_ayecode-ui-settings', |
213 | 213 | 'appearance_page_gutenberg-widgets' |
214 | 214 | ); |
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
215 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
216 | 216 | |
217 | 217 | $screen = get_current_screen(); |
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
221 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
222 | 222 | $load = true; |
223 | 223 | } |
224 | 224 | } |
@@ -231,25 +231,25 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function enqueue_style() { |
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
234 | + if (is_admin() && !$this->is_aui_screen()) { |
|
235 | 235 | // don't add wp-admin scripts if not requested to |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
238 | 238 | |
239 | 239 | $rtl = is_rtl() ? '-rtl' : ''; |
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if ($this->settings[$css_setting]) { |
|
242 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
244 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
245 | + wp_enqueue_style('ayecode-ui'); |
|
246 | 246 | |
247 | 247 | // flatpickr |
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
248 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
249 | 249 | |
250 | 250 | |
251 | 251 | // fix some wp-admin issues |
252 | - if(is_admin()){ |
|
252 | + if (is_admin()) { |
|
253 | 253 | $custom_css = " |
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | padding: 0; |
296 | 296 | } |
297 | 297 | "; |
298 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
298 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // custom changes |
302 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
302 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | function aui_init_flatpickr(){ |
560 | 560 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
561 | 561 | $aui_doing_init_flatpickr = true; |
562 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
562 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
563 | 563 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
564 | 564 | } |
565 | 565 | $aui_doing_init_flatpickr = false; |
@@ -989,10 +989,10 @@ discard block |
||
989 | 989 | /* |
990 | 990 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
991 | 991 | */ |
992 | - return str_replace( array( |
|
992 | + return str_replace(array( |
|
993 | 993 | '<script>', |
994 | 994 | '</script>' |
995 | - ), '', self::minify_js($output) ); |
|
995 | + ), '', self::minify_js($output)); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | |
@@ -1006,13 +1006,13 @@ discard block |
||
1006 | 1006 | ob_start(); |
1007 | 1007 | ?> |
1008 | 1008 | <script> |
1009 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1009 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1010 | 1010 | /* With Avada builder */ |
1011 | 1011 | |
1012 | 1012 | <?php } ?> |
1013 | 1013 | </script> |
1014 | 1014 | <?php |
1015 | - return str_replace( array( |
|
1015 | + return str_replace(array( |
|
1016 | 1016 | '<script>', |
1017 | 1017 | '</script>' |
1018 | 1018 | ), '', ob_get_clean()); |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * If this remains small then its best to use this than to add another JS file. |
1025 | 1025 | */ |
1026 | - public function inline_script_file_browser(){ |
|
1026 | + public function inline_script_file_browser() { |
|
1027 | 1027 | ob_start(); |
1028 | 1028 | ?> |
1029 | 1029 | <script> |
@@ -1038,10 +1038,10 @@ discard block |
||
1038 | 1038 | /* |
1039 | 1039 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1040 | 1040 | */ |
1041 | - return str_replace( array( |
|
1041 | + return str_replace(array( |
|
1042 | 1042 | '<script>', |
1043 | 1043 | '</script>' |
1044 | - ), '', $output ); |
|
1044 | + ), '', $output); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | /** |
@@ -1049,50 +1049,50 @@ discard block |
||
1049 | 1049 | */ |
1050 | 1050 | public function enqueue_scripts() { |
1051 | 1051 | |
1052 | - if( is_admin() && !$this->is_aui_screen()){ |
|
1052 | + if (is_admin() && !$this->is_aui_screen()) { |
|
1053 | 1053 | // don't add wp-admin scripts if not requested to |
1054 | - }else { |
|
1054 | + } else { |
|
1055 | 1055 | |
1056 | 1056 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
1057 | 1057 | |
1058 | 1058 | // select2 |
1059 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1059 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
1060 | 1060 | |
1061 | 1061 | // flatpickr |
1062 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1062 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
1063 | 1063 | |
1064 | 1064 | // Bootstrap file browser |
1065 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1066 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1065 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
1066 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
1067 | 1067 | |
1068 | 1068 | $load_inline = false; |
1069 | 1069 | |
1070 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1070 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
1071 | 1071 | // Bootstrap bundle |
1072 | 1072 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
1073 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1073 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
1074 | 1074 | 'select2', |
1075 | 1075 | 'jquery' |
1076 | - ), $this->latest, $this->is_bs3_compat() ); |
|
1076 | + ), $this->latest, $this->is_bs3_compat()); |
|
1077 | 1077 | // if in admin then add to footer for compatibility. |
1078 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1078 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
1079 | 1079 | $script = $this->inline_script(); |
1080 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1081 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1080 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
1081 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
1082 | 1082 | $url = $this->url . 'assets/js/popper.min.js'; |
1083 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1084 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1083 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
1084 | + wp_enqueue_script('bootstrap-js-popper'); |
|
1085 | 1085 | $load_inline = true; |
1086 | 1086 | } else { |
1087 | 1087 | $load_inline = true; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
1091 | - if ( $load_inline ) { |
|
1092 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1093 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
1091 | + if ($load_inline) { |
|
1092 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
1093 | + wp_enqueue_script('bootstrap-dummy'); |
|
1094 | 1094 | $script = $this->inline_script(); |
1095 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1095 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
1096 | 1096 | } |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1101,9 +1101,9 @@ discard block |
||
1101 | 1101 | /** |
1102 | 1102 | * Enqueue flatpickr if called. |
1103 | 1103 | */ |
1104 | - public function enqueue_flatpickr(){ |
|
1105 | - wp_enqueue_style( 'flatpickr' ); |
|
1106 | - wp_enqueue_script( 'flatpickr' ); |
|
1104 | + public function enqueue_flatpickr() { |
|
1105 | + wp_enqueue_style('flatpickr'); |
|
1106 | + wp_enqueue_script('flatpickr'); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | /** |
@@ -1115,15 +1115,15 @@ discard block |
||
1115 | 1115 | |
1116 | 1116 | $url = ''; |
1117 | 1117 | // check if we are inside a plugin |
1118 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1118 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
1119 | 1119 | |
1120 | 1120 | // add check in-case user has changed wp-content dir name. |
1121 | 1121 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
1122 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1123 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1122 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
1123 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
1124 | 1124 | |
1125 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1126 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1125 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
1126 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | return $url; |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | * Register the database settings with WordPress. |
1134 | 1134 | */ |
1135 | 1135 | public function register_settings() { |
1136 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1136 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | /** |
@@ -1142,10 +1142,10 @@ discard block |
||
1142 | 1142 | */ |
1143 | 1143 | public function menu_item() { |
1144 | 1144 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
1145 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1145 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1146 | 1146 | $this, |
1147 | 1147 | 'settings_page' |
1148 | - ) ); |
|
1148 | + )); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | /** |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | * |
1154 | 1154 | * @return array |
1155 | 1155 | */ |
1156 | - public function theme_js_settings(){ |
|
1156 | + public function theme_js_settings() { |
|
1157 | 1157 | return array( |
1158 | 1158 | 'ayetheme' => 'popper', |
1159 | 1159 | 'listimia' => 'required', |
@@ -1169,17 +1169,17 @@ discard block |
||
1169 | 1169 | */ |
1170 | 1170 | public function get_settings() { |
1171 | 1171 | |
1172 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1172 | + $db_settings = get_option('ayecode-ui-settings'); |
|
1173 | 1173 | $js_default = 'core-popper'; |
1174 | 1174 | $js_default_backend = $js_default; |
1175 | 1175 | |
1176 | 1176 | // maybe set defaults (if no settings set) |
1177 | - if(empty($db_settings)){ |
|
1178 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1177 | + if (empty($db_settings)) { |
|
1178 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
1179 | 1179 | $theme_js_settings = self::theme_js_settings(); |
1180 | - if(isset($theme_js_settings[$active_theme])){ |
|
1180 | + if (isset($theme_js_settings[$active_theme])) { |
|
1181 | 1181 | $js_default = $theme_js_settings[$active_theme]; |
1182 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1182 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
1183 | 1183 | } |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1192,14 +1192,14 @@ discard block |
||
1192 | 1192 | 'disable_admin' => '', // URL snippets to disable loading on admin |
1193 | 1193 | ); |
1194 | 1194 | |
1195 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1195 | + $settings = wp_parse_args($db_settings, $defaults); |
|
1196 | 1196 | |
1197 | 1197 | /** |
1198 | 1198 | * Filter the Bootstrap settings. |
1199 | 1199 | * |
1200 | 1200 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
1201 | 1201 | */ |
1202 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1202 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1207,90 +1207,90 @@ discard block |
||
1207 | 1207 | * The settings page html output. |
1208 | 1208 | */ |
1209 | 1209 | public function settings_page() { |
1210 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1211 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1210 | + if (!current_user_can('manage_options')) { |
|
1211 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
1212 | 1212 | } |
1213 | 1213 | ?> |
1214 | 1214 | <div class="wrap"> |
1215 | 1215 | <h1><?php echo $this->name; ?></h1> |
1216 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
1216 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
1217 | 1217 | <form method="post" action="options.php"> |
1218 | 1218 | <?php |
1219 | - settings_fields( 'ayecode-ui-settings' ); |
|
1220 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1219 | + settings_fields('ayecode-ui-settings'); |
|
1220 | + do_settings_sections('ayecode-ui-settings'); |
|
1221 | 1221 | ?> |
1222 | 1222 | |
1223 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
1223 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
1224 | 1224 | <table class="form-table wpbs-table-settings"> |
1225 | 1225 | <tr valign="top"> |
1226 | 1226 | <th scope="row"><label |
1227 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1227 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1228 | 1228 | <td> |
1229 | 1229 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
1230 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1231 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
1232 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1230 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1231 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
1232 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1233 | 1233 | </select> |
1234 | 1234 | </td> |
1235 | 1235 | </tr> |
1236 | 1236 | |
1237 | 1237 | <tr valign="top"> |
1238 | 1238 | <th scope="row"><label |
1239 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1239 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1240 | 1240 | <td> |
1241 | 1241 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
1242 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1243 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1244 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1245 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1242 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1243 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1244 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1245 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1246 | 1246 | </select> |
1247 | 1247 | </td> |
1248 | 1248 | </tr> |
1249 | 1249 | |
1250 | 1250 | <tr valign="top"> |
1251 | 1251 | <th scope="row"><label |
1252 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
1252 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
1253 | 1253 | <td> |
1254 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1255 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
1254 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1255 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
1256 | 1256 | </td> |
1257 | 1257 | </tr> |
1258 | 1258 | |
1259 | 1259 | </table> |
1260 | 1260 | |
1261 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
1261 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
1262 | 1262 | <table class="form-table wpbs-table-settings"> |
1263 | 1263 | <tr valign="top"> |
1264 | 1264 | <th scope="row"><label |
1265 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1265 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1266 | 1266 | <td> |
1267 | 1267 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
1268 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1269 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
1270 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1268 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1269 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
1270 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1271 | 1271 | </select> |
1272 | 1272 | </td> |
1273 | 1273 | </tr> |
1274 | 1274 | |
1275 | 1275 | <tr valign="top"> |
1276 | 1276 | <th scope="row"><label |
1277 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1277 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1278 | 1278 | <td> |
1279 | 1279 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
1280 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1281 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1282 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1283 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1280 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1281 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1282 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1283 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1284 | 1284 | </select> |
1285 | 1285 | </td> |
1286 | 1286 | </tr> |
1287 | 1287 | |
1288 | 1288 | <tr valign="top"> |
1289 | 1289 | <th scope="row"><label |
1290 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
1290 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
1291 | 1291 | <td> |
1292 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
1293 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
1292 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
1293 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
1294 | 1294 | |
1295 | 1295 | </td> |
1296 | 1296 | </tr> |
@@ -1308,9 +1308,9 @@ discard block |
||
1308 | 1308 | <?php |
1309 | 1309 | } |
1310 | 1310 | |
1311 | - public function customizer_settings($wp_customize){ |
|
1311 | + public function customizer_settings($wp_customize) { |
|
1312 | 1312 | $wp_customize->add_section('aui_settings', array( |
1313 | - 'title' => __('AyeCode UI','aui'), |
|
1313 | + 'title' => __('AyeCode UI', 'aui'), |
|
1314 | 1314 | 'priority' => 120, |
1315 | 1315 | )); |
1316 | 1316 | |
@@ -1324,8 +1324,8 @@ discard block |
||
1324 | 1324 | 'type' => 'option', |
1325 | 1325 | 'transport' => 'refresh', |
1326 | 1326 | )); |
1327 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1328 | - 'label' => __('Primary Color','aui'), |
|
1327 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1328 | + 'label' => __('Primary Color', 'aui'), |
|
1329 | 1329 | 'section' => 'aui_settings', |
1330 | 1330 | 'settings' => 'aui_options[color_primary]', |
1331 | 1331 | ))); |
@@ -1337,8 +1337,8 @@ discard block |
||
1337 | 1337 | 'type' => 'option', |
1338 | 1338 | 'transport' => 'refresh', |
1339 | 1339 | )); |
1340 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1341 | - 'label' => __('Secondary Color','aui'), |
|
1340 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1341 | + 'label' => __('Secondary Color', 'aui'), |
|
1342 | 1342 | 'section' => 'aui_settings', |
1343 | 1343 | 'settings' => 'aui_options[color_secondary]', |
1344 | 1344 | ))); |
@@ -1364,12 +1364,12 @@ discard block |
||
1364 | 1364 | .collapse.show:not(.in){display: inherit;} |
1365 | 1365 | .fade.show{opacity: 1;} |
1366 | 1366 | |
1367 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
1367 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
1368 | 1368 | /* KLEO theme specific */ |
1369 | 1369 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;} |
1370 | 1370 | <?php } ?> |
1371 | 1371 | |
1372 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1372 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1373 | 1373 | /* With Avada builder */ |
1374 | 1374 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
1375 | 1375 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1377,10 +1377,10 @@ discard block |
||
1377 | 1377 | <?php } ?> |
1378 | 1378 | </style> |
1379 | 1379 | <?php |
1380 | - return str_replace( array( |
|
1380 | + return str_replace(array( |
|
1381 | 1381 | '<style>', |
1382 | 1382 | '</style>' |
1383 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1383 | + ), '', self::minify_css(ob_get_clean())); |
|
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | |
@@ -1397,16 +1397,16 @@ discard block |
||
1397 | 1397 | <?php |
1398 | 1398 | |
1399 | 1399 | // BS v3 compat |
1400 | - if( self::is_bs3_compat() ){ |
|
1400 | + if (self::is_bs3_compat()) { |
|
1401 | 1401 | echo self::bs3_compat_css(); |
1402 | 1402 | } |
1403 | 1403 | |
1404 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1405 | - echo self::css_primary($primary_color,$compatibility); |
|
1404 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
1405 | + echo self::css_primary($primary_color, $compatibility); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1409 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1408 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
1409 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | // Set admin bar z-index lower when modal is open. |
@@ -1419,10 +1419,10 @@ discard block |
||
1419 | 1419 | /* |
1420 | 1420 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1421 | 1421 | */ |
1422 | - return str_replace( array( |
|
1422 | + return str_replace(array( |
|
1423 | 1423 | '<style>', |
1424 | 1424 | '</style>' |
1425 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1425 | + ), '', self::minify_css(ob_get_clean())); |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
@@ -1430,48 +1430,48 @@ discard block |
||
1430 | 1430 | * |
1431 | 1431 | * @return bool |
1432 | 1432 | */ |
1433 | - public static function is_bs3_compat(){ |
|
1433 | + public static function is_bs3_compat() { |
|
1434 | 1434 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1435 | 1435 | } |
1436 | 1436 | |
1437 | - public static function css_primary($color_code,$compatibility){; |
|
1437 | + public static function css_primary($color_code, $compatibility) {; |
|
1438 | 1438 | $color_code = sanitize_hex_color($color_code); |
1439 | - if(!$color_code){return '';} |
|
1439 | + if (!$color_code) {return ''; } |
|
1440 | 1440 | /** |
1441 | 1441 | * c = color, b = background color, o = border-color, f = fill |
1442 | 1442 | */ |
1443 | 1443 | $selectors = array( |
1444 | 1444 | 'a' => array('c'), |
1445 | - '.btn-primary' => array('b','o'), |
|
1446 | - '.btn-primary.disabled' => array('b','o'), |
|
1447 | - '.btn-primary:disabled' => array('b','o'), |
|
1448 | - '.btn-outline-primary' => array('c','o'), |
|
1449 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1450 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1451 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1452 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1445 | + '.btn-primary' => array('b', 'o'), |
|
1446 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1447 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1448 | + '.btn-outline-primary' => array('c', 'o'), |
|
1449 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1450 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1451 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1452 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1453 | 1453 | '.btn-link' => array('c'), |
1454 | 1454 | '.dropdown-item.active' => array('b'), |
1455 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1456 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1455 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1456 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1457 | 1457 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1458 | 1458 | // '.custom-range::-moz-range-thumb' => array('b'), |
1459 | 1459 | // '.custom-range::-ms-thumb' => array('b'), |
1460 | 1460 | '.nav-pills .nav-link.active' => array('b'), |
1461 | 1461 | '.nav-pills .show>.nav-link' => array('b'), |
1462 | 1462 | '.page-link' => array('c'), |
1463 | - '.page-item.active .page-link' => array('b','o'), |
|
1463 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1464 | 1464 | '.badge-primary' => array('b'), |
1465 | - '.alert-primary' => array('b','o'), |
|
1465 | + '.alert-primary' => array('b', 'o'), |
|
1466 | 1466 | '.progress-bar' => array('b'), |
1467 | - '.list-group-item.active' => array('b','o'), |
|
1468 | - '.bg-primary' => array('b','f'), |
|
1467 | + '.list-group-item.active' => array('b', 'o'), |
|
1468 | + '.bg-primary' => array('b', 'f'), |
|
1469 | 1469 | '.btn-link.btn-primary' => array('c'), |
1470 | 1470 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1471 | 1471 | ); |
1472 | 1472 | |
1473 | 1473 | $important_selectors = array( |
1474 | - '.bg-primary' => array('b','f'), |
|
1474 | + '.bg-primary' => array('b', 'f'), |
|
1475 | 1475 | '.border-primary' => array('o'), |
1476 | 1476 | '.text-primary' => array('c'), |
1477 | 1477 | ); |
@@ -1488,116 +1488,116 @@ discard block |
||
1488 | 1488 | $output = ''; |
1489 | 1489 | |
1490 | 1490 | // build rules into each type |
1491 | - foreach($selectors as $selector => $types){ |
|
1492 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1493 | - $types = array_combine($types,$types); |
|
1494 | - if(isset($types['c'])){$color[] = $selector;} |
|
1495 | - if(isset($types['b'])){$background[] = $selector;} |
|
1496 | - if(isset($types['o'])){$border[] = $selector;} |
|
1497 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1491 | + foreach ($selectors as $selector => $types) { |
|
1492 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1493 | + $types = array_combine($types, $types); |
|
1494 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1495 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1496 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1497 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | // build rules into each type |
1501 | - foreach($important_selectors as $selector => $types){ |
|
1502 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1503 | - $types = array_combine($types,$types); |
|
1504 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1505 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1506 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1507 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1501 | + foreach ($important_selectors as $selector => $types) { |
|
1502 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1503 | + $types = array_combine($types, $types); |
|
1504 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1505 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1506 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1507 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | // add any color rules |
1511 | - if(!empty($color)){ |
|
1512 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1511 | + if (!empty($color)) { |
|
1512 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1513 | 1513 | } |
1514 | - if(!empty($color_i)){ |
|
1515 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1514 | + if (!empty($color_i)) { |
|
1515 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | 1518 | // add any background color rules |
1519 | - if(!empty($background)){ |
|
1520 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1519 | + if (!empty($background)) { |
|
1520 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1521 | 1521 | } |
1522 | - if(!empty($background_i)){ |
|
1523 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1522 | + if (!empty($background_i)) { |
|
1523 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1524 | 1524 | } |
1525 | 1525 | |
1526 | 1526 | // add any border color rules |
1527 | - if(!empty($border)){ |
|
1528 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1527 | + if (!empty($border)) { |
|
1528 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1529 | 1529 | } |
1530 | - if(!empty($border_i)){ |
|
1531 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1530 | + if (!empty($border_i)) { |
|
1531 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | // add any fill color rules |
1535 | - if(!empty($fill)){ |
|
1536 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1535 | + if (!empty($fill)) { |
|
1536 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1537 | 1537 | } |
1538 | - if(!empty($fill_i)){ |
|
1539 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1538 | + if (!empty($fill_i)) { |
|
1539 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1540 | 1540 | } |
1541 | 1541 | |
1542 | 1542 | |
1543 | 1543 | $prefix = $compatibility ? ".bsui " : ""; |
1544 | 1544 | |
1545 | 1545 | // darken |
1546 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1547 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1548 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1546 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1547 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1548 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1549 | 1549 | |
1550 | 1550 | // lighten |
1551 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1551 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1552 | 1552 | |
1553 | 1553 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1554 | - $op_25 = $color_code."40"; // 25% opacity |
|
1554 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1555 | 1555 | |
1556 | 1556 | |
1557 | 1557 | // button states |
1558 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1559 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1560 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1561 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1558 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1559 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1560 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1561 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1562 | 1562 | |
1563 | 1563 | |
1564 | 1564 | // dropdown's |
1565 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1565 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1566 | 1566 | |
1567 | 1567 | |
1568 | 1568 | // input states |
1569 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1569 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1570 | 1570 | |
1571 | 1571 | // page link |
1572 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1572 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | 1573 | |
1574 | 1574 | return $output; |
1575 | 1575 | } |
1576 | 1576 | |
1577 | - public static function css_secondary($color_code,$compatibility){; |
|
1577 | + public static function css_secondary($color_code, $compatibility) {; |
|
1578 | 1578 | $color_code = sanitize_hex_color($color_code); |
1579 | - if(!$color_code){return '';} |
|
1579 | + if (!$color_code) {return ''; } |
|
1580 | 1580 | /** |
1581 | 1581 | * c = color, b = background color, o = border-color, f = fill |
1582 | 1582 | */ |
1583 | 1583 | $selectors = array( |
1584 | - '.btn-secondary' => array('b','o'), |
|
1585 | - '.btn-secondary.disabled' => array('b','o'), |
|
1586 | - '.btn-secondary:disabled' => array('b','o'), |
|
1587 | - '.btn-outline-secondary' => array('c','o'), |
|
1588 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1584 | + '.btn-secondary' => array('b', 'o'), |
|
1585 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1586 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1587 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1588 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1589 | 1589 | '.btn-outline-secondary.disabled' => array('c'), |
1590 | 1590 | '.btn-outline-secondary:disabled' => array('c'), |
1591 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1592 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1593 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1591 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1592 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1593 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1594 | 1594 | '.badge-secondary' => array('b'), |
1595 | - '.alert-secondary' => array('b','o'), |
|
1595 | + '.alert-secondary' => array('b', 'o'), |
|
1596 | 1596 | '.btn-link.btn-secondary' => array('c'), |
1597 | 1597 | ); |
1598 | 1598 | |
1599 | 1599 | $important_selectors = array( |
1600 | - '.bg-secondary' => array('b','f'), |
|
1600 | + '.bg-secondary' => array('b', 'f'), |
|
1601 | 1601 | '.border-secondary' => array('o'), |
1602 | 1602 | '.text-secondary' => array('c'), |
1603 | 1603 | ); |
@@ -1614,77 +1614,77 @@ discard block |
||
1614 | 1614 | $output = ''; |
1615 | 1615 | |
1616 | 1616 | // build rules into each type |
1617 | - foreach($selectors as $selector => $types){ |
|
1618 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1619 | - $types = array_combine($types,$types); |
|
1620 | - if(isset($types['c'])){$color[] = $selector;} |
|
1621 | - if(isset($types['b'])){$background[] = $selector;} |
|
1622 | - if(isset($types['o'])){$border[] = $selector;} |
|
1623 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1617 | + foreach ($selectors as $selector => $types) { |
|
1618 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1619 | + $types = array_combine($types, $types); |
|
1620 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1621 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1622 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1623 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | // build rules into each type |
1627 | - foreach($important_selectors as $selector => $types){ |
|
1628 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1629 | - $types = array_combine($types,$types); |
|
1630 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1631 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1632 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1633 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1627 | + foreach ($important_selectors as $selector => $types) { |
|
1628 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1629 | + $types = array_combine($types, $types); |
|
1630 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1631 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1632 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1633 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | // add any color rules |
1637 | - if(!empty($color)){ |
|
1638 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1637 | + if (!empty($color)) { |
|
1638 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1639 | 1639 | } |
1640 | - if(!empty($color_i)){ |
|
1641 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1640 | + if (!empty($color_i)) { |
|
1641 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | // add any background color rules |
1645 | - if(!empty($background)){ |
|
1646 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1645 | + if (!empty($background)) { |
|
1646 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1647 | 1647 | } |
1648 | - if(!empty($background_i)){ |
|
1649 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1648 | + if (!empty($background_i)) { |
|
1649 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | // add any border color rules |
1653 | - if(!empty($border)){ |
|
1654 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1653 | + if (!empty($border)) { |
|
1654 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1655 | 1655 | } |
1656 | - if(!empty($border_i)){ |
|
1657 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1656 | + if (!empty($border_i)) { |
|
1657 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | // add any fill color rules |
1661 | - if(!empty($fill)){ |
|
1662 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1661 | + if (!empty($fill)) { |
|
1662 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1663 | 1663 | } |
1664 | - if(!empty($fill_i)){ |
|
1665 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1664 | + if (!empty($fill_i)) { |
|
1665 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | |
1669 | 1669 | $prefix = $compatibility ? ".bsui " : ""; |
1670 | 1670 | |
1671 | 1671 | // darken |
1672 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1673 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1674 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1672 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1673 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1674 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1675 | 1675 | |
1676 | 1676 | // lighten |
1677 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1677 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1678 | 1678 | |
1679 | 1679 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1680 | - $op_25 = $color_code."40"; // 25% opacity |
|
1680 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1681 | 1681 | |
1682 | 1682 | |
1683 | 1683 | // button states |
1684 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1685 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1686 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1687 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1684 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1685 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1686 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1687 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1688 | 1688 | |
1689 | 1689 | |
1690 | 1690 | return $output; |
@@ -1720,8 +1720,8 @@ discard block |
||
1720 | 1720 | /** |
1721 | 1721 | * Check if we should display examples. |
1722 | 1722 | */ |
1723 | - public function maybe_show_examples(){ |
|
1724 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1723 | + public function maybe_show_examples() { |
|
1724 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
1725 | 1725 | echo "<head>"; |
1726 | 1726 | wp_head(); |
1727 | 1727 | echo "</head>"; |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | * |
1738 | 1738 | * @return string |
1739 | 1739 | */ |
1740 | - public function get_examples(){ |
|
1740 | + public function get_examples() { |
|
1741 | 1741 | $output = ''; |
1742 | 1742 | |
1743 | 1743 | |
@@ -1843,74 +1843,74 @@ discard block |
||
1843 | 1843 | */ |
1844 | 1844 | public static function calendar_params() { |
1845 | 1845 | $params = array( |
1846 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1847 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1848 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1849 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1850 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1851 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1852 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1853 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1854 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1855 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1856 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1857 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1858 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1859 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1860 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1861 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1862 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1863 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1864 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1865 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1866 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1867 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1868 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1869 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1870 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1871 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1872 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1873 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1874 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1875 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1876 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1877 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1878 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1879 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1880 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1881 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1882 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1883 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1884 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1885 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1886 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1887 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1888 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1889 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1890 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1891 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1892 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1893 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1894 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1895 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1896 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1897 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1898 | - 'am_lower' => __( 'am', 'aui' ), |
|
1899 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1900 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1901 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1902 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1846 | + 'month_long_1' => __('January', 'aui'), |
|
1847 | + 'month_long_2' => __('February', 'aui'), |
|
1848 | + 'month_long_3' => __('March', 'aui'), |
|
1849 | + 'month_long_4' => __('April', 'aui'), |
|
1850 | + 'month_long_5' => __('May', 'aui'), |
|
1851 | + 'month_long_6' => __('June', 'aui'), |
|
1852 | + 'month_long_7' => __('July', 'aui'), |
|
1853 | + 'month_long_8' => __('August', 'aui'), |
|
1854 | + 'month_long_9' => __('September', 'aui'), |
|
1855 | + 'month_long_10' => __('October', 'aui'), |
|
1856 | + 'month_long_11' => __('November', 'aui'), |
|
1857 | + 'month_long_12' => __('December', 'aui'), |
|
1858 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
1859 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
1860 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
1861 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
1862 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
1863 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
1864 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
1865 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
1866 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
1867 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
1868 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
1869 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
1870 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
1871 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
1872 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
1873 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
1874 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
1875 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
1876 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
1877 | + 'day_s2_1' => __('Su', 'aui'), |
|
1878 | + 'day_s2_2' => __('Mo', 'aui'), |
|
1879 | + 'day_s2_3' => __('Tu', 'aui'), |
|
1880 | + 'day_s2_4' => __('We', 'aui'), |
|
1881 | + 'day_s2_5' => __('Th', 'aui'), |
|
1882 | + 'day_s2_6' => __('Fr', 'aui'), |
|
1883 | + 'day_s2_7' => __('Sa', 'aui'), |
|
1884 | + 'day_s3_1' => __('Sun', 'aui'), |
|
1885 | + 'day_s3_2' => __('Mon', 'aui'), |
|
1886 | + 'day_s3_3' => __('Tue', 'aui'), |
|
1887 | + 'day_s3_4' => __('Wed', 'aui'), |
|
1888 | + 'day_s3_5' => __('Thu', 'aui'), |
|
1889 | + 'day_s3_6' => __('Fri', 'aui'), |
|
1890 | + 'day_s3_7' => __('Sat', 'aui'), |
|
1891 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
1892 | + 'day_s5_2' => __('Monday', 'aui'), |
|
1893 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
1894 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
1895 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
1896 | + 'day_s5_6' => __('Friday', 'aui'), |
|
1897 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
1898 | + 'am_lower' => __('am', 'aui'), |
|
1899 | + 'pm_lower' => __('pm', 'aui'), |
|
1900 | + 'am_upper' => __('AM', 'aui'), |
|
1901 | + 'pm_upper' => __('PM', 'aui'), |
|
1902 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
1903 | 1903 | 'time_24hr' => false, |
1904 | - 'year' => __( 'Year', 'aui' ), |
|
1905 | - 'hour' => __( 'Hour', 'aui' ), |
|
1906 | - 'minute' => __( 'Minute', 'aui' ), |
|
1907 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1908 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1909 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1910 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1904 | + 'year' => __('Year', 'aui'), |
|
1905 | + 'hour' => __('Hour', 'aui'), |
|
1906 | + 'minute' => __('Minute', 'aui'), |
|
1907 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
1908 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
1909 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
1910 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
1911 | 1911 | ); |
1912 | 1912 | |
1913 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1913 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
1914 | 1914 | } |
1915 | 1915 | |
1916 | 1916 | /** |
@@ -1923,47 +1923,47 @@ discard block |
||
1923 | 1923 | public static function flatpickr_locale() { |
1924 | 1924 | $params = self::calendar_params(); |
1925 | 1925 | |
1926 | - if ( is_string( $params ) ) { |
|
1927 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1926 | + if (is_string($params)) { |
|
1927 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
1928 | 1928 | } else { |
1929 | - foreach ( (array) $params as $key => $value ) { |
|
1930 | - if ( ! is_scalar( $value ) ) { |
|
1929 | + foreach ((array) $params as $key => $value) { |
|
1930 | + if (!is_scalar($value)) { |
|
1931 | 1931 | continue; |
1932 | 1932 | } |
1933 | 1933 | |
1934 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1934 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1935 | 1935 | } |
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | $day_s3 = array(); |
1939 | 1939 | $day_s5 = array(); |
1940 | 1940 | |
1941 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1942 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1943 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1941 | + for ($i = 1; $i <= 7; $i++) { |
|
1942 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
1943 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | $month_s = array(); |
1947 | 1947 | $month_long = array(); |
1948 | 1948 | |
1949 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1950 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1951 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1949 | + for ($i = 1; $i <= 12; $i++) { |
|
1950 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
1951 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
1952 | 1952 | } |
1953 | 1953 | |
1954 | 1954 | ob_start(); |
1955 | -if ( 0 ) { ?><script><?php } ?> |
|
1955 | +if (0) { ?><script><?php } ?> |
|
1956 | 1956 | { |
1957 | 1957 | weekdays: { |
1958 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
1959 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
1958 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
1959 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
1960 | 1960 | }, |
1961 | 1961 | months: { |
1962 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
1963 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
1962 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
1963 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
1964 | 1964 | }, |
1965 | 1965 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
1966 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
1966 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
1967 | 1967 | ordinal: function (nth) { |
1968 | 1968 | var s = nth % 100; |
1969 | 1969 | if (s > 3 && s < 21) |
@@ -1979,21 +1979,21 @@ discard block |
||
1979 | 1979 | return "th"; |
1980 | 1980 | } |
1981 | 1981 | }, |
1982 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
1983 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
1984 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
1985 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
1986 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
1987 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
1988 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
1989 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
1990 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
1982 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
1983 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
1984 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
1985 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
1986 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
1987 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
1988 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
1989 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
1990 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
1991 | 1991 | } |
1992 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
1992 | +<?php if (0) { ?></script><?php } ?> |
|
1993 | 1993 | <?php |
1994 | 1994 | $locale = ob_get_clean(); |
1995 | 1995 | |
1996 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
1996 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | /** |
@@ -2005,20 +2005,20 @@ discard block |
||
2005 | 2005 | */ |
2006 | 2006 | public static function select2_params() { |
2007 | 2007 | $params = array( |
2008 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2009 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2010 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2011 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2012 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2013 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2014 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2015 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2016 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2017 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2018 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2008 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
2009 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
2010 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
2011 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
2012 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
2013 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
2014 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
2015 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
2016 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
2017 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
2018 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
2019 | 2019 | ); |
2020 | 2020 | |
2021 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2021 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
2022 | 2022 | } |
2023 | 2023 | |
2024 | 2024 | /** |
@@ -2031,17 +2031,17 @@ discard block |
||
2031 | 2031 | public static function select2_locale() { |
2032 | 2032 | $params = self::select2_params(); |
2033 | 2033 | |
2034 | - foreach ( (array) $params as $key => $value ) { |
|
2035 | - if ( ! is_scalar( $value ) ) { |
|
2034 | + foreach ((array) $params as $key => $value) { |
|
2035 | + if (!is_scalar($value)) { |
|
2036 | 2036 | continue; |
2037 | 2037 | } |
2038 | 2038 | |
2039 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2039 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2040 | 2040 | } |
2041 | 2041 | |
2042 | - $locale = json_encode( $params ); |
|
2042 | + $locale = json_encode($params); |
|
2043 | 2043 | |
2044 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2044 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
2045 | 2045 | } |
2046 | 2046 | |
2047 | 2047 | /** |
@@ -2054,35 +2054,35 @@ discard block |
||
2054 | 2054 | public static function timeago_locale() { |
2055 | 2055 | $params = array( |
2056 | 2056 | 'prefix_ago' => '', |
2057 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2058 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2057 | + 'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'), |
|
2058 | + 'prefix_after' => _x('after', 'time ago', 'aui') . ' ', |
|
2059 | 2059 | 'suffix_after' => '', |
2060 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2061 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2062 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2063 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2064 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2065 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2066 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2067 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2068 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2069 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2070 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2060 | + 'seconds' => _x('less than a minute', 'time ago', 'aui'), |
|
2061 | + 'minute' => _x('about a minute', 'time ago', 'aui'), |
|
2062 | + 'minutes' => _x('%d minutes', 'time ago', 'aui'), |
|
2063 | + 'hour' => _x('about an hour', 'time ago', 'aui'), |
|
2064 | + 'hours' => _x('about %d hours', 'time ago', 'aui'), |
|
2065 | + 'day' => _x('a day', 'time ago', 'aui'), |
|
2066 | + 'days' => _x('%d days', 'time ago', 'aui'), |
|
2067 | + 'month' => _x('about a month', 'time ago', 'aui'), |
|
2068 | + 'months' => _x('%d months', 'time ago', 'aui'), |
|
2069 | + 'year' => _x('about a year', 'time ago', 'aui'), |
|
2070 | + 'years' => _x('%d years', 'time ago', 'aui'), |
|
2071 | 2071 | ); |
2072 | 2072 | |
2073 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2073 | + $params = apply_filters('ayecode_ui_timeago_params', $params); |
|
2074 | 2074 | |
2075 | - foreach ( (array) $params as $key => $value ) { |
|
2076 | - if ( ! is_scalar( $value ) ) { |
|
2075 | + foreach ((array) $params as $key => $value) { |
|
2076 | + if (!is_scalar($value)) { |
|
2077 | 2077 | continue; |
2078 | 2078 | } |
2079 | 2079 | |
2080 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2080 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2081 | 2081 | } |
2082 | 2082 | |
2083 | - $locale = json_encode( $params ); |
|
2083 | + $locale = json_encode($params); |
|
2084 | 2084 | |
2085 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2085 | + return apply_filters('ayecode_ui_timeago_locale', trim($locale)); |
|
2086 | 2086 | } |
2087 | 2087 | |
2088 | 2088 | /** |
@@ -2093,7 +2093,7 @@ discard block |
||
2093 | 2093 | * @return mixed |
2094 | 2094 | */ |
2095 | 2095 | public static function minify_js($input) { |
2096 | - if(trim($input) === "") return $input; |
|
2096 | + if (trim($input) === "") return $input; |
|
2097 | 2097 | return preg_replace( |
2098 | 2098 | array( |
2099 | 2099 | // Remove comment(s) |
@@ -2125,7 +2125,7 @@ discard block |
||
2125 | 2125 | * @return mixed |
2126 | 2126 | */ |
2127 | 2127 | public static function minify_css($input) { |
2128 | - if(trim($input) === "") return $input; |
|
2128 | + if (trim($input) === "") return $input; |
|
2129 | 2129 | return preg_replace( |
2130 | 2130 | array( |
2131 | 2131 | // Remove comment(s) |
@@ -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 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,52 +119,52 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $merge_tags = array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field(strtolower($invoice->get_label())), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_label())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
150 | + $payment_form_data = $invoice->get_meta('payment_form_data', true); |
|
151 | 151 | |
152 | - if ( is_array( $payment_form_data ) ) { |
|
152 | + if (is_array($payment_form_data)) { |
|
153 | 153 | |
154 | - foreach ( $payment_form_data as $label => $value ) { |
|
154 | + foreach ($payment_form_data as $label => $value) { |
|
155 | 155 | |
156 | - $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | - $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
156 | + $label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label)); |
|
157 | + $value = is_array($value) ? implode(', ', $value) : $value; |
|
158 | 158 | |
159 | - if ( is_scalar ( $value ) ) { |
|
160 | - $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
159 | + if (is_scalar($value)) { |
|
160 | + $merge_tags["{{$label}}"] = wp_kses_post($value); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
167 | + return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * @param string|array $recipients |
177 | 177 | * @param array $extra_args Extra template args. |
178 | 178 | */ |
179 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
179 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
180 | 180 | |
181 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
181 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
182 | 182 | |
183 | - if ( apply_filters( 'getpaid_skip_invoice_email', false, $type, $invoice ) ) { |
|
183 | + if (apply_filters('getpaid_skip_invoice_email', false, $type, $invoice)) { |
|
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
@@ -188,29 +188,29 @@ discard block |
||
188 | 188 | $merge_tags = $email->get_merge_tags(); |
189 | 189 | |
190 | 190 | $result = $mailer->send( |
191 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
192 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
193 | - $email->get_content( $merge_tags, $extra_args ), |
|
191 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
192 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
193 | + $email->get_content($merge_tags, $extra_args), |
|
194 | 194 | $email->get_attachments() |
195 | 195 | ); |
196 | 196 | |
197 | 197 | // Maybe send a copy to the admin. |
198 | - if ( $email->include_admin_bcc() ) { |
|
198 | + if ($email->include_admin_bcc()) { |
|
199 | 199 | $mailer->send( |
200 | 200 | wpinv_get_admin_email(), |
201 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
202 | - $email->get_content( $merge_tags ), |
|
201 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
202 | + $email->get_content($merge_tags), |
|
203 | 203 | $email->get_attachments() |
204 | 204 | ); |
205 | 205 | } |
206 | 206 | |
207 | - if ( $result ) { |
|
208 | - $invoice->add_note( sprintf( __( 'Successfully sent %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
207 | + if ($result) { |
|
208 | + $invoice->add_note(sprintf(__('Successfully sent %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
209 | 209 | } else { |
210 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
210 | + $invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
211 | 211 | } |
212 | 212 | |
213 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
213 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
214 | 214 | |
215 | 215 | return $result; |
216 | 216 | } |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | * @param array $recipients |
222 | 222 | * @param GetPaid_Notification_Email $email |
223 | 223 | */ |
224 | - public function filter_email_recipients( $recipients, $email ) { |
|
224 | + public function filter_email_recipients($recipients, $email) { |
|
225 | 225 | |
226 | - if ( ! $email->is_admin_email() ) { |
|
226 | + if (!$email->is_admin_email()) { |
|
227 | 227 | $cc = $email->object->get_email_cc(); |
228 | 228 | |
229 | - if ( ! empty( $cc ) ) { |
|
230 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
231 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
229 | + if (!empty($cc)) { |
|
230 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
231 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | } |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @param WPInv_Invoice $invoice |
244 | 244 | */ |
245 | - public function new_invoice( $invoice ) { |
|
245 | + public function new_invoice($invoice) { |
|
246 | 246 | |
247 | 247 | // Only send this email for invoices created via the admin page. |
248 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
248 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
249 | 249 | return; |
250 | 250 | } |
251 | 251 | |
252 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
252 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
253 | 253 | $recipient = wpinv_get_admin_email(); |
254 | 254 | |
255 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
255 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
256 | 256 | |
257 | 257 | } |
258 | 258 | |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param WPInv_Invoice $invoice |
263 | 263 | */ |
264 | - public function cancelled_invoice( $invoice ) { |
|
264 | + public function cancelled_invoice($invoice) { |
|
265 | 265 | |
266 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
266 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
267 | 267 | $recipient = wpinv_get_admin_email(); |
268 | 268 | |
269 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
269 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param WPInv_Invoice $invoice |
277 | 277 | */ |
278 | - public function failed_invoice( $invoice ) { |
|
278 | + public function failed_invoice($invoice) { |
|
279 | 279 | |
280 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
280 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
281 | 281 | $recipient = wpinv_get_admin_email(); |
282 | 282 | |
283 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
283 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
284 | 284 | |
285 | 285 | } |
286 | 286 | |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @param WPInv_Invoice $invoice |
291 | 291 | */ |
292 | - public function onhold_invoice( $invoice ) { |
|
292 | + public function onhold_invoice($invoice) { |
|
293 | 293 | |
294 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
294 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
295 | 295 | $recipient = $invoice->get_email(); |
296 | 296 | |
297 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
297 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
298 | 298 | |
299 | 299 | } |
300 | 300 | |
@@ -303,12 +303,12 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param WPInv_Invoice $invoice |
305 | 305 | */ |
306 | - public function processing_invoice( $invoice ) { |
|
306 | + public function processing_invoice($invoice) { |
|
307 | 307 | |
308 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
308 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
309 | 309 | $recipient = $invoice->get_email(); |
310 | 310 | |
311 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
311 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
@@ -317,17 +317,17 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @param WPInv_Invoice $invoice |
319 | 319 | */ |
320 | - public function completed_invoice( $invoice ) { |
|
320 | + public function completed_invoice($invoice) { |
|
321 | 321 | |
322 | 322 | // (Maybe) abort if it is a renewal invoice. |
323 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
323 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
327 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
328 | 328 | $recipient = $invoice->get_email(); |
329 | 329 | |
330 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
330 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
331 | 331 | |
332 | 332 | } |
333 | 333 | |
@@ -336,12 +336,12 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @param WPInv_Invoice $invoice |
338 | 338 | */ |
339 | - public function refunded_invoice( $invoice ) { |
|
339 | + public function refunded_invoice($invoice) { |
|
340 | 340 | |
341 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
341 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
342 | 342 | $recipient = $invoice->get_email(); |
343 | 343 | |
344 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
344 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
345 | 345 | |
346 | 346 | } |
347 | 347 | |
@@ -351,21 +351,21 @@ discard block |
||
351 | 351 | * @param WPInv_Invoice $invoice |
352 | 352 | * @param bool $force |
353 | 353 | */ |
354 | - public function user_invoice( $invoice, $force = false ) { |
|
354 | + public function user_invoice($invoice, $force = false) { |
|
355 | 355 | |
356 | - if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
356 | + if (!empty($GLOBALS['wpinv_skip_invoice_notification'])) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | 360 | // Only send this email for invoices created via the admin page. |
361 | - if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) { |
|
361 | + if (!$invoice->is_type('invoice') || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) { |
|
362 | 362 | return; |
363 | 363 | } |
364 | 364 | |
365 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
365 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
366 | 366 | $recipient = $invoice->get_email(); |
367 | 367 | |
368 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
368 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
369 | 369 | |
370 | 370 | } |
371 | 371 | |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | * @param int $invoice |
376 | 376 | * @return bool |
377 | 377 | */ |
378 | - public function is_payment_form_invoice( $invoice ) { |
|
379 | - $is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
380 | - return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice ); |
|
378 | + public function is_payment_form_invoice($invoice) { |
|
379 | + $is_payment_form_invoice = empty($_GET['getpaid-admin-action']) && ('payment_form' == get_post_meta($invoice, 'wpinv_created_via', true) || 'geodirectory' == get_post_meta($invoice, 'wpinv_created_via', true)); |
|
380 | + return apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -386,12 +386,12 @@ discard block |
||
386 | 386 | * @param WPInv_Invoice $invoice |
387 | 387 | * @param string $note |
388 | 388 | */ |
389 | - public function user_note( $invoice, $note ) { |
|
389 | + public function user_note($invoice, $note) { |
|
390 | 390 | |
391 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
391 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
392 | 392 | $recipient = $invoice->get_email(); |
393 | 393 | |
394 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
394 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @param WPInv_Invoice $invoice |
402 | 402 | */ |
403 | - public function force_send_overdue_notice( $invoice ) { |
|
404 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
405 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
403 | + public function force_send_overdue_notice($invoice) { |
|
404 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
405 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -413,37 +413,37 @@ discard block |
||
413 | 413 | public function overdue() { |
414 | 414 | global $wpdb; |
415 | 415 | |
416 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
416 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
417 | 417 | |
418 | 418 | // Fetch reminder days. |
419 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
419 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
420 | 420 | |
421 | 421 | // Abort if non is set. |
422 | - if ( empty( $reminder_days ) ) { |
|
422 | + if (empty($reminder_days)) { |
|
423 | 423 | return; |
424 | 424 | } |
425 | 425 | |
426 | 426 | // Retrieve date query. |
427 | - $date_query = $this->get_date_query( $reminder_days ); |
|
427 | + $date_query = $this->get_date_query($reminder_days); |
|
428 | 428 | |
429 | 429 | // Invoices table. |
430 | 430 | $table = $wpdb->prefix . 'getpaid_invoices'; |
431 | 431 | |
432 | 432 | // Fetch invoices. |
433 | - $invoices = $wpdb->get_col( |
|
433 | + $invoices = $wpdb->get_col( |
|
434 | 434 | "SELECT posts.ID FROM $wpdb->posts as posts |
435 | 435 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
436 | 436 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
437 | 437 | |
438 | - foreach ( $invoices as $invoice ) { |
|
438 | + foreach ($invoices as $invoice) { |
|
439 | 439 | |
440 | 440 | // Only send this email for invoices created via the admin page. |
441 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
442 | - $invoice = new WPInv_Invoice( $invoice ); |
|
441 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
442 | + $invoice = new WPInv_Invoice($invoice); |
|
443 | 443 | $email->object = $invoice; |
444 | 444 | |
445 | - if ( $invoice->needs_payment() ) { |
|
446 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
445 | + if ($invoice->needs_payment()) { |
|
446 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | } |
@@ -458,14 +458,14 @@ discard block |
||
458 | 458 | * @param array $reminder_days |
459 | 459 | * @return string |
460 | 460 | */ |
461 | - public function get_date_query( $reminder_days ) { |
|
461 | + public function get_date_query($reminder_days) { |
|
462 | 462 | |
463 | 463 | $date_query = array( |
464 | 464 | 'relation' => 'OR' |
465 | 465 | ); |
466 | 466 | |
467 | - foreach ( $reminder_days as $days ) { |
|
468 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
467 | + foreach ($reminder_days as $days) { |
|
468 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
469 | 469 | |
470 | 470 | $date_query[] = array( |
471 | 471 | 'year' => $date['year'], |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
478 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
479 | 479 | |
480 | 480 | return $date_query->get_sql(); |
481 | 481 |
@@ -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 | * This function is responsible for sending emails. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
35 | + public function send($to, $subject, $email, $attachments = array()) { |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * Allow to filter data on per-email basis. |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $data = apply_filters( |
41 | 41 | 'getpaid_email_data', |
42 | 42 | array( |
43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
45 | - 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
43 | + 'to' => array_filter(array_unique(wpinv_parse_list($to))), |
|
44 | + 'subject' => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES), |
|
45 | + 'email' => apply_filters('wpinv_mail_content', $email), |
|
46 | 46 | 'headers' => $this->get_headers(), |
47 | 47 | 'attachments' => $attachments, |
48 | 48 | ), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Remove slashes. |
53 | - $data = (array) wp_unslash( $data ); |
|
53 | + $data = (array) wp_unslash($data); |
|
54 | 54 | |
55 | 55 | // Cache it. |
56 | 56 | $this->wp_mail_data = $data; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | $result = false; |
62 | 62 | |
63 | - foreach ( $this->wp_mail_data['to'] as $to ) { |
|
64 | - $result = $this->_send( $to, $data ); |
|
63 | + foreach ($this->wp_mail_data['to'] as $to) { |
|
64 | + $result = $this->_send($to, $data); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Remove our hooks. |
@@ -82,24 +82,24 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - protected function _send( $to, $data ) { |
|
85 | + protected function _send($to, $data) { |
|
86 | 86 | |
87 | 87 | // Prepare the sending function. |
88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
88 | + $sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail'); |
|
89 | 89 | |
90 | 90 | // Send the actual email. |
91 | 91 | $result = call_user_func( |
92 | 92 | $sending_function, |
93 | 93 | $to, |
94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
94 | + html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')), |
|
95 | 95 | $data['email'], |
96 | 96 | $data['headers'], |
97 | 97 | $data['attachments'] |
98 | 98 | ); |
99 | 99 | |
100 | - if ( ! $result ) { |
|
101 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
100 | + if (!$result) { |
|
101 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']); |
|
102 | + wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $result; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | $name = $this->get_from_name(); |
114 | 114 | $reply_to = $this->get_reply_to(); |
115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
115 | + $headers = array("Reply-To:$name <$reply_to>"); |
|
116 | 116 | |
117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
117 | + return apply_filters('getpaid_email_headers', $headers, $this); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function before_sending() { |
127 | 127 | |
128 | - do_action( 'getpaid_before_send_email', $this ); |
|
129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
128 | + do_action('getpaid_before_send_email', $this); |
|
129 | + add_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
130 | + add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
131 | + add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
132 | + add_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function get_from_name() { |
140 | 140 | |
141 | - $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
|
141 | + $from_name = wpinv_get_option('email_from_name', get_bloginfo('name')); |
|
142 | 142 | |
143 | - if ( empty( $from_name ) ) { |
|
144 | - $from_name = get_bloginfo( 'name' ); |
|
143 | + if (empty($from_name)) { |
|
144 | + $from_name = get_bloginfo('name'); |
|
145 | 145 | } |
146 | 146 | |
147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
147 | + return wp_specialchars_decode($from_name, ENT_QUOTES); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function get_from_address() { |
154 | 154 | |
155 | - $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
|
155 | + $from_address = wpinv_get_option('email_from', $this->default_from_address()); |
|
156 | 156 | |
157 | - if ( ! is_email( $from_address ) ) { |
|
158 | - $from_address = $this->default_from_address(); |
|
157 | + if (!is_email($from_address)) { |
|
158 | + $from_address = $this->default_from_address(); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $from_address; |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | public function default_from_address() { |
175 | 175 | |
176 | 176 | // Get the site domain and get rid of www. |
177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
179 | - $sitename = substr( $sitename, 4 ); |
|
177 | + $sitename = strtolower($_SERVER['SERVER_NAME']); |
|
178 | + if (substr($sitename, 0, 4) == 'www.') { |
|
179 | + $sitename = substr($sitename, 4); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $from_email = 'wordpress@' . $sitename; |
183 | 183 | |
184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
184 | + return apply_filters('getpaid_default_from_address', $from_email); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | |
196 | 196 | $reply_to = wpinv_get_admin_email(); |
197 | 197 | |
198 | - if ( ! is_email( $reply_to ) ) { |
|
199 | - $reply_to = get_option( 'admin_email' ); |
|
198 | + if (!is_email($reply_to)) { |
|
199 | + $reply_to = get_option('admin_email'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $reply_to; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | */ |
209 | 209 | public function get_content_type() { |
210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
210 | + return apply_filters('getpaid_email_content_type', 'text/html', $this); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return array wp_mail_data. |
217 | 217 | */ |
218 | - public function ensure_email_content( $args ) { |
|
218 | + public function ensure_email_content($args) { |
|
219 | 219 | $args['message'] = $this->wp_mail_data['email']; |
220 | 220 | return $args; |
221 | 221 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function after_sending() { |
228 | 228 | |
229 | - do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
|
230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
229 | + do_action('getpaid_after_send_email', $this->wp_mail_data); |
|
230 | + remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
231 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
232 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
233 | + remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->exists()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,45 +95,45 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | 100 | |
101 | 101 | $subscription_id = $sub->get_id(); |
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
104 | 104 | |
105 | - if ( 1 < count( $subscription_groups ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
105 | + if (1 < count($subscription_groups)) { |
|
106 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
107 | 107 | } |
108 | 108 | |
109 | - if ( ! empty( $subscription_group ) ) { |
|
110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
109 | + if (!empty($subscription_group)) { |
|
110 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
111 | 111 | } |
112 | 112 | |
113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
113 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
114 | 114 | |
115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
115 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
116 | 116 | |
117 | 117 | ?> |
118 | 118 | |
119 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
119 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
120 | 120 | |
121 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
122 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
123 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
121 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
122 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
123 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
124 | 124 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
125 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
125 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
126 | 126 | |
127 | 127 | <div id="poststuff"> |
128 | 128 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
129 | 129 | |
130 | 130 | <div id="postbox-container-1" class="postbox-container"> |
131 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
131 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
132 | 132 | </div> |
133 | 133 | |
134 | 134 | <div id="postbox-container-2" class="postbox-container"> |
135 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
136 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
135 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
136 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
137 | 137 | </div> |
138 | 138 | |
139 | 139 | </div> |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param WPInv_Subscription $sub |
154 | 154 | */ |
155 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
155 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
156 | 156 | |
157 | 157 | // Subscription items. |
158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
158 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
159 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
160 | 160 | |
161 | 161 | // Prepare subscription detail columns. |
162 | 162 | $fields = apply_filters( |
163 | 163 | 'getpaid_subscription_admin_page_fields', |
164 | 164 | array( |
165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | - 'status' => __( 'Status', 'invoicing' ), |
|
165 | + 'subscription' => __('Subscription', 'invoicing'), |
|
166 | + 'customer' => __('Customer', 'invoicing'), |
|
167 | + 'amount' => __('Amount', 'invoicing'), |
|
168 | + 'start_date' => __('Start Date', 'invoicing'), |
|
169 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
170 | + 'renewals' => __('Payments', 'invoicing'), |
|
171 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
172 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
173 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
174 | + 'status' => __('Status', 'invoicing'), |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | |
178 | - if ( ! $sub->is_active() ) { |
|
178 | + if (!$sub->is_active()) { |
|
179 | 179 | |
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
180 | + if (isset($fields['renews_on'])) { |
|
181 | + unset($fields['renews_on']); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
184 | + if (isset($fields['gateway'])) { |
|
185 | + unset($fields['gateway']); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $profile_id = $sub->get_profile_id(); |
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
192 | + unset($fields['profile_id']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
199 | 199 | |
200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
200 | + <?php foreach ($fields as $key => $label) : ?> |
|
201 | 201 | |
202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
203 | 203 | |
204 | 204 | <th class="w-25" style="font-weight: 500;"> |
205 | - <?php echo sanitize_text_field( $label ); ?> |
|
205 | + <?php echo sanitize_text_field($label); ?> |
|
206 | 206 | </th> |
207 | 207 | |
208 | 208 | <td class="w-75 text-muted"> |
209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub, $subscription_group ); ?> |
|
209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub, $subscription_group); ?> |
|
210 | 210 | </td> |
211 | 211 | |
212 | 212 | </tr> |
@@ -224,129 +224,129 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param WPInv_Subscription $subscription |
226 | 226 | */ |
227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __('(Missing User)', 'invoicing'); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata($subscription->get_customer_id()); |
|
232 | + if ($user) { |
|
233 | 233 | |
234 | 234 | $username = sprintf( |
235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
236 | + absint($user->ID), |
|
237 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | 242 | echo $username; |
243 | 243 | } |
244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Displays the subscription amount. |
248 | 248 | * |
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
252 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
253 | 253 | echo "<span>$amount</span>"; |
254 | 254 | } |
255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Displays the subscription id. |
259 | 259 | * |
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
263 | - echo '#' . absint( $subscription->get_id() ); |
|
262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
263 | + echo '#' . absint($subscription->get_id()); |
|
264 | 264 | } |
265 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
265 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Displays the subscription renewal date. |
269 | 269 | * |
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
272 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
273 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
274 | 274 | } |
275 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
275 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Displays the subscription renewal date. |
279 | 279 | * |
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
282 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
283 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
284 | 284 | } |
285 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
285 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Displays the subscription renewal count. |
289 | 289 | * |
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
292 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
293 | 293 | $max_bills = $subscription->get_bill_times(); |
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
295 | 295 | } |
296 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
296 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
297 | 297 | /** |
298 | 298 | * Displays the subscription item. |
299 | 299 | * |
300 | 300 | * @param WPInv_Subscription $subscription |
301 | 301 | * @param false|array $subscription_group |
302 | 302 | */ |
303 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
303 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
305 | + if (empty($subscription_group)) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | - echo implode( ' | ', $markup ); |
|
310 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
311 | + echo implode(' | ', $markup); |
|
312 | 312 | |
313 | 313 | } |
314 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
314 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Displays the subscription gateway. |
318 | 318 | * |
319 | 319 | * @param WPInv_Subscription $subscription |
320 | 320 | */ |
321 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
321 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
322 | 322 | |
323 | 323 | $gateway = $subscription->get_gateway(); |
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
325 | + if (!empty($gateway)) { |
|
326 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
327 | 327 | } else { |
328 | 328 | echo "—"; |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
332 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Displays the subscription status. |
336 | 336 | * |
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
339 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
340 | 340 | echo $subscription->get_status_label_html(); |
341 | 341 | } |
342 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
342 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Displays the subscription profile id. |
346 | 346 | * |
347 | 347 | * @param WPInv_Subscription $subscription |
348 | 348 | */ |
349 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
349 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
350 | 350 | |
351 | 351 | $profile_id = $subscription->get_profile_id(); |
352 | 352 | |
@@ -355,32 +355,32 @@ discard block |
||
355 | 355 | 'type' => 'text', |
356 | 356 | 'id' => 'wpinv_subscription_profile_id', |
357 | 357 | 'name' => 'wpinv_subscription_profile_id', |
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
358 | + 'label' => __('Profile Id', 'invoicing'), |
|
359 | 359 | 'label_type' => 'hidden', |
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => sanitize_text_field( $profile_id ), |
|
360 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
361 | + 'value' => sanitize_text_field($profile_id), |
|
362 | 362 | 'input_group_right' => '', |
363 | 363 | 'no_wrap' => true, |
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
367 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
368 | 368 | |
369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | - if ( ! empty( $url ) ) { |
|
371 | - $url = esc_url_raw( $url ); |
|
372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
369 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
370 | + if (!empty($url)) { |
|
371 | + $url = esc_url_raw($url); |
|
372 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
376 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Displays the subscriptions update metabox. |
380 | 380 | * |
381 | 381 | * @param WPInv_Subscription $subscription |
382 | 382 | */ |
383 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
383 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
384 | 384 | |
385 | 385 | ?> |
386 | 386 | <div class="mt-3"> |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | 'id' => 'subscription_status_update_select', |
394 | 394 | 'required' => true, |
395 | 395 | 'no_wrap' => false, |
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
396 | + 'label' => __('Subscription Status', 'invoicing'), |
|
397 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
398 | 398 | 'select2' => true, |
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
399 | + 'value' => $subscription->get_status('edit'), |
|
400 | 400 | ) |
401 | 401 | ); |
402 | 402 | ?> |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
405 | 405 | |
406 | 406 | <?php |
407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
407 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
408 | 408 | |
409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
409 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
410 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
411 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
412 | 412 | |
413 | - if ( $subscription->is_active() ) { |
|
413 | + if ($subscription->is_active()) { |
|
414 | 414 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
415 | 415 | } |
416 | 416 | |
@@ -423,31 +423,31 @@ discard block |
||
423 | 423 | * @param WPInv_Subscription $subscription |
424 | 424 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
425 | 425 | */ |
426 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
426 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
427 | 427 | |
428 | 428 | $columns = apply_filters( |
429 | 429 | 'getpaid_subscription_related_invoices_columns', |
430 | 430 | array( |
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
431 | + 'invoice' => __('Invoice', 'invoicing'), |
|
432 | + 'relationship' => __('Relationship', 'invoicing'), |
|
433 | + 'date' => __('Date', 'invoicing'), |
|
434 | + 'status' => __('Status', 'invoicing'), |
|
435 | + 'total' => __('Total', 'invoicing'), |
|
436 | 436 | ), |
437 | 437 | $subscription |
438 | 438 | ); |
439 | 439 | |
440 | 440 | // Prepare the invoices. |
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
441 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
442 | 442 | $parent = $subscription->get_parent_invoice(); |
443 | 443 | |
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
444 | + if ($parent->exists()) { |
|
445 | + $payments = array_merge(array($parent), $payments); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | $table_class = 'w-100 bg-white'; |
449 | 449 | |
450 | - if ( ! is_admin() ) { |
|
450 | + if (!is_admin()) { |
|
451 | 451 | $table_class = 'table table-bordered'; |
452 | 452 | } |
453 | 453 | |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = sanitize_text_field( $label ); |
|
462 | + foreach ($columns as $key => $label) { |
|
463 | + $key = esc_attr($key); |
|
464 | + $label = sanitize_text_field($label); |
|
465 | 465 | $class = 'text-left'; |
466 | 466 | |
467 | 467 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -472,57 +472,57 @@ discard block |
||
472 | 472 | |
473 | 473 | <tbody> |
474 | 474 | |
475 | - <?php if ( empty( $payments ) ) : ?> |
|
475 | + <?php if (empty($payments)) : ?> |
|
476 | 476 | <tr> |
477 | 477 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
478 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
478 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
479 | 479 | </td> |
480 | 480 | </tr> |
481 | 481 | <?php endif; ?> |
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach ($payments as $payment) : |
|
486 | 486 | |
487 | 487 | // Ensure that we have an invoice. |
488 | - $payment = new WPInv_Invoice( $payment ); |
|
488 | + $payment = new WPInv_Invoice($payment); |
|
489 | 489 | |
490 | 490 | // Abort if the invoice is invalid... |
491 | - if ( ! $payment->exists() ) { |
|
491 | + if (!$payment->exists()) { |
|
492 | 492 | continue; |
493 | 493 | } |
494 | 494 | |
495 | 495 | // ... or belongs to a different subscription. |
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
496 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
497 | 497 | continue; |
498 | 498 | } |
499 | 499 | |
500 | 500 | echo '<tr>'; |
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach (array_keys($columns) as $key) { |
|
503 | 503 | |
504 | 504 | $class = 'text-left'; |
505 | 505 | |
506 | 506 | echo "<td class='p-2 $class'>"; |
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch ($key) { |
|
509 | 509 | |
510 | 510 | case 'total': |
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
511 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
512 | 512 | break; |
513 | 513 | |
514 | 514 | case 'relationship': |
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
515 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
516 | 516 | break; |
517 | 517 | |
518 | 518 | case 'date': |
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
519 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'status': |
523 | 523 | |
524 | 524 | $status = $payment->get_status_nicename(); |
525 | - if ( is_admin() ) { |
|
525 | + if (is_admin()) { |
|
526 | 526 | $status = $payment->get_status_label_html(); |
527 | 527 | } |
528 | 528 | |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'invoice': |
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
533 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
534 | 534 | |
535 | - if ( ! is_admin() ) { |
|
536 | - $link = esc_url( $payment->get_view_url() ); |
|
535 | + if (!is_admin()) { |
|
536 | + $link = esc_url($payment->get_view_url()); |
|
537 | 537 | } |
538 | 538 | |
539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
539 | + $invoice = sanitize_text_field($payment->get_number()); |
|
540 | 540 | echo "<a href='$link'>$invoice</a>"; |
541 | 541 | break; |
542 | 542 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param WPInv_Subscription $subscription |
566 | 566 | */ |
567 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
567 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
568 | 568 | |
569 | 569 | // Fetch the subscription group. |
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
570 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
571 | 571 | |
572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
572 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | $columns = apply_filters( |
578 | 578 | 'getpaid_subscription_item_details_columns', |
579 | 579 | array( |
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
580 | + 'item_name' => __('Item', 'invoicing'), |
|
581 | + 'price' => __('Price', 'invoicing'), |
|
582 | + 'tax' => __('Tax', 'invoicing'), |
|
583 | + 'discount' => __('Discount', 'invoicing'), |
|
584 | 584 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
585 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
586 | 586 | ), |
587 | 587 | $subscription |
588 | 588 | ); |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | |
592 | 592 | $invoice = $subscription->get_parent_invoice(); |
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
594 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
595 | + unset($columns['tax']); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $table_class = 'w-100 bg-white'; |
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
600 | + if (!is_admin()) { |
|
601 | 601 | $table_class = 'table table-bordered'; |
602 | 602 | } |
603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | <tr> |
611 | 611 | <?php |
612 | 612 | |
613 | - foreach ( $columns as $key => $label ) { |
|
614 | - $key = esc_attr( $key ); |
|
615 | - $label = sanitize_text_field( $label ); |
|
613 | + foreach ($columns as $key => $label) { |
|
614 | + $key = esc_attr($key); |
|
615 | + $label = sanitize_text_field($label); |
|
616 | 616 | $class = 'text-left'; |
617 | 617 | |
618 | 618 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -625,48 +625,48 @@ discard block |
||
625 | 625 | |
626 | 626 | <?php |
627 | 627 | |
628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
628 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
629 | 629 | |
630 | 630 | echo '<tr>'; |
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach (array_keys($columns) as $key) { |
|
633 | 633 | |
634 | 634 | $class = 'text-left'; |
635 | 635 | |
636 | 636 | echo "<td class='p-2 $class'>"; |
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch ($key) { |
|
639 | 639 | |
640 | 640 | case 'item_name': |
641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
642 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo sanitize_text_field( $item_name ); |
|
644 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
645 | + echo sanitize_text_field($item_name); |
|
646 | 646 | } else { |
647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
647 | + printf('%1$s x %2$d', sanitize_text_field($item_name), (float) $subscription_group_item['quantity']); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | break; |
651 | 651 | |
652 | 652 | case 'price': |
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
653 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'tax': |
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
657 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'discount': |
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
661 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'initial': |
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
665 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'recurring': |
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
669 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
670 | 670 | break; |
671 | 671 | |
672 | 672 | } |
@@ -679,24 +679,24 @@ discard block |
||
679 | 679 | |
680 | 680 | endforeach; |
681 | 681 | |
682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
682 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
683 | 683 | |
684 | 684 | echo '<tr>'; |
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach (array_keys($columns) as $key) { |
|
687 | 687 | |
688 | 688 | $class = 'text-left'; |
689 | 689 | |
690 | 690 | echo "<td class='p-2 $class'>"; |
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch ($key) { |
|
693 | 693 | |
694 | 694 | case 'item_name': |
695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
695 | + echo sanitize_text_field($subscription_group_fee['name']); |
|
696 | 696 | break; |
697 | 697 | |
698 | 698 | case 'price': |
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
699 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'tax': |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | break; |
709 | 709 | |
710 | 710 | case 'initial': |
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
711 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
712 | 712 | break; |
713 | 713 | |
714 | 714 | case 'recurring': |
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
715 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | } |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | * @param WPInv_Subscription $subscription |
742 | 742 | * @param bool $skip_current |
743 | 743 | */ |
744 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
744 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
745 | 745 | |
746 | 746 | // Fetch the subscription groups. |
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
748 | 748 | |
749 | - if ( empty( $subscription_groups ) ) { |
|
749 | + if (empty($subscription_groups)) { |
|
750 | 750 | return; |
751 | 751 | } |
752 | 752 | |
@@ -754,23 +754,23 @@ discard block |
||
754 | 754 | $columns = apply_filters( |
755 | 755 | 'getpaid_subscription_related_subscriptions_columns', |
756 | 756 | array( |
757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | - 'item' => __( 'Items', 'invoicing' ), |
|
762 | - 'status' => __( 'Status', 'invoicing' ), |
|
757 | + 'subscription' => __('Subscription', 'invoicing'), |
|
758 | + 'start_date' => __('Start Date', 'invoicing'), |
|
759 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
760 | + 'renewals' => __('Payments', 'invoicing'), |
|
761 | + 'item' => __('Items', 'invoicing'), |
|
762 | + 'status' => __('Status', 'invoicing'), |
|
763 | 763 | ), |
764 | 764 | $subscription |
765 | 765 | ); |
766 | 766 | |
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + if ($subscription->get_status() == 'pending') { |
|
768 | + unset($columns['start_date'], $columns['renewal_date']); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | $table_class = 'w-100 bg-white'; |
772 | 772 | |
773 | - if ( ! is_admin() ) { |
|
773 | + if (!is_admin()) { |
|
774 | 774 | $table_class = 'table table-bordered'; |
775 | 775 | } |
776 | 776 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | <tr> |
784 | 784 | <?php |
785 | 785 | |
786 | - foreach ( $columns as $key => $label ) { |
|
787 | - $key = esc_attr( $key ); |
|
788 | - $label = sanitize_text_field( $label ); |
|
786 | + foreach ($columns as $key => $label) { |
|
787 | + $key = esc_attr($key); |
|
788 | + $label = sanitize_text_field($label); |
|
789 | 789 | $class = 'text-left'; |
790 | 790 | |
791 | 791 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -798,62 +798,62 @@ discard block |
||
798 | 798 | |
799 | 799 | <?php |
800 | 800 | |
801 | - foreach( $subscription_groups as $subscription_group ) : |
|
801 | + foreach ($subscription_groups as $subscription_group) : |
|
802 | 802 | |
803 | 803 | // Do not list current subscription. |
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
804 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Ensure the subscription exists. |
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
809 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
811 | + if (!$_suscription->exists()) { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | echo '<tr>'; |
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach (array_keys($columns) as $key) { |
|
818 | 818 | |
819 | 819 | $class = 'text-left'; |
820 | 820 | |
821 | 821 | echo "<td class='p-2 $class'>"; |
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch ($key) { |
|
824 | 824 | |
825 | 825 | case 'status': |
826 | 826 | echo $_suscription->get_status_label_html(); |
827 | 827 | break; |
828 | 828 | |
829 | 829 | case 'item': |
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
830 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
831 | + echo implode(' | ', $markup); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'renewals': |
835 | 835 | $max_bills = $_suscription->get_bill_times(); |
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
837 | 837 | break; |
838 | 838 | |
839 | 839 | case 'renewal_date': |
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
841 | 841 | break; |
842 | 842 | |
843 | 843 | case 'start_date': |
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
845 | 845 | break; |
846 | 846 | |
847 | 847 | case 'subscription': |
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
848 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
849 | 849 | printf( |
850 | 850 | '%1$s#%2$s%3$s', |
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
851 | + '<a href="' . esc_url($url) . '">', |
|
852 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
853 | 853 | '</a>' |
854 | 854 | ); |
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
857 | 857 | break; |
858 | 858 | |
859 | 859 | } |