@@ -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); |
@@ -13,462 +13,462 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
149 | - } |
|
150 | - |
|
151 | - // Invoice addons. |
|
152 | - if ( $this->supports( 'addons' ) ) { |
|
153 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | - } |
|
155 | - |
|
156 | - // Gateway settings. |
|
157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
149 | + } |
|
150 | + |
|
151 | + // Invoice addons. |
|
152 | + if ( $this->supports( 'addons' ) ) { |
|
153 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + } |
|
155 | + |
|
156 | + // Gateway settings. |
|
157 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
158 | 158 | |
159 | 159 | |
160 | - // Gateway checkout fiellds. |
|
161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | - |
|
163 | - // Process payment. |
|
164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | - |
|
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' ) ); |
|
169 | - } |
|
170 | - |
|
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 ); |
|
173 | - |
|
174 | - // Generate the transaction url. |
|
175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | - |
|
177 | - // Generate the subscription url. |
|
178 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | - |
|
180 | - // Confirm payments. |
|
181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | - |
|
183 | - // Verify IPNs. |
|
184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | - |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Checks if this gateway is a given gateway. |
|
190 | - * |
|
191 | - * @since 1.0.19 |
|
192 | - * @return bool |
|
193 | - */ |
|
194 | - public function is( $gateway ) { |
|
195 | - return $gateway == $this->id; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Returns a users saved tokens for this gateway. |
|
200 | - * |
|
201 | - * @since 1.0.19 |
|
202 | - * @return array |
|
203 | - */ |
|
204 | - public function get_tokens( $sandbox = null ) { |
|
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 ); |
|
208 | - |
|
209 | - if ( is_array( $tokens ) ) { |
|
210 | - $this->tokens = $tokens; |
|
211 | - } |
|
212 | - |
|
213 | - } |
|
214 | - |
|
215 | - if ( ! is_bool( $sandbox ) ) { |
|
216 | - return $this->tokens; |
|
217 | - } |
|
218 | - |
|
219 | - // Filter tokens. |
|
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | - |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Saves a token for this gateway. |
|
227 | - * |
|
228 | - * @since 1.0.19 |
|
229 | - */ |
|
230 | - public function save_token( $token ) { |
|
231 | - |
|
232 | - $tokens = $this->get_tokens(); |
|
233 | - $tokens[] = $token; |
|
234 | - |
|
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | - |
|
237 | - $this->tokens = $tokens; |
|
238 | - |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Return the title for admin screens. |
|
243 | - * |
|
244 | - * @return string |
|
245 | - */ |
|
246 | - public function get_method_title() { |
|
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Return the description for admin screens. |
|
252 | - * |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function get_method_description() { |
|
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Get the success url. |
|
261 | - * |
|
262 | - * @param WPInv_Invoice $invoice Invoice object. |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function get_return_url( $invoice ) { |
|
266 | - |
|
267 | - // Payment success url |
|
268 | - $return_url = add_query_arg( |
|
269 | - array( |
|
270 | - 'payment-confirm' => $this->id, |
|
271 | - 'invoice_key' => $invoice->get_key(), |
|
272 | - 'utm_nooverride' => 1 |
|
273 | - ), |
|
274 | - wpinv_get_success_page_uri() |
|
275 | - ); |
|
276 | - |
|
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Confirms payments when rendering the success page. |
|
282 | - * |
|
283 | - * @param string $content Success page content. |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function confirm_payment( $content ) { |
|
287 | - |
|
288 | - // Retrieve the invoice. |
|
289 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | - |
|
292 | - // Ensure that it exists and that it is pending payment. |
|
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | - return $content; |
|
295 | - } |
|
296 | - |
|
297 | - // Can the user view this invoice?? |
|
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | - return $content; |
|
300 | - } |
|
301 | - |
|
302 | - // Show payment processing indicator. |
|
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Processes ipns and marks payments as complete. |
|
308 | - * |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - public function verify_ipn() {} |
|
312 | - |
|
313 | - /** |
|
314 | - * Processes invoice addons. |
|
315 | - * |
|
316 | - * @param WPInv_Invoice $invoice |
|
317 | - * @param GetPaid_Form_Item[] $items |
|
318 | - * @return WPInv_Invoice |
|
319 | - */ |
|
320 | - public function process_addons( $invoice, $items ) { |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | - * |
|
327 | - * @param string $transaction_url transaction url. |
|
328 | - * @param WPInv_Invoice $invoice Invoice object. |
|
329 | - * @return string transaction URL, or empty string. |
|
330 | - */ |
|
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | - |
|
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
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 ); |
|
339 | - } |
|
340 | - |
|
341 | - return $transaction_url; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | - * |
|
347 | - * @param string $subscription_url transaction url. |
|
348 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | - * @return string subscription URL, or empty string. |
|
350 | - */ |
|
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | - |
|
353 | - $profile_id = $subscription->get_profile_id(); |
|
354 | - |
|
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
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 ); |
|
360 | - |
|
361 | - } |
|
362 | - |
|
363 | - return $subscription_url; |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Check if the gateway is available for use. |
|
368 | - * |
|
369 | - * @return bool |
|
370 | - */ |
|
371 | - public function is_available() { |
|
372 | - return ! empty( $this->enabled ); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Return the gateway's title. |
|
377 | - * |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - public function get_title() { |
|
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Return the gateway's description. |
|
386 | - * |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function get_description() { |
|
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Process Payment. |
|
395 | - * |
|
396 | - * |
|
397 | - * @param WPInv_Invoice $invoice Invoice. |
|
398 | - * @param array $submission_data Posted checkout fields. |
|
399 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | - * @return void |
|
401 | - */ |
|
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
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 ); |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * Process refund. |
|
409 | - * |
|
410 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | - * a passed in amount. |
|
412 | - * |
|
413 | - * @param WPInv_Invoice $invoice Invoice. |
|
414 | - * @param float $amount Refund amount. |
|
415 | - * @param string $reason Refund reason. |
|
416 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | - */ |
|
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Displays the payment fields, credit cards etc. |
|
424 | - * |
|
425 | - * @param int $invoice_id 0 or invoice id. |
|
426 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | - */ |
|
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Filters the gateway settings. |
|
434 | - * |
|
435 | - * @param array $admin_settings |
|
436 | - */ |
|
437 | - public function admin_settings( $admin_settings ) { |
|
438 | - return $admin_settings; |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Retrieves the value of a gateway setting. |
|
443 | - * |
|
444 | - * @param string $option |
|
445 | - */ |
|
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * Check if a gateway supports a given feature. |
|
452 | - * |
|
453 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | - * |
|
456 | - * @param string $feature string The name of a feature to test support for. |
|
457 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | - * @since 1.0.19 |
|
459 | - */ |
|
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns the credit card form html. |
|
466 | - * |
|
467 | - * @param bool $save whether or not to display the save button. |
|
468 | - */ |
|
160 | + // Gateway checkout fiellds. |
|
161 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | + |
|
163 | + // Process payment. |
|
164 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | + |
|
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' ) ); |
|
169 | + } |
|
170 | + |
|
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 ); |
|
173 | + |
|
174 | + // Generate the transaction url. |
|
175 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | + |
|
177 | + // Generate the subscription url. |
|
178 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | + |
|
180 | + // Confirm payments. |
|
181 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | + |
|
183 | + // Verify IPNs. |
|
184 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | + |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Checks if this gateway is a given gateway. |
|
190 | + * |
|
191 | + * @since 1.0.19 |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | + public function is( $gateway ) { |
|
195 | + return $gateway == $this->id; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Returns a users saved tokens for this gateway. |
|
200 | + * |
|
201 | + * @since 1.0.19 |
|
202 | + * @return array |
|
203 | + */ |
|
204 | + public function get_tokens( $sandbox = null ) { |
|
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 ); |
|
208 | + |
|
209 | + if ( is_array( $tokens ) ) { |
|
210 | + $this->tokens = $tokens; |
|
211 | + } |
|
212 | + |
|
213 | + } |
|
214 | + |
|
215 | + if ( ! is_bool( $sandbox ) ) { |
|
216 | + return $this->tokens; |
|
217 | + } |
|
218 | + |
|
219 | + // Filter tokens. |
|
220 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | + return wp_list_filter( $this->tokens, $args ); |
|
222 | + |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Saves a token for this gateway. |
|
227 | + * |
|
228 | + * @since 1.0.19 |
|
229 | + */ |
|
230 | + public function save_token( $token ) { |
|
231 | + |
|
232 | + $tokens = $this->get_tokens(); |
|
233 | + $tokens[] = $token; |
|
234 | + |
|
235 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | + |
|
237 | + $this->tokens = $tokens; |
|
238 | + |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Return the title for admin screens. |
|
243 | + * |
|
244 | + * @return string |
|
245 | + */ |
|
246 | + public function get_method_title() { |
|
247 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Return the description for admin screens. |
|
252 | + * |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function get_method_description() { |
|
256 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Get the success url. |
|
261 | + * |
|
262 | + * @param WPInv_Invoice $invoice Invoice object. |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function get_return_url( $invoice ) { |
|
266 | + |
|
267 | + // Payment success url |
|
268 | + $return_url = add_query_arg( |
|
269 | + array( |
|
270 | + 'payment-confirm' => $this->id, |
|
271 | + 'invoice_key' => $invoice->get_key(), |
|
272 | + 'utm_nooverride' => 1 |
|
273 | + ), |
|
274 | + wpinv_get_success_page_uri() |
|
275 | + ); |
|
276 | + |
|
277 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Confirms payments when rendering the success page. |
|
282 | + * |
|
283 | + * @param string $content Success page content. |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function confirm_payment( $content ) { |
|
287 | + |
|
288 | + // Retrieve the invoice. |
|
289 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | + |
|
292 | + // Ensure that it exists and that it is pending payment. |
|
293 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | + return $content; |
|
295 | + } |
|
296 | + |
|
297 | + // Can the user view this invoice?? |
|
298 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | + return $content; |
|
300 | + } |
|
301 | + |
|
302 | + // Show payment processing indicator. |
|
303 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Processes ipns and marks payments as complete. |
|
308 | + * |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + public function verify_ipn() {} |
|
312 | + |
|
313 | + /** |
|
314 | + * Processes invoice addons. |
|
315 | + * |
|
316 | + * @param WPInv_Invoice $invoice |
|
317 | + * @param GetPaid_Form_Item[] $items |
|
318 | + * @return WPInv_Invoice |
|
319 | + */ |
|
320 | + public function process_addons( $invoice, $items ) { |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | + * |
|
327 | + * @param string $transaction_url transaction url. |
|
328 | + * @param WPInv_Invoice $invoice Invoice object. |
|
329 | + * @return string transaction URL, or empty string. |
|
330 | + */ |
|
331 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | + |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
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 ); |
|
339 | + } |
|
340 | + |
|
341 | + return $transaction_url; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | + * |
|
347 | + * @param string $subscription_url transaction url. |
|
348 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | + * @return string subscription URL, or empty string. |
|
350 | + */ |
|
351 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | + |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | + |
|
355 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
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 ); |
|
360 | + |
|
361 | + } |
|
362 | + |
|
363 | + return $subscription_url; |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Check if the gateway is available for use. |
|
368 | + * |
|
369 | + * @return bool |
|
370 | + */ |
|
371 | + public function is_available() { |
|
372 | + return ! empty( $this->enabled ); |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Return the gateway's title. |
|
377 | + * |
|
378 | + * @return string |
|
379 | + */ |
|
380 | + public function get_title() { |
|
381 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Return the gateway's description. |
|
386 | + * |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function get_description() { |
|
390 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Process Payment. |
|
395 | + * |
|
396 | + * |
|
397 | + * @param WPInv_Invoice $invoice Invoice. |
|
398 | + * @param array $submission_data Posted checkout fields. |
|
399 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | + * @return void |
|
401 | + */ |
|
402 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
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 ); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Process refund. |
|
409 | + * |
|
410 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | + * a passed in amount. |
|
412 | + * |
|
413 | + * @param WPInv_Invoice $invoice Invoice. |
|
414 | + * @param float $amount Refund amount. |
|
415 | + * @param string $reason Refund reason. |
|
416 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | + */ |
|
418 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Displays the payment fields, credit cards etc. |
|
424 | + * |
|
425 | + * @param int $invoice_id 0 or invoice id. |
|
426 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | + */ |
|
428 | + public function payment_fields( $invoice_id, $form ) { |
|
429 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Filters the gateway settings. |
|
434 | + * |
|
435 | + * @param array $admin_settings |
|
436 | + */ |
|
437 | + public function admin_settings( $admin_settings ) { |
|
438 | + return $admin_settings; |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Retrieves the value of a gateway setting. |
|
443 | + * |
|
444 | + * @param string $option |
|
445 | + */ |
|
446 | + public function get_option( $option, $default = false ) { |
|
447 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * Check if a gateway supports a given feature. |
|
452 | + * |
|
453 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | + * |
|
456 | + * @param string $feature string The name of a feature to test support for. |
|
457 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | + * @since 1.0.19 |
|
459 | + */ |
|
460 | + public function supports( $feature ) { |
|
461 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns the credit card form html. |
|
466 | + * |
|
467 | + * @param bool $save whether or not to display the save button. |
|
468 | + */ |
|
469 | 469 | public function get_cc_form( $save = false ) { |
470 | 470 | |
471 | - ob_start(); |
|
471 | + ob_start(); |
|
472 | 472 | |
473 | 473 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
474 | 474 | |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | 565 | 'label' => __( 'CCV', 'invoicing' ), |
566 | - 'label_type' => 'vertical', |
|
567 | - 'class' => 'form-control-sm', |
|
568 | - 'extra_attributes' => array( |
|
569 | - 'autocomplete' => "cc-csc", |
|
570 | - ), |
|
566 | + 'label_type' => 'vertical', |
|
567 | + 'class' => 'form-control-sm', |
|
568 | + 'extra_attributes' => array( |
|
569 | + 'autocomplete' => "cc-csc", |
|
570 | + ), |
|
571 | 571 | ) |
572 | 572 | ); |
573 | 573 | ?> |
@@ -577,192 +577,192 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
581 | - echo $this->save_payment_method_checkbox(); |
|
582 | - } |
|
580 | + if ( $save ) { |
|
581 | + echo $this->save_payment_method_checkbox(); |
|
582 | + } |
|
583 | 583 | |
584 | - ?> |
|
584 | + ?> |
|
585 | 585 | </div> |
586 | 586 | |
587 | 587 | </div> |
588 | 588 | <?php |
589 | 589 | |
590 | - return ob_get_clean(); |
|
590 | + return ob_get_clean(); |
|
591 | + |
|
592 | + } |
|
591 | 593 | |
594 | + /** |
|
595 | + * Displays a new payment method entry form. |
|
596 | + * |
|
597 | + * @since 1.0.19 |
|
598 | + */ |
|
599 | + public function new_payment_method_entry( $form ) { |
|
600 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
592 | 601 | } |
593 | 602 | |
594 | - /** |
|
595 | - * Displays a new payment method entry form. |
|
596 | - * |
|
597 | - * @since 1.0.19 |
|
598 | - */ |
|
599 | - public function new_payment_method_entry( $form ) { |
|
600 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
601 | - } |
|
602 | - |
|
603 | - /** |
|
604 | - * Grab and display our saved payment methods. |
|
605 | - * |
|
606 | - * @since 1.0.19 |
|
607 | - */ |
|
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() ) ) ) . '">'; |
|
610 | - |
|
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
613 | - } |
|
614 | - |
|
615 | - $html .= $this->get_new_payment_method_option_html(); |
|
616 | - $html .= '</ul>'; |
|
617 | - |
|
618 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
619 | - } |
|
620 | - |
|
621 | - /** |
|
622 | - * Gets saved payment method HTML from a token. |
|
623 | - * |
|
624 | - * @since 1.0.19 |
|
625 | - * @param array $token Payment Token. |
|
626 | - * @return string Generated payment method HTML |
|
627 | - */ |
|
628 | - public function get_saved_payment_method_option_html( $token ) { |
|
629 | - |
|
630 | - return sprintf( |
|
631 | - '<li class="getpaid-payment-method form-group"> |
|
603 | + /** |
|
604 | + * Grab and display our saved payment methods. |
|
605 | + * |
|
606 | + * @since 1.0.19 |
|
607 | + */ |
|
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() ) ) ) . '">'; |
|
610 | + |
|
611 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
613 | + } |
|
614 | + |
|
615 | + $html .= $this->get_new_payment_method_option_html(); |
|
616 | + $html .= '</ul>'; |
|
617 | + |
|
618 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
619 | + } |
|
620 | + |
|
621 | + /** |
|
622 | + * Gets saved payment method HTML from a token. |
|
623 | + * |
|
624 | + * @since 1.0.19 |
|
625 | + * @param array $token Payment Token. |
|
626 | + * @return string Generated payment method HTML |
|
627 | + */ |
|
628 | + public function get_saved_payment_method_option_html( $token ) { |
|
629 | + |
|
630 | + return sprintf( |
|
631 | + '<li class="getpaid-payment-method form-group"> |
|
632 | 632 | <label> |
633 | 633 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
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'] ) |
|
642 | - ); |
|
643 | - |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
648 | - * |
|
649 | - * @since 1.0.19 |
|
650 | - */ |
|
651 | - public function get_new_payment_method_option_html() { |
|
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 ); |
|
654 | - |
|
655 | - return sprintf( |
|
656 | - '<li class="getpaid-new-payment-method"> |
|
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 | + ); |
|
643 | + |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
648 | + * |
|
649 | + * @since 1.0.19 |
|
650 | + */ |
|
651 | + public function get_new_payment_method_option_html() { |
|
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 ); |
|
654 | + |
|
655 | + return sprintf( |
|
656 | + '<li class="getpaid-new-payment-method"> |
|
657 | 657 | <label> |
658 | 658 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
659 | 659 | <span>%2$s</span> |
660 | 660 | </label> |
661 | 661 | </li>', |
662 | - esc_attr( $this->id ), |
|
663 | - esc_html( $label ) |
|
664 | - ); |
|
665 | - |
|
666 | - } |
|
667 | - |
|
668 | - /** |
|
669 | - * Outputs a checkbox for saving a new payment method to the database. |
|
670 | - * |
|
671 | - * @since 1.0.19 |
|
672 | - */ |
|
673 | - public function save_payment_method_checkbox() { |
|
674 | - |
|
675 | - return aui()->input( |
|
676 | - array( |
|
677 | - 'type' => 'checkbox', |
|
678 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
680 | - 'required' => false, |
|
681 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
682 | - 'value' => 'true', |
|
683 | - 'checked' => true, |
|
684 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
685 | - ) |
|
686 | - ); |
|
687 | - |
|
688 | - } |
|
689 | - |
|
690 | - /** |
|
691 | - * Registers the gateway. |
|
692 | - * |
|
693 | - * @return array |
|
694 | - */ |
|
695 | - public function register_gateway( $gateways ) { |
|
696 | - |
|
697 | - $gateways[ $this->id ] = array( |
|
698 | - |
|
699 | - 'admin_label' => $this->method_title, |
|
662 | + esc_attr( $this->id ), |
|
663 | + esc_html( $label ) |
|
664 | + ); |
|
665 | + |
|
666 | + } |
|
667 | + |
|
668 | + /** |
|
669 | + * Outputs a checkbox for saving a new payment method to the database. |
|
670 | + * |
|
671 | + * @since 1.0.19 |
|
672 | + */ |
|
673 | + public function save_payment_method_checkbox() { |
|
674 | + |
|
675 | + return aui()->input( |
|
676 | + array( |
|
677 | + 'type' => 'checkbox', |
|
678 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
680 | + 'required' => false, |
|
681 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
682 | + 'value' => 'true', |
|
683 | + 'checked' => true, |
|
684 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
685 | + ) |
|
686 | + ); |
|
687 | + |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Registers the gateway. |
|
692 | + * |
|
693 | + * @return array |
|
694 | + */ |
|
695 | + public function register_gateway( $gateways ) { |
|
696 | + |
|
697 | + $gateways[ $this->id ] = array( |
|
698 | + |
|
699 | + 'admin_label' => $this->method_title, |
|
700 | 700 | 'checkout_label' => $this->title, |
701 | - 'ordering' => $this->order, |
|
701 | + 'ordering' => $this->order, |
|
702 | 702 | |
703 | - ); |
|
703 | + ); |
|
704 | 704 | |
705 | - return $gateways; |
|
705 | + return $gateways; |
|
706 | 706 | |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - /** |
|
710 | - * Checks whether or not this is a sandbox request. |
|
711 | - * |
|
712 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
713 | - * @return bool |
|
714 | - */ |
|
715 | - public function is_sandbox( $invoice = null ) { |
|
709 | + /** |
|
710 | + * Checks whether or not this is a sandbox request. |
|
711 | + * |
|
712 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
713 | + * @return bool |
|
714 | + */ |
|
715 | + public function is_sandbox( $invoice = null ) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
718 | - return $invoice->get_mode() == 'test'; |
|
719 | - } |
|
717 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
718 | + return $invoice->get_mode() == 'test'; |
|
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 | |
725 | - /** |
|
726 | - * Renames the checkout button |
|
727 | - * |
|
728 | - * @return string |
|
729 | - */ |
|
730 | - public function rename_checkout_button() { |
|
731 | - return $this->checkout_button_text; |
|
732 | - } |
|
725 | + /** |
|
726 | + * Renames the checkout button |
|
727 | + * |
|
728 | + * @return string |
|
729 | + */ |
|
730 | + public function rename_checkout_button() { |
|
731 | + return $this->checkout_button_text; |
|
732 | + } |
|
733 | 733 | |
734 | - /** |
|
735 | - * Validate gateway currency |
|
736 | - * |
|
737 | - * @return bool |
|
738 | - */ |
|
739 | - public function validate_currency( $validation, $currency ) { |
|
734 | + /** |
|
735 | + * Validate gateway currency |
|
736 | + * |
|
737 | + * @return bool |
|
738 | + */ |
|
739 | + public function validate_currency( $validation, $currency ) { |
|
740 | 740 | |
741 | - // Required currencies. |
|
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
743 | - return false; |
|
744 | - } |
|
741 | + // Required currencies. |
|
742 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
743 | + return false; |
|
744 | + } |
|
745 | 745 | |
746 | - // Excluded currencies. |
|
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
748 | - return false; |
|
749 | - } |
|
746 | + // Excluded currencies. |
|
747 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
748 | + return false; |
|
749 | + } |
|
750 | 750 | |
751 | - return $validation; |
|
752 | - } |
|
751 | + return $validation; |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * Displays an error |
|
756 | - * |
|
757 | - */ |
|
758 | - public function show_error( $code, $message, $type ) { |
|
754 | + /** |
|
755 | + * Displays an error |
|
756 | + * |
|
757 | + */ |
|
758 | + public function show_error( $code, $message, $type ) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
762 | - } |
|
760 | + if ( is_admin() ) { |
|
761 | + getpaid_admin()->{"show_$type"}( $message ); |
|
762 | + } |
|
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error( $code, $message, $type ); |
|
765 | 765 | |
766 | - } |
|
766 | + } |
|
767 | 767 | |
768 | 768 | } |
@@ -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 |
@@ -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); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
16 | - exit; |
|
16 | + exit; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -21,236 +21,236 @@ discard block |
||
21 | 21 | */ |
22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
23 | 23 | |
24 | - /** |
|
25 | - * A Class to be able to change settings for Font Awesome. |
|
26 | - * |
|
27 | - * Class AyeCode_UI_Settings |
|
28 | - * @ver 1.0.0 |
|
29 | - * @todo decide how to implement textdomain |
|
30 | - */ |
|
31 | - class AyeCode_UI_Settings { |
|
32 | - |
|
33 | - /** |
|
34 | - * Class version version. |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - public $version = '0.1.47'; |
|
39 | - |
|
40 | - /** |
|
41 | - * Class textdomain. |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - public $textdomain = 'aui'; |
|
46 | - |
|
47 | - /** |
|
48 | - * Latest version of Bootstrap at time of publish published. |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - public $latest = "4.5.3"; |
|
53 | - |
|
54 | - /** |
|
55 | - * Current version of select2 being used. |
|
56 | - * |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - public $select2_version = "4.0.11"; |
|
60 | - |
|
61 | - /** |
|
62 | - * The title. |
|
63 | - * |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - public $name = 'AyeCode UI'; |
|
67 | - |
|
68 | - /** |
|
69 | - * The relative url to the assets. |
|
70 | - * |
|
71 | - * @var string |
|
72 | - */ |
|
73 | - public $url = ''; |
|
74 | - |
|
75 | - /** |
|
76 | - * Holds the settings values. |
|
77 | - * |
|
78 | - * @var array |
|
79 | - */ |
|
80 | - private $settings; |
|
81 | - |
|
82 | - /** |
|
83 | - * AyeCode_UI_Settings instance. |
|
84 | - * |
|
85 | - * @access private |
|
86 | - * @since 1.0.0 |
|
87 | - * @var AyeCode_UI_Settings There can be only one! |
|
88 | - */ |
|
89 | - private static $instance = null; |
|
90 | - |
|
91 | - /** |
|
92 | - * Main AyeCode_UI_Settings Instance. |
|
93 | - * |
|
94 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | - * |
|
96 | - * @since 1.0.0 |
|
97 | - * @static |
|
98 | - * @return AyeCode_UI_Settings - Main instance. |
|
99 | - */ |
|
100 | - public static function instance() { |
|
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | - |
|
103 | - self::$instance = new AyeCode_UI_Settings; |
|
104 | - |
|
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
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' ) ); |
|
110 | - |
|
111 | - // Maybe show example page |
|
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | - } |
|
114 | - |
|
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | - |
|
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | - } |
|
119 | - |
|
120 | - return self::$instance; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Setup some constants. |
|
125 | - */ |
|
126 | - public function constants(){ |
|
127 | - define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | - define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Initiate the settings and add the required action hooks. |
|
135 | - */ |
|
136 | - public function init() { |
|
137 | - $this->constants(); |
|
138 | - $this->settings = $this->get_settings(); |
|
139 | - $this->url = $this->get_url(); |
|
140 | - |
|
141 | - /** |
|
142 | - * Maybe load CSS |
|
143 | - * |
|
144 | - * We load super early in case there is a theme version that might change the colors |
|
145 | - */ |
|
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | - } |
|
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | - } |
|
152 | - |
|
153 | - // maybe load JS |
|
154 | - if ( $this->settings['js'] ) { |
|
155 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | - } |
|
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | - } |
|
161 | - |
|
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 ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Check if we should load the admin scripts or not. |
|
172 | - * |
|
173 | - * @return bool |
|
174 | - */ |
|
175 | - public function load_admin_scripts(){ |
|
176 | - $result = true; |
|
177 | - |
|
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 ){ |
|
183 | - return false; // return early, no point checking further |
|
184 | - } |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - return $result; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Add a html font size to the footer. |
|
193 | - */ |
|
194 | - public function html_font_size(){ |
|
195 | - $this->settings = $this->get_settings(); |
|
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | - } |
|
24 | + /** |
|
25 | + * A Class to be able to change settings for Font Awesome. |
|
26 | + * |
|
27 | + * Class AyeCode_UI_Settings |
|
28 | + * @ver 1.0.0 |
|
29 | + * @todo decide how to implement textdomain |
|
30 | + */ |
|
31 | + class AyeCode_UI_Settings { |
|
32 | + |
|
33 | + /** |
|
34 | + * Class version version. |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public $version = '0.1.47'; |
|
39 | + |
|
40 | + /** |
|
41 | + * Class textdomain. |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + public $textdomain = 'aui'; |
|
46 | + |
|
47 | + /** |
|
48 | + * Latest version of Bootstrap at time of publish published. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + public $latest = "4.5.3"; |
|
53 | + |
|
54 | + /** |
|
55 | + * Current version of select2 being used. |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + public $select2_version = "4.0.11"; |
|
60 | + |
|
61 | + /** |
|
62 | + * The title. |
|
63 | + * |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + public $name = 'AyeCode UI'; |
|
67 | + |
|
68 | + /** |
|
69 | + * The relative url to the assets. |
|
70 | + * |
|
71 | + * @var string |
|
72 | + */ |
|
73 | + public $url = ''; |
|
74 | + |
|
75 | + /** |
|
76 | + * Holds the settings values. |
|
77 | + * |
|
78 | + * @var array |
|
79 | + */ |
|
80 | + private $settings; |
|
81 | + |
|
82 | + /** |
|
83 | + * AyeCode_UI_Settings instance. |
|
84 | + * |
|
85 | + * @access private |
|
86 | + * @since 1.0.0 |
|
87 | + * @var AyeCode_UI_Settings There can be only one! |
|
88 | + */ |
|
89 | + private static $instance = null; |
|
90 | + |
|
91 | + /** |
|
92 | + * Main AyeCode_UI_Settings Instance. |
|
93 | + * |
|
94 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | + * |
|
96 | + * @since 1.0.0 |
|
97 | + * @static |
|
98 | + * @return AyeCode_UI_Settings - Main instance. |
|
99 | + */ |
|
100 | + public static function instance() { |
|
101 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | + |
|
103 | + self::$instance = new AyeCode_UI_Settings; |
|
104 | + |
|
105 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
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' ) ); |
|
110 | + |
|
111 | + // Maybe show example page |
|
112 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | + } |
|
198 | 114 | |
199 | - /** |
|
200 | - * Check if the current admin screen should load scripts. |
|
201 | - * |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - public function is_aui_screen(){ |
|
205 | - $load = false; |
|
206 | - // check if we should load or not |
|
207 | - if ( is_admin() ) { |
|
208 | - // Only enable on set pages |
|
209 | - $aui_screens = array( |
|
210 | - 'page', |
|
211 | - 'post', |
|
212 | - 'settings_page_ayecode-ui-settings', |
|
213 | - 'appearance_page_gutenberg-widgets' |
|
214 | - ); |
|
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | - |
|
217 | - $screen = get_current_screen(); |
|
115 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | + |
|
117 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | + } |
|
119 | + |
|
120 | + return self::$instance; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Setup some constants. |
|
125 | + */ |
|
126 | + public function constants(){ |
|
127 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | + if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Initiate the settings and add the required action hooks. |
|
135 | + */ |
|
136 | + public function init() { |
|
137 | + $this->constants(); |
|
138 | + $this->settings = $this->get_settings(); |
|
139 | + $this->url = $this->get_url(); |
|
140 | + |
|
141 | + /** |
|
142 | + * Maybe load CSS |
|
143 | + * |
|
144 | + * We load super early in case there is a theme version that might change the colors |
|
145 | + */ |
|
146 | + if ( $this->settings['css'] ) { |
|
147 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | + } |
|
149 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | + } |
|
152 | + |
|
153 | + // maybe load JS |
|
154 | + if ( $this->settings['js'] ) { |
|
155 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | + } |
|
158 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | + } |
|
161 | + |
|
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 ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Check if we should load the admin scripts or not. |
|
172 | + * |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | + public function load_admin_scripts(){ |
|
176 | + $result = true; |
|
177 | + |
|
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 ){ |
|
183 | + return false; // return early, no point checking further |
|
184 | + } |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + return $result; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Add a html font size to the footer. |
|
193 | + */ |
|
194 | + public function html_font_size(){ |
|
195 | + $this->settings = $this->get_settings(); |
|
196 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Check if the current admin screen should load scripts. |
|
201 | + * |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + public function is_aui_screen(){ |
|
205 | + $load = false; |
|
206 | + // check if we should load or not |
|
207 | + if ( is_admin() ) { |
|
208 | + // Only enable on set pages |
|
209 | + $aui_screens = array( |
|
210 | + 'page', |
|
211 | + 'post', |
|
212 | + 'settings_page_ayecode-ui-settings', |
|
213 | + 'appearance_page_gutenberg-widgets' |
|
214 | + ); |
|
215 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | + |
|
217 | + $screen = get_current_screen(); |
|
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | - $load = true; |
|
223 | - } |
|
224 | - } |
|
221 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | + $load = true; |
|
223 | + } |
|
224 | + } |
|
225 | 225 | |
226 | - return $load; |
|
227 | - } |
|
226 | + return $load; |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * Adds the styles. |
|
231 | - */ |
|
232 | - public function enqueue_style() { |
|
229 | + /** |
|
230 | + * Adds the styles. |
|
231 | + */ |
|
232 | + public function enqueue_style() { |
|
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
235 | - // don't add wp-admin scripts if not requested to |
|
236 | - }else{ |
|
237 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
234 | + if( is_admin() && !$this->is_aui_screen()){ |
|
235 | + // don't add wp-admin scripts if not requested to |
|
236 | + }else{ |
|
237 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
238 | 238 | |
239 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
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 | - // flatpickr |
|
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
247 | + // flatpickr |
|
248 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
249 | 249 | |
250 | 250 | |
251 | - // fix some wp-admin issues |
|
252 | - if(is_admin()){ |
|
253 | - $custom_css = " |
|
251 | + // fix some wp-admin issues |
|
252 | + if(is_admin()){ |
|
253 | + $custom_css = " |
|
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
256 | 256 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -289,35 +289,35 @@ discard block |
||
289 | 289 | } |
290 | 290 | "; |
291 | 291 | |
292 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
293 | - $custom_css .= " |
|
292 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
293 | + $custom_css .= " |
|
294 | 294 | .edit-post-sidebar input[type=color].components-text-control__input{ |
295 | 295 | padding: 0; |
296 | 296 | } |
297 | 297 | "; |
298 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
299 | - } |
|
298 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
299 | + } |
|
300 | 300 | |
301 | - // custom changes |
|
302 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
301 | + // custom changes |
|
302 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
303 | 303 | |
304 | - } |
|
305 | - } |
|
304 | + } |
|
305 | + } |
|
306 | 306 | |
307 | 307 | |
308 | - } |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * Get inline script used if bootstrap enqueued |
|
312 | + * |
|
313 | + * If this remains small then its best to use this than to add another JS file. |
|
314 | + */ |
|
315 | + public function inline_script() { |
|
316 | + // Flatpickr calendar locale |
|
317 | + $flatpickr_locale = self::flatpickr_locale(); |
|
309 | 318 | |
310 | - /** |
|
311 | - * Get inline script used if bootstrap enqueued |
|
312 | - * |
|
313 | - * If this remains small then its best to use this than to add another JS file. |
|
314 | - */ |
|
315 | - public function inline_script() { |
|
316 | - // Flatpickr calendar locale |
|
317 | - $flatpickr_locale = self::flatpickr_locale(); |
|
318 | - |
|
319 | - ob_start(); |
|
320 | - ?> |
|
319 | + ob_start(); |
|
320 | + ?> |
|
321 | 321 | <script> |
322 | 322 | /** |
323 | 323 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -982,29 +982,29 @@ discard block |
||
982 | 982 | |
983 | 983 | </script> |
984 | 984 | <?php |
985 | - $output = ob_get_clean(); |
|
985 | + $output = ob_get_clean(); |
|
986 | 986 | |
987 | 987 | |
988 | 988 | |
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( |
|
993 | - '<script>', |
|
994 | - '</script>' |
|
995 | - ), '', self::minify_js($output) ); |
|
996 | - } |
|
997 | - |
|
998 | - |
|
999 | - /** |
|
1000 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1001 | - * |
|
1002 | - * @TODO we may need this when other conflicts arrise. |
|
1003 | - * @return mixed |
|
1004 | - */ |
|
1005 | - public static function bs3_compat_js() { |
|
1006 | - ob_start(); |
|
1007 | - ?> |
|
992 | + return str_replace( array( |
|
993 | + '<script>', |
|
994 | + '</script>' |
|
995 | + ), '', self::minify_js($output) ); |
|
996 | + } |
|
997 | + |
|
998 | + |
|
999 | + /** |
|
1000 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1001 | + * |
|
1002 | + * @TODO we may need this when other conflicts arrise. |
|
1003 | + * @return mixed |
|
1004 | + */ |
|
1005 | + public static function bs3_compat_js() { |
|
1006 | + ob_start(); |
|
1007 | + ?> |
|
1008 | 1008 | <script> |
1009 | 1009 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
1010 | 1010 | /* With Avada builder */ |
@@ -1012,20 +1012,20 @@ discard block |
||
1012 | 1012 | <?php } ?> |
1013 | 1013 | </script> |
1014 | 1014 | <?php |
1015 | - return str_replace( array( |
|
1016 | - '<script>', |
|
1017 | - '</script>' |
|
1018 | - ), '', ob_get_clean()); |
|
1019 | - } |
|
1020 | - |
|
1021 | - /** |
|
1022 | - * Get inline script used if bootstrap file browser enqueued. |
|
1023 | - * |
|
1024 | - * If this remains small then its best to use this than to add another JS file. |
|
1025 | - */ |
|
1026 | - public function inline_script_file_browser(){ |
|
1027 | - ob_start(); |
|
1028 | - ?> |
|
1015 | + return str_replace( array( |
|
1016 | + '<script>', |
|
1017 | + '</script>' |
|
1018 | + ), '', ob_get_clean()); |
|
1019 | + } |
|
1020 | + |
|
1021 | + /** |
|
1022 | + * Get inline script used if bootstrap file browser enqueued. |
|
1023 | + * |
|
1024 | + * If this remains small then its best to use this than to add another JS file. |
|
1025 | + */ |
|
1026 | + public function inline_script_file_browser(){ |
|
1027 | + ob_start(); |
|
1028 | + ?> |
|
1029 | 1029 | <script> |
1030 | 1030 | // run on doc ready |
1031 | 1031 | jQuery(document).ready(function () { |
@@ -1033,192 +1033,192 @@ discard block |
||
1033 | 1033 | }); |
1034 | 1034 | </script> |
1035 | 1035 | <?php |
1036 | - $output = ob_get_clean(); |
|
1036 | + $output = ob_get_clean(); |
|
1037 | 1037 | |
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( |
|
1042 | - '<script>', |
|
1043 | - '</script>' |
|
1044 | - ), '', $output ); |
|
1045 | - } |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * Adds the Font Awesome JS. |
|
1049 | - */ |
|
1050 | - public function enqueue_scripts() { |
|
1051 | - |
|
1052 | - if( is_admin() && !$this->is_aui_screen()){ |
|
1053 | - // don't add wp-admin scripts if not requested to |
|
1054 | - }else { |
|
1055 | - |
|
1056 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1057 | - |
|
1058 | - // select2 |
|
1059 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1060 | - |
|
1061 | - // flatpickr |
|
1062 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1063 | - |
|
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() ); |
|
1067 | - |
|
1068 | - $load_inline = false; |
|
1069 | - |
|
1070 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1071 | - // Bootstrap bundle |
|
1072 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1073 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1074 | - 'select2', |
|
1075 | - 'jquery' |
|
1076 | - ), $this->latest, $this->is_bs3_compat() ); |
|
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' ); |
|
1079 | - $script = $this->inline_script(); |
|
1080 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1081 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
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' ); |
|
1085 | - $load_inline = true; |
|
1086 | - } else { |
|
1087 | - $load_inline = true; |
|
1088 | - } |
|
1089 | - |
|
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' ); |
|
1094 | - $script = $this->inline_script(); |
|
1095 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1096 | - } |
|
1097 | - } |
|
1098 | - |
|
1099 | - } |
|
1100 | - |
|
1101 | - /** |
|
1102 | - * Enqueue flatpickr if called. |
|
1103 | - */ |
|
1104 | - public function enqueue_flatpickr(){ |
|
1105 | - wp_enqueue_style( 'flatpickr' ); |
|
1106 | - wp_enqueue_script( 'flatpickr' ); |
|
1107 | - } |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * Get the url path to the current folder. |
|
1111 | - * |
|
1112 | - * @return string |
|
1113 | - */ |
|
1114 | - public function get_url() { |
|
1115 | - |
|
1116 | - $url = ''; |
|
1117 | - // check if we are inside a plugin |
|
1118 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1119 | - |
|
1120 | - // add check in-case user has changed wp-content dir name. |
|
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()); |
|
1124 | - |
|
1125 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1126 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1127 | - } |
|
1128 | - |
|
1129 | - return $url; |
|
1130 | - } |
|
1131 | - |
|
1132 | - /** |
|
1133 | - * Register the database settings with WordPress. |
|
1134 | - */ |
|
1135 | - public function register_settings() { |
|
1136 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1137 | - } |
|
1138 | - |
|
1139 | - /** |
|
1140 | - * Add the WordPress settings menu item. |
|
1141 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1142 | - */ |
|
1143 | - public function menu_item() { |
|
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( |
|
1146 | - $this, |
|
1147 | - 'settings_page' |
|
1148 | - ) ); |
|
1149 | - } |
|
1150 | - |
|
1151 | - /** |
|
1152 | - * Get a list of themes and their default JS settings. |
|
1153 | - * |
|
1154 | - * @return array |
|
1155 | - */ |
|
1156 | - public function theme_js_settings(){ |
|
1157 | - return array( |
|
1158 | - 'ayetheme' => 'popper', |
|
1159 | - 'listimia' => 'required', |
|
1160 | - 'listimia_backend' => 'core-popper', |
|
1161 | - //'avada' => 'required', // removed as we now add compatibility |
|
1162 | - ); |
|
1163 | - } |
|
1164 | - |
|
1165 | - /** |
|
1166 | - * Get the current Font Awesome output settings. |
|
1167 | - * |
|
1168 | - * @return array The array of settings. |
|
1169 | - */ |
|
1170 | - public function get_settings() { |
|
1171 | - |
|
1172 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1173 | - $js_default = 'core-popper'; |
|
1174 | - $js_default_backend = $js_default; |
|
1175 | - |
|
1176 | - // maybe set defaults (if no settings set) |
|
1177 | - if(empty($db_settings)){ |
|
1178 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1179 | - $theme_js_settings = self::theme_js_settings(); |
|
1180 | - if(isset($theme_js_settings[$active_theme])){ |
|
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; |
|
1183 | - } |
|
1184 | - } |
|
1185 | - |
|
1186 | - $defaults = array( |
|
1187 | - 'css' => 'compatibility', // core, compatibility |
|
1188 | - 'js' => $js_default, // js to load, core-popper, popper |
|
1189 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
1190 | - 'css_backend' => 'compatibility', // core, compatibility |
|
1191 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1192 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1193 | - ); |
|
1194 | - |
|
1195 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1196 | - |
|
1197 | - /** |
|
1198 | - * Filter the Bootstrap settings. |
|
1199 | - * |
|
1200 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1201 | - */ |
|
1202 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1203 | - } |
|
1204 | - |
|
1041 | + return str_replace( array( |
|
1042 | + '<script>', |
|
1043 | + '</script>' |
|
1044 | + ), '', $output ); |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * Adds the Font Awesome JS. |
|
1049 | + */ |
|
1050 | + public function enqueue_scripts() { |
|
1051 | + |
|
1052 | + if( is_admin() && !$this->is_aui_screen()){ |
|
1053 | + // don't add wp-admin scripts if not requested to |
|
1054 | + }else { |
|
1055 | + |
|
1056 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1057 | + |
|
1058 | + // select2 |
|
1059 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1060 | + |
|
1061 | + // flatpickr |
|
1062 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1063 | + |
|
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() ); |
|
1067 | + |
|
1068 | + $load_inline = false; |
|
1069 | + |
|
1070 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1071 | + // Bootstrap bundle |
|
1072 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1073 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1074 | + 'select2', |
|
1075 | + 'jquery' |
|
1076 | + ), $this->latest, $this->is_bs3_compat() ); |
|
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' ); |
|
1079 | + $script = $this->inline_script(); |
|
1080 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1081 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
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' ); |
|
1085 | + $load_inline = true; |
|
1086 | + } else { |
|
1087 | + $load_inline = true; |
|
1088 | + } |
|
1205 | 1089 | |
1206 | - /** |
|
1207 | - * The settings page html output. |
|
1208 | - */ |
|
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' ) ); |
|
1212 | - } |
|
1213 | - ?> |
|
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' ); |
|
1094 | + $script = $this->inline_script(); |
|
1095 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1096 | + } |
|
1097 | + } |
|
1098 | + |
|
1099 | + } |
|
1100 | + |
|
1101 | + /** |
|
1102 | + * Enqueue flatpickr if called. |
|
1103 | + */ |
|
1104 | + public function enqueue_flatpickr(){ |
|
1105 | + wp_enqueue_style( 'flatpickr' ); |
|
1106 | + wp_enqueue_script( 'flatpickr' ); |
|
1107 | + } |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * Get the url path to the current folder. |
|
1111 | + * |
|
1112 | + * @return string |
|
1113 | + */ |
|
1114 | + public function get_url() { |
|
1115 | + |
|
1116 | + $url = ''; |
|
1117 | + // check if we are inside a plugin |
|
1118 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1119 | + |
|
1120 | + // add check in-case user has changed wp-content dir name. |
|
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()); |
|
1124 | + |
|
1125 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1126 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1127 | + } |
|
1128 | + |
|
1129 | + return $url; |
|
1130 | + } |
|
1131 | + |
|
1132 | + /** |
|
1133 | + * Register the database settings with WordPress. |
|
1134 | + */ |
|
1135 | + public function register_settings() { |
|
1136 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1137 | + } |
|
1138 | + |
|
1139 | + /** |
|
1140 | + * Add the WordPress settings menu item. |
|
1141 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1142 | + */ |
|
1143 | + public function menu_item() { |
|
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( |
|
1146 | + $this, |
|
1147 | + 'settings_page' |
|
1148 | + ) ); |
|
1149 | + } |
|
1150 | + |
|
1151 | + /** |
|
1152 | + * Get a list of themes and their default JS settings. |
|
1153 | + * |
|
1154 | + * @return array |
|
1155 | + */ |
|
1156 | + public function theme_js_settings(){ |
|
1157 | + return array( |
|
1158 | + 'ayetheme' => 'popper', |
|
1159 | + 'listimia' => 'required', |
|
1160 | + 'listimia_backend' => 'core-popper', |
|
1161 | + //'avada' => 'required', // removed as we now add compatibility |
|
1162 | + ); |
|
1163 | + } |
|
1164 | + |
|
1165 | + /** |
|
1166 | + * Get the current Font Awesome output settings. |
|
1167 | + * |
|
1168 | + * @return array The array of settings. |
|
1169 | + */ |
|
1170 | + public function get_settings() { |
|
1171 | + |
|
1172 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1173 | + $js_default = 'core-popper'; |
|
1174 | + $js_default_backend = $js_default; |
|
1175 | + |
|
1176 | + // maybe set defaults (if no settings set) |
|
1177 | + if(empty($db_settings)){ |
|
1178 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
1179 | + $theme_js_settings = self::theme_js_settings(); |
|
1180 | + if(isset($theme_js_settings[$active_theme])){ |
|
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; |
|
1183 | + } |
|
1184 | + } |
|
1185 | + |
|
1186 | + $defaults = array( |
|
1187 | + 'css' => 'compatibility', // core, compatibility |
|
1188 | + 'js' => $js_default, // js to load, core-popper, popper |
|
1189 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
1190 | + 'css_backend' => 'compatibility', // core, compatibility |
|
1191 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1192 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1193 | + ); |
|
1194 | + |
|
1195 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
1196 | + |
|
1197 | + /** |
|
1198 | + * Filter the Bootstrap settings. |
|
1199 | + * |
|
1200 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1201 | + */ |
|
1202 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1203 | + } |
|
1204 | + |
|
1205 | + |
|
1206 | + /** |
|
1207 | + * The settings page html output. |
|
1208 | + */ |
|
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' ) ); |
|
1212 | + } |
|
1213 | + ?> |
|
1214 | 1214 | <div class="wrap"> |
1215 | 1215 | <h1><?php echo $this->name; ?></h1> |
1216 | 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' ); |
|
1221 | - ?> |
|
1219 | + settings_fields( 'ayecode-ui-settings' ); |
|
1220 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
1221 | + ?> |
|
1222 | 1222 | |
1223 | 1223 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
1224 | 1224 | <table class="form-table wpbs-table-settings"> |
@@ -1298,60 +1298,60 @@ discard block |
||
1298 | 1298 | </table> |
1299 | 1299 | |
1300 | 1300 | <?php |
1301 | - submit_button(); |
|
1302 | - ?> |
|
1301 | + submit_button(); |
|
1302 | + ?> |
|
1303 | 1303 | </form> |
1304 | 1304 | |
1305 | 1305 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
1306 | 1306 | </div> |
1307 | 1307 | |
1308 | 1308 | <?php |
1309 | - } |
|
1310 | - |
|
1311 | - public function customizer_settings($wp_customize){ |
|
1312 | - $wp_customize->add_section('aui_settings', array( |
|
1313 | - 'title' => __('AyeCode UI','aui'), |
|
1314 | - 'priority' => 120, |
|
1315 | - )); |
|
1316 | - |
|
1317 | - // ============================= |
|
1318 | - // = Color Picker = |
|
1319 | - // ============================= |
|
1320 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1321 | - 'default' => AUI_PRIMARY_COLOR, |
|
1322 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1323 | - 'capability' => 'edit_theme_options', |
|
1324 | - 'type' => 'option', |
|
1325 | - 'transport' => 'refresh', |
|
1326 | - )); |
|
1327 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1328 | - 'label' => __('Primary Color','aui'), |
|
1329 | - 'section' => 'aui_settings', |
|
1330 | - 'settings' => 'aui_options[color_primary]', |
|
1331 | - ))); |
|
1332 | - |
|
1333 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1334 | - 'default' => '#6c757d', |
|
1335 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1336 | - 'capability' => 'edit_theme_options', |
|
1337 | - 'type' => 'option', |
|
1338 | - 'transport' => 'refresh', |
|
1339 | - )); |
|
1340 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1341 | - 'label' => __('Secondary Color','aui'), |
|
1342 | - 'section' => 'aui_settings', |
|
1343 | - 'settings' => 'aui_options[color_secondary]', |
|
1344 | - ))); |
|
1345 | - } |
|
1346 | - |
|
1347 | - /** |
|
1348 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1349 | - * |
|
1350 | - * @return mixed |
|
1351 | - */ |
|
1352 | - public static function bs3_compat_css() { |
|
1353 | - ob_start(); |
|
1354 | - ?> |
|
1309 | + } |
|
1310 | + |
|
1311 | + public function customizer_settings($wp_customize){ |
|
1312 | + $wp_customize->add_section('aui_settings', array( |
|
1313 | + 'title' => __('AyeCode UI','aui'), |
|
1314 | + 'priority' => 120, |
|
1315 | + )); |
|
1316 | + |
|
1317 | + // ============================= |
|
1318 | + // = Color Picker = |
|
1319 | + // ============================= |
|
1320 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1321 | + 'default' => AUI_PRIMARY_COLOR, |
|
1322 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1323 | + 'capability' => 'edit_theme_options', |
|
1324 | + 'type' => 'option', |
|
1325 | + 'transport' => 'refresh', |
|
1326 | + )); |
|
1327 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1328 | + 'label' => __('Primary Color','aui'), |
|
1329 | + 'section' => 'aui_settings', |
|
1330 | + 'settings' => 'aui_options[color_primary]', |
|
1331 | + ))); |
|
1332 | + |
|
1333 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1334 | + 'default' => '#6c757d', |
|
1335 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1336 | + 'capability' => 'edit_theme_options', |
|
1337 | + 'type' => 'option', |
|
1338 | + 'transport' => 'refresh', |
|
1339 | + )); |
|
1340 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1341 | + 'label' => __('Secondary Color','aui'), |
|
1342 | + 'section' => 'aui_settings', |
|
1343 | + 'settings' => 'aui_options[color_secondary]', |
|
1344 | + ))); |
|
1345 | + } |
|
1346 | + |
|
1347 | + /** |
|
1348 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1349 | + * |
|
1350 | + * @return mixed |
|
1351 | + */ |
|
1352 | + public static function bs3_compat_css() { |
|
1353 | + ob_start(); |
|
1354 | + ?> |
|
1355 | 1355 | <style> |
1356 | 1356 | /* Bootstrap 3 compatibility */ |
1357 | 1357 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1377,579 +1377,579 @@ discard block |
||
1377 | 1377 | <?php } ?> |
1378 | 1378 | </style> |
1379 | 1379 | <?php |
1380 | - return str_replace( array( |
|
1381 | - '<style>', |
|
1382 | - '</style>' |
|
1383 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1384 | - } |
|
1380 | + return str_replace( array( |
|
1381 | + '<style>', |
|
1382 | + '</style>' |
|
1383 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1384 | + } |
|
1385 | 1385 | |
1386 | 1386 | |
1387 | - public static function custom_css($compatibility = true) { |
|
1388 | - $settings = get_option('aui_options'); |
|
1387 | + public static function custom_css($compatibility = true) { |
|
1388 | + $settings = get_option('aui_options'); |
|
1389 | 1389 | |
1390 | - ob_start(); |
|
1390 | + ob_start(); |
|
1391 | 1391 | |
1392 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1393 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1394 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
1395 | - ?> |
|
1392 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1393 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1394 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
1395 | + ?> |
|
1396 | 1396 | <style> |
1397 | 1397 | <?php |
1398 | 1398 | |
1399 | - // BS v3 compat |
|
1400 | - if( self::is_bs3_compat() ){ |
|
1401 | - echo self::bs3_compat_css(); |
|
1402 | - } |
|
1399 | + // BS v3 compat |
|
1400 | + if( self::is_bs3_compat() ){ |
|
1401 | + echo self::bs3_compat_css(); |
|
1402 | + } |
|
1403 | 1403 | |
1404 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1405 | - echo self::css_primary($primary_color,$compatibility); |
|
1406 | - } |
|
1404 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1405 | + echo self::css_primary($primary_color,$compatibility); |
|
1406 | + } |
|
1407 | 1407 | |
1408 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1409 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1410 | - } |
|
1408 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1409 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1410 | + } |
|
1411 | 1411 | |
1412 | - // Set admin bar z-index lower when modal is open. |
|
1413 | - echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1412 | + // Set admin bar z-index lower when modal is open. |
|
1413 | + echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1414 | 1414 | ?> |
1415 | 1415 | </style> |
1416 | 1416 | <?php |
1417 | 1417 | |
1418 | 1418 | |
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( |
|
1423 | - '<style>', |
|
1424 | - '</style>' |
|
1425 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1426 | - } |
|
1427 | - |
|
1428 | - /** |
|
1429 | - * Check if we should add booststrap 3 compatibility changes. |
|
1430 | - * |
|
1431 | - * @return bool |
|
1432 | - */ |
|
1433 | - public static function is_bs3_compat(){ |
|
1434 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1435 | - } |
|
1436 | - |
|
1437 | - public static function css_primary($color_code,$compatibility){; |
|
1438 | - $color_code = sanitize_hex_color($color_code); |
|
1439 | - if(!$color_code){return '';} |
|
1440 | - /** |
|
1441 | - * c = color, b = background color, o = border-color, f = fill |
|
1442 | - */ |
|
1443 | - $selectors = array( |
|
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'), |
|
1453 | - '.btn-link' => array('c'), |
|
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'), |
|
1422 | + return str_replace( array( |
|
1423 | + '<style>', |
|
1424 | + '</style>' |
|
1425 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1426 | + } |
|
1427 | + |
|
1428 | + /** |
|
1429 | + * Check if we should add booststrap 3 compatibility changes. |
|
1430 | + * |
|
1431 | + * @return bool |
|
1432 | + */ |
|
1433 | + public static function is_bs3_compat(){ |
|
1434 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1435 | + } |
|
1436 | + |
|
1437 | + public static function css_primary($color_code,$compatibility){; |
|
1438 | + $color_code = sanitize_hex_color($color_code); |
|
1439 | + if(!$color_code){return '';} |
|
1440 | + /** |
|
1441 | + * c = color, b = background color, o = border-color, f = fill |
|
1442 | + */ |
|
1443 | + $selectors = array( |
|
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'), |
|
1453 | + '.btn-link' => array('c'), |
|
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'), |
|
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 | - '.nav-pills .nav-link.active' => array('b'), |
|
1461 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1462 | - '.page-link' => array('c'), |
|
1463 | - '.page-item.active .page-link' => array('b','o'), |
|
1464 | - '.badge-primary' => array('b'), |
|
1465 | - '.alert-primary' => array('b','o'), |
|
1466 | - '.progress-bar' => array('b'), |
|
1467 | - '.list-group-item.active' => array('b','o'), |
|
1468 | - '.bg-primary' => array('b','f'), |
|
1469 | - '.btn-link.btn-primary' => array('c'), |
|
1470 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1471 | - ); |
|
1472 | - |
|
1473 | - $important_selectors = array( |
|
1474 | - '.bg-primary' => array('b','f'), |
|
1475 | - '.border-primary' => array('o'), |
|
1476 | - '.text-primary' => array('c'), |
|
1477 | - ); |
|
1478 | - |
|
1479 | - $color = array(); |
|
1480 | - $color_i = array(); |
|
1481 | - $background = array(); |
|
1482 | - $background_i = array(); |
|
1483 | - $border = array(); |
|
1484 | - $border_i = array(); |
|
1485 | - $fill = array(); |
|
1486 | - $fill_i = array(); |
|
1487 | - |
|
1488 | - $output = ''; |
|
1489 | - |
|
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;} |
|
1498 | - } |
|
1499 | - |
|
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;} |
|
1508 | - } |
|
1509 | - |
|
1510 | - // add any color rules |
|
1511 | - if(!empty($color)){ |
|
1512 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1513 | - } |
|
1514 | - if(!empty($color_i)){ |
|
1515 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1516 | - } |
|
1517 | - |
|
1518 | - // add any background color rules |
|
1519 | - if(!empty($background)){ |
|
1520 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1521 | - } |
|
1522 | - if(!empty($background_i)){ |
|
1523 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1524 | - } |
|
1525 | - |
|
1526 | - // add any border color rules |
|
1527 | - if(!empty($border)){ |
|
1528 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1529 | - } |
|
1530 | - if(!empty($border_i)){ |
|
1531 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1532 | - } |
|
1533 | - |
|
1534 | - // add any fill color rules |
|
1535 | - if(!empty($fill)){ |
|
1536 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1537 | - } |
|
1538 | - if(!empty($fill_i)){ |
|
1539 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1540 | - } |
|
1541 | - |
|
1542 | - |
|
1543 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1544 | - |
|
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"); |
|
1549 | - |
|
1550 | - // lighten |
|
1551 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1552 | - |
|
1553 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1554 | - $op_25 = $color_code."40"; // 25% opacity |
|
1555 | - |
|
1556 | - |
|
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;} "; |
|
1562 | - |
|
1563 | - |
|
1564 | - // dropdown's |
|
1565 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1566 | - |
|
1567 | - |
|
1568 | - // input states |
|
1569 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1570 | - |
|
1571 | - // page link |
|
1572 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | - |
|
1574 | - return $output; |
|
1575 | - } |
|
1576 | - |
|
1577 | - public static function css_secondary($color_code,$compatibility){; |
|
1578 | - $color_code = sanitize_hex_color($color_code); |
|
1579 | - if(!$color_code){return '';} |
|
1580 | - /** |
|
1581 | - * c = color, b = background color, o = border-color, f = fill |
|
1582 | - */ |
|
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'), |
|
1589 | - '.btn-outline-secondary.disabled' => array('c'), |
|
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'), |
|
1594 | - '.badge-secondary' => array('b'), |
|
1595 | - '.alert-secondary' => array('b','o'), |
|
1596 | - '.btn-link.btn-secondary' => array('c'), |
|
1597 | - ); |
|
1598 | - |
|
1599 | - $important_selectors = array( |
|
1600 | - '.bg-secondary' => array('b','f'), |
|
1601 | - '.border-secondary' => array('o'), |
|
1602 | - '.text-secondary' => array('c'), |
|
1603 | - ); |
|
1604 | - |
|
1605 | - $color = array(); |
|
1606 | - $color_i = array(); |
|
1607 | - $background = array(); |
|
1608 | - $background_i = array(); |
|
1609 | - $border = array(); |
|
1610 | - $border_i = array(); |
|
1611 | - $fill = array(); |
|
1612 | - $fill_i = array(); |
|
1613 | - |
|
1614 | - $output = ''; |
|
1615 | - |
|
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;} |
|
1624 | - } |
|
1625 | - |
|
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;} |
|
1634 | - } |
|
1635 | - |
|
1636 | - // add any color rules |
|
1637 | - if(!empty($color)){ |
|
1638 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1639 | - } |
|
1640 | - if(!empty($color_i)){ |
|
1641 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1642 | - } |
|
1643 | - |
|
1644 | - // add any background color rules |
|
1645 | - if(!empty($background)){ |
|
1646 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1647 | - } |
|
1648 | - if(!empty($background_i)){ |
|
1649 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1650 | - } |
|
1651 | - |
|
1652 | - // add any border color rules |
|
1653 | - if(!empty($border)){ |
|
1654 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1655 | - } |
|
1656 | - if(!empty($border_i)){ |
|
1657 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1658 | - } |
|
1659 | - |
|
1660 | - // add any fill color rules |
|
1661 | - if(!empty($fill)){ |
|
1662 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1663 | - } |
|
1664 | - if(!empty($fill_i)){ |
|
1665 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1666 | - } |
|
1667 | - |
|
1668 | - |
|
1669 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1670 | - |
|
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"); |
|
1675 | - |
|
1676 | - // lighten |
|
1677 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1678 | - |
|
1679 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1680 | - $op_25 = $color_code."40"; // 25% opacity |
|
1681 | - |
|
1682 | - |
|
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;} "; |
|
1688 | - |
|
1689 | - |
|
1690 | - return $output; |
|
1691 | - } |
|
1692 | - |
|
1693 | - /** |
|
1694 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1695 | - * |
|
1696 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1697 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1698 | - * |
|
1699 | - * @return string |
|
1700 | - */ |
|
1701 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1702 | - $hexCode = ltrim($hexCode, '#'); |
|
1703 | - |
|
1704 | - if (strlen($hexCode) == 3) { |
|
1705 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1706 | - } |
|
1707 | - |
|
1708 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1709 | - |
|
1710 | - foreach ($hexCode as & $color) { |
|
1711 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1712 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1713 | - |
|
1714 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1715 | - } |
|
1716 | - |
|
1717 | - return '#' . implode($hexCode); |
|
1718 | - } |
|
1719 | - |
|
1720 | - /** |
|
1721 | - * Check if we should display examples. |
|
1722 | - */ |
|
1723 | - public function maybe_show_examples(){ |
|
1724 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1725 | - echo "<head>"; |
|
1726 | - wp_head(); |
|
1727 | - echo "</head>"; |
|
1728 | - echo "<body>"; |
|
1729 | - echo $this->get_examples(); |
|
1730 | - echo "</body>"; |
|
1731 | - exit; |
|
1732 | - } |
|
1733 | - } |
|
1734 | - |
|
1735 | - /** |
|
1736 | - * Get developer examples. |
|
1737 | - * |
|
1738 | - * @return string |
|
1739 | - */ |
|
1740 | - public function get_examples(){ |
|
1741 | - $output = ''; |
|
1742 | - |
|
1743 | - |
|
1744 | - // open form |
|
1745 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1746 | - |
|
1747 | - // input example |
|
1748 | - $output .= aui()->input(array( |
|
1749 | - 'type' => 'text', |
|
1750 | - 'id' => 'text-example', |
|
1751 | - 'name' => 'text-example', |
|
1752 | - 'placeholder' => 'text placeholder', |
|
1753 | - 'title' => 'Text input example', |
|
1754 | - 'value' => '', |
|
1755 | - 'required' => false, |
|
1756 | - 'help_text' => 'help text', |
|
1757 | - 'label' => 'Text input example label' |
|
1758 | - )); |
|
1759 | - |
|
1760 | - // input example |
|
1761 | - $output .= aui()->input(array( |
|
1762 | - 'type' => 'url', |
|
1763 | - 'id' => 'text-example2', |
|
1764 | - 'name' => 'text-example', |
|
1765 | - 'placeholder' => 'url placeholder', |
|
1766 | - 'title' => 'Text input example', |
|
1767 | - 'value' => '', |
|
1768 | - 'required' => false, |
|
1769 | - 'help_text' => 'help text', |
|
1770 | - 'label' => 'Text input example label' |
|
1771 | - )); |
|
1772 | - |
|
1773 | - // checkbox example |
|
1774 | - $output .= aui()->input(array( |
|
1775 | - 'type' => 'checkbox', |
|
1776 | - 'id' => 'checkbox-example', |
|
1777 | - 'name' => 'checkbox-example', |
|
1778 | - 'placeholder' => 'checkbox-example', |
|
1779 | - 'title' => 'Checkbox example', |
|
1780 | - 'value' => '1', |
|
1781 | - 'checked' => true, |
|
1782 | - 'required' => false, |
|
1783 | - 'help_text' => 'help text', |
|
1784 | - 'label' => 'Checkbox checked' |
|
1785 | - )); |
|
1786 | - |
|
1787 | - // checkbox example |
|
1788 | - $output .= aui()->input(array( |
|
1789 | - 'type' => 'checkbox', |
|
1790 | - 'id' => 'checkbox-example2', |
|
1791 | - 'name' => 'checkbox-example2', |
|
1792 | - 'placeholder' => 'checkbox-example', |
|
1793 | - 'title' => 'Checkbox example', |
|
1794 | - 'value' => '1', |
|
1795 | - 'checked' => false, |
|
1796 | - 'required' => false, |
|
1797 | - 'help_text' => 'help text', |
|
1798 | - 'label' => 'Checkbox un-checked' |
|
1799 | - )); |
|
1800 | - |
|
1801 | - // switch example |
|
1802 | - $output .= aui()->input(array( |
|
1803 | - 'type' => 'checkbox', |
|
1804 | - 'id' => 'switch-example', |
|
1805 | - 'name' => 'switch-example', |
|
1806 | - 'placeholder' => 'checkbox-example', |
|
1807 | - 'title' => 'Switch example', |
|
1808 | - 'value' => '1', |
|
1809 | - 'checked' => true, |
|
1810 | - 'switch' => true, |
|
1811 | - 'required' => false, |
|
1812 | - 'help_text' => 'help text', |
|
1813 | - 'label' => 'Switch on' |
|
1814 | - )); |
|
1815 | - |
|
1816 | - // switch example |
|
1817 | - $output .= aui()->input(array( |
|
1818 | - 'type' => 'checkbox', |
|
1819 | - 'id' => 'switch-example2', |
|
1820 | - 'name' => 'switch-example2', |
|
1821 | - 'placeholder' => 'checkbox-example', |
|
1822 | - 'title' => 'Switch example', |
|
1823 | - 'value' => '1', |
|
1824 | - 'checked' => false, |
|
1825 | - 'switch' => true, |
|
1826 | - 'required' => false, |
|
1827 | - 'help_text' => 'help text', |
|
1828 | - 'label' => 'Switch off' |
|
1829 | - )); |
|
1830 | - |
|
1831 | - // close form |
|
1832 | - $output .= "</form>"; |
|
1833 | - |
|
1834 | - return $output; |
|
1835 | - } |
|
1836 | - |
|
1837 | - /** |
|
1838 | - * Calendar params. |
|
1839 | - * |
|
1840 | - * @since 0.1.44 |
|
1841 | - * |
|
1842 | - * @return array Calendar params. |
|
1843 | - */ |
|
1844 | - public static function calendar_params() { |
|
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' ), |
|
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' ) |
|
1911 | - ); |
|
1912 | - |
|
1913 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1914 | - } |
|
1915 | - |
|
1916 | - /** |
|
1917 | - * Flatpickr calendar localize. |
|
1918 | - * |
|
1919 | - * @since 0.1.44 |
|
1920 | - * |
|
1921 | - * @return string Calendar locale. |
|
1922 | - */ |
|
1923 | - public static function flatpickr_locale() { |
|
1924 | - $params = self::calendar_params(); |
|
1925 | - |
|
1926 | - if ( is_string( $params ) ) { |
|
1927 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1928 | - } else { |
|
1929 | - foreach ( (array) $params as $key => $value ) { |
|
1930 | - if ( ! is_scalar( $value ) ) { |
|
1931 | - continue; |
|
1932 | - } |
|
1933 | - |
|
1934 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1935 | - } |
|
1936 | - } |
|
1460 | + '.nav-pills .nav-link.active' => array('b'), |
|
1461 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1462 | + '.page-link' => array('c'), |
|
1463 | + '.page-item.active .page-link' => array('b','o'), |
|
1464 | + '.badge-primary' => array('b'), |
|
1465 | + '.alert-primary' => array('b','o'), |
|
1466 | + '.progress-bar' => array('b'), |
|
1467 | + '.list-group-item.active' => array('b','o'), |
|
1468 | + '.bg-primary' => array('b','f'), |
|
1469 | + '.btn-link.btn-primary' => array('c'), |
|
1470 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1471 | + ); |
|
1472 | + |
|
1473 | + $important_selectors = array( |
|
1474 | + '.bg-primary' => array('b','f'), |
|
1475 | + '.border-primary' => array('o'), |
|
1476 | + '.text-primary' => array('c'), |
|
1477 | + ); |
|
1478 | + |
|
1479 | + $color = array(); |
|
1480 | + $color_i = array(); |
|
1481 | + $background = array(); |
|
1482 | + $background_i = array(); |
|
1483 | + $border = array(); |
|
1484 | + $border_i = array(); |
|
1485 | + $fill = array(); |
|
1486 | + $fill_i = array(); |
|
1487 | + |
|
1488 | + $output = ''; |
|
1489 | + |
|
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;} |
|
1498 | + } |
|
1499 | + |
|
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;} |
|
1508 | + } |
|
1509 | + |
|
1510 | + // add any color rules |
|
1511 | + if(!empty($color)){ |
|
1512 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1513 | + } |
|
1514 | + if(!empty($color_i)){ |
|
1515 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1516 | + } |
|
1517 | + |
|
1518 | + // add any background color rules |
|
1519 | + if(!empty($background)){ |
|
1520 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1521 | + } |
|
1522 | + if(!empty($background_i)){ |
|
1523 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1524 | + } |
|
1525 | + |
|
1526 | + // add any border color rules |
|
1527 | + if(!empty($border)){ |
|
1528 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1529 | + } |
|
1530 | + if(!empty($border_i)){ |
|
1531 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1532 | + } |
|
1533 | + |
|
1534 | + // add any fill color rules |
|
1535 | + if(!empty($fill)){ |
|
1536 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1537 | + } |
|
1538 | + if(!empty($fill_i)){ |
|
1539 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1540 | + } |
|
1541 | + |
|
1542 | + |
|
1543 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1544 | + |
|
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"); |
|
1549 | + |
|
1550 | + // lighten |
|
1551 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1552 | + |
|
1553 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1554 | + $op_25 = $color_code."40"; // 25% opacity |
|
1555 | + |
|
1556 | + |
|
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;} "; |
|
1562 | + |
|
1563 | + |
|
1564 | + // dropdown's |
|
1565 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1566 | + |
|
1567 | + |
|
1568 | + // input states |
|
1569 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1570 | + |
|
1571 | + // page link |
|
1572 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | + |
|
1574 | + return $output; |
|
1575 | + } |
|
1576 | + |
|
1577 | + public static function css_secondary($color_code,$compatibility){; |
|
1578 | + $color_code = sanitize_hex_color($color_code); |
|
1579 | + if(!$color_code){return '';} |
|
1580 | + /** |
|
1581 | + * c = color, b = background color, o = border-color, f = fill |
|
1582 | + */ |
|
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'), |
|
1589 | + '.btn-outline-secondary.disabled' => array('c'), |
|
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'), |
|
1594 | + '.badge-secondary' => array('b'), |
|
1595 | + '.alert-secondary' => array('b','o'), |
|
1596 | + '.btn-link.btn-secondary' => array('c'), |
|
1597 | + ); |
|
1598 | + |
|
1599 | + $important_selectors = array( |
|
1600 | + '.bg-secondary' => array('b','f'), |
|
1601 | + '.border-secondary' => array('o'), |
|
1602 | + '.text-secondary' => array('c'), |
|
1603 | + ); |
|
1604 | + |
|
1605 | + $color = array(); |
|
1606 | + $color_i = array(); |
|
1607 | + $background = array(); |
|
1608 | + $background_i = array(); |
|
1609 | + $border = array(); |
|
1610 | + $border_i = array(); |
|
1611 | + $fill = array(); |
|
1612 | + $fill_i = array(); |
|
1613 | + |
|
1614 | + $output = ''; |
|
1615 | + |
|
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;} |
|
1624 | + } |
|
1625 | + |
|
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;} |
|
1634 | + } |
|
1635 | + |
|
1636 | + // add any color rules |
|
1637 | + if(!empty($color)){ |
|
1638 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1639 | + } |
|
1640 | + if(!empty($color_i)){ |
|
1641 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1642 | + } |
|
1643 | + |
|
1644 | + // add any background color rules |
|
1645 | + if(!empty($background)){ |
|
1646 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1647 | + } |
|
1648 | + if(!empty($background_i)){ |
|
1649 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1650 | + } |
|
1651 | + |
|
1652 | + // add any border color rules |
|
1653 | + if(!empty($border)){ |
|
1654 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1655 | + } |
|
1656 | + if(!empty($border_i)){ |
|
1657 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1658 | + } |
|
1659 | + |
|
1660 | + // add any fill color rules |
|
1661 | + if(!empty($fill)){ |
|
1662 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1663 | + } |
|
1664 | + if(!empty($fill_i)){ |
|
1665 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1666 | + } |
|
1667 | + |
|
1668 | + |
|
1669 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1670 | + |
|
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"); |
|
1675 | + |
|
1676 | + // lighten |
|
1677 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1678 | + |
|
1679 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1680 | + $op_25 = $color_code."40"; // 25% opacity |
|
1681 | + |
|
1682 | + |
|
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;} "; |
|
1688 | + |
|
1689 | + |
|
1690 | + return $output; |
|
1691 | + } |
|
1692 | + |
|
1693 | + /** |
|
1694 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1695 | + * |
|
1696 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1697 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1698 | + * |
|
1699 | + * @return string |
|
1700 | + */ |
|
1701 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1702 | + $hexCode = ltrim($hexCode, '#'); |
|
1703 | + |
|
1704 | + if (strlen($hexCode) == 3) { |
|
1705 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1706 | + } |
|
1707 | + |
|
1708 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1709 | + |
|
1710 | + foreach ($hexCode as & $color) { |
|
1711 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1712 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1713 | + |
|
1714 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1715 | + } |
|
1716 | + |
|
1717 | + return '#' . implode($hexCode); |
|
1718 | + } |
|
1719 | + |
|
1720 | + /** |
|
1721 | + * Check if we should display examples. |
|
1722 | + */ |
|
1723 | + public function maybe_show_examples(){ |
|
1724 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1725 | + echo "<head>"; |
|
1726 | + wp_head(); |
|
1727 | + echo "</head>"; |
|
1728 | + echo "<body>"; |
|
1729 | + echo $this->get_examples(); |
|
1730 | + echo "</body>"; |
|
1731 | + exit; |
|
1732 | + } |
|
1733 | + } |
|
1734 | + |
|
1735 | + /** |
|
1736 | + * Get developer examples. |
|
1737 | + * |
|
1738 | + * @return string |
|
1739 | + */ |
|
1740 | + public function get_examples(){ |
|
1741 | + $output = ''; |
|
1742 | + |
|
1743 | + |
|
1744 | + // open form |
|
1745 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1746 | + |
|
1747 | + // input example |
|
1748 | + $output .= aui()->input(array( |
|
1749 | + 'type' => 'text', |
|
1750 | + 'id' => 'text-example', |
|
1751 | + 'name' => 'text-example', |
|
1752 | + 'placeholder' => 'text placeholder', |
|
1753 | + 'title' => 'Text input example', |
|
1754 | + 'value' => '', |
|
1755 | + 'required' => false, |
|
1756 | + 'help_text' => 'help text', |
|
1757 | + 'label' => 'Text input example label' |
|
1758 | + )); |
|
1759 | + |
|
1760 | + // input example |
|
1761 | + $output .= aui()->input(array( |
|
1762 | + 'type' => 'url', |
|
1763 | + 'id' => 'text-example2', |
|
1764 | + 'name' => 'text-example', |
|
1765 | + 'placeholder' => 'url placeholder', |
|
1766 | + 'title' => 'Text input example', |
|
1767 | + 'value' => '', |
|
1768 | + 'required' => false, |
|
1769 | + 'help_text' => 'help text', |
|
1770 | + 'label' => 'Text input example label' |
|
1771 | + )); |
|
1772 | + |
|
1773 | + // checkbox example |
|
1774 | + $output .= aui()->input(array( |
|
1775 | + 'type' => 'checkbox', |
|
1776 | + 'id' => 'checkbox-example', |
|
1777 | + 'name' => 'checkbox-example', |
|
1778 | + 'placeholder' => 'checkbox-example', |
|
1779 | + 'title' => 'Checkbox example', |
|
1780 | + 'value' => '1', |
|
1781 | + 'checked' => true, |
|
1782 | + 'required' => false, |
|
1783 | + 'help_text' => 'help text', |
|
1784 | + 'label' => 'Checkbox checked' |
|
1785 | + )); |
|
1786 | + |
|
1787 | + // checkbox example |
|
1788 | + $output .= aui()->input(array( |
|
1789 | + 'type' => 'checkbox', |
|
1790 | + 'id' => 'checkbox-example2', |
|
1791 | + 'name' => 'checkbox-example2', |
|
1792 | + 'placeholder' => 'checkbox-example', |
|
1793 | + 'title' => 'Checkbox example', |
|
1794 | + 'value' => '1', |
|
1795 | + 'checked' => false, |
|
1796 | + 'required' => false, |
|
1797 | + 'help_text' => 'help text', |
|
1798 | + 'label' => 'Checkbox un-checked' |
|
1799 | + )); |
|
1800 | + |
|
1801 | + // switch example |
|
1802 | + $output .= aui()->input(array( |
|
1803 | + 'type' => 'checkbox', |
|
1804 | + 'id' => 'switch-example', |
|
1805 | + 'name' => 'switch-example', |
|
1806 | + 'placeholder' => 'checkbox-example', |
|
1807 | + 'title' => 'Switch example', |
|
1808 | + 'value' => '1', |
|
1809 | + 'checked' => true, |
|
1810 | + 'switch' => true, |
|
1811 | + 'required' => false, |
|
1812 | + 'help_text' => 'help text', |
|
1813 | + 'label' => 'Switch on' |
|
1814 | + )); |
|
1815 | + |
|
1816 | + // switch example |
|
1817 | + $output .= aui()->input(array( |
|
1818 | + 'type' => 'checkbox', |
|
1819 | + 'id' => 'switch-example2', |
|
1820 | + 'name' => 'switch-example2', |
|
1821 | + 'placeholder' => 'checkbox-example', |
|
1822 | + 'title' => 'Switch example', |
|
1823 | + 'value' => '1', |
|
1824 | + 'checked' => false, |
|
1825 | + 'switch' => true, |
|
1826 | + 'required' => false, |
|
1827 | + 'help_text' => 'help text', |
|
1828 | + 'label' => 'Switch off' |
|
1829 | + )); |
|
1830 | + |
|
1831 | + // close form |
|
1832 | + $output .= "</form>"; |
|
1833 | + |
|
1834 | + return $output; |
|
1835 | + } |
|
1836 | + |
|
1837 | + /** |
|
1838 | + * Calendar params. |
|
1839 | + * |
|
1840 | + * @since 0.1.44 |
|
1841 | + * |
|
1842 | + * @return array Calendar params. |
|
1843 | + */ |
|
1844 | + public static function calendar_params() { |
|
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' ), |
|
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' ) |
|
1911 | + ); |
|
1912 | + |
|
1913 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1914 | + } |
|
1915 | + |
|
1916 | + /** |
|
1917 | + * Flatpickr calendar localize. |
|
1918 | + * |
|
1919 | + * @since 0.1.44 |
|
1920 | + * |
|
1921 | + * @return string Calendar locale. |
|
1922 | + */ |
|
1923 | + public static function flatpickr_locale() { |
|
1924 | + $params = self::calendar_params(); |
|
1925 | + |
|
1926 | + if ( is_string( $params ) ) { |
|
1927 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1928 | + } else { |
|
1929 | + foreach ( (array) $params as $key => $value ) { |
|
1930 | + if ( ! is_scalar( $value ) ) { |
|
1931 | + continue; |
|
1932 | + } |
|
1933 | + |
|
1934 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1935 | + } |
|
1936 | + } |
|
1937 | 1937 | |
1938 | - $day_s3 = array(); |
|
1939 | - $day_s5 = array(); |
|
1938 | + $day_s3 = array(); |
|
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 ] ); |
|
1944 | - } |
|
1941 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
1942 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1943 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1944 | + } |
|
1945 | 1945 | |
1946 | - $month_s = array(); |
|
1947 | - $month_long = array(); |
|
1946 | + $month_s = array(); |
|
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 ] ); |
|
1952 | - } |
|
1949 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
1950 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1951 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1952 | + } |
|
1953 | 1953 | |
1954 | 1954 | ob_start(); |
1955 | 1955 | if ( 0 ) { ?><script><?php } ?> |
@@ -1991,184 +1991,184 @@ discard block |
||
1991 | 1991 | } |
1992 | 1992 | <?php if ( 0 ) { ?></script><?php } ?> |
1993 | 1993 | <?php |
1994 | - $locale = ob_get_clean(); |
|
1995 | - |
|
1996 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
1997 | - } |
|
1998 | - |
|
1999 | - /** |
|
2000 | - * Select2 JS params. |
|
2001 | - * |
|
2002 | - * @since 0.1.44 |
|
2003 | - * |
|
2004 | - * @return array Select2 JS params. |
|
2005 | - */ |
|
2006 | - public static function select2_params() { |
|
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' ) |
|
2019 | - ); |
|
2020 | - |
|
2021 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2022 | - } |
|
2023 | - |
|
2024 | - /** |
|
2025 | - * Select2 JS localize. |
|
2026 | - * |
|
2027 | - * @since 0.1.44 |
|
2028 | - * |
|
2029 | - * @return string Select2 JS locale. |
|
2030 | - */ |
|
2031 | - public static function select2_locale() { |
|
2032 | - $params = self::select2_params(); |
|
2033 | - |
|
2034 | - foreach ( (array) $params as $key => $value ) { |
|
2035 | - if ( ! is_scalar( $value ) ) { |
|
2036 | - continue; |
|
2037 | - } |
|
2038 | - |
|
2039 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2040 | - } |
|
2041 | - |
|
2042 | - $locale = json_encode( $params ); |
|
2043 | - |
|
2044 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2045 | - } |
|
2046 | - |
|
2047 | - /** |
|
2048 | - * Time ago JS localize. |
|
2049 | - * |
|
2050 | - * @since 0.1.47 |
|
2051 | - * |
|
2052 | - * @return string Time ago JS locale. |
|
2053 | - */ |
|
2054 | - public static function timeago_locale() { |
|
2055 | - $params = array( |
|
2056 | - 'prefix_ago' => '', |
|
2057 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2058 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
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' ), |
|
2071 | - ); |
|
2072 | - |
|
2073 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2074 | - |
|
2075 | - foreach ( (array) $params as $key => $value ) { |
|
2076 | - if ( ! is_scalar( $value ) ) { |
|
2077 | - continue; |
|
2078 | - } |
|
2079 | - |
|
2080 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2081 | - } |
|
2082 | - |
|
2083 | - $locale = json_encode( $params ); |
|
2084 | - |
|
2085 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2086 | - } |
|
2087 | - |
|
2088 | - /** |
|
2089 | - * JavaScript Minifier |
|
2090 | - * |
|
2091 | - * @param $input |
|
2092 | - * |
|
2093 | - * @return mixed |
|
2094 | - */ |
|
2095 | - public static function minify_js($input) { |
|
2096 | - if(trim($input) === "") return $input; |
|
2097 | - return preg_replace( |
|
2098 | - array( |
|
2099 | - // Remove comment(s) |
|
2100 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2101 | - // Remove white-space(s) outside the string and regex |
|
2102 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2103 | - // Remove the last semicolon |
|
2104 | - '#;+\}#', |
|
2105 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2106 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2107 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
2108 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2109 | - ), |
|
2110 | - array( |
|
2111 | - '$1', |
|
2112 | - '$1$2', |
|
2113 | - '}', |
|
2114 | - '$1$3', |
|
2115 | - '$1.$3' |
|
2116 | - ), |
|
2117 | - $input); |
|
2118 | - } |
|
1994 | + $locale = ob_get_clean(); |
|
1995 | + |
|
1996 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
1997 | + } |
|
1998 | + |
|
1999 | + /** |
|
2000 | + * Select2 JS params. |
|
2001 | + * |
|
2002 | + * @since 0.1.44 |
|
2003 | + * |
|
2004 | + * @return array Select2 JS params. |
|
2005 | + */ |
|
2006 | + public static function select2_params() { |
|
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' ) |
|
2019 | + ); |
|
2020 | + |
|
2021 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2022 | + } |
|
2023 | + |
|
2024 | + /** |
|
2025 | + * Select2 JS localize. |
|
2026 | + * |
|
2027 | + * @since 0.1.44 |
|
2028 | + * |
|
2029 | + * @return string Select2 JS locale. |
|
2030 | + */ |
|
2031 | + public static function select2_locale() { |
|
2032 | + $params = self::select2_params(); |
|
2033 | + |
|
2034 | + foreach ( (array) $params as $key => $value ) { |
|
2035 | + if ( ! is_scalar( $value ) ) { |
|
2036 | + continue; |
|
2037 | + } |
|
2119 | 2038 | |
2120 | - /** |
|
2121 | - * Minify CSS |
|
2122 | - * |
|
2123 | - * @param $input |
|
2124 | - * |
|
2125 | - * @return mixed |
|
2126 | - */ |
|
2127 | - public static function minify_css($input) { |
|
2128 | - if(trim($input) === "") return $input; |
|
2129 | - return preg_replace( |
|
2130 | - array( |
|
2131 | - // Remove comment(s) |
|
2132 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2133 | - // Remove unused white-space(s) |
|
2134 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2135 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2136 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2137 | - // Replace `:0 0 0 0` with `:0` |
|
2138 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2139 | - // Replace `background-position:0` with `background-position:0 0` |
|
2140 | - '#(background-position):0(?=[;\}])#si', |
|
2141 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2142 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2143 | - // Minify string value |
|
2144 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2145 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2146 | - // Minify HEX color code |
|
2147 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2148 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
2149 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2150 | - // Remove empty selector(s) |
|
2151 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2152 | - ), |
|
2153 | - array( |
|
2154 | - '$1', |
|
2155 | - '$1$2$3$4$5$6$7', |
|
2156 | - '$1', |
|
2157 | - ':0', |
|
2158 | - '$1:0 0', |
|
2159 | - '.$1', |
|
2160 | - '$1$3', |
|
2161 | - '$1$2$4$5', |
|
2162 | - '$1$2$3', |
|
2163 | - '$1:0', |
|
2164 | - '$1$2' |
|
2165 | - ), |
|
2166 | - $input); |
|
2167 | - } |
|
2168 | - } |
|
2039 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2040 | + } |
|
2041 | + |
|
2042 | + $locale = json_encode( $params ); |
|
2043 | + |
|
2044 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2045 | + } |
|
2046 | + |
|
2047 | + /** |
|
2048 | + * Time ago JS localize. |
|
2049 | + * |
|
2050 | + * @since 0.1.47 |
|
2051 | + * |
|
2052 | + * @return string Time ago JS locale. |
|
2053 | + */ |
|
2054 | + public static function timeago_locale() { |
|
2055 | + $params = array( |
|
2056 | + 'prefix_ago' => '', |
|
2057 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2058 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
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' ), |
|
2071 | + ); |
|
2072 | + |
|
2073 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2074 | + |
|
2075 | + foreach ( (array) $params as $key => $value ) { |
|
2076 | + if ( ! is_scalar( $value ) ) { |
|
2077 | + continue; |
|
2078 | + } |
|
2169 | 2079 | |
2170 | - /** |
|
2171 | - * Run the class if found. |
|
2172 | - */ |
|
2173 | - AyeCode_UI_Settings::instance(); |
|
2080 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2081 | + } |
|
2082 | + |
|
2083 | + $locale = json_encode( $params ); |
|
2084 | + |
|
2085 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2086 | + } |
|
2087 | + |
|
2088 | + /** |
|
2089 | + * JavaScript Minifier |
|
2090 | + * |
|
2091 | + * @param $input |
|
2092 | + * |
|
2093 | + * @return mixed |
|
2094 | + */ |
|
2095 | + public static function minify_js($input) { |
|
2096 | + if(trim($input) === "") return $input; |
|
2097 | + return preg_replace( |
|
2098 | + array( |
|
2099 | + // Remove comment(s) |
|
2100 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2101 | + // Remove white-space(s) outside the string and regex |
|
2102 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2103 | + // Remove the last semicolon |
|
2104 | + '#;+\}#', |
|
2105 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2106 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2107 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
2108 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2109 | + ), |
|
2110 | + array( |
|
2111 | + '$1', |
|
2112 | + '$1$2', |
|
2113 | + '}', |
|
2114 | + '$1$3', |
|
2115 | + '$1.$3' |
|
2116 | + ), |
|
2117 | + $input); |
|
2118 | + } |
|
2119 | + |
|
2120 | + /** |
|
2121 | + * Minify CSS |
|
2122 | + * |
|
2123 | + * @param $input |
|
2124 | + * |
|
2125 | + * @return mixed |
|
2126 | + */ |
|
2127 | + public static function minify_css($input) { |
|
2128 | + if(trim($input) === "") return $input; |
|
2129 | + return preg_replace( |
|
2130 | + array( |
|
2131 | + // Remove comment(s) |
|
2132 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2133 | + // Remove unused white-space(s) |
|
2134 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2135 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2136 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2137 | + // Replace `:0 0 0 0` with `:0` |
|
2138 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2139 | + // Replace `background-position:0` with `background-position:0 0` |
|
2140 | + '#(background-position):0(?=[;\}])#si', |
|
2141 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2142 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2143 | + // Minify string value |
|
2144 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2145 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2146 | + // Minify HEX color code |
|
2147 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2148 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
2149 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2150 | + // Remove empty selector(s) |
|
2151 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2152 | + ), |
|
2153 | + array( |
|
2154 | + '$1', |
|
2155 | + '$1$2$3$4$5$6$7', |
|
2156 | + '$1', |
|
2157 | + ':0', |
|
2158 | + '$1:0 0', |
|
2159 | + '.$1', |
|
2160 | + '$1$3', |
|
2161 | + '$1$2$4$5', |
|
2162 | + '$1$2$3', |
|
2163 | + '$1:0', |
|
2164 | + '$1$2' |
|
2165 | + ), |
|
2166 | + $input); |
|
2167 | + } |
|
2168 | + } |
|
2169 | + |
|
2170 | + /** |
|
2171 | + * Run the class if found. |
|
2172 | + */ |
|
2173 | + AyeCode_UI_Settings::instance(); |
|
2174 | 2174 | } |
2175 | 2175 | \ No newline at end of file |
@@ -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) |
@@ -126,8 +126,12 @@ discard block |
||
126 | 126 | public function constants(){ |
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) { |
|
130 | + define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + if (!defined('AUI_SECONDARY_COLOR')) { |
|
133 | + define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
134 | + } |
|
131 | 135 | } |
132 | 136 | |
133 | 137 | /** |
@@ -233,7 +237,7 @@ discard block |
||
233 | 237 | |
234 | 238 | if( is_admin() && !$this->is_aui_screen()){ |
235 | 239 | // don't add wp-admin scripts if not requested to |
236 | - }else{ |
|
240 | + } else{ |
|
237 | 241 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
238 | 242 | |
239 | 243 | $rtl = is_rtl() ? '-rtl' : ''; |
@@ -1051,7 +1055,7 @@ discard block |
||
1051 | 1055 | |
1052 | 1056 | if( is_admin() && !$this->is_aui_screen()){ |
1053 | 1057 | // don't add wp-admin scripts if not requested to |
1054 | - }else { |
|
1058 | + } else { |
|
1055 | 1059 | |
1056 | 1060 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
1057 | 1061 | |
@@ -2093,7 +2097,9 @@ discard block |
||
2093 | 2097 | * @return mixed |
2094 | 2098 | */ |
2095 | 2099 | public static function minify_js($input) { |
2096 | - if(trim($input) === "") return $input; |
|
2100 | + if(trim($input) === "") { |
|
2101 | + return $input; |
|
2102 | + } |
|
2097 | 2103 | return preg_replace( |
2098 | 2104 | array( |
2099 | 2105 | // Remove comment(s) |
@@ -2125,7 +2131,9 @@ discard block |
||
2125 | 2131 | * @return mixed |
2126 | 2132 | */ |
2127 | 2133 | public static function minify_css($input) { |
2128 | - if(trim($input) === "") return $input; |
|
2134 | + if(trim($input) === "") { |
|
2135 | + return $input; |
|
2136 | + } |
|
2129 | 2137 | return preg_replace( |
2130 | 2138 | array( |
2131 | 2139 | // Remove comment(s) |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | 14 | private static $installed = array ( |
15 | - 'root' => |
|
16 | - array ( |
|
15 | + 'root' => |
|
16 | + array ( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
@@ -21,87 +21,87 @@ discard block |
||
21 | 21 | ), |
22 | 22 | 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | - ), |
|
25 | - 'versions' => |
|
26 | - array ( |
|
24 | + ), |
|
25 | + 'versions' => |
|
26 | + array ( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | 28 | array ( |
29 | - 'pretty_version' => '1.0.3', |
|
30 | - 'version' => '1.0.3.0', |
|
31 | - 'aliases' => |
|
32 | - array ( |
|
33 | - ), |
|
34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
29 | + 'pretty_version' => '1.0.3', |
|
30 | + 'version' => '1.0.3.0', |
|
31 | + 'aliases' => |
|
32 | + array ( |
|
33 | + ), |
|
34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | 37 | array ( |
38 | - 'pretty_version' => 'dev-master', |
|
39 | - 'version' => 'dev-master', |
|
40 | - 'aliases' => |
|
41 | - array ( |
|
42 | - ), |
|
43 | - 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
|
38 | + 'pretty_version' => 'dev-master', |
|
39 | + 'version' => 'dev-master', |
|
40 | + 'aliases' => |
|
41 | + array ( |
|
42 | + ), |
|
43 | + 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
|
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | 46 | array ( |
47 | - 'pretty_version' => '0.1.47', |
|
48 | - 'version' => '0.1.47.0', |
|
49 | - 'aliases' => |
|
50 | - array ( |
|
51 | - ), |
|
52 | - 'reference' => '4bb5b0c46c494155ba402c379dc7a50cfb7b707e', |
|
47 | + 'pretty_version' => '0.1.47', |
|
48 | + 'version' => '0.1.47.0', |
|
49 | + 'aliases' => |
|
50 | + array ( |
|
51 | + ), |
|
52 | + 'reference' => '4bb5b0c46c494155ba402c379dc7a50cfb7b707e', |
|
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | 55 | array ( |
56 | - 'pretty_version' => '1.0.12', |
|
57 | - 'version' => '1.0.12.0', |
|
58 | - 'aliases' => |
|
59 | - array ( |
|
60 | - ), |
|
61 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
56 | + 'pretty_version' => '1.0.12', |
|
57 | + 'version' => '1.0.12.0', |
|
58 | + 'aliases' => |
|
59 | + array ( |
|
60 | + ), |
|
61 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | 64 | array ( |
65 | - 'pretty_version' => '1.0.25', |
|
66 | - 'version' => '1.0.25.0', |
|
67 | - 'aliases' => |
|
68 | - array ( |
|
69 | - ), |
|
70 | - 'reference' => '046b2b3ee8f765322bf74725554aa777b6e4979b', |
|
65 | + 'pretty_version' => '1.0.25', |
|
66 | + 'version' => '1.0.25.0', |
|
67 | + 'aliases' => |
|
68 | + array ( |
|
69 | + ), |
|
70 | + 'reference' => '046b2b3ee8f765322bf74725554aa777b6e4979b', |
|
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | 73 | array ( |
74 | - 'pretty_version' => 'v1.11.0', |
|
75 | - 'version' => '1.11.0.0', |
|
76 | - 'aliases' => |
|
77 | - array ( |
|
78 | - ), |
|
79 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
74 | + 'pretty_version' => 'v1.11.0', |
|
75 | + 'version' => '1.11.0.0', |
|
76 | + 'aliases' => |
|
77 | + array ( |
|
78 | + ), |
|
79 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | 82 | array ( |
83 | - 'pretty_version' => 'v1.6.0', |
|
84 | - 'version' => '1.6.0.0', |
|
85 | - 'aliases' => |
|
86 | - array ( |
|
87 | - ), |
|
88 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
83 | + 'pretty_version' => 'v1.6.0', |
|
84 | + 'version' => '1.6.0.0', |
|
85 | + 'aliases' => |
|
86 | + array ( |
|
87 | + ), |
|
88 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | 91 | array ( |
92 | - 'replaced' => |
|
93 | - array ( |
|
92 | + 'replaced' => |
|
93 | + array ( |
|
94 | 94 | 0 => '*', |
95 | - ), |
|
95 | + ), |
|
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | 98 | array ( |
99 | - 'replaced' => |
|
100 | - array ( |
|
99 | + 'replaced' => |
|
100 | + array ( |
|
101 | 101 | 0 => '*', |
102 | - ), |
|
102 | + ), |
|
103 | + ), |
|
103 | 104 | ), |
104 | - ), |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 |
@@ -11,93 +11,93 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.47', |
48 | 48 | 'version' => '0.1.47.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => '4bb5b0c46c494155ba402c379dc7a50cfb7b707e', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.12', |
57 | 57 | 'version' => '1.0.12.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.25', |
66 | 66 | 'version' => '1.0.25.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => '046b2b3ee8f765322bf74725554aa777b6e4979b', |
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => 'v1.11.0', |
75 | 75 | 'version' => '1.11.0.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.6.0', |
84 | 84 | 'version' => '1.6.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'replaced' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 0 => '*', |
95 | 95 | ), |
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | - array ( |
|
98 | + array( |
|
99 | 99 | 'replaced' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 0 => '*', |
102 | 102 | ), |
103 | 103 | ), |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'root' => |
|
3 | - array ( |
|
2 | + 'root' => |
|
3 | + array ( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
@@ -8,85 +8,85 @@ discard block |
||
8 | 8 | ), |
9 | 9 | 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | - ), |
|
12 | - 'versions' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'versions' => |
|
13 | + array ( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | 15 | array ( |
16 | - 'pretty_version' => '1.0.3', |
|
17 | - 'version' => '1.0.3.0', |
|
18 | - 'aliases' => |
|
19 | - array ( |
|
20 | - ), |
|
21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
16 | + 'pretty_version' => '1.0.3', |
|
17 | + 'version' => '1.0.3.0', |
|
18 | + 'aliases' => |
|
19 | + array ( |
|
20 | + ), |
|
21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | 24 | array ( |
25 | - 'pretty_version' => 'dev-master', |
|
26 | - 'version' => 'dev-master', |
|
27 | - 'aliases' => |
|
28 | - array ( |
|
29 | - ), |
|
30 | - 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
|
25 | + 'pretty_version' => 'dev-master', |
|
26 | + 'version' => 'dev-master', |
|
27 | + 'aliases' => |
|
28 | + array ( |
|
29 | + ), |
|
30 | + 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
|
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | 33 | array ( |
34 | - 'pretty_version' => '0.1.47', |
|
35 | - 'version' => '0.1.47.0', |
|
36 | - 'aliases' => |
|
37 | - array ( |
|
38 | - ), |
|
39 | - 'reference' => '4bb5b0c46c494155ba402c379dc7a50cfb7b707e', |
|
34 | + 'pretty_version' => '0.1.47', |
|
35 | + 'version' => '0.1.47.0', |
|
36 | + 'aliases' => |
|
37 | + array ( |
|
38 | + ), |
|
39 | + 'reference' => '4bb5b0c46c494155ba402c379dc7a50cfb7b707e', |
|
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | 42 | array ( |
43 | - 'pretty_version' => '1.0.12', |
|
44 | - 'version' => '1.0.12.0', |
|
45 | - 'aliases' => |
|
46 | - array ( |
|
47 | - ), |
|
48 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
43 | + 'pretty_version' => '1.0.12', |
|
44 | + 'version' => '1.0.12.0', |
|
45 | + 'aliases' => |
|
46 | + array ( |
|
47 | + ), |
|
48 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | 51 | array ( |
52 | - 'pretty_version' => '1.0.25', |
|
53 | - 'version' => '1.0.25.0', |
|
54 | - 'aliases' => |
|
55 | - array ( |
|
56 | - ), |
|
57 | - 'reference' => '046b2b3ee8f765322bf74725554aa777b6e4979b', |
|
52 | + 'pretty_version' => '1.0.25', |
|
53 | + 'version' => '1.0.25.0', |
|
54 | + 'aliases' => |
|
55 | + array ( |
|
56 | + ), |
|
57 | + 'reference' => '046b2b3ee8f765322bf74725554aa777b6e4979b', |
|
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | 60 | array ( |
61 | - 'pretty_version' => 'v1.11.0', |
|
62 | - 'version' => '1.11.0.0', |
|
63 | - 'aliases' => |
|
64 | - array ( |
|
65 | - ), |
|
66 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
61 | + 'pretty_version' => 'v1.11.0', |
|
62 | + 'version' => '1.11.0.0', |
|
63 | + 'aliases' => |
|
64 | + array ( |
|
65 | + ), |
|
66 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | 69 | array ( |
70 | - 'pretty_version' => 'v1.6.0', |
|
71 | - 'version' => '1.6.0.0', |
|
72 | - 'aliases' => |
|
73 | - array ( |
|
74 | - ), |
|
75 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
70 | + 'pretty_version' => 'v1.6.0', |
|
71 | + 'version' => '1.6.0.0', |
|
72 | + 'aliases' => |
|
73 | + array ( |
|
74 | + ), |
|
75 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | 78 | array ( |
79 | - 'replaced' => |
|
80 | - array ( |
|
79 | + 'replaced' => |
|
80 | + array ( |
|
81 | 81 | 0 => '*', |
82 | - ), |
|
82 | + ), |
|
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | 85 | array ( |
86 | - 'replaced' => |
|
87 | - array ( |
|
86 | + 'replaced' => |
|
87 | + array ( |
|
88 | 88 | 0 => '*', |
89 | - ), |
|
89 | + ), |
|
90 | + ), |
|
90 | 91 | ), |
91 | - ), |
|
92 | 92 | ); |
@@ -1,90 +1,90 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => '18efaac45c9478c4666486cdad54cd55d374607a', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.47', |
35 | 35 | 'version' => '0.1.47.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => '4bb5b0c46c494155ba402c379dc7a50cfb7b707e', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.12', |
44 | 44 | 'version' => '1.0.12.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.25', |
53 | 53 | 'version' => '1.0.25.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => '046b2b3ee8f765322bf74725554aa777b6e4979b', |
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => 'v1.11.0', |
62 | 62 | 'version' => '1.11.0.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.6.0', |
71 | 71 | 'version' => '1.6.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'replaced' => |
80 | - array ( |
|
80 | + array( |
|
81 | 81 | 0 => '*', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'replaced' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 0 => '*', |
89 | 89 | ), |
90 | 90 | ), |
@@ -12,473 +12,473 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Invoice_Notification_Emails { |
14 | 14 | |
15 | - /** |
|
16 | - * The array of invoice email actions. |
|
17 | - * |
|
18 | - * @param array |
|
19 | - */ |
|
20 | - public $invoice_actions; |
|
21 | - |
|
22 | - /** |
|
23 | - * Class constructor |
|
24 | - * |
|
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - |
|
28 | - $this->invoice_actions = apply_filters( |
|
29 | - 'getpaid_notification_email_invoice_triggers', |
|
30 | - array( |
|
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
32 | - 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
|
33 | - 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
|
34 | - 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
|
35 | - 'getpaid_invoice_status_wpi-processing' => 'processing_invoice', |
|
36 | - 'getpaid_invoice_status_publish' => 'completed_invoice', |
|
37 | - 'getpaid_invoice_status_wpi-renewal' => 'completed_invoice', |
|
38 | - 'getpaid_invoice_status_wpi-refunded' => 'refunded_invoice', |
|
39 | - 'getpaid_new_customer_note' => 'user_note', |
|
40 | - 'getpaid_daily_maintenance' => 'overdue', |
|
41 | - ) |
|
42 | - ); |
|
43 | - |
|
44 | - $this->init_hooks(); |
|
45 | - |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Registers email hooks. |
|
50 | - */ |
|
51 | - public function init_hooks() { |
|
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 ); |
|
55 | - |
|
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
58 | - } |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Registers an email hook for an invoice action. |
|
63 | - * |
|
64 | - * @param string $hook |
|
65 | - * @param string|array $email_type |
|
66 | - */ |
|
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
68 | - |
|
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
70 | - |
|
71 | - foreach ( $email_type as $type ) { |
|
72 | - |
|
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
74 | - |
|
75 | - // Abort if it is not active. |
|
76 | - if ( ! $email->is_active() ) { |
|
77 | - continue; |
|
78 | - } |
|
79 | - |
|
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
82 | - continue; |
|
83 | - } |
|
84 | - |
|
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
86 | - } |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Filters invoice merge tags. |
|
92 | - * |
|
93 | - * @param array $merge_tags |
|
94 | - * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
95 | - */ |
|
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
97 | - |
|
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
99 | - return array_merge( |
|
100 | - $merge_tags, |
|
101 | - $this->get_invoice_merge_tags( $object ) |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
106 | - return array_merge( |
|
107 | - $merge_tags, |
|
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - return $merge_tags; |
|
113 | - |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Generates invoice merge tags. |
|
118 | - * |
|
119 | - * @param WPInv_Invoice $invoice |
|
120 | - * @return array |
|
121 | - */ |
|
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
123 | - |
|
124 | - // Abort if it does not exist. |
|
125 | - if ( ! $invoice->get_id() ) { |
|
126 | - return array(); |
|
127 | - } |
|
128 | - |
|
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' ), |
|
148 | - ); |
|
149 | - |
|
150 | - $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
151 | - |
|
152 | - if ( is_array( $payment_form_data ) ) { |
|
153 | - |
|
154 | - foreach ( $payment_form_data as $label => $value ) { |
|
155 | - |
|
156 | - $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | - $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
158 | - |
|
159 | - if ( is_scalar ( $value ) ) { |
|
160 | - $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
161 | - } |
|
162 | - |
|
163 | - } |
|
164 | - |
|
165 | - } |
|
166 | - |
|
167 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Helper function to send an email. |
|
172 | - * |
|
173 | - * @param WPInv_Invoice $invoice |
|
174 | - * @param GetPaid_Notification_Email $email |
|
175 | - * @param string $type |
|
176 | - * @param string|array $recipients |
|
177 | - * @param array $extra_args Extra template args. |
|
178 | - */ |
|
179 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
180 | - |
|
181 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
182 | - |
|
183 | - if ( apply_filters( 'getpaid_skip_invoice_email', false, $type, $invoice ) ) { |
|
184 | - return; |
|
185 | - } |
|
186 | - |
|
187 | - $mailer = new GetPaid_Notification_Email_Sender(); |
|
188 | - $merge_tags = $email->get_merge_tags(); |
|
189 | - |
|
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 ), |
|
194 | - $email->get_attachments() |
|
195 | - ); |
|
196 | - |
|
197 | - // Maybe send a copy to the admin. |
|
198 | - if ( $email->include_admin_bcc() ) { |
|
199 | - $mailer->send( |
|
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 ), |
|
203 | - $email->get_attachments() |
|
204 | - ); |
|
205 | - } |
|
206 | - |
|
207 | - if ( $result ) { |
|
208 | - $invoice->add_note( sprintf( __( 'Successfully sent %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
209 | - } else { |
|
210 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
211 | - } |
|
212 | - |
|
213 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
214 | - |
|
215 | - return $result; |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * Also send emails to any cc users. |
|
220 | - * |
|
221 | - * @param array $recipients |
|
222 | - * @param GetPaid_Notification_Email $email |
|
223 | - */ |
|
224 | - public function filter_email_recipients( $recipients, $email ) { |
|
225 | - |
|
226 | - if ( ! $email->is_admin_email() ) { |
|
227 | - $cc = $email->object->get_email_cc(); |
|
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 ) ) ); |
|
232 | - } |
|
15 | + /** |
|
16 | + * The array of invoice email actions. |
|
17 | + * |
|
18 | + * @param array |
|
19 | + */ |
|
20 | + public $invoice_actions; |
|
21 | + |
|
22 | + /** |
|
23 | + * Class constructor |
|
24 | + * |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + |
|
28 | + $this->invoice_actions = apply_filters( |
|
29 | + 'getpaid_notification_email_invoice_triggers', |
|
30 | + array( |
|
31 | + 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
32 | + 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
|
33 | + 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
|
34 | + 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
|
35 | + 'getpaid_invoice_status_wpi-processing' => 'processing_invoice', |
|
36 | + 'getpaid_invoice_status_publish' => 'completed_invoice', |
|
37 | + 'getpaid_invoice_status_wpi-renewal' => 'completed_invoice', |
|
38 | + 'getpaid_invoice_status_wpi-refunded' => 'refunded_invoice', |
|
39 | + 'getpaid_new_customer_note' => 'user_note', |
|
40 | + 'getpaid_daily_maintenance' => 'overdue', |
|
41 | + ) |
|
42 | + ); |
|
43 | + |
|
44 | + $this->init_hooks(); |
|
45 | + |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Registers email hooks. |
|
50 | + */ |
|
51 | + public function init_hooks() { |
|
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 ); |
|
55 | + |
|
56 | + foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | + $this->init_email_type_hook( $hook, $email_type ); |
|
58 | + } |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Registers an email hook for an invoice action. |
|
63 | + * |
|
64 | + * @param string $hook |
|
65 | + * @param string|array $email_type |
|
66 | + */ |
|
67 | + public function init_email_type_hook( $hook, $email_type ) { |
|
68 | + |
|
69 | + $email_type = wpinv_parse_list( $email_type ); |
|
70 | + |
|
71 | + foreach ( $email_type as $type ) { |
|
72 | + |
|
73 | + $email = new GetPaid_Notification_Email( $type ); |
|
74 | + |
|
75 | + // Abort if it is not active. |
|
76 | + if ( ! $email->is_active() ) { |
|
77 | + continue; |
|
78 | + } |
|
79 | + |
|
80 | + if ( method_exists( $this, $type ) ) { |
|
81 | + add_action( $hook, array( $this, $type ), 100, 2 ); |
|
82 | + continue; |
|
83 | + } |
|
84 | + |
|
85 | + do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
86 | + } |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Filters invoice merge tags. |
|
92 | + * |
|
93 | + * @param array $merge_tags |
|
94 | + * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
95 | + */ |
|
96 | + public function invoice_merge_tags( $merge_tags, $object ) { |
|
97 | + |
|
98 | + if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
99 | + return array_merge( |
|
100 | + $merge_tags, |
|
101 | + $this->get_invoice_merge_tags( $object ) |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
106 | + return array_merge( |
|
107 | + $merge_tags, |
|
108 | + $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + return $merge_tags; |
|
113 | + |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Generates invoice merge tags. |
|
118 | + * |
|
119 | + * @param WPInv_Invoice $invoice |
|
120 | + * @return array |
|
121 | + */ |
|
122 | + public function get_invoice_merge_tags( $invoice ) { |
|
123 | + |
|
124 | + // Abort if it does not exist. |
|
125 | + if ( ! $invoice->get_id() ) { |
|
126 | + return array(); |
|
127 | + } |
|
128 | + |
|
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' ), |
|
148 | + ); |
|
149 | + |
|
150 | + $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
151 | + |
|
152 | + if ( is_array( $payment_form_data ) ) { |
|
153 | + |
|
154 | + foreach ( $payment_form_data as $label => $value ) { |
|
155 | + |
|
156 | + $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | + $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
158 | + |
|
159 | + if ( is_scalar ( $value ) ) { |
|
160 | + $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
161 | + } |
|
162 | + |
|
163 | + } |
|
164 | + |
|
165 | + } |
|
166 | + |
|
167 | + return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Helper function to send an email. |
|
172 | + * |
|
173 | + * @param WPInv_Invoice $invoice |
|
174 | + * @param GetPaid_Notification_Email $email |
|
175 | + * @param string $type |
|
176 | + * @param string|array $recipients |
|
177 | + * @param array $extra_args Extra template args. |
|
178 | + */ |
|
179 | + public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
180 | + |
|
181 | + do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
182 | + |
|
183 | + if ( apply_filters( 'getpaid_skip_invoice_email', false, $type, $invoice ) ) { |
|
184 | + return; |
|
185 | + } |
|
186 | + |
|
187 | + $mailer = new GetPaid_Notification_Email_Sender(); |
|
188 | + $merge_tags = $email->get_merge_tags(); |
|
189 | + |
|
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 ), |
|
194 | + $email->get_attachments() |
|
195 | + ); |
|
196 | + |
|
197 | + // Maybe send a copy to the admin. |
|
198 | + if ( $email->include_admin_bcc() ) { |
|
199 | + $mailer->send( |
|
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 ), |
|
203 | + $email->get_attachments() |
|
204 | + ); |
|
205 | + } |
|
206 | + |
|
207 | + if ( $result ) { |
|
208 | + $invoice->add_note( sprintf( __( 'Successfully sent %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
209 | + } else { |
|
210 | + $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
211 | + } |
|
212 | + |
|
213 | + do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
214 | + |
|
215 | + return $result; |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * Also send emails to any cc users. |
|
220 | + * |
|
221 | + * @param array $recipients |
|
222 | + * @param GetPaid_Notification_Email $email |
|
223 | + */ |
|
224 | + public function filter_email_recipients( $recipients, $email ) { |
|
225 | + |
|
226 | + if ( ! $email->is_admin_email() ) { |
|
227 | + $cc = $email->object->get_email_cc(); |
|
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 ) ) ); |
|
232 | + } |
|
233 | 233 | |
234 | - } |
|
234 | + } |
|
235 | 235 | |
236 | - return $recipients; |
|
236 | + return $recipients; |
|
237 | 237 | |
238 | - } |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Sends a new invoice notification. |
|
242 | - * |
|
243 | - * @param WPInv_Invoice $invoice |
|
244 | - */ |
|
245 | - public function new_invoice( $invoice ) { |
|
240 | + /** |
|
241 | + * Sends a new invoice notification. |
|
242 | + * |
|
243 | + * @param WPInv_Invoice $invoice |
|
244 | + */ |
|
245 | + public function new_invoice( $invoice ) { |
|
246 | 246 | |
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() ) ) { |
|
249 | - return; |
|
250 | - } |
|
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() ) ) { |
|
249 | + return; |
|
250 | + } |
|
251 | 251 | |
252 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
253 | - $recipient = wpinv_get_admin_email(); |
|
252 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
259 | - /** |
|
260 | - * Sends a cancelled invoice notification. |
|
261 | - * |
|
262 | - * @param WPInv_Invoice $invoice |
|
263 | - */ |
|
264 | - public function cancelled_invoice( $invoice ) { |
|
259 | + /** |
|
260 | + * Sends a cancelled invoice notification. |
|
261 | + * |
|
262 | + * @param WPInv_Invoice $invoice |
|
263 | + */ |
|
264 | + public function cancelled_invoice( $invoice ) { |
|
265 | 265 | |
266 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
267 | - $recipient = wpinv_get_admin_email(); |
|
266 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
273 | - /** |
|
274 | - * Sends a failed invoice notification. |
|
275 | - * |
|
276 | - * @param WPInv_Invoice $invoice |
|
277 | - */ |
|
278 | - public function failed_invoice( $invoice ) { |
|
273 | + /** |
|
274 | + * Sends a failed invoice notification. |
|
275 | + * |
|
276 | + * @param WPInv_Invoice $invoice |
|
277 | + */ |
|
278 | + public function failed_invoice( $invoice ) { |
|
279 | 279 | |
280 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
281 | - $recipient = wpinv_get_admin_email(); |
|
280 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
287 | - /** |
|
288 | - * Sends a notification whenever an invoice is put on hold. |
|
289 | - * |
|
290 | - * @param WPInv_Invoice $invoice |
|
291 | - */ |
|
292 | - public function onhold_invoice( $invoice ) { |
|
287 | + /** |
|
288 | + * Sends a notification whenever an invoice is put on hold. |
|
289 | + * |
|
290 | + * @param WPInv_Invoice $invoice |
|
291 | + */ |
|
292 | + public function onhold_invoice( $invoice ) { |
|
293 | 293 | |
294 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
295 | - $recipient = $invoice->get_email(); |
|
294 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
301 | - /** |
|
302 | - * Sends a notification whenever an invoice is marked as processing payment. |
|
303 | - * |
|
304 | - * @param WPInv_Invoice $invoice |
|
305 | - */ |
|
306 | - public function processing_invoice( $invoice ) { |
|
301 | + /** |
|
302 | + * Sends a notification whenever an invoice is marked as processing payment. |
|
303 | + * |
|
304 | + * @param WPInv_Invoice $invoice |
|
305 | + */ |
|
306 | + public function processing_invoice( $invoice ) { |
|
307 | 307 | |
308 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
309 | - $recipient = $invoice->get_email(); |
|
308 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
315 | - /** |
|
316 | - * Sends a notification whenever an invoice is paid. |
|
317 | - * |
|
318 | - * @param WPInv_Invoice $invoice |
|
319 | - */ |
|
320 | - public function completed_invoice( $invoice ) { |
|
315 | + /** |
|
316 | + * Sends a notification whenever an invoice is paid. |
|
317 | + * |
|
318 | + * @param WPInv_Invoice $invoice |
|
319 | + */ |
|
320 | + public function completed_invoice( $invoice ) { |
|
321 | 321 | |
322 | - // (Maybe) abort if it is a renewal invoice. |
|
323 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
324 | - return; |
|
325 | - } |
|
322 | + // (Maybe) abort if it is a renewal invoice. |
|
323 | + if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
324 | + return; |
|
325 | + } |
|
326 | 326 | |
327 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
328 | - $recipient = $invoice->get_email(); |
|
327 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
334 | - /** |
|
335 | - * Sends a notification whenever an invoice is refunded. |
|
336 | - * |
|
337 | - * @param WPInv_Invoice $invoice |
|
338 | - */ |
|
339 | - public function refunded_invoice( $invoice ) { |
|
334 | + /** |
|
335 | + * Sends a notification whenever an invoice is refunded. |
|
336 | + * |
|
337 | + * @param WPInv_Invoice $invoice |
|
338 | + */ |
|
339 | + public function refunded_invoice( $invoice ) { |
|
340 | 340 | |
341 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
342 | - $recipient = $invoice->get_email(); |
|
341 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | |
348 | - /** |
|
349 | - * Notifies a user about new invoices |
|
350 | - * |
|
351 | - * @param WPInv_Invoice $invoice |
|
352 | - * @param bool $force |
|
353 | - */ |
|
354 | - public function user_invoice( $invoice, $force = false ) { |
|
348 | + /** |
|
349 | + * Notifies a user about new invoices |
|
350 | + * |
|
351 | + * @param WPInv_Invoice $invoice |
|
352 | + * @param bool $force |
|
353 | + */ |
|
354 | + public function user_invoice( $invoice, $force = false ) { |
|
355 | 355 | |
356 | - if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
357 | - return; |
|
358 | - } |
|
359 | - |
|
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() ) ) ) { |
|
362 | - return; |
|
363 | - } |
|
356 | + if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
357 | + return; |
|
358 | + } |
|
359 | + |
|
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() ) ) ) { |
|
362 | + return; |
|
363 | + } |
|
364 | 364 | |
365 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
366 | - $recipient = $invoice->get_email(); |
|
365 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
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 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * Checks if an invoice is a payment form invoice. |
|
374 | - * |
|
375 | - * @param int $invoice |
|
376 | - * @return bool |
|
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 ); |
|
381 | - } |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * Checks if an invoice is a payment form invoice. |
|
374 | + * |
|
375 | + * @param int $invoice |
|
376 | + * @return bool |
|
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 ); |
|
381 | + } |
|
382 | 382 | |
383 | - /** |
|
384 | - * Notifies admin about new invoice notes |
|
385 | - * |
|
386 | - * @param WPInv_Invoice $invoice |
|
387 | - * @param string $note |
|
388 | - */ |
|
389 | - public function user_note( $invoice, $note ) { |
|
390 | - |
|
391 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
392 | - $recipient = $invoice->get_email(); |
|
383 | + /** |
|
384 | + * Notifies admin about new invoice notes |
|
385 | + * |
|
386 | + * @param WPInv_Invoice $invoice |
|
387 | + * @param string $note |
|
388 | + */ |
|
389 | + public function user_note( $invoice, $note ) { |
|
390 | + |
|
391 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
392 | + $recipient = $invoice->get_email(); |
|
393 | 393 | |
394 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
395 | - |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * (Force) Sends overdue notices. |
|
400 | - * |
|
401 | - * @param WPInv_Invoice $invoice |
|
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() ); |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * Sends overdue notices. |
|
410 | - * |
|
411 | - * @TODO: Create an invoices query class. |
|
412 | - */ |
|
413 | - public function overdue() { |
|
414 | - global $wpdb; |
|
415 | - |
|
416 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
417 | - |
|
418 | - // Fetch reminder days. |
|
419 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
420 | - |
|
421 | - // Abort if non is set. |
|
422 | - if ( empty( $reminder_days ) ) { |
|
423 | - return; |
|
424 | - } |
|
425 | - |
|
426 | - // Retrieve date query. |
|
427 | - $date_query = $this->get_date_query( $reminder_days ); |
|
428 | - |
|
429 | - // Invoices table. |
|
430 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
431 | - |
|
432 | - // Fetch invoices. |
|
433 | - $invoices = $wpdb->get_col( |
|
434 | - "SELECT posts.ID FROM $wpdb->posts as posts |
|
394 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
395 | + |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * (Force) Sends overdue notices. |
|
400 | + * |
|
401 | + * @param WPInv_Invoice $invoice |
|
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() ); |
|
406 | + } |
|
407 | + |
|
408 | + /** |
|
409 | + * Sends overdue notices. |
|
410 | + * |
|
411 | + * @TODO: Create an invoices query class. |
|
412 | + */ |
|
413 | + public function overdue() { |
|
414 | + global $wpdb; |
|
415 | + |
|
416 | + $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
417 | + |
|
418 | + // Fetch reminder days. |
|
419 | + $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
420 | + |
|
421 | + // Abort if non is set. |
|
422 | + if ( empty( $reminder_days ) ) { |
|
423 | + return; |
|
424 | + } |
|
425 | + |
|
426 | + // Retrieve date query. |
|
427 | + $date_query = $this->get_date_query( $reminder_days ); |
|
428 | + |
|
429 | + // Invoices table. |
|
430 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
431 | + |
|
432 | + // Fetch invoices. |
|
433 | + $invoices = $wpdb->get_col( |
|
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 | - // 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 ); |
|
443 | - $email->object = $invoice; |
|
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 ); |
|
443 | + $email->object = $invoice; |
|
444 | 444 | |
445 | - if ( $invoice->needs_payment() ) { |
|
446 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
447 | - } |
|
445 | + if ( $invoice->needs_payment() ) { |
|
446 | + $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
447 | + } |
|
448 | 448 | |
449 | - } |
|
449 | + } |
|
450 | 450 | |
451 | - } |
|
451 | + } |
|
452 | 452 | |
453 | - } |
|
453 | + } |
|
454 | 454 | |
455 | - /** |
|
456 | - * Calculates the date query for an invoices query |
|
457 | - * |
|
458 | - * @param array $reminder_days |
|
459 | - * @return string |
|
460 | - */ |
|
461 | - public function get_date_query( $reminder_days ) { |
|
455 | + /** |
|
456 | + * Calculates the date query for an invoices query |
|
457 | + * |
|
458 | + * @param array $reminder_days |
|
459 | + * @return string |
|
460 | + */ |
|
461 | + public function get_date_query( $reminder_days ) { |
|
462 | 462 | |
463 | - $date_query = array( |
|
464 | - 'relation' => 'OR' |
|
465 | - ); |
|
463 | + $date_query = array( |
|
464 | + 'relation' => 'OR' |
|
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 | - $date_query[] = array( |
|
471 | - 'year' => $date['year'], |
|
472 | - 'month' => $date['month'], |
|
473 | - 'day' => $date['day'], |
|
474 | - ); |
|
470 | + $date_query[] = array( |
|
471 | + 'year' => $date['year'], |
|
472 | + 'month' => $date['month'], |
|
473 | + 'day' => $date['day'], |
|
474 | + ); |
|
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 | - return $date_query->get_sql(); |
|
480 | + return $date_query->get_sql(); |
|
481 | 481 | |
482 | - } |
|
482 | + } |
|
483 | 483 | |
484 | 484 | } |
@@ -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 |
@@ -13,17 +13,17 @@ discard block |
||
13 | 13 | class GetPaid_Notification_Email_Sender { |
14 | 14 | |
15 | 15 | /** |
16 | - * Whether or not we should inline CSS into the email. |
|
17 | - */ |
|
18 | - public $inline_css = true; |
|
16 | + * Whether or not we should inline CSS into the email. |
|
17 | + */ |
|
18 | + public $inline_css = true; |
|
19 | 19 | |
20 | 20 | /** |
21 | - * The wp_mail() data. |
|
22 | - */ |
|
21 | + * The wp_mail() data. |
|
22 | + */ |
|
23 | 23 | public $wp_mail_data = null; |
24 | 24 | |
25 | 25 | /** |
26 | - * Sends a new email. |
|
26 | + * Sends a new email. |
|
27 | 27 | * |
28 | 28 | * @param string|array $to The recipients email or an array of recipient emails. |
29 | 29 | * @param string $subject The email's subject. |
@@ -31,49 +31,49 @@ discard block |
||
31 | 31 | * @param array $attachments The email attachments. |
32 | 32 | * |
33 | 33 | * @return bool |
34 | - */ |
|
35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
34 | + */ |
|
35 | + public function send( $to, $subject, $email, $attachments = array() ) { |
|
36 | 36 | |
37 | - /* |
|
37 | + /* |
|
38 | 38 | * Allow to filter data on per-email basis. |
39 | 39 | */ |
40 | - $data = apply_filters( |
|
41 | - 'getpaid_email_data', |
|
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 ), |
|
46 | - 'headers' => $this->get_headers(), |
|
47 | - 'attachments' => $attachments, |
|
48 | - ), |
|
49 | - $this |
|
50 | - ); |
|
40 | + $data = apply_filters( |
|
41 | + 'getpaid_email_data', |
|
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 ), |
|
46 | + 'headers' => $this->get_headers(), |
|
47 | + 'attachments' => $attachments, |
|
48 | + ), |
|
49 | + $this |
|
50 | + ); |
|
51 | 51 | |
52 | 52 | // Remove slashes. |
53 | 53 | $data = (array) wp_unslash( $data ); |
54 | 54 | |
55 | 55 | // Cache it. |
56 | - $this->wp_mail_data = $data; |
|
56 | + $this->wp_mail_data = $data; |
|
57 | 57 | |
58 | - // Attach our own hooks. |
|
59 | - $this->before_sending(); |
|
58 | + // Attach our own hooks. |
|
59 | + $this->before_sending(); |
|
60 | 60 | |
61 | 61 | $result = false; |
62 | 62 | |
63 | 63 | foreach ( $this->wp_mail_data['to'] as $to ) { |
64 | - $result = $this->_send( $to, $data ); |
|
64 | + $result = $this->_send( $to, $data ); |
|
65 | 65 | } |
66 | 66 | |
67 | - // Remove our hooks. |
|
68 | - $this->after_sending(); |
|
67 | + // Remove our hooks. |
|
68 | + $this->after_sending(); |
|
69 | 69 | |
70 | - $this->wp_mail_data = null; |
|
70 | + $this->wp_mail_data = null; |
|
71 | 71 | |
72 | - return $result; |
|
73 | - } |
|
72 | + return $result; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Does the actual sending. |
|
75 | + /** |
|
76 | + * Does the actual sending. |
|
77 | 77 | * |
78 | 78 | * @param string $to The recipient's email. |
79 | 79 | * @param array $data The email's data. |
@@ -81,81 +81,81 @@ discard block |
||
81 | 81 | * @param array $attachments The email attachments. |
82 | 82 | * |
83 | 83 | * @return bool |
84 | - */ |
|
85 | - protected function _send( $to, $data ) { |
|
86 | - |
|
87 | - // Prepare the sending function. |
|
88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
89 | - |
|
90 | - // Send the actual email. |
|
91 | - $result = call_user_func( |
|
92 | - $sending_function, |
|
93 | - $to, |
|
94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
95 | - $data['email'], |
|
96 | - $data['headers'], |
|
97 | - $data['attachments'] |
|
98 | - ); |
|
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__ ); |
|
103 | - } |
|
104 | - |
|
105 | - return $result; |
|
106 | - } |
|
84 | + */ |
|
85 | + protected function _send( $to, $data ) { |
|
86 | + |
|
87 | + // Prepare the sending function. |
|
88 | + $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
89 | + |
|
90 | + // Send the actual email. |
|
91 | + $result = call_user_func( |
|
92 | + $sending_function, |
|
93 | + $to, |
|
94 | + html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
95 | + $data['email'], |
|
96 | + $data['headers'], |
|
97 | + $data['attachments'] |
|
98 | + ); |
|
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__ ); |
|
103 | + } |
|
104 | + |
|
105 | + return $result; |
|
106 | + } |
|
107 | 107 | |
108 | 108 | /** |
109 | - * Retrieves email headers. |
|
110 | - */ |
|
111 | - public function get_headers() { |
|
109 | + * Retrieves email headers. |
|
110 | + */ |
|
111 | + public function get_headers() { |
|
112 | 112 | |
113 | - $name = $this->get_from_name(); |
|
114 | - $reply_to = $this->get_reply_to(); |
|
115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
113 | + $name = $this->get_from_name(); |
|
114 | + $reply_to = $this->get_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 | |
121 | 121 | /** |
122 | - * Fires before an email is sent |
|
123 | - * |
|
124 | - * @since 1.0.0 |
|
125 | - */ |
|
126 | - public function before_sending() { |
|
122 | + * Fires before an email is sent |
|
123 | + * |
|
124 | + * @since 1.0.0 |
|
125 | + */ |
|
126 | + public function before_sending() { |
|
127 | 127 | |
128 | 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 ); |
|
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 | |
136 | 136 | /** |
137 | - * Returns the from name. |
|
138 | - */ |
|
139 | - public function get_from_name() { |
|
137 | + * Returns the from name. |
|
138 | + */ |
|
139 | + public function get_from_name() { |
|
140 | 140 | |
141 | 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 | /** |
151 | - * Returns the from email. |
|
152 | - */ |
|
153 | - public function get_from_address() { |
|
151 | + * Returns the from email. |
|
152 | + */ |
|
153 | + public function get_from_address() { |
|
154 | 154 | |
155 | 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; |
@@ -163,75 +163,75 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * The default emails from address. |
|
167 | - * |
|
168 | - * Defaults to wordpress@$sitename |
|
169 | - * Some hosts will block outgoing mail from this address if it doesn't exist, |
|
170 | - * but there's no easy alternative. Defaulting to admin_email might appear to be |
|
171 | - * another option, but some hosts may refuse to relay mail from an unknown domain. |
|
172 | - * |
|
173 | - */ |
|
174 | - public function default_from_address() { |
|
175 | - |
|
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 ); |
|
180 | - } |
|
181 | - |
|
182 | - $from_email = 'wordpress@' . $sitename; |
|
183 | - |
|
184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
166 | + * The default emails from address. |
|
167 | + * |
|
168 | + * Defaults to wordpress@$sitename |
|
169 | + * Some hosts will block outgoing mail from this address if it doesn't exist, |
|
170 | + * but there's no easy alternative. Defaulting to admin_email might appear to be |
|
171 | + * another option, but some hosts may refuse to relay mail from an unknown domain. |
|
172 | + * |
|
173 | + */ |
|
174 | + public function default_from_address() { |
|
175 | + |
|
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 ); |
|
180 | + } |
|
181 | + |
|
182 | + $from_email = 'wordpress@' . $sitename; |
|
183 | + |
|
184 | + return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | - * Get the email reply-to. |
|
190 | - * |
|
191 | - * |
|
192 | - * @return string The email reply-to address. |
|
193 | - */ |
|
194 | - public function get_reply_to() { |
|
189 | + * Get the email reply-to. |
|
190 | + * |
|
191 | + * |
|
192 | + * @return string The email reply-to address. |
|
193 | + */ |
|
194 | + public function get_reply_to() { |
|
195 | 195 | |
196 | - $reply_to = wpinv_get_admin_email(); |
|
196 | + $reply_to = wpinv_get_admin_email(); |
|
197 | 197 | |
198 | - if ( ! is_email( $reply_to ) ) { |
|
199 | - $reply_to = get_option( 'admin_email' ); |
|
200 | - } |
|
198 | + if ( ! is_email( $reply_to ) ) { |
|
199 | + $reply_to = get_option( 'admin_email' ); |
|
200 | + } |
|
201 | 201 | |
202 | - return $reply_to; |
|
202 | + return $reply_to; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Get the email content type. |
|
207 | - * |
|
208 | - */ |
|
209 | - public function get_content_type() { |
|
210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
206 | + * Get the email content type. |
|
207 | + * |
|
208 | + */ |
|
209 | + public function get_content_type() { |
|
210 | + return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * Ensures that our email messages are not messed up by template plugins. |
|
215 | - * |
|
216 | - * @return array wp_mail_data. |
|
217 | - */ |
|
218 | - public function ensure_email_content( $args ) { |
|
219 | - $args['message'] = $this->wp_mail_data['email']; |
|
220 | - return $args; |
|
214 | + * Ensures that our email messages are not messed up by template plugins. |
|
215 | + * |
|
216 | + * @return array wp_mail_data. |
|
217 | + */ |
|
218 | + public function ensure_email_content( $args ) { |
|
219 | + $args['message'] = $this->wp_mail_data['email']; |
|
220 | + return $args; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * A little house keeping after an email is sent. |
|
225 | - * |
|
226 | - */ |
|
227 | - public function after_sending() { |
|
224 | + * A little house keeping after an email is sent. |
|
225 | + * |
|
226 | + */ |
|
227 | + public function after_sending() { |
|
228 | 228 | |
229 | 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 ); |
|
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 | |
237 | 237 | } |
@@ -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 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - echo aui()->alert( |
|
29 | - array( |
|
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ) |
|
33 | - ); |
|
28 | + echo aui()->alert( |
|
29 | + array( |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ) |
|
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 | - // Display a single subscription. |
|
38 | - wpinv_recurring_subscription_details(); |
|
39 | - } else { |
|
37 | + // Display a single subscription. |
|
38 | + wpinv_recurring_subscription_details(); |
|
39 | + } else { |
|
40 | 40 | |
41 | - // Display a list of available subscriptions. |
|
42 | - getpaid_print_subscriptions_list(); |
|
43 | - } |
|
41 | + // Display a list of available subscriptions. |
|
42 | + getpaid_print_subscriptions_list(); |
|
43 | + } |
|
44 | 44 | |
45 | - ?> |
|
45 | + ?> |
|
46 | 46 | |
47 | 47 | </div> |
48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function getpaid_print_subscriptions_list() { |
61 | 61 | |
62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | - $subscribers_table->prepare_items(); |
|
62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | + $subscribers_table->prepare_items(); |
|
64 | 64 | |
65 | - ?> |
|
65 | + ?> |
|
66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,41 +80,41 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | - // Fetch the subscription. |
|
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
83 | + // Fetch the subscription. |
|
84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | + if ( ! $sub->exists() ) { |
|
86 | 86 | |
87 | - echo aui()->alert( |
|
88 | - array( |
|
89 | - 'type' => 'danger', |
|
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | - ) |
|
92 | - ); |
|
87 | + echo aui()->alert( |
|
88 | + array( |
|
89 | + 'type' => 'danger', |
|
90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return; |
|
95 | - } |
|
94 | + return; |
|
95 | + } |
|
96 | 96 | |
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' ); |
|
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' ); |
|
100 | 100 | |
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' ) ); |
|
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' ) ); |
|
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' ); |
|
107 | - } |
|
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 | + } |
|
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' ); |
|
111 | - } |
|
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 | + } |
|
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 | 119 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
120 | 120 | |
@@ -154,45 +154,45 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function getpaid_admin_subscription_details_metabox( $sub ) { |
156 | 156 | |
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'] ); |
|
160 | - |
|
161 | - // Prepare subscription detail columns. |
|
162 | - $fields = apply_filters( |
|
163 | - 'getpaid_subscription_admin_page_fields', |
|
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' ), |
|
175 | - ) |
|
176 | - ); |
|
177 | - |
|
178 | - if ( ! $sub->is_active() ) { |
|
179 | - |
|
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
182 | - } |
|
183 | - |
|
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
186 | - } |
|
187 | - |
|
188 | - } |
|
189 | - |
|
190 | - $profile_id = $sub->get_profile_id(); |
|
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
193 | - } |
|
194 | - |
|
195 | - ?> |
|
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'] ); |
|
160 | + |
|
161 | + // Prepare subscription detail columns. |
|
162 | + $fields = apply_filters( |
|
163 | + 'getpaid_subscription_admin_page_fields', |
|
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' ), |
|
175 | + ) |
|
176 | + ); |
|
177 | + |
|
178 | + if ( ! $sub->is_active() ) { |
|
179 | + |
|
180 | + if ( isset( $fields['renews_on'] ) ) { |
|
181 | + unset( $fields['renews_on'] ); |
|
182 | + } |
|
183 | + |
|
184 | + if ( isset( $fields['gateway'] ) ) { |
|
185 | + unset( $fields['gateway'] ); |
|
186 | + } |
|
187 | + |
|
188 | + } |
|
189 | + |
|
190 | + $profile_id = $sub->get_profile_id(); |
|
191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | + unset( $fields['profile_id'] ); |
|
193 | + } |
|
194 | + |
|
195 | + ?> |
|
196 | 196 | |
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | */ |
227 | 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 | - $username = sprintf( |
|
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 ) |
|
238 | - ); |
|
234 | + $username = sprintf( |
|
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 ) |
|
238 | + ); |
|
239 | 239 | |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | - echo $username; |
|
242 | + echo $username; |
|
243 | 243 | } |
244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | - echo "<span>$amount</span>"; |
|
252 | + $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | + echo "<span>$amount</span>"; |
|
254 | 254 | } |
255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
263 | - echo '#' . absint( $subscription->get_id() ); |
|
263 | + echo '#' . absint( $subscription->get_id() ); |
|
264 | 264 | } |
265 | 265 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | 272 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
273 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
274 | 274 | } |
275 | 275 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | 282 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
283 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
284 | 284 | } |
285 | 285 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
286 | 286 | |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | 292 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
293 | - $max_bills = $subscription->get_bill_times(); |
|
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
293 | + $max_bills = $subscription->get_bill_times(); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
295 | 295 | } |
296 | 296 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
297 | 297 | /** |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | */ |
303 | 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() ); |
|
307 | - return; |
|
308 | - } |
|
305 | + if ( empty( $subscription_group ) ) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
307 | + return; |
|
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 | 314 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
322 | 322 | |
323 | - $gateway = $subscription->get_gateway(); |
|
323 | + $gateway = $subscription->get_gateway(); |
|
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
327 | - } else { |
|
328 | - echo "—"; |
|
329 | - } |
|
325 | + if ( ! empty( $gateway ) ) { |
|
326 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
327 | + } else { |
|
328 | + echo "—"; |
|
329 | + } |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | 339 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
340 | - echo $subscription->get_status_label_html(); |
|
340 | + echo $subscription->get_status_label_html(); |
|
341 | 341 | } |
342 | 342 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
343 | 343 | |
@@ -348,29 +348,29 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
350 | 350 | |
351 | - $profile_id = $subscription->get_profile_id(); |
|
352 | - |
|
353 | - $input = aui()->input( |
|
354 | - array( |
|
355 | - 'type' => 'text', |
|
356 | - 'id' => 'wpinv_subscription_profile_id', |
|
357 | - 'name' => 'wpinv_subscription_profile_id', |
|
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
359 | - 'label_type' => 'hidden', |
|
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => sanitize_text_field( $profile_id ), |
|
362 | - 'input_group_right' => '', |
|
363 | - 'no_wrap' => true, |
|
364 | - ) |
|
365 | - ); |
|
366 | - |
|
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
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>'; |
|
373 | - } |
|
351 | + $profile_id = $subscription->get_profile_id(); |
|
352 | + |
|
353 | + $input = aui()->input( |
|
354 | + array( |
|
355 | + 'type' => 'text', |
|
356 | + 'id' => 'wpinv_subscription_profile_id', |
|
357 | + 'name' => 'wpinv_subscription_profile_id', |
|
358 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
359 | + 'label_type' => 'hidden', |
|
360 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | + 'value' => sanitize_text_field( $profile_id ), |
|
362 | + 'input_group_right' => '', |
|
363 | + 'no_wrap' => true, |
|
364 | + ) |
|
365 | + ); |
|
366 | + |
|
367 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
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>'; |
|
373 | + } |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -382,39 +382,39 @@ discard block |
||
382 | 382 | */ |
383 | 383 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
384 | 384 | |
385 | - ?> |
|
385 | + ?> |
|
386 | 386 | <div class="mt-3"> |
387 | 387 | |
388 | 388 | <?php |
389 | - echo aui()->select( |
|
390 | - array( |
|
391 | - 'options' => getpaid_get_subscription_statuses(), |
|
392 | - 'name' => 'subscription_status', |
|
393 | - 'id' => 'subscription_status_update_select', |
|
394 | - 'required' => true, |
|
395 | - 'no_wrap' => false, |
|
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
398 | - 'select2' => true, |
|
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
400 | - ) |
|
401 | - ); |
|
402 | - ?> |
|
389 | + echo aui()->select( |
|
390 | + array( |
|
391 | + 'options' => getpaid_get_subscription_statuses(), |
|
392 | + 'name' => 'subscription_status', |
|
393 | + 'id' => 'subscription_status_update_select', |
|
394 | + 'required' => true, |
|
395 | + 'no_wrap' => false, |
|
396 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
398 | + 'select2' => true, |
|
399 | + 'value' => $subscription->get_status( 'edit' ), |
|
400 | + ) |
|
401 | + ); |
|
402 | + ?> |
|
403 | 403 | |
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() ) { |
|
414 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
415 | - } |
|
413 | + if ( $subscription->is_active() ) { |
|
414 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
415 | + } |
|
416 | 416 | |
417 | - echo '</div></div>'; |
|
417 | + echo '</div></div>'; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -425,33 +425,33 @@ discard block |
||
425 | 425 | */ |
426 | 426 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
427 | 427 | |
428 | - $columns = apply_filters( |
|
429 | - 'getpaid_subscription_related_invoices_columns', |
|
430 | - array( |
|
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
436 | - ), |
|
437 | - $subscription |
|
438 | - ); |
|
439 | - |
|
440 | - // Prepare the invoices. |
|
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
442 | - $parent = $subscription->get_parent_invoice(); |
|
443 | - |
|
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
446 | - } |
|
447 | - |
|
448 | - $table_class = 'w-100 bg-white'; |
|
449 | - |
|
450 | - if ( ! is_admin() ) { |
|
451 | - $table_class = 'table table-bordered'; |
|
452 | - } |
|
453 | - |
|
454 | - ?> |
|
428 | + $columns = apply_filters( |
|
429 | + 'getpaid_subscription_related_invoices_columns', |
|
430 | + array( |
|
431 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | + 'date' => __( 'Date', 'invoicing' ), |
|
434 | + 'status' => __( 'Status', 'invoicing' ), |
|
435 | + 'total' => __( 'Total', 'invoicing' ), |
|
436 | + ), |
|
437 | + $subscription |
|
438 | + ); |
|
439 | + |
|
440 | + // Prepare the invoices. |
|
441 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
442 | + $parent = $subscription->get_parent_invoice(); |
|
443 | + |
|
444 | + if ( $parent->exists() ) { |
|
445 | + $payments = array_merge( array( $parent ), $payments ); |
|
446 | + } |
|
447 | + |
|
448 | + $table_class = 'w-100 bg-white'; |
|
449 | + |
|
450 | + if ( ! is_admin() ) { |
|
451 | + $table_class = 'table table-bordered'; |
|
452 | + } |
|
453 | + |
|
454 | + ?> |
|
455 | 455 | <div class="m-0" style="overflow: auto;"> |
456 | 456 | |
457 | 457 | <table class="<?php echo $table_class; ?>"> |
@@ -459,14 +459,14 @@ 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 ); |
|
465 | - $class = 'text-left'; |
|
466 | - |
|
467 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
468 | - } |
|
469 | - ?> |
|
462 | + foreach ( $columns as $key => $label ) { |
|
463 | + $key = esc_attr( $key ); |
|
464 | + $label = sanitize_text_field( $label ); |
|
465 | + $class = 'text-left'; |
|
466 | + |
|
467 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
468 | + } |
|
469 | + ?> |
|
470 | 470 | </tr> |
471 | 471 | </thead> |
472 | 472 | |
@@ -482,73 +482,73 @@ discard block |
||
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach( $payments as $payment ) : |
|
486 | 486 | |
487 | - // Ensure that we have an invoice. |
|
488 | - $payment = new WPInv_Invoice( $payment ); |
|
487 | + // Ensure that we have an invoice. |
|
488 | + $payment = new WPInv_Invoice( $payment ); |
|
489 | 489 | |
490 | - // Abort if the invoice is invalid... |
|
491 | - if ( ! $payment->exists() ) { |
|
492 | - continue; |
|
493 | - } |
|
490 | + // Abort if the invoice is invalid... |
|
491 | + if ( ! $payment->exists() ) { |
|
492 | + continue; |
|
493 | + } |
|
494 | 494 | |
495 | - // ... or belongs to a different subscription. |
|
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
497 | - continue; |
|
498 | - } |
|
495 | + // ... or belongs to a different subscription. |
|
496 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
497 | + continue; |
|
498 | + } |
|
499 | 499 | |
500 | - echo '<tr>'; |
|
500 | + echo '<tr>'; |
|
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach ( array_keys( $columns ) as $key ) { |
|
503 | 503 | |
504 | - $class = 'text-left'; |
|
504 | + $class = 'text-left'; |
|
505 | 505 | |
506 | - echo "<td class='p-2 $class'>"; |
|
506 | + echo "<td class='p-2 $class'>"; |
|
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch( $key ) { |
|
509 | 509 | |
510 | - case 'total': |
|
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
512 | - break; |
|
510 | + case 'total': |
|
511 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
512 | + break; |
|
513 | 513 | |
514 | - case 'relationship': |
|
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
516 | - break; |
|
514 | + case 'relationship': |
|
515 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
516 | + break; |
|
517 | 517 | |
518 | - case 'date': |
|
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
520 | - break; |
|
518 | + case 'date': |
|
519 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
520 | + break; |
|
521 | 521 | |
522 | - case 'status': |
|
522 | + case 'status': |
|
523 | 523 | |
524 | - $status = $payment->get_status_nicename(); |
|
525 | - if ( is_admin() ) { |
|
526 | - $status = $payment->get_status_label_html(); |
|
527 | - } |
|
524 | + $status = $payment->get_status_nicename(); |
|
525 | + if ( is_admin() ) { |
|
526 | + $status = $payment->get_status_label_html(); |
|
527 | + } |
|
528 | 528 | |
529 | - echo $status; |
|
530 | - break; |
|
529 | + echo $status; |
|
530 | + break; |
|
531 | 531 | |
532 | - case 'invoice': |
|
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
532 | + case 'invoice': |
|
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() ); |
|
537 | - } |
|
535 | + if ( ! is_admin() ) { |
|
536 | + $link = esc_url( $payment->get_view_url() ); |
|
537 | + } |
|
538 | 538 | |
539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
540 | - echo "<a href='$link'>$invoice</a>"; |
|
541 | - break; |
|
542 | - } |
|
539 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
540 | + echo "<a href='$link'>$invoice</a>"; |
|
541 | + break; |
|
542 | + } |
|
543 | 543 | |
544 | - echo '</td>'; |
|
544 | + echo '</td>'; |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - echo '</tr>'; |
|
548 | + echo '</tr>'; |
|
549 | 549 | |
550 | - endforeach; |
|
551 | - ?> |
|
550 | + endforeach; |
|
551 | + ?> |
|
552 | 552 | |
553 | 553 | </tbody> |
554 | 554 | |
@@ -566,42 +566,42 @@ discard block |
||
566 | 566 | */ |
567 | 567 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
568 | 568 | |
569 | - // Fetch the subscription group. |
|
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
569 | + // Fetch the subscription group. |
|
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'] ) ) { |
|
573 | - return; |
|
574 | - } |
|
572 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
573 | + return; |
|
574 | + } |
|
575 | 575 | |
576 | - // Prepare table columns. |
|
577 | - $columns = apply_filters( |
|
578 | - 'getpaid_subscription_item_details_columns', |
|
579 | - array( |
|
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
586 | - ), |
|
587 | - $subscription |
|
588 | - ); |
|
576 | + // Prepare table columns. |
|
577 | + $columns = apply_filters( |
|
578 | + 'getpaid_subscription_item_details_columns', |
|
579 | + array( |
|
580 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | + 'price' => __( 'Price', 'invoicing' ), |
|
582 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
585 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
586 | + ), |
|
587 | + $subscription |
|
588 | + ); |
|
589 | 589 | |
590 | - // Prepare the invoices. |
|
590 | + // Prepare the invoices. |
|
591 | 591 | |
592 | - $invoice = $subscription->get_parent_invoice(); |
|
592 | + $invoice = $subscription->get_parent_invoice(); |
|
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
596 | - } |
|
594 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | + unset( $columns['tax'] ); |
|
596 | + } |
|
597 | 597 | |
598 | - $table_class = 'w-100 bg-white'; |
|
598 | + $table_class = 'w-100 bg-white'; |
|
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
601 | - $table_class = 'table table-bordered'; |
|
602 | - } |
|
600 | + if ( ! is_admin() ) { |
|
601 | + $table_class = 'table table-bordered'; |
|
602 | + } |
|
603 | 603 | |
604 | - ?> |
|
604 | + ?> |
|
605 | 605 | <div class="m-0" style="overflow: auto;"> |
606 | 606 | |
607 | 607 | <table class="<?php echo $table_class; ?>"> |
@@ -610,14 +610,14 @@ 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 ); |
|
616 | - $class = 'text-left'; |
|
613 | + foreach ( $columns as $key => $label ) { |
|
614 | + $key = esc_attr( $key ); |
|
615 | + $label = sanitize_text_field( $label ); |
|
616 | + $class = 'text-left'; |
|
617 | 617 | |
618 | - echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
619 | - } |
|
620 | - ?> |
|
618 | + echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
619 | + } |
|
620 | + ?> |
|
621 | 621 | </tr> |
622 | 622 | </thead> |
623 | 623 | |
@@ -625,106 +625,106 @@ 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 | - echo '<tr>'; |
|
630 | + echo '<tr>'; |
|
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach ( array_keys( $columns ) as $key ) { |
|
633 | 633 | |
634 | - $class = 'text-left'; |
|
634 | + $class = 'text-left'; |
|
635 | 635 | |
636 | - echo "<td class='p-2 $class'>"; |
|
636 | + echo "<td class='p-2 $class'>"; |
|
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch( $key ) { |
|
639 | 639 | |
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; |
|
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; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo sanitize_text_field( $item_name ); |
|
646 | - } else { |
|
647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
648 | - } |
|
644 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | + echo sanitize_text_field( $item_name ); |
|
646 | + } else { |
|
647 | + printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
648 | + } |
|
649 | 649 | |
650 | - break; |
|
650 | + break; |
|
651 | 651 | |
652 | - case 'price': |
|
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
654 | - break; |
|
652 | + case 'price': |
|
653 | + echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
654 | + break; |
|
655 | 655 | |
656 | - case 'tax': |
|
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
658 | - break; |
|
656 | + case 'tax': |
|
657 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
658 | + break; |
|
659 | 659 | |
660 | - case 'discount': |
|
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
662 | - break; |
|
660 | + case 'discount': |
|
661 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
662 | + break; |
|
663 | 663 | |
664 | - case 'initial': |
|
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
666 | - break; |
|
664 | + case 'initial': |
|
665 | + echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
666 | + break; |
|
667 | 667 | |
668 | - case 'recurring': |
|
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
670 | - break; |
|
668 | + case 'recurring': |
|
669 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
670 | + break; |
|
671 | 671 | |
672 | - } |
|
672 | + } |
|
673 | 673 | |
674 | - echo '</td>'; |
|
674 | + echo '</td>'; |
|
675 | 675 | |
676 | - } |
|
676 | + } |
|
677 | 677 | |
678 | - echo '</tr>'; |
|
678 | + echo '</tr>'; |
|
679 | 679 | |
680 | - endforeach; |
|
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 | - echo '<tr>'; |
|
684 | + echo '<tr>'; |
|
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach ( array_keys( $columns ) as $key ) { |
|
687 | 687 | |
688 | - $class = 'text-left'; |
|
688 | + $class = 'text-left'; |
|
689 | 689 | |
690 | - echo "<td class='p-2 $class'>"; |
|
690 | + echo "<td class='p-2 $class'>"; |
|
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch( $key ) { |
|
693 | 693 | |
694 | - case 'item_name': |
|
695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
696 | - break; |
|
694 | + case 'item_name': |
|
695 | + echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
696 | + break; |
|
697 | 697 | |
698 | - case 'price': |
|
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
700 | - break; |
|
698 | + case 'price': |
|
699 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
700 | + break; |
|
701 | 701 | |
702 | - case 'tax': |
|
703 | - echo "—"; |
|
704 | - break; |
|
702 | + case 'tax': |
|
703 | + echo "—"; |
|
704 | + break; |
|
705 | 705 | |
706 | - case 'discount': |
|
707 | - echo "—"; |
|
708 | - break; |
|
706 | + case 'discount': |
|
707 | + echo "—"; |
|
708 | + break; |
|
709 | 709 | |
710 | - case 'initial': |
|
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
712 | - break; |
|
710 | + case 'initial': |
|
711 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
712 | + break; |
|
713 | 713 | |
714 | - case 'recurring': |
|
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
716 | - break; |
|
714 | + case 'recurring': |
|
715 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
716 | + break; |
|
717 | 717 | |
718 | - } |
|
718 | + } |
|
719 | 719 | |
720 | - echo '</td>'; |
|
720 | + echo '</td>'; |
|
721 | 721 | |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | - echo '</tr>'; |
|
724 | + echo '</tr>'; |
|
725 | 725 | |
726 | - endforeach; |
|
727 | - ?> |
|
726 | + endforeach; |
|
727 | + ?> |
|
728 | 728 | |
729 | 729 | </tbody> |
730 | 730 | |
@@ -743,38 +743,38 @@ discard block |
||
743 | 743 | */ |
744 | 744 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
745 | 745 | |
746 | - // Fetch the subscription groups. |
|
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
748 | - |
|
749 | - if ( empty( $subscription_groups ) ) { |
|
750 | - return; |
|
751 | - } |
|
752 | - |
|
753 | - // Prepare table columns. |
|
754 | - $columns = apply_filters( |
|
755 | - 'getpaid_subscription_related_subscriptions_columns', |
|
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' ), |
|
763 | - ), |
|
764 | - $subscription |
|
765 | - ); |
|
766 | - |
|
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
769 | - } |
|
770 | - |
|
771 | - $table_class = 'w-100 bg-white'; |
|
772 | - |
|
773 | - if ( ! is_admin() ) { |
|
774 | - $table_class = 'table table-bordered'; |
|
775 | - } |
|
776 | - |
|
777 | - ?> |
|
746 | + // Fetch the subscription groups. |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
748 | + |
|
749 | + if ( empty( $subscription_groups ) ) { |
|
750 | + return; |
|
751 | + } |
|
752 | + |
|
753 | + // Prepare table columns. |
|
754 | + $columns = apply_filters( |
|
755 | + 'getpaid_subscription_related_subscriptions_columns', |
|
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' ), |
|
763 | + ), |
|
764 | + $subscription |
|
765 | + ); |
|
766 | + |
|
767 | + if ( $subscription->get_status() == 'pending' ) { |
|
768 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
769 | + } |
|
770 | + |
|
771 | + $table_class = 'w-100 bg-white'; |
|
772 | + |
|
773 | + if ( ! is_admin() ) { |
|
774 | + $table_class = 'table table-bordered'; |
|
775 | + } |
|
776 | + |
|
777 | + ?> |
|
778 | 778 | <div class="m-0" style="overflow: auto;"> |
779 | 779 | |
780 | 780 | <table class="<?php echo $table_class; ?>"> |
@@ -783,14 +783,14 @@ 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 ); |
|
789 | - $class = 'text-left'; |
|
786 | + foreach ( $columns as $key => $label ) { |
|
787 | + $key = esc_attr( $key ); |
|
788 | + $label = sanitize_text_field( $label ); |
|
789 | + $class = 'text-left'; |
|
790 | 790 | |
791 | - echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
792 | - } |
|
793 | - ?> |
|
791 | + echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
792 | + } |
|
793 | + ?> |
|
794 | 794 | </tr> |
795 | 795 | </thead> |
796 | 796 | |
@@ -798,74 +798,74 @@ 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 | - // Do not list current subscription. |
|
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
805 | - continue; |
|
806 | - } |
|
803 | + // Do not list current subscription. |
|
804 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
805 | + continue; |
|
806 | + } |
|
807 | 807 | |
808 | - // Ensure the subscription exists. |
|
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
808 | + // Ensure the subscription exists. |
|
809 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
812 | - continue; |
|
813 | - } |
|
811 | + if ( ! $_suscription->exists() ) { |
|
812 | + continue; |
|
813 | + } |
|
814 | 814 | |
815 | - echo '<tr>'; |
|
815 | + echo '<tr>'; |
|
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach ( array_keys( $columns ) as $key ) { |
|
818 | 818 | |
819 | - $class = 'text-left'; |
|
819 | + $class = 'text-left'; |
|
820 | 820 | |
821 | - echo "<td class='p-2 $class'>"; |
|
821 | + echo "<td class='p-2 $class'>"; |
|
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch( $key ) { |
|
824 | 824 | |
825 | - case 'status': |
|
826 | - echo $_suscription->get_status_label_html(); |
|
827 | - break; |
|
825 | + case 'status': |
|
826 | + echo $_suscription->get_status_label_html(); |
|
827 | + break; |
|
828 | 828 | |
829 | - case 'item': |
|
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
832 | - break; |
|
829 | + case 'item': |
|
830 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | + echo implode( ' | ', $markup ); |
|
832 | + break; |
|
833 | 833 | |
834 | - case 'renewals': |
|
835 | - $max_bills = $_suscription->get_bill_times(); |
|
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
837 | - break; |
|
834 | + case 'renewals': |
|
835 | + $max_bills = $_suscription->get_bill_times(); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
837 | + break; |
|
838 | 838 | |
839 | - case 'renewal_date': |
|
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
841 | - break; |
|
839 | + case 'renewal_date': |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
841 | + break; |
|
842 | 842 | |
843 | - case 'start_date': |
|
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
845 | - break; |
|
843 | + case 'start_date': |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
845 | + break; |
|
846 | 846 | |
847 | - case 'subscription': |
|
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
849 | - printf( |
|
850 | - '%1$s#%2$s%3$s', |
|
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
853 | - '</a>' |
|
854 | - ); |
|
847 | + case 'subscription': |
|
848 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
849 | + printf( |
|
850 | + '%1$s#%2$s%3$s', |
|
851 | + '<a href="' . esc_url( $url ) . '">', |
|
852 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
853 | + '</a>' |
|
854 | + ); |
|
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
857 | - break; |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
857 | + break; |
|
858 | 858 | |
859 | - } |
|
859 | + } |
|
860 | 860 | |
861 | - echo '</td>'; |
|
861 | + echo '</td>'; |
|
862 | 862 | |
863 | - } |
|
863 | + } |
|
864 | 864 | |
865 | - echo '</tr>'; |
|
865 | + echo '</tr>'; |
|
866 | 866 | |
867 | - endforeach; |
|
868 | - ?> |
|
867 | + endforeach; |
|
868 | + ?> |
|
869 | 869 | |
870 | 870 | </tbody> |
871 | 871 |
@@ -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 | } |