@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GetPaid |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param array $args |
17 | 17 | * @see wp_dropdown_users |
18 | 18 | */ |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | |
21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
22 | 22 | $args['show'] = 'display_name_with_login'; |
23 | 23 | } |
24 | 24 | |
25 | - return wp_dropdown_users( $args ); |
|
25 | + return wp_dropdown_users($args); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @return string capability to check against |
33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
34 | 34 | */ |
35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
37 | + if (current_user_can('manage_options')) { |
|
38 | 38 | return 'manage_options'; |
39 | 39 | }; |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return bool |
49 | 49 | */ |
50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
51 | - return current_user_can( wpinv_get_capability() ); |
|
51 | + return current_user_can(wpinv_get_capability()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
60 | +function wpinv_create_user($email, $prefix = '') { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
67 | 67 | 'user_pass' => wp_generate_password(), |
68 | 68 | 'user_email' => $email, |
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
72 | - return wp_insert_user( $args ); |
|
72 | + return wp_insert_user($args); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * @since 1.0.19 |
80 | 80 | * @return bool|WP_User |
81 | 81 | */ |
82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
82 | +function wpinv_generate_user_name($prefix = '') { |
|
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
86 | - $prefix = trim( $prefix, '.' ); |
|
85 | + $prefix = strtok($prefix, '@'); |
|
86 | + $prefix = trim($prefix, '.'); |
|
87 | 87 | |
88 | 88 | // Sanitize the username. |
89 | - $prefix = sanitize_user( $prefix, true ); |
|
89 | + $prefix = sanitize_user($prefix, true); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
98 | 98 | |
99 | - while ( username_exists( $username ) ) { |
|
99 | + while (username_exists($username)) { |
|
100 | 100 | $username = $prefix + $postfix; |
101 | - $postfix ++; |
|
101 | + $postfix++; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $tabs = array( |
116 | 116 | |
117 | 117 | 'gp-invoices' => array( |
118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
121 | 121 | ), |
122 | 122 | |
123 | 123 | 'gp-subscriptions' => array( |
124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
125 | 125 | 'content' => '[wpinv_subscriptions]', |
126 | 126 | 'icon' => 'fas fa-redo', |
127 | 127 | ), |
128 | 128 | |
129 | 129 | 'gp-edit-address' => array( |
130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
130 | + 'label' => __('Billing Address', 'invoicing'), |
|
131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
132 | 132 | 'icon' => 'fas fa-credit-card', |
133 | 133 | ), |
134 | 134 | |
135 | 135 | ); |
136 | 136 | |
137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
138 | 138 | |
139 | 139 | // Make sure address editing is last on the list. |
140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
140 | + if (isset($tabs['gp-edit-address'])) { |
|
141 | 141 | $address = $tabs['gp-edit-address']; |
142 | - unset( $tabs['gp-edit-address'] ); |
|
142 | + unset($tabs['gp-edit-address']); |
|
143 | 143 | $tabs['gp-edit-address'] = $address; |
144 | 144 | } |
145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | * @param array $tab |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
156 | +function getpaid_prepare_user_content_tab($tab) { |
|
157 | 157 | |
158 | - if ( ! empty( $tab['callback'] ) ) { |
|
159 | - return call_user_func( $tab['callback'] ); |
|
158 | + if (!empty($tab['callback'])) { |
|
159 | + return call_user_func($tab['callback']); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $tab['content'] ) ) { |
|
163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
162 | + if (!empty($tab['content'])) { |
|
163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $notice = aui()->alert( |
167 | 167 | array( |
168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
169 | 169 | 'type' => 'error', |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param string $default |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
184 | +function getpaid_get_tab_url($tab, $default) { |
|
185 | 185 | global $getpaid_tab_url; |
186 | 186 | |
187 | - if ( empty( $getpaid_tab_url ) ) { |
|
187 | + if (empty($getpaid_tab_url)) { |
|
188 | 188 | return $default; |
189 | 189 | } |
190 | 190 | |
191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
191 | + return sprintf($getpaid_tab_url, $tab); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | |
209 | 209 | <?php |
210 | 210 | |
211 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
211 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
212 | 212 | |
213 | 213 | // Display the country. |
214 | - if ( 'country' == $key ) { |
|
214 | + if ('country' == $key) { |
|
215 | 215 | |
216 | 216 | echo aui()->select( |
217 | 217 | array( |
218 | 218 | 'options' => wpinv_get_country_list(), |
219 | - 'name' => esc_attr( $key ), |
|
220 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
221 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
219 | + 'name' => esc_attr($key), |
|
220 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
221 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
222 | 222 | 'placeholder' => $label, |
223 | - 'label' => wp_kses_post( $label ), |
|
223 | + 'label' => wp_kses_post($label), |
|
224 | 224 | 'label_type' => 'vertical', |
225 | 225 | 'class' => 'getpaid-address-field', |
226 | 226 | ) |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Display the state. |
232 | - else if ( 'state' == $key ) { |
|
232 | + else if ('state' == $key) { |
|
233 | 233 | |
234 | - echo getpaid_get_states_select_markup ( |
|
235 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
236 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
234 | + echo getpaid_get_states_select_markup( |
|
235 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
236 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
237 | 237 | $label, |
238 | 238 | $label, |
239 | 239 | '', |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | |
247 | 247 | echo aui()->input( |
248 | 248 | array( |
249 | - 'name' => esc_attr( $key ), |
|
250 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
249 | + 'name' => esc_attr($key), |
|
250 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
251 | 251 | 'placeholder' => $label, |
252 | - 'label' => wp_kses_post( $label ), |
|
252 | + 'label' => wp_kses_post($label), |
|
253 | 253 | 'label_type' => 'vertical', |
254 | 254 | 'type' => 'text', |
255 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
255 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
256 | 256 | 'class' => 'getpaid-address-field', |
257 | 257 | ) |
258 | 258 | ); |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | |
262 | 262 | } |
263 | 263 | |
264 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
264 | + do_action('getpaid_display_address_edit_tab'); |
|
265 | 265 | |
266 | 266 | echo aui()->input( |
267 | 267 | array( |
268 | 268 | 'name' => 'getpaid_profile_edit_submit_button', |
269 | 269 | 'id' => 'getpaid_profile_edit_submit_button', |
270 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
271 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
270 | + 'value' => __('Save Address', 'invoicing'), |
|
271 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
272 | 272 | 'type' => 'submit', |
273 | 273 | 'class' => 'btn btn-primary btn-block submit-button', |
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | |
277 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
278 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
277 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
278 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
279 | 279 | ?> |
280 | 280 | |
281 | 281 | </form> |
@@ -292,20 +292,20 @@ discard block |
||
292 | 292 | * @since 2.1.4 |
293 | 293 | * @param array $data |
294 | 294 | */ |
295 | -function getpaid_save_address_edit_tab( $data ) { |
|
295 | +function getpaid_save_address_edit_tab($data) { |
|
296 | 296 | |
297 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
297 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
298 | 298 | |
299 | - if ( isset( $data[ $field ] ) ) { |
|
300 | - $value = sanitize_text_field( $data[ $field ] ); |
|
301 | - update_user_meta( get_current_user_id(), '_wpinv_' . $field, $value ); |
|
299 | + if (isset($data[$field])) { |
|
300 | + $value = sanitize_text_field($data[$field]); |
|
301 | + update_user_meta(get_current_user_id(), '_wpinv_' . $field, $value); |
|
302 | 302 | } |
303 | 303 | |
304 | - wpinv_set_error( 'address_updated', __( 'You billing address has been updated', 'invoicing' ), 'success'); |
|
304 | + wpinv_set_error('address_updated', __('You billing address has been updated', 'invoicing'), 'success'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | } |
308 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
308 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
309 | 309 | |
310 | 310 | |
311 | 311 | /* |
@@ -323,27 +323,27 @@ discard block |
||
323 | 323 | * @param array $tabs |
324 | 324 | * @return array |
325 | 325 | */ |
326 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
326 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
327 | 327 | |
328 | 328 | // Abort if the integration is inactive. |
329 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
329 | + if (!getpaid_is_userswp_integration_active()) { |
|
330 | 330 | return $tabs; |
331 | 331 | } |
332 | 332 | |
333 | - $new_tabs = array(); |
|
333 | + $new_tabs = array(); |
|
334 | 334 | |
335 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
335 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
336 | 336 | |
337 | - $new_tabs[ $slug ] = array( |
|
338 | - 'title' => $tab[ 'label'], |
|
339 | - 'icon' => $tab[ 'icon'], |
|
337 | + $new_tabs[$slug] = array( |
|
338 | + 'title' => $tab['label'], |
|
339 | + 'icon' => $tab['icon'], |
|
340 | 340 | ); |
341 | 341 | |
342 | 342 | } |
343 | 343 | |
344 | - return array_merge( $tabs, $new_tabs ); |
|
344 | + return array_merge($tabs, $new_tabs); |
|
345 | 345 | } |
346 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
346 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Display our UsersWP account tabs. |
@@ -352,18 +352,18 @@ discard block |
||
352 | 352 | * @param array $tabs |
353 | 353 | * @return array |
354 | 354 | */ |
355 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
355 | +function getpaid_display_userswp_account_tabs($tab) { |
|
356 | 356 | global $getpaid_tab_url; |
357 | 357 | |
358 | 358 | $our_tabs = getpaid_get_user_content_tabs(); |
359 | 359 | |
360 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
361 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
362 | - echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ); |
|
360 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
361 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
362 | + echo getpaid_prepare_user_content_tab($our_tabs[$tab]); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | } |
366 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
366 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | /** |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | * @param string $tab Current tab. |
375 | 375 | * @return string Title. |
376 | 376 | */ |
377 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
377 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
378 | 378 | |
379 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
379 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
380 | 380 | |
381 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
382 | - return $our_tabs[ $tab ]['label']; |
|
381 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
382 | + return $our_tabs[$tab]['label']; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | return $title; |
386 | 386 | } |
387 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
387 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * Registers the UsersWP integration settings. |
@@ -393,26 +393,26 @@ discard block |
||
393 | 393 | * @param array $settings An array of integration settings. |
394 | 394 | * @return array |
395 | 395 | */ |
396 | -function getpaid_register_userswp_settings( $settings ) { |
|
396 | +function getpaid_register_userswp_settings($settings) { |
|
397 | 397 | |
398 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
398 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
399 | 399 | |
400 | 400 | $settings[] = array( |
401 | 401 | |
402 | 402 | 'id' => 'userswp', |
403 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
403 | + 'label' => __('UsersWP', 'invoicing'), |
|
404 | 404 | 'settings' => array( |
405 | 405 | |
406 | 406 | 'userswp_settings' => array( |
407 | 407 | 'id' => 'userswp_settings', |
408 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
408 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
409 | 409 | 'type' => 'header', |
410 | 410 | ), |
411 | 411 | |
412 | 412 | 'enable_userswp' => array( |
413 | 413 | 'id' => 'enable_userswp', |
414 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
415 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
414 | + 'name' => __('Enable Integration', 'invoicing'), |
|
415 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
416 | 416 | 'type' => 'checkbox', |
417 | 417 | 'std' => 1, |
418 | 418 | ) |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | |
426 | 426 | return $settings; |
427 | 427 | } |
428 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
428 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
429 | 429 | |
430 | 430 | /** |
431 | 431 | * Checks if the integration is enabled. |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @return bool |
435 | 435 | */ |
436 | 436 | function getpaid_is_userswp_integration_active() { |
437 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
438 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
437 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
438 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /* |
@@ -453,26 +453,26 @@ discard block |
||
453 | 453 | * @param array $settings An array of integration settings. |
454 | 454 | * @return array |
455 | 455 | */ |
456 | -function getpaid_register_buddypress_settings( $settings ) { |
|
456 | +function getpaid_register_buddypress_settings($settings) { |
|
457 | 457 | |
458 | - if ( class_exists( 'BuddyPress' ) ) { |
|
458 | + if (class_exists('BuddyPress')) { |
|
459 | 459 | |
460 | 460 | $settings[] = array( |
461 | 461 | |
462 | 462 | 'id' => 'buddypress', |
463 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
463 | + 'label' => __('BuddyPress', 'invoicing'), |
|
464 | 464 | 'settings' => array( |
465 | 465 | |
466 | 466 | 'buddypress_settings' => array( |
467 | 467 | 'id' => 'buddypress_settings', |
468 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
468 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
469 | 469 | 'type' => 'header', |
470 | 470 | ), |
471 | 471 | |
472 | 472 | 'enable_buddypress' => array( |
473 | 473 | 'id' => 'enable_buddypress', |
474 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
475 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
474 | + 'name' => __('Enable Integration', 'invoicing'), |
|
475 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
476 | 476 | 'type' => 'checkbox', |
477 | 477 | 'std' => 1, |
478 | 478 | ) |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | |
486 | 486 | return $settings; |
487 | 487 | } |
488 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
488 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * Checks if the integration is enabled. |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @return bool |
495 | 495 | */ |
496 | 496 | function getpaid_is_buddypress_integration_active() { |
497 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
498 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
497 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
498 | + return class_exists('BuddyPress') && !empty($enabled); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function getpaid_setup_buddypress_integration() { |
508 | 508 | |
509 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
510 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php' ); |
|
509 | + if (getpaid_is_buddypress_integration_active()) { |
|
510 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'); |
|
511 | 511 | buddypress()->getpaid = new BP_GetPaid_Component(); |
512 | 512 | } |
513 | 513 | |
514 | 514 | } |
515 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
515 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | return array( |
14 | 14 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | 'global' => true, |
19 | 19 | 'rate' => 20, |
20 | 20 | 'reduced_rate' => 13, |
21 | - 'name' => __( 'VAT', 'invoicing' ), |
|
21 | + 'name' => __('VAT', 'invoicing'), |
|
22 | 22 | ), |
23 | 23 | |
24 | 24 | array( |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'global' => true, |
28 | 28 | 'rate' => 21, |
29 | 29 | 'reduced_rate' => 12, |
30 | - 'name' => __( 'VAT', 'invoicing' ), |
|
30 | + 'name' => __('VAT', 'invoicing'), |
|
31 | 31 | ), |
32 | 32 | |
33 | 33 | array( |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'global' => true, |
37 | 37 | 'rate' => 20, |
38 | 38 | 'reduced_rate' => 9, |
39 | - 'name' => __( 'VAT', 'invoicing' ), |
|
39 | + 'name' => __('VAT', 'invoicing'), |
|
40 | 40 | ), |
41 | 41 | |
42 | 42 | array( |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'global' => true, |
46 | 46 | 'rate' => 19, |
47 | 47 | 'reduced_rate' => 9, |
48 | - 'name' => __( 'VAT', 'invoicing' ), |
|
48 | + 'name' => __('VAT', 'invoicing'), |
|
49 | 49 | ), |
50 | 50 | |
51 | 51 | array( |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'global' => true, |
55 | 55 | 'rate' => 21, |
56 | 56 | 'reduced_rate' => 15, |
57 | - 'name' => __( 'VAT', 'invoicing' ), |
|
57 | + 'name' => __('VAT', 'invoicing'), |
|
58 | 58 | ), |
59 | 59 | |
60 | 60 | array( |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'global' => true, |
64 | 64 | 'rate' => 25, |
65 | 65 | 'reduced_rate' => 25, |
66 | - 'name' => __( 'VAT', 'invoicing' ), |
|
66 | + 'name' => __('VAT', 'invoicing'), |
|
67 | 67 | ), |
68 | 68 | |
69 | 69 | array( |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'global' => true, |
73 | 73 | 'rate' => 16, |
74 | 74 | 'reduced_rate' => 5, |
75 | - 'name' => __( 'VAT', 'invoicing' ), |
|
75 | + 'name' => __('VAT', 'invoicing'), |
|
76 | 76 | ), |
77 | 77 | |
78 | 78 | array( |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'global' => true, |
82 | 82 | 'rate' => 20, |
83 | 83 | 'reduced_rate' => 9, |
84 | - 'name' => __( 'VAT', 'invoicing' ), |
|
84 | + 'name' => __('VAT', 'invoicing'), |
|
85 | 85 | ), |
86 | 86 | |
87 | 87 | array( |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'global' => true, |
91 | 91 | 'rate' => 24, |
92 | 92 | 'reduced_rate' => 13, |
93 | - 'name' => __( 'VAT', 'invoicing' ), |
|
93 | + 'name' => __('VAT', 'invoicing'), |
|
94 | 94 | ), |
95 | 95 | |
96 | 96 | array( |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'global' => true, |
100 | 100 | 'rate' => 21, |
101 | 101 | 'reduced_rate' => 10, |
102 | - 'name' => __( 'VAT', 'invoicing' ), |
|
102 | + 'name' => __('VAT', 'invoicing'), |
|
103 | 103 | ), |
104 | 104 | |
105 | 105 | array( |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | 'global' => true, |
109 | 109 | 'rate' => 24, |
110 | 110 | 'reduced_rate' => 14, |
111 | - 'name' => __( 'VAT', 'invoicing' ), |
|
111 | + 'name' => __('VAT', 'invoicing'), |
|
112 | 112 | ), |
113 | 113 | |
114 | 114 | array( |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'global' => true, |
118 | 118 | 'rate' => 20, |
119 | 119 | 'reduced_rate' => 10, |
120 | - 'name' => __( 'VAT', 'invoicing' ), |
|
120 | + 'name' => __('VAT', 'invoicing'), |
|
121 | 121 | ), |
122 | 122 | |
123 | 123 | array( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | 'global' => true, |
127 | 127 | 'rate' => 25, |
128 | 128 | 'reduced_rate' => 13, |
129 | - 'name' => __( 'VAT', 'invoicing' ), |
|
129 | + 'name' => __('VAT', 'invoicing'), |
|
130 | 130 | ), |
131 | 131 | |
132 | 132 | array( |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | 'global' => true, |
136 | 136 | 'rate' => 22, |
137 | 137 | 'reduced_rate' => 10, |
138 | - 'name' => __( 'VAT', 'invoicing' ), |
|
138 | + 'name' => __('VAT', 'invoicing'), |
|
139 | 139 | ), |
140 | 140 | |
141 | 141 | array( |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'global' => true, |
145 | 145 | 'rate' => 21, |
146 | 146 | 'reduced_rate' => 12, |
147 | - 'name' => __( 'VAT', 'invoicing' ), |
|
147 | + 'name' => __('VAT', 'invoicing'), |
|
148 | 148 | ), |
149 | 149 | |
150 | 150 | array( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'global' => true, |
154 | 154 | 'rate' => 21, |
155 | 155 | 'reduced_rate' => 9, |
156 | - 'name' => __( 'VAT', 'invoicing' ), |
|
156 | + 'name' => __('VAT', 'invoicing'), |
|
157 | 157 | ), |
158 | 158 | |
159 | 159 | array( |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'global' => true, |
163 | 163 | 'rate' => 17, |
164 | 164 | 'reduced_rate' => 14, |
165 | - 'name' => __( 'VAT', 'invoicing' ), |
|
165 | + 'name' => __('VAT', 'invoicing'), |
|
166 | 166 | ), |
167 | 167 | |
168 | 168 | array( |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | 'global' => true, |
172 | 172 | 'rate' => 27, |
173 | 173 | 'reduced_rate' => 18, |
174 | - 'name' => __( 'VAT', 'invoicing' ), |
|
174 | + 'name' => __('VAT', 'invoicing'), |
|
175 | 175 | ), |
176 | 176 | |
177 | 177 | array( |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'global' => true, |
181 | 181 | 'rate' => 21, |
182 | 182 | 'reduced_rate' => 13.5, |
183 | - 'name' => __( 'VAT', 'invoicing' ), |
|
183 | + 'name' => __('VAT', 'invoicing'), |
|
184 | 184 | ), |
185 | 185 | |
186 | 186 | array( |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'global' => true, |
190 | 190 | 'rate' => 18, |
191 | 191 | 'reduced_rate' => 7, |
192 | - 'name' => __( 'VAT', 'invoicing' ), |
|
192 | + 'name' => __('VAT', 'invoicing'), |
|
193 | 193 | ), |
194 | 194 | |
195 | 195 | array( |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | 'global' => true, |
199 | 199 | 'rate' => 21, |
200 | 200 | 'reduced_rate' => 9, |
201 | - 'name' => __( 'VAT', 'invoicing' ), |
|
201 | + 'name' => __('VAT', 'invoicing'), |
|
202 | 202 | ), |
203 | 203 | |
204 | 204 | array( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'global' => true, |
208 | 208 | 'rate' => 23, |
209 | 209 | 'reduced_rate' => 8, |
210 | - 'name' => __( 'VAT', 'invoicing' ), |
|
210 | + 'name' => __('VAT', 'invoicing'), |
|
211 | 211 | ), |
212 | 212 | |
213 | 213 | array( |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | 'global' => true, |
217 | 217 | 'rate' => 23, |
218 | 218 | 'reduced_rate' => 13, |
219 | - 'name' => __( 'VAT', 'invoicing' ), |
|
219 | + 'name' => __('VAT', 'invoicing'), |
|
220 | 220 | ), |
221 | 221 | |
222 | 222 | array( |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'global' => true, |
226 | 226 | 'rate' => 19, |
227 | 227 | 'reduced_rate' => 9, |
228 | - 'name' => __( 'VAT', 'invoicing' ), |
|
228 | + 'name' => __('VAT', 'invoicing'), |
|
229 | 229 | ), |
230 | 230 | |
231 | 231 | array( |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | 'global' => true, |
235 | 235 | 'rate' => 22, |
236 | 236 | 'reduced_rate' => 9.5, |
237 | - 'name' => __( 'VAT', 'invoicing' ), |
|
237 | + 'name' => __('VAT', 'invoicing'), |
|
238 | 238 | ), |
239 | 239 | |
240 | 240 | array( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | 'global' => true, |
244 | 244 | 'rate' => 20, |
245 | 245 | 'reduced_rate' => 10, |
246 | - 'name' => __( 'VAT', 'invoicing' ), |
|
246 | + 'name' => __('VAT', 'invoicing'), |
|
247 | 247 | ), |
248 | 248 | |
249 | 249 | array( |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | 'global' => true, |
253 | 253 | 'rate' => 25, |
254 | 254 | 'reduced_rate' => 12, |
255 | - 'name' => __( 'VAT', 'invoicing' ), |
|
255 | + 'name' => __('VAT', 'invoicing'), |
|
256 | 256 | ), |
257 | 257 | |
258 | 258 | array( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'global' => true, |
262 | 262 | 'rate' => 20, |
263 | 263 | 'reduced_rate' => 5, |
264 | - 'name' => __( 'VAT', 'invoicing' ), |
|
264 | + 'name' => __('VAT', 'invoicing'), |
|
265 | 265 | ) |
266 | 266 | |
267 | 267 | ); |
@@ -17,45 +17,45 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class BP_GetPaid_Component extends BP_Component { |
19 | 19 | |
20 | - /** |
|
21 | - * Start the component setup process. |
|
22 | - * |
|
23 | - * @since 2.1.5 |
|
24 | - */ |
|
25 | - public function __construct() { |
|
26 | - parent::start( |
|
27 | - 'getpaid', |
|
28 | - 'GetPaid', |
|
29 | - buddypress()->plugin_dir, |
|
30 | - array( |
|
31 | - 'adminbar_myaccount_order' => 30, |
|
32 | - ) |
|
33 | - ); |
|
34 | - } |
|
20 | + /** |
|
21 | + * Start the component setup process. |
|
22 | + * |
|
23 | + * @since 2.1.5 |
|
24 | + */ |
|
25 | + public function __construct() { |
|
26 | + parent::start( |
|
27 | + 'getpaid', |
|
28 | + 'GetPaid', |
|
29 | + buddypress()->plugin_dir, |
|
30 | + array( |
|
31 | + 'adminbar_myaccount_order' => 30, |
|
32 | + ) |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | /** |
37 | - * Set up component global variables. |
|
38 | - * |
|
39 | - * @since 2.1.5 |
|
40 | - * |
|
41 | - * |
|
42 | - * @param array $args { |
|
43 | - * All values are optional. |
|
44 | - * @type string $slug The component slug. Used to construct certain URLs, such as 'friends' in |
|
45 | - * http://example.com/members/joe/friends/. Default: the value of $this->id. |
|
46 | - * @type string $root_slug The component root slug. Note that this value is generally unused if the |
|
47 | - * component has a root directory (the slug will be overridden by the |
|
48 | - * post_name of the directory page). Default: the slug of the directory page |
|
49 | - * if one is found, otherwise an empty string. |
|
50 | - * @type bool $has_directory Set to true if the component requires an associated WordPress page. |
|
51 | - * @type callable $notification_callback Optional. The callable function that formats the component's notifications. |
|
52 | - * @type string $search_term Optional. The placeholder text in the component directory search box. Eg, |
|
53 | - * 'Search Groups...'. |
|
54 | - * @type array $global_tables Optional. An array of database table names. |
|
55 | - * @type array $meta_tables Optional. An array of metadata table names. |
|
56 | - * } |
|
57 | - */ |
|
58 | - public function setup_globals( $args = array() ) { |
|
37 | + * Set up component global variables. |
|
38 | + * |
|
39 | + * @since 2.1.5 |
|
40 | + * |
|
41 | + * |
|
42 | + * @param array $args { |
|
43 | + * All values are optional. |
|
44 | + * @type string $slug The component slug. Used to construct certain URLs, such as 'friends' in |
|
45 | + * http://example.com/members/joe/friends/. Default: the value of $this->id. |
|
46 | + * @type string $root_slug The component root slug. Note that this value is generally unused if the |
|
47 | + * component has a root directory (the slug will be overridden by the |
|
48 | + * post_name of the directory page). Default: the slug of the directory page |
|
49 | + * if one is found, otherwise an empty string. |
|
50 | + * @type bool $has_directory Set to true if the component requires an associated WordPress page. |
|
51 | + * @type callable $notification_callback Optional. The callable function that formats the component's notifications. |
|
52 | + * @type string $search_term Optional. The placeholder text in the component directory search box. Eg, |
|
53 | + * 'Search Groups...'. |
|
54 | + * @type array $global_tables Optional. An array of database table names. |
|
55 | + * @type array $meta_tables Optional. An array of metadata table names. |
|
56 | + * } |
|
57 | + */ |
|
58 | + public function setup_globals( $args = array() ) { |
|
59 | 59 | parent::setup_globals( |
60 | 60 | array( |
61 | 61 | 'id' => 'getpaid', |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | 'has_directory' => false |
65 | 65 | ) |
66 | 66 | ); |
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Set up component navigation. |
|
71 | - * |
|
72 | - * @since 2.1.5 |
|
73 | - * |
|
74 | - * @see BP_Component::setup_nav() for a description of arguments. |
|
75 | - * |
|
76 | - * @param array $main_nav Optional. See BP_Component::setup_nav() for description. |
|
77 | - * @param array $sub_nav Optional. See BP_Component::setup_nav() for description. |
|
78 | - */ |
|
79 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
80 | - |
|
81 | - // Abort if the integration is inactive. |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Set up component navigation. |
|
71 | + * |
|
72 | + * @since 2.1.5 |
|
73 | + * |
|
74 | + * @see BP_Component::setup_nav() for a description of arguments. |
|
75 | + * |
|
76 | + * @param array $main_nav Optional. See BP_Component::setup_nav() for description. |
|
77 | + * @param array $sub_nav Optional. See BP_Component::setup_nav() for description. |
|
78 | + */ |
|
79 | + public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
80 | + |
|
81 | + // Abort if the integration is inactive. |
|
82 | 82 | if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) { |
83 | 83 | return; |
84 | 84 | } |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | - // Determine user to use. |
|
92 | - $user_domain = bp_loggedin_user_domain(); |
|
93 | - $slug = 'getpaid'; |
|
94 | - $payments_link = trailingslashit( $user_domain . $slug ); |
|
95 | - |
|
96 | - // Add 'Payments' to the main navigation. |
|
97 | - $main_nav = array( |
|
98 | - 'name' => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ), |
|
99 | - 'slug' => $slug, |
|
100 | - 'position' => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ), |
|
101 | - 'screen_function' => array( $this, 'display_current_tab' ), |
|
102 | - 'default_subnav_slug' => 'gp-edit-address', |
|
91 | + // Determine user to use. |
|
92 | + $user_domain = bp_loggedin_user_domain(); |
|
93 | + $slug = 'getpaid'; |
|
94 | + $payments_link = trailingslashit( $user_domain . $slug ); |
|
95 | + |
|
96 | + // Add 'Payments' to the main navigation. |
|
97 | + $main_nav = array( |
|
98 | + 'name' => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ), |
|
99 | + 'slug' => $slug, |
|
100 | + 'position' => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ), |
|
101 | + 'screen_function' => array( $this, 'display_current_tab' ), |
|
102 | + 'default_subnav_slug' => 'gp-edit-address', |
|
103 | 103 | 'show_for_displayed_user' => false, |
104 | - 'item_css_id' => $this->id, |
|
105 | - 'parent_url' => $user_domain, |
|
106 | - 'parent_slug' => buddypress()->slug, |
|
107 | - ); |
|
104 | + 'item_css_id' => $this->id, |
|
105 | + 'parent_url' => $user_domain, |
|
106 | + 'parent_slug' => buddypress()->slug, |
|
107 | + ); |
|
108 | 108 | |
109 | - // Add the subnav items to the payments nav item if we are using a theme that supports this. |
|
109 | + // Add the subnav items to the payments nav item if we are using a theme that supports this. |
|
110 | 110 | foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) { |
111 | 111 | |
112 | 112 | $sub_nav[] = array( |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | 'parent_slug' => $slug, |
117 | 117 | 'position' => 10, |
118 | 118 | 'screen_function' => function() use ( $tab ) { |
119 | - $GLOBALS['getpaid_bp_current_tab'] = $tab; |
|
120 | - $this->display_current_tab(); |
|
119 | + $GLOBALS['getpaid_bp_current_tab'] = $tab; |
|
120 | + $this->display_current_tab(); |
|
121 | 121 | }, |
122 | 122 | 'show_for_displayed_user' => false, |
123 | 123 | 'item_css_id' => "getpaid-bp-$_slug", |
@@ -125,27 +125,27 @@ discard block |
||
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Set up the component entries in the WordPress Admin Bar. |
|
133 | - * |
|
134 | - * @since 2.1.5 |
|
135 | - * |
|
136 | - * @see BP_Component::setup_nav() for a description of the $wp_admin_nav |
|
137 | - * parameter array. |
|
138 | - * |
|
139 | - * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a |
|
140 | - * description. |
|
141 | - */ |
|
142 | - public function setup_admin_bar( $wp_admin_nav = array() ) { |
|
143 | - |
|
144 | - // Menus for logged in user. |
|
145 | - if ( is_user_logged_in() ) { |
|
128 | + parent::setup_nav( $main_nav, $sub_nav ); |
|
129 | + } |
|
146 | 130 | |
147 | - // Setup the logged in user variables. |
|
148 | - $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' ); |
|
131 | + /** |
|
132 | + * Set up the component entries in the WordPress Admin Bar. |
|
133 | + * |
|
134 | + * @since 2.1.5 |
|
135 | + * |
|
136 | + * @see BP_Component::setup_nav() for a description of the $wp_admin_nav |
|
137 | + * parameter array. |
|
138 | + * |
|
139 | + * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a |
|
140 | + * description. |
|
141 | + */ |
|
142 | + public function setup_admin_bar( $wp_admin_nav = array() ) { |
|
143 | + |
|
144 | + // Menus for logged in user. |
|
145 | + if ( is_user_logged_in() ) { |
|
146 | + |
|
147 | + // Setup the logged in user variables. |
|
148 | + $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' ); |
|
149 | 149 | |
150 | 150 | // Add the "Payments" sub menu. |
151 | 151 | $wp_admin_nav[] = array( |
@@ -167,50 +167,50 @@ discard block |
||
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | - } |
|
171 | - |
|
172 | - parent::setup_admin_bar( $wp_admin_nav ); |
|
173 | - } |
|
170 | + } |
|
174 | 171 | |
175 | - /** |
|
176 | - * Retrieves the current tab. |
|
177 | - * |
|
178 | - * @since 2.1.5 |
|
179 | - */ |
|
180 | - public function get_current_tab() { |
|
181 | - global $getpaid_bp_current_tab; |
|
172 | + parent::setup_admin_bar( $wp_admin_nav ); |
|
173 | + } |
|
182 | 174 | |
183 | - if ( empty( $getpaid_bp_current_tab ) ) { |
|
184 | - return array( |
|
185 | - 'label' => __( 'Invoices', 'invoicing' ), |
|
186 | - 'content' => '[wpinv_history]', |
|
187 | - 'icon' => 'fas fa-file-invoice', |
|
188 | - ); |
|
189 | - } |
|
175 | + /** |
|
176 | + * Retrieves the current tab. |
|
177 | + * |
|
178 | + * @since 2.1.5 |
|
179 | + */ |
|
180 | + public function get_current_tab() { |
|
181 | + global $getpaid_bp_current_tab; |
|
182 | + |
|
183 | + if ( empty( $getpaid_bp_current_tab ) ) { |
|
184 | + return array( |
|
185 | + 'label' => __( 'Invoices', 'invoicing' ), |
|
186 | + 'content' => '[wpinv_history]', |
|
187 | + 'icon' => 'fas fa-file-invoice', |
|
188 | + ); |
|
189 | + } |
|
190 | 190 | |
191 | - return $getpaid_bp_current_tab; |
|
192 | - } |
|
191 | + return $getpaid_bp_current_tab; |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
195 | - * Displays the current tab. |
|
196 | - * |
|
197 | - * @since 2.1.5 |
|
198 | - */ |
|
199 | - public function display_current_tab() { |
|
194 | + /** |
|
195 | + * Displays the current tab. |
|
196 | + * |
|
197 | + * @since 2.1.5 |
|
198 | + */ |
|
199 | + public function display_current_tab() { |
|
200 | 200 | |
201 | - add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) ); |
|
202 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
201 | + add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) ); |
|
202 | + $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
203 | 203 | |
204 | 204 | bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Handles the actual display of the current tab. |
|
209 | - * |
|
210 | - * @since 2.1.5 |
|
211 | - */ |
|
212 | - public function handle_display_current_tab() { |
|
213 | - echo getpaid_prepare_user_content_tab( $this->get_current_tab() ); |
|
214 | - } |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Handles the actual display of the current tab. |
|
209 | + * |
|
210 | + * @since 2.1.5 |
|
211 | + */ |
|
212 | + public function handle_display_current_tab() { |
|
213 | + echo getpaid_prepare_user_content_tab( $this->get_current_tab() ); |
|
214 | + } |
|
215 | 215 | |
216 | 216 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly. |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Main GetPaid Class. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @type array $meta_tables Optional. An array of metadata table names. |
56 | 56 | * } |
57 | 57 | */ |
58 | - public function setup_globals( $args = array() ) { |
|
58 | + public function setup_globals($args = array()) { |
|
59 | 59 | parent::setup_globals( |
60 | 60 | array( |
61 | 61 | 'id' => 'getpaid', |
@@ -76,29 +76,29 @@ discard block |
||
76 | 76 | * @param array $main_nav Optional. See BP_Component::setup_nav() for description. |
77 | 77 | * @param array $sub_nav Optional. See BP_Component::setup_nav() for description. |
78 | 78 | */ |
79 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
79 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
80 | 80 | |
81 | 81 | // Abort if the integration is inactive. |
82 | - if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) { |
|
82 | + if (!getpaid_is_buddypress_integration_active() || !is_user_logged_in()) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Or a user is not viewing their profile. |
87 | - if ( bp_displayed_user_id() != bp_loggedin_user_id() ) { |
|
87 | + if (bp_displayed_user_id() != bp_loggedin_user_id()) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Determine user to use. |
92 | 92 | $user_domain = bp_loggedin_user_domain(); |
93 | 93 | $slug = 'getpaid'; |
94 | - $payments_link = trailingslashit( $user_domain . $slug ); |
|
94 | + $payments_link = trailingslashit($user_domain . $slug); |
|
95 | 95 | |
96 | 96 | // Add 'Payments' to the main navigation. |
97 | 97 | $main_nav = array( |
98 | - 'name' => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ), |
|
98 | + 'name' => _x('Billing', 'BuddyPress profile payments screen nav', 'invoicing'), |
|
99 | 99 | 'slug' => $slug, |
100 | - 'position' => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ), |
|
101 | - 'screen_function' => array( $this, 'display_current_tab' ), |
|
100 | + 'position' => apply_filters('wpinv_bp_nav_position', wpinv_get_option('wpinv_menu_position', 91), $slug), |
|
101 | + 'screen_function' => array($this, 'display_current_tab'), |
|
102 | 102 | 'default_subnav_slug' => 'gp-edit-address', |
103 | 103 | 'show_for_displayed_user' => false, |
104 | 104 | 'item_css_id' => $this->id, |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | ); |
108 | 108 | |
109 | 109 | // Add the subnav items to the payments nav item if we are using a theme that supports this. |
110 | - foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) { |
|
110 | + foreach (getpaid_get_user_content_tabs() as $_slug => $tab) { |
|
111 | 111 | |
112 | 112 | $sub_nav[] = array( |
113 | - 'name' => $tab[ 'label'], |
|
113 | + 'name' => $tab['label'], |
|
114 | 114 | 'slug' => $_slug, |
115 | 115 | 'parent_url' => $payments_link, |
116 | 116 | 'parent_slug' => $slug, |
117 | 117 | 'position' => 10, |
118 | - 'screen_function' => function() use ( $tab ) { |
|
118 | + 'screen_function' => function() use ($tab) { |
|
119 | 119 | $GLOBALS['getpaid_bp_current_tab'] = $tab; |
120 | 120 | $this->display_current_tab(); |
121 | 121 | }, |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
128 | + parent::setup_nav($main_nav, $sub_nav); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a |
140 | 140 | * description. |
141 | 141 | */ |
142 | - public function setup_admin_bar( $wp_admin_nav = array() ) { |
|
142 | + public function setup_admin_bar($wp_admin_nav = array()) { |
|
143 | 143 | |
144 | 144 | // Menus for logged in user. |
145 | - if ( is_user_logged_in() ) { |
|
145 | + if (is_user_logged_in()) { |
|
146 | 146 | |
147 | 147 | // Setup the logged in user variables. |
148 | - $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' ); |
|
148 | + $payments_link = trailingslashit(bp_loggedin_user_domain() . 'getpaid/'); |
|
149 | 149 | |
150 | 150 | // Add the "Payments" sub menu. |
151 | 151 | $wp_admin_nav[] = array( |
152 | 152 | 'parent' => buddypress()->my_account_menu_id, |
153 | 153 | 'id' => 'my-account-getpaid', |
154 | - 'title' => _x( 'Billing', 'BuddyPress my account payments sub nav', 'invoicing' ), |
|
154 | + 'title' => _x('Billing', 'BuddyPress my account payments sub nav', 'invoicing'), |
|
155 | 155 | 'href' => $payments_link . 'gp-edit-address' |
156 | 156 | ); |
157 | 157 | |
158 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
158 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
159 | 159 | |
160 | 160 | $wp_admin_nav[] = array( |
161 | 161 | 'parent' => 'my-account-getpaid', |
162 | 162 | 'id' => 'my-account-getpaid' . $slug, |
163 | - 'title' => $tab[ 'label'], |
|
164 | - 'href' => trailingslashit( $payments_link . $slug ), |
|
163 | + 'title' => $tab['label'], |
|
164 | + 'href' => trailingslashit($payments_link . $slug), |
|
165 | 165 | 'position' => 20 |
166 | 166 | ); |
167 | 167 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | } |
171 | 171 | |
172 | - parent::setup_admin_bar( $wp_admin_nav ); |
|
172 | + parent::setup_admin_bar($wp_admin_nav); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | public function get_current_tab() { |
181 | 181 | global $getpaid_bp_current_tab; |
182 | 182 | |
183 | - if ( empty( $getpaid_bp_current_tab ) ) { |
|
183 | + if (empty($getpaid_bp_current_tab)) { |
|
184 | 184 | return array( |
185 | - 'label' => __( 'Invoices', 'invoicing' ), |
|
185 | + 'label' => __('Invoices', 'invoicing'), |
|
186 | 186 | 'content' => '[wpinv_history]', |
187 | 187 | 'icon' => 'fas fa-file-invoice', |
188 | 188 | ); |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function display_current_tab() { |
200 | 200 | |
201 | - add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) ); |
|
202 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
201 | + add_action('bp_template_content', array($this, 'handle_display_current_tab')); |
|
202 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
203 | 203 | |
204 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
204 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @since 2.1.5 |
211 | 211 | */ |
212 | 212 | public function handle_display_current_tab() { |
213 | - echo getpaid_prepare_user_content_tab( $this->get_current_tab() ); |
|
213 | + echo getpaid_prepare_user_content_tab($this->get_current_tab()); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | } |
@@ -14,538 +14,538 @@ |
||
14 | 14 | */ |
15 | 15 | class WPInv_Plugin { |
16 | 16 | |
17 | - /** |
|
18 | - * GetPaid version. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * Data container. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $data = array(); |
|
30 | - |
|
31 | - /** |
|
32 | - * Form elements instance. |
|
33 | - * |
|
34 | - * @var WPInv_Payment_Form_Elements |
|
35 | - */ |
|
36 | - public $form_elements; |
|
37 | - |
|
38 | - /** |
|
39 | - * @param array An array of payment gateways. |
|
40 | - */ |
|
41 | - public $gateways; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class constructor. |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->define_constants(); |
|
48 | - $this->includes(); |
|
49 | - $this->init_hooks(); |
|
50 | - $this->set_properties(); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Sets a custom data property. |
|
55 | - * |
|
56 | - * @param string $prop The prop to set. |
|
57 | - * @param mixed $value The value to retrieve. |
|
58 | - */ |
|
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets a custom data property. |
|
65 | - * |
|
66 | - * @param string $prop The prop to set. |
|
67 | - * @return mixed The value. |
|
68 | - */ |
|
69 | - public function get( $prop ) { |
|
70 | - |
|
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
73 | - } |
|
74 | - |
|
75 | - return null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Define class properties. |
|
80 | - */ |
|
81 | - public function set_properties() { |
|
82 | - |
|
83 | - // Sessions. |
|
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | - $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | - |
|
88 | - // Init other objects. |
|
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Define plugin constants. |
|
106 | - */ |
|
107 | - public function define_constants() { |
|
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | - $this->version = WPINV_VERSION; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Hook into actions and filters. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - */ |
|
118 | - protected function init_hooks() { |
|
119 | - /* Internationalize the text strings used. */ |
|
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | - |
|
122 | - // Init the plugin after WordPress inits. |
|
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - // Fires after registering actions. |
|
135 | - do_action( 'wpinv_actions', $this ); |
|
136 | - do_action( 'getpaid_actions', $this ); |
|
137 | - |
|
138 | - } |
|
139 | - |
|
140 | - public function plugins_loaded() { |
|
141 | - /* Internationalize the text strings used. */ |
|
142 | - $this->load_textdomain(); |
|
143 | - |
|
144 | - do_action( 'wpinv_loaded' ); |
|
145 | - |
|
146 | - // Fix oxygen page builder conflict |
|
147 | - if ( function_exists( 'ct_css_output' ) ) { |
|
148 | - wpinv_oxygen_fix_conflict(); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Load the translation of the plugin. |
|
154 | - * |
|
155 | - * @since 1.0 |
|
156 | - */ |
|
157 | - public function load_textdomain( $locale = NULL ) { |
|
158 | - if ( empty( $locale ) ) { |
|
159 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
160 | - } |
|
161 | - |
|
162 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
163 | - |
|
164 | - unload_textdomain( 'invoicing' ); |
|
165 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
166 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
167 | - |
|
168 | - /** |
|
169 | - * Define language constants. |
|
170 | - */ |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Include required core files used in admin and on the frontend. |
|
176 | - */ |
|
177 | - public function includes() { |
|
178 | - |
|
179 | - // Start with the settings. |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
181 | - |
|
182 | - // Packages/libraries. |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
185 | - |
|
186 | - // Load functions. |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
188 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
189 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
202 | - |
|
203 | - // Register autoloader. |
|
204 | - try { |
|
205 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
206 | - } catch ( Exception $e ) { |
|
207 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | - } |
|
209 | - |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
231 | - |
|
232 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
233 | - GetPaid_Post_Types_Admin::init(); |
|
234 | - |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
241 | - // load the user class only on the users.php page |
|
242 | - global $pagenow; |
|
243 | - if($pagenow=='users.php'){ |
|
244 | - new WPInv_Admin_Users(); |
|
245 | - } |
|
246 | - } |
|
247 | - |
|
248 | - // Register cli commands |
|
249 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
250 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
251 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
252 | - } |
|
253 | - |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Class autoloader |
|
258 | - * |
|
259 | - * @param string $class_name The name of the class to load. |
|
260 | - * @access public |
|
261 | - * @since 1.0.19 |
|
262 | - * @return void |
|
263 | - */ |
|
264 | - public function autoload( $class_name ) { |
|
265 | - |
|
266 | - // Normalize the class name... |
|
267 | - $class_name = strtolower( $class_name ); |
|
268 | - |
|
269 | - // ... and make sure it is our class. |
|
270 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
271 | - return; |
|
272 | - } |
|
273 | - |
|
274 | - // Next, prepare the file name from the class. |
|
275 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
276 | - |
|
277 | - // Base path of the classes. |
|
278 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
279 | - |
|
280 | - // And an array of possible locations in order of importance. |
|
281 | - $locations = array( |
|
282 | - "$plugin_path/includes", |
|
283 | - "$plugin_path/includes/data-stores", |
|
284 | - "$plugin_path/includes/gateways", |
|
285 | - "$plugin_path/includes/payments", |
|
286 | - "$plugin_path/includes/geolocation", |
|
287 | - "$plugin_path/includes/reports", |
|
288 | - "$plugin_path/includes/api", |
|
289 | - "$plugin_path/includes/admin", |
|
290 | - "$plugin_path/includes/admin/meta-boxes", |
|
291 | - ); |
|
292 | - |
|
293 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
294 | - |
|
295 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
296 | - include trailingslashit( $location ) . $file_name; |
|
297 | - break; |
|
298 | - } |
|
299 | - |
|
300 | - } |
|
301 | - |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Inits hooks etc. |
|
306 | - */ |
|
307 | - public function init() { |
|
308 | - |
|
309 | - // Fires before getpaid inits. |
|
310 | - do_action( 'before_getpaid_init', $this ); |
|
311 | - |
|
312 | - // Maybe upgrade. |
|
313 | - $this->maybe_upgrade_database(); |
|
314 | - |
|
315 | - // Load default gateways. |
|
316 | - $gateways = apply_filters( |
|
317 | - 'getpaid_default_gateways', |
|
318 | - array( |
|
319 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
320 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
321 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
322 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
323 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
324 | - ) |
|
325 | - ); |
|
326 | - |
|
327 | - foreach ( $gateways as $id => $class ) { |
|
328 | - $this->gateways[ $id ] = new $class(); |
|
329 | - } |
|
330 | - |
|
331 | - // Fires after getpaid inits. |
|
332 | - do_action( 'getpaid_init', $this ); |
|
333 | - |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Checks if this is an IPN request and processes it. |
|
338 | - */ |
|
339 | - public function maybe_process_ipn() { |
|
340 | - |
|
341 | - // Ensure that this is an IPN request. |
|
342 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
343 | - return; |
|
344 | - } |
|
345 | - |
|
346 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
347 | - |
|
348 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
349 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
350 | - exit; |
|
351 | - |
|
352 | - } |
|
353 | - |
|
354 | - public function enqueue_scripts() { |
|
355 | - |
|
356 | - // Fires before adding scripts. |
|
357 | - do_action( 'getpaid_enqueue_scripts' ); |
|
358 | - |
|
359 | - $localize = array(); |
|
360 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
361 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
362 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
363 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
364 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
365 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
366 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
367 | - |
|
368 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
369 | - |
|
370 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
371 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
372 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
373 | - } |
|
374 | - |
|
375 | - public function wpinv_actions() { |
|
376 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
377 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
378 | - } |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
17 | + /** |
|
18 | + * GetPaid version. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * Data container. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $data = array(); |
|
30 | + |
|
31 | + /** |
|
32 | + * Form elements instance. |
|
33 | + * |
|
34 | + * @var WPInv_Payment_Form_Elements |
|
35 | + */ |
|
36 | + public $form_elements; |
|
37 | + |
|
38 | + /** |
|
39 | + * @param array An array of payment gateways. |
|
40 | + */ |
|
41 | + public $gateways; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class constructor. |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->define_constants(); |
|
48 | + $this->includes(); |
|
49 | + $this->init_hooks(); |
|
50 | + $this->set_properties(); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Sets a custom data property. |
|
55 | + * |
|
56 | + * @param string $prop The prop to set. |
|
57 | + * @param mixed $value The value to retrieve. |
|
58 | + */ |
|
59 | + public function set( $prop, $value ) { |
|
60 | + $this->data[ $prop ] = $value; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets a custom data property. |
|
65 | + * |
|
66 | + * @param string $prop The prop to set. |
|
67 | + * @return mixed The value. |
|
68 | + */ |
|
69 | + public function get( $prop ) { |
|
70 | + |
|
71 | + if ( isset( $this->data[ $prop ] ) ) { |
|
72 | + return $this->data[ $prop ]; |
|
73 | + } |
|
74 | + |
|
75 | + return null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Define class properties. |
|
80 | + */ |
|
81 | + public function set_properties() { |
|
82 | + |
|
83 | + // Sessions. |
|
84 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | + $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | + |
|
88 | + // Init other objects. |
|
89 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | + $this->set( 'notes', new WPInv_Notes() ); |
|
91 | + $this->set( 'api', new WPInv_API() ); |
|
92 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | + $this->set( 'template', new GetPaid_Template() ); |
|
94 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Define plugin constants. |
|
106 | + */ |
|
107 | + public function define_constants() { |
|
108 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | + $this->version = WPINV_VERSION; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Hook into actions and filters. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + */ |
|
118 | + protected function init_hooks() { |
|
119 | + /* Internationalize the text strings used. */ |
|
120 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | + |
|
122 | + // Init the plugin after WordPress inits. |
|
123 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | + add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | + add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | + add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
131 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | + |
|
134 | + // Fires after registering actions. |
|
135 | + do_action( 'wpinv_actions', $this ); |
|
136 | + do_action( 'getpaid_actions', $this ); |
|
137 | + |
|
138 | + } |
|
139 | + |
|
140 | + public function plugins_loaded() { |
|
141 | + /* Internationalize the text strings used. */ |
|
142 | + $this->load_textdomain(); |
|
143 | + |
|
144 | + do_action( 'wpinv_loaded' ); |
|
145 | + |
|
146 | + // Fix oxygen page builder conflict |
|
147 | + if ( function_exists( 'ct_css_output' ) ) { |
|
148 | + wpinv_oxygen_fix_conflict(); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Load the translation of the plugin. |
|
154 | + * |
|
155 | + * @since 1.0 |
|
156 | + */ |
|
157 | + public function load_textdomain( $locale = NULL ) { |
|
158 | + if ( empty( $locale ) ) { |
|
159 | + $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
160 | + } |
|
161 | + |
|
162 | + $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
163 | + |
|
164 | + unload_textdomain( 'invoicing' ); |
|
165 | + load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
166 | + load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
167 | + |
|
168 | + /** |
|
169 | + * Define language constants. |
|
170 | + */ |
|
171 | + require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Include required core files used in admin and on the frontend. |
|
176 | + */ |
|
177 | + public function includes() { |
|
178 | + |
|
179 | + // Start with the settings. |
|
180 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
181 | + |
|
182 | + // Packages/libraries. |
|
183 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
184 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
185 | + |
|
186 | + // Load functions. |
|
187 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
188 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
189 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
190 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
191 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
192 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
193 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
195 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
196 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
199 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
200 | + require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
202 | + |
|
203 | + // Register autoloader. |
|
204 | + try { |
|
205 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
206 | + } catch ( Exception $e ) { |
|
207 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | + } |
|
209 | + |
|
210 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
211 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
212 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
213 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
216 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
217 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
218 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
219 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
220 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
221 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
222 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
223 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
231 | + |
|
232 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
233 | + GetPaid_Post_Types_Admin::init(); |
|
234 | + |
|
235 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
236 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
237 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
238 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
241 | + // load the user class only on the users.php page |
|
242 | + global $pagenow; |
|
243 | + if($pagenow=='users.php'){ |
|
244 | + new WPInv_Admin_Users(); |
|
245 | + } |
|
246 | + } |
|
247 | + |
|
248 | + // Register cli commands |
|
249 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
250 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
251 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
252 | + } |
|
253 | + |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Class autoloader |
|
258 | + * |
|
259 | + * @param string $class_name The name of the class to load. |
|
260 | + * @access public |
|
261 | + * @since 1.0.19 |
|
262 | + * @return void |
|
263 | + */ |
|
264 | + public function autoload( $class_name ) { |
|
265 | + |
|
266 | + // Normalize the class name... |
|
267 | + $class_name = strtolower( $class_name ); |
|
268 | + |
|
269 | + // ... and make sure it is our class. |
|
270 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
271 | + return; |
|
272 | + } |
|
273 | + |
|
274 | + // Next, prepare the file name from the class. |
|
275 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
276 | + |
|
277 | + // Base path of the classes. |
|
278 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
279 | + |
|
280 | + // And an array of possible locations in order of importance. |
|
281 | + $locations = array( |
|
282 | + "$plugin_path/includes", |
|
283 | + "$plugin_path/includes/data-stores", |
|
284 | + "$plugin_path/includes/gateways", |
|
285 | + "$plugin_path/includes/payments", |
|
286 | + "$plugin_path/includes/geolocation", |
|
287 | + "$plugin_path/includes/reports", |
|
288 | + "$plugin_path/includes/api", |
|
289 | + "$plugin_path/includes/admin", |
|
290 | + "$plugin_path/includes/admin/meta-boxes", |
|
291 | + ); |
|
292 | + |
|
293 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
294 | + |
|
295 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
296 | + include trailingslashit( $location ) . $file_name; |
|
297 | + break; |
|
298 | + } |
|
299 | + |
|
300 | + } |
|
301 | + |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Inits hooks etc. |
|
306 | + */ |
|
307 | + public function init() { |
|
308 | + |
|
309 | + // Fires before getpaid inits. |
|
310 | + do_action( 'before_getpaid_init', $this ); |
|
311 | + |
|
312 | + // Maybe upgrade. |
|
313 | + $this->maybe_upgrade_database(); |
|
314 | + |
|
315 | + // Load default gateways. |
|
316 | + $gateways = apply_filters( |
|
317 | + 'getpaid_default_gateways', |
|
318 | + array( |
|
319 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
320 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
321 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
322 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
323 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
324 | + ) |
|
325 | + ); |
|
326 | + |
|
327 | + foreach ( $gateways as $id => $class ) { |
|
328 | + $this->gateways[ $id ] = new $class(); |
|
329 | + } |
|
330 | + |
|
331 | + // Fires after getpaid inits. |
|
332 | + do_action( 'getpaid_init', $this ); |
|
333 | + |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Checks if this is an IPN request and processes it. |
|
338 | + */ |
|
339 | + public function maybe_process_ipn() { |
|
340 | + |
|
341 | + // Ensure that this is an IPN request. |
|
342 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
343 | + return; |
|
344 | + } |
|
345 | + |
|
346 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
347 | + |
|
348 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
349 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
350 | + exit; |
|
351 | + |
|
352 | + } |
|
353 | + |
|
354 | + public function enqueue_scripts() { |
|
355 | + |
|
356 | + // Fires before adding scripts. |
|
357 | + do_action( 'getpaid_enqueue_scripts' ); |
|
358 | + |
|
359 | + $localize = array(); |
|
360 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
361 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
362 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
363 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
364 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
365 | + $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
366 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
367 | + |
|
368 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
369 | + |
|
370 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
371 | + wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
372 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
373 | + } |
|
374 | + |
|
375 | + public function wpinv_actions() { |
|
376 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
377 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
378 | + } |
|
379 | + } |
|
380 | + |
|
381 | + /** |
|
382 | 382 | * Fires an action after verifying that a user can fire them. |
383 | - * |
|
384 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
385 | - * current user owns the invoice/subscription. |
|
383 | + * |
|
384 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
385 | + * current user owns the invoice/subscription. |
|
386 | 386 | */ |
387 | 387 | public function maybe_do_authenticated_action() { |
388 | 388 | |
389 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
389 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
390 | + |
|
391 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
392 | + $data = wp_unslash( $_REQUEST ); |
|
393 | + if ( is_user_logged_in() ) { |
|
394 | + do_action( "getpaid_authenticated_action_$key", $data ); |
|
395 | + } |
|
396 | + |
|
397 | + do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
390 | 398 | |
391 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
392 | - $data = wp_unslash( $_REQUEST ); |
|
393 | - if ( is_user_logged_in() ) { |
|
394 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
395 | - } |
|
399 | + } |
|
396 | 400 | |
397 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
401 | + } |
|
402 | + |
|
403 | + public function pre_get_posts( $wp_query ) { |
|
398 | 404 | |
399 | - } |
|
405 | + if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
406 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
407 | + } |
|
400 | 408 | |
409 | + return $wp_query; |
|
401 | 410 | } |
402 | 411 | |
403 | - public function pre_get_posts( $wp_query ) { |
|
404 | - |
|
405 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
406 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
407 | - } |
|
408 | - |
|
409 | - return $wp_query; |
|
410 | - } |
|
411 | - |
|
412 | - /** |
|
413 | - * Register widgets |
|
414 | - * |
|
415 | - */ |
|
416 | - public function register_widgets() { |
|
417 | - |
|
418 | - // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
419 | - // So we disable our widgets when editing a page with UX Builder. |
|
420 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
421 | - return; |
|
422 | - } |
|
423 | - |
|
424 | - $widgets = apply_filters( |
|
425 | - 'getpaid_widget_classes', |
|
426 | - array( |
|
427 | - 'WPInv_Checkout_Widget', |
|
428 | - 'WPInv_History_Widget', |
|
429 | - 'WPInv_Receipt_Widget', |
|
430 | - 'WPInv_Subscriptions_Widget', |
|
431 | - 'WPInv_Buy_Item_Widget', |
|
432 | - 'WPInv_Messages_Widget', |
|
433 | - 'WPInv_GetPaid_Widget' |
|
434 | - ) |
|
435 | - ); |
|
436 | - |
|
437 | - foreach ( $widgets as $widget ) { |
|
438 | - register_widget( $widget ); |
|
439 | - } |
|
412 | + /** |
|
413 | + * Register widgets |
|
414 | + * |
|
415 | + */ |
|
416 | + public function register_widgets() { |
|
417 | + |
|
418 | + // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
419 | + // So we disable our widgets when editing a page with UX Builder. |
|
420 | + if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
421 | + return; |
|
422 | + } |
|
423 | + |
|
424 | + $widgets = apply_filters( |
|
425 | + 'getpaid_widget_classes', |
|
426 | + array( |
|
427 | + 'WPInv_Checkout_Widget', |
|
428 | + 'WPInv_History_Widget', |
|
429 | + 'WPInv_Receipt_Widget', |
|
430 | + 'WPInv_Subscriptions_Widget', |
|
431 | + 'WPInv_Buy_Item_Widget', |
|
432 | + 'WPInv_Messages_Widget', |
|
433 | + 'WPInv_GetPaid_Widget' |
|
434 | + ) |
|
435 | + ); |
|
436 | + |
|
437 | + foreach ( $widgets as $widget ) { |
|
438 | + register_widget( $widget ); |
|
439 | + } |
|
440 | 440 | |
441 | - } |
|
441 | + } |
|
442 | 442 | |
443 | - /** |
|
444 | - * Upgrades the database. |
|
445 | - * |
|
446 | - * @since 2.0.2 |
|
447 | - */ |
|
448 | - public function maybe_upgrade_database() { |
|
443 | + /** |
|
444 | + * Upgrades the database. |
|
445 | + * |
|
446 | + * @since 2.0.2 |
|
447 | + */ |
|
448 | + public function maybe_upgrade_database() { |
|
449 | 449 | |
450 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
450 | + $wpi_version = get_option( 'wpinv_version', 0 ); |
|
451 | 451 | |
452 | - if ( $wpi_version == WPINV_VERSION ) { |
|
453 | - return; |
|
454 | - } |
|
452 | + if ( $wpi_version == WPINV_VERSION ) { |
|
453 | + return; |
|
454 | + } |
|
455 | 455 | |
456 | - $installer = new GetPaid_Installer(); |
|
456 | + $installer = new GetPaid_Installer(); |
|
457 | 457 | |
458 | - if ( empty( $wpi_version ) ) { |
|
459 | - return $installer->upgrade_db( 0 ); |
|
460 | - } |
|
458 | + if ( empty( $wpi_version ) ) { |
|
459 | + return $installer->upgrade_db( 0 ); |
|
460 | + } |
|
461 | 461 | |
462 | - $upgrades = array( |
|
463 | - '0.0.5' => '004', |
|
464 | - '1.0.3' => '102', |
|
465 | - '2.0.0' => '118', |
|
466 | - '2.0.8' => '207', |
|
467 | - ); |
|
462 | + $upgrades = array( |
|
463 | + '0.0.5' => '004', |
|
464 | + '1.0.3' => '102', |
|
465 | + '2.0.0' => '118', |
|
466 | + '2.0.8' => '207', |
|
467 | + ); |
|
468 | 468 | |
469 | - foreach ( $upgrades as $key => $method ) { |
|
469 | + foreach ( $upgrades as $key => $method ) { |
|
470 | 470 | |
471 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
472 | - return $installer->upgrade_db( $method ); |
|
473 | - } |
|
471 | + if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
472 | + return $installer->upgrade_db( $method ); |
|
473 | + } |
|
474 | 474 | |
475 | - } |
|
475 | + } |
|
476 | 476 | |
477 | - } |
|
477 | + } |
|
478 | 478 | |
479 | - /** |
|
480 | - * Flushes the permalinks if needed. |
|
481 | - * |
|
482 | - * @since 2.0.8 |
|
483 | - */ |
|
484 | - public function maybe_flush_permalinks() { |
|
479 | + /** |
|
480 | + * Flushes the permalinks if needed. |
|
481 | + * |
|
482 | + * @since 2.0.8 |
|
483 | + */ |
|
484 | + public function maybe_flush_permalinks() { |
|
485 | 485 | |
486 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
486 | + $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
487 | 487 | |
488 | - if ( ! empty( $flush ) ) { |
|
489 | - flush_rewrite_rules(); |
|
490 | - delete_option( 'wpinv_flush_permalinks' ); |
|
491 | - } |
|
488 | + if ( ! empty( $flush ) ) { |
|
489 | + flush_rewrite_rules(); |
|
490 | + delete_option( 'wpinv_flush_permalinks' ); |
|
491 | + } |
|
492 | 492 | |
493 | - } |
|
493 | + } |
|
494 | 494 | |
495 | - /** |
|
496 | - * Remove our pages from yoast sitemaps. |
|
497 | - * |
|
498 | - * @since 1.0.19 |
|
499 | - * @param int[] $excluded_posts_ids |
|
500 | - */ |
|
501 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
495 | + /** |
|
496 | + * Remove our pages from yoast sitemaps. |
|
497 | + * |
|
498 | + * @since 1.0.19 |
|
499 | + * @param int[] $excluded_posts_ids |
|
500 | + */ |
|
501 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
502 | 502 | |
503 | - // Ensure that we have an array. |
|
504 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
505 | - $excluded_posts_ids = array(); |
|
506 | - } |
|
503 | + // Ensure that we have an array. |
|
504 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
505 | + $excluded_posts_ids = array(); |
|
506 | + } |
|
507 | 507 | |
508 | - // Prepare our pages. |
|
509 | - $our_pages = array(); |
|
508 | + // Prepare our pages. |
|
509 | + $our_pages = array(); |
|
510 | 510 | |
511 | - // Checkout page. |
|
512 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
511 | + // Checkout page. |
|
512 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
513 | 513 | |
514 | - // Success page. |
|
515 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
514 | + // Success page. |
|
515 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
516 | 516 | |
517 | - // Failure page. |
|
518 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
517 | + // Failure page. |
|
518 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
519 | 519 | |
520 | - // History page. |
|
521 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
520 | + // History page. |
|
521 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
522 | 522 | |
523 | - // Subscriptions page. |
|
524 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
523 | + // Subscriptions page. |
|
524 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
525 | 525 | |
526 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
526 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
527 | 527 | |
528 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
529 | - return array_unique( $excluded_posts_ids ); |
|
528 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
529 | + return array_unique( $excluded_posts_ids ); |
|
530 | 530 | |
531 | - } |
|
531 | + } |
|
532 | 532 | |
533 | - /** |
|
534 | - * Displays additional footer code. |
|
535 | - * |
|
536 | - * @since 2.0.0 |
|
537 | - */ |
|
538 | - public function wp_footer() { |
|
539 | - wpinv_get_template( 'frontend-footer.php' ); |
|
540 | - } |
|
533 | + /** |
|
534 | + * Displays additional footer code. |
|
535 | + * |
|
536 | + * @since 2.0.0 |
|
537 | + */ |
|
538 | + public function wp_footer() { |
|
539 | + wpinv_get_template( 'frontend-footer.php' ); |
|
540 | + } |
|
541 | 541 | |
542 | - /** |
|
543 | - * Displays additional header code. |
|
544 | - * |
|
545 | - * @since 2.0.0 |
|
546 | - */ |
|
547 | - public function wp_head() { |
|
548 | - wpinv_get_template( 'frontend-head.php' ); |
|
549 | - } |
|
542 | + /** |
|
543 | + * Displays additional header code. |
|
544 | + * |
|
545 | + * @since 2.0.0 |
|
546 | + */ |
|
547 | + public function wp_head() { |
|
548 | + wpinv_get_template( 'frontend-head.php' ); |
|
549 | + } |
|
550 | 550 | |
551 | 551 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,23 +117,23 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | 133 | |
134 | 134 | // Fires after registering actions. |
135 | - do_action( 'wpinv_actions', $this ); |
|
136 | - do_action( 'getpaid_actions', $this ); |
|
135 | + do_action('wpinv_actions', $this); |
|
136 | + do_action('getpaid_actions', $this); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | /* Internationalize the text strings used. */ |
142 | 142 | $this->load_textdomain(); |
143 | 143 | |
144 | - do_action( 'wpinv_loaded' ); |
|
144 | + do_action('wpinv_loaded'); |
|
145 | 145 | |
146 | 146 | // Fix oxygen page builder conflict |
147 | - if ( function_exists( 'ct_css_output' ) ) { |
|
147 | + if (function_exists('ct_css_output')) { |
|
148 | 148 | wpinv_oxygen_fix_conflict(); |
149 | 149 | } |
150 | 150 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | - public function load_textdomain( $locale = NULL ) { |
|
158 | - if ( empty( $locale ) ) { |
|
159 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
157 | + public function load_textdomain($locale = NULL) { |
|
158 | + if (empty($locale)) { |
|
159 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
160 | 160 | } |
161 | 161 | |
162 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
162 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
163 | 163 | |
164 | - unload_textdomain( 'invoicing' ); |
|
165 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
166 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
164 | + unload_textdomain('invoicing'); |
|
165 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
166 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Define language constants. |
170 | 170 | */ |
171 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,78 +177,78 @@ discard block |
||
177 | 177 | public function includes() { |
178 | 178 | |
179 | 179 | // Start with the settings. |
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
181 | 181 | |
182 | 182 | // Packages/libraries. |
183 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
185 | 185 | |
186 | 186 | // Load functions. |
187 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
188 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
189 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
188 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
189 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
202 | 202 | |
203 | 203 | // Register autoloader. |
204 | 204 | try { |
205 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
206 | - } catch ( Exception $e ) { |
|
207 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
205 | + spl_autoload_register(array($this, 'autoload'), true); |
|
206 | + } catch (Exception $e) { |
|
207 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
208 | 208 | } |
209 | 209 | |
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
231 | - |
|
232 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
231 | + |
|
232 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
233 | 233 | GetPaid_Post_Types_Admin::init(); |
234 | 234 | |
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
241 | 241 | // load the user class only on the users.php page |
242 | 242 | global $pagenow; |
243 | - if($pagenow=='users.php'){ |
|
243 | + if ($pagenow == 'users.php') { |
|
244 | 244 | new WPInv_Admin_Users(); |
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Register cli commands |
249 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
250 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
251 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
249 | + if (defined('WP_CLI') && WP_CLI) { |
|
250 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
251 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | * @since 1.0.19 |
262 | 262 | * @return void |
263 | 263 | */ |
264 | - public function autoload( $class_name ) { |
|
264 | + public function autoload($class_name) { |
|
265 | 265 | |
266 | 266 | // Normalize the class name... |
267 | - $class_name = strtolower( $class_name ); |
|
267 | + $class_name = strtolower($class_name); |
|
268 | 268 | |
269 | 269 | // ... and make sure it is our class. |
270 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
270 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
271 | 271 | return; |
272 | 272 | } |
273 | 273 | |
274 | 274 | // Next, prepare the file name from the class. |
275 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
275 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
276 | 276 | |
277 | 277 | // Base path of the classes. |
278 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
278 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
279 | 279 | |
280 | 280 | // And an array of possible locations in order of importance. |
281 | 281 | $locations = array( |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | "$plugin_path/includes/admin/meta-boxes", |
291 | 291 | ); |
292 | 292 | |
293 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
293 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
294 | 294 | |
295 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
296 | - include trailingslashit( $location ) . $file_name; |
|
295 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
296 | + include trailingslashit($location) . $file_name; |
|
297 | 297 | break; |
298 | 298 | } |
299 | 299 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | public function init() { |
308 | 308 | |
309 | 309 | // Fires before getpaid inits. |
310 | - do_action( 'before_getpaid_init', $this ); |
|
310 | + do_action('before_getpaid_init', $this); |
|
311 | 311 | |
312 | 312 | // Maybe upgrade. |
313 | 313 | $this->maybe_upgrade_database(); |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | ) |
325 | 325 | ); |
326 | 326 | |
327 | - foreach ( $gateways as $id => $class ) { |
|
328 | - $this->gateways[ $id ] = new $class(); |
|
327 | + foreach ($gateways as $id => $class) { |
|
328 | + $this->gateways[$id] = new $class(); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | // Fires after getpaid inits. |
332 | - do_action( 'getpaid_init', $this ); |
|
332 | + do_action('getpaid_init', $this); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | public function maybe_process_ipn() { |
340 | 340 | |
341 | 341 | // Ensure that this is an IPN request. |
342 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
342 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
343 | 343 | return; |
344 | 344 | } |
345 | 345 | |
346 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
346 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
347 | 347 | |
348 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
349 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
348 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
349 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
350 | 350 | exit; |
351 | 351 | |
352 | 352 | } |
@@ -354,27 +354,27 @@ discard block |
||
354 | 354 | public function enqueue_scripts() { |
355 | 355 | |
356 | 356 | // Fires before adding scripts. |
357 | - do_action( 'getpaid_enqueue_scripts' ); |
|
357 | + do_action('getpaid_enqueue_scripts'); |
|
358 | 358 | |
359 | 359 | $localize = array(); |
360 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
361 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
362 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
360 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
361 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
362 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
363 | 363 | $localize['UseTaxes'] = wpinv_use_taxes(); |
364 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
365 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
366 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
364 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
365 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
366 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
367 | 367 | |
368 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
368 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
369 | 369 | |
370 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
371 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
372 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
370 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
371 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
372 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | public function wpinv_actions() { |
376 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
377 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
376 | + if (isset($_REQUEST['wpi_action'])) { |
|
377 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -386,24 +386,24 @@ discard block |
||
386 | 386 | */ |
387 | 387 | public function maybe_do_authenticated_action() { |
388 | 388 | |
389 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
389 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
390 | 390 | |
391 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
392 | - $data = wp_unslash( $_REQUEST ); |
|
393 | - if ( is_user_logged_in() ) { |
|
394 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
391 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
392 | + $data = wp_unslash($_REQUEST); |
|
393 | + if (is_user_logged_in()) { |
|
394 | + do_action("getpaid_authenticated_action_$key", $data); |
|
395 | 395 | } |
396 | 396 | |
397 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
397 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
398 | 398 | |
399 | 399 | } |
400 | 400 | |
401 | 401 | } |
402 | 402 | |
403 | - public function pre_get_posts( $wp_query ) { |
|
403 | + public function pre_get_posts($wp_query) { |
|
404 | 404 | |
405 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
406 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
405 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
406 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $wp_query; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
419 | 419 | // So we disable our widgets when editing a page with UX Builder. |
420 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
420 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
421 | 421 | return; |
422 | 422 | } |
423 | 423 | |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | ) |
435 | 435 | ); |
436 | 436 | |
437 | - foreach ( $widgets as $widget ) { |
|
438 | - register_widget( $widget ); |
|
437 | + foreach ($widgets as $widget) { |
|
438 | + register_widget($widget); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | } |
@@ -447,29 +447,29 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function maybe_upgrade_database() { |
449 | 449 | |
450 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
450 | + $wpi_version = get_option('wpinv_version', 0); |
|
451 | 451 | |
452 | - if ( $wpi_version == WPINV_VERSION ) { |
|
452 | + if ($wpi_version == WPINV_VERSION) { |
|
453 | 453 | return; |
454 | 454 | } |
455 | 455 | |
456 | 456 | $installer = new GetPaid_Installer(); |
457 | 457 | |
458 | - if ( empty( $wpi_version ) ) { |
|
459 | - return $installer->upgrade_db( 0 ); |
|
458 | + if (empty($wpi_version)) { |
|
459 | + return $installer->upgrade_db(0); |
|
460 | 460 | } |
461 | 461 | |
462 | - $upgrades = array( |
|
462 | + $upgrades = array( |
|
463 | 463 | '0.0.5' => '004', |
464 | 464 | '1.0.3' => '102', |
465 | 465 | '2.0.0' => '118', |
466 | 466 | '2.0.8' => '207', |
467 | 467 | ); |
468 | 468 | |
469 | - foreach ( $upgrades as $key => $method ) { |
|
469 | + foreach ($upgrades as $key => $method) { |
|
470 | 470 | |
471 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
472 | - return $installer->upgrade_db( $method ); |
|
471 | + if (version_compare($wpi_version, $key, '<')) { |
|
472 | + return $installer->upgrade_db($method); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | } |
@@ -483,11 +483,11 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function maybe_flush_permalinks() { |
485 | 485 | |
486 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
486 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
487 | 487 | |
488 | - if ( ! empty( $flush ) ) { |
|
488 | + if (!empty($flush)) { |
|
489 | 489 | flush_rewrite_rules(); |
490 | - delete_option( 'wpinv_flush_permalinks' ); |
|
490 | + delete_option('wpinv_flush_permalinks'); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | * @since 1.0.19 |
499 | 499 | * @param int[] $excluded_posts_ids |
500 | 500 | */ |
501 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
501 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
502 | 502 | |
503 | 503 | // Ensure that we have an array. |
504 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
504 | + if (!is_array($excluded_posts_ids)) { |
|
505 | 505 | $excluded_posts_ids = array(); |
506 | 506 | } |
507 | 507 | |
@@ -509,24 +509,24 @@ discard block |
||
509 | 509 | $our_pages = array(); |
510 | 510 | |
511 | 511 | // Checkout page. |
512 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
512 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
513 | 513 | |
514 | 514 | // Success page. |
515 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
515 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
516 | 516 | |
517 | 517 | // Failure page. |
518 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
518 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
519 | 519 | |
520 | 520 | // History page. |
521 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
521 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
522 | 522 | |
523 | 523 | // Subscriptions page. |
524 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
524 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
525 | 525 | |
526 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
526 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
527 | 527 | |
528 | 528 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
529 | - return array_unique( $excluded_posts_ids ); |
|
529 | + return array_unique($excluded_posts_ids); |
|
530 | 530 | |
531 | 531 | } |
532 | 532 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @since 2.0.0 |
537 | 537 | */ |
538 | 538 | public function wp_footer() { |
539 | - wpinv_get_template( 'frontend-footer.php' ); |
|
539 | + wpinv_get_template('frontend-footer.php'); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @since 2.0.0 |
546 | 546 | */ |
547 | 547 | public function wp_head() { |
548 | - wpinv_get_template( 'frontend-head.php' ); |
|
548 | + wpinv_get_template('frontend-head.php'); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | } |