@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | $css = getpaid_get_email_css(); |
111 | 111 | |
112 | 112 | // include css inliner |
113 | - if ( ! class_exists( 'Emogrifier' ) ) { |
|
114 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
113 | + if ( ! class_exists( 'Emogrifier' ) ) { |
|
114 | + include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // Inline the css. |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $message = wpinv_email_style_body( $message ); |
191 | 191 | $to = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) ); |
192 | 192 | |
193 | - return $mailer->send( |
|
193 | + return $mailer->send( |
|
194 | 194 | $to, |
195 | 195 | $subject, |
196 | 196 | $message, |
@@ -31,36 +31,36 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | - $can_checkout = true; // Always true for now |
|
34 | + $can_checkout = true; // Always true for now |
|
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | + $page_id = absint( $page_id ); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | + $page_id = absint( $page_id ); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | + $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | + $ret = $ret ? is_page( $ret ) : false; |
|
63 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
@@ -103,55 +103,55 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
110 | - // Check for backward compatibility |
|
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
109 | + if ( !empty( $args ) ) { |
|
110 | + // Check for backward compatibility |
|
111 | + if ( is_string( $args ) ) |
|
112 | + $args = str_replace( '?', '', $args ); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args( $args ); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
117 | - } |
|
116 | + $uri = add_query_arg( $args, $uri ); |
|
117 | + } |
|
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | - } |
|
123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | + } |
|
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function wpinv_get_success_page_url( $query_string = null ) { |
131 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | - $success_page = get_permalink( $success_page ); |
|
131 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | + $success_page = get_permalink( $success_page ); |
|
133 | 133 | |
134 | - if ( $query_string ) |
|
135 | - $success_page .= $query_string; |
|
134 | + if ( $query_string ) |
|
135 | + $success_page .= $query_string; |
|
136 | 136 | |
137 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
137 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
141 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
141 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
143 | 143 | |
144 | - if ( $extras ) |
|
145 | - $uri .= $extras; |
|
144 | + if ( $extras ) |
|
145 | + $uri .= $extras; |
|
146 | 146 | |
147 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
147 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function wpinv_is_failed_transaction_page() { |
151 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
151 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
154 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -226,36 +226,36 @@ discard block |
||
226 | 226 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
227 | 227 | |
228 | 228 | if ( $require_billing_details ) { |
229 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
230 | - $required_fields['first_name'] = array( |
|
231 | - 'error_id' => 'invalid_first_name', |
|
232 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
233 | - ); |
|
234 | - } |
|
235 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
236 | - $required_fields['address'] = array( |
|
237 | - 'error_id' => 'invalid_address', |
|
238 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
239 | - ); |
|
240 | - } |
|
241 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
242 | - $required_fields['city'] = array( |
|
243 | - 'error_id' => 'invalid_city', |
|
244 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
245 | - ); |
|
246 | - } |
|
247 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
248 | - $required_fields['state'] = array( |
|
249 | - 'error_id' => 'invalid_state', |
|
250 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
251 | - ); |
|
252 | - } |
|
253 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
254 | - $required_fields['country'] = array( |
|
255 | - 'error_id' => 'invalid_country', |
|
256 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
257 | - ); |
|
258 | - } |
|
229 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
230 | + $required_fields['first_name'] = array( |
|
231 | + 'error_id' => 'invalid_first_name', |
|
232 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
233 | + ); |
|
234 | + } |
|
235 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
236 | + $required_fields['address'] = array( |
|
237 | + 'error_id' => 'invalid_address', |
|
238 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
239 | + ); |
|
240 | + } |
|
241 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
242 | + $required_fields['city'] = array( |
|
243 | + 'error_id' => 'invalid_city', |
|
244 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
245 | + ); |
|
246 | + } |
|
247 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
248 | + $required_fields['state'] = array( |
|
249 | + 'error_id' => 'invalid_state', |
|
250 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
251 | + ); |
|
252 | + } |
|
253 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
254 | + $required_fields['country'] = array( |
|
255 | + 'error_id' => 'invalid_country', |
|
256 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
257 | + ); |
|
258 | + } |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @return array |
78 | 78 | */ |
79 | 79 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
80 | - $invoice_statuses = array( |
|
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
80 | + $invoice_statuses = array( |
|
81 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | 82 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
83 | 83 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
84 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | 87 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
88 | 88 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
89 | 89 | ); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | function wpinv_status_nicename( $status ) { |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @return string |
209 | 209 | */ |
210 | 210 | function getpaid_get_price_format() { |
211 | - $currency_pos = wpinv_currency_position(); |
|
212 | - $format = '%1$s%2$s'; |
|
211 | + $currency_pos = wpinv_currency_position(); |
|
212 | + $format = '%1$s%2$s'; |
|
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
215 | - case 'left': |
|
216 | - $format = '%1$s%2$s'; |
|
217 | - break; |
|
218 | - case 'right': |
|
219 | - $format = '%2$s%1$s'; |
|
220 | - break; |
|
221 | - case 'left_space': |
|
222 | - $format = '%1$s %2$s'; |
|
223 | - break; |
|
224 | - case 'right_space': |
|
225 | - $format = '%2$s %1$s'; |
|
226 | - break; |
|
227 | - } |
|
214 | + switch ( $currency_pos ) { |
|
215 | + case 'left': |
|
216 | + $format = '%1$s%2$s'; |
|
217 | + break; |
|
218 | + case 'right': |
|
219 | + $format = '%2$s%1$s'; |
|
220 | + break; |
|
221 | + case 'left_space': |
|
222 | + $format = '%1$s %2$s'; |
|
223 | + break; |
|
224 | + case 'right_space': |
|
225 | + $format = '%2$s %1$s'; |
|
226 | + break; |
|
227 | + } |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | 331 | function getpaid_maybe_define_constant( $name, $value ) { |
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
334 | - } |
|
332 | + if ( ! defined( $name ) ) { |
|
333 | + define( $name, $value ); |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get( 'arg_separator.output' ); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | function wpinv_rgb_from_hex( $color ) { |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | - } |
|
687 | + if ( ! is_array( $list ) ) { |
|
688 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | + } |
|
690 | 690 | |
691 | - return $list; |
|
691 | + return $list; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | } |
709 | 709 | |
710 | 710 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
711 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
712 | 712 | |
713 | - return $data; |
|
713 | + return $data; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -739,17 +739,17 @@ discard block |
||
739 | 739 | */ |
740 | 740 | function wpinv_clean( $var ) { |
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if ( is_array( $var ) ) { |
|
743 | + return array_map( 'wpinv_clean', $var ); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | if ( is_object( $var ) ) { |
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
747 | + $object_vars = get_object_vars( $var ); |
|
748 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | + $var->$property_name = wpinv_clean( $property_value ); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | 754 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
755 | 755 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | */ |
763 | 763 | function getpaid_convert_price_string_to_options( $str ) { |
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
765 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | 766 | $options = array(); |
767 | 767 | |
768 | 768 | foreach ( $raw_options as $option ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -862,15 +862,15 @@ discard block |
||
862 | 862 | function getpaid_limit_length( $string, $limit ) { |
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | - } |
|
869 | - } else { |
|
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | - } |
|
873 | - } |
|
865 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | + if ( mb_strlen( $string ) > $limit ) { |
|
867 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | + } |
|
869 | + } else { |
|
870 | + if ( strlen( $string ) > $limit ) { |
|
871 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | + } |
|
873 | + } |
|
874 | 874 | return $string; |
875 | 875 | |
876 | 876 | } |
@@ -117,14 +117,14 @@ |
||
117 | 117 | */ |
118 | 118 | function getpaid_doing_it_wrong( $function, $message, $version ) { |
119 | 119 | |
120 | - $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | - |
|
122 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | - } else { |
|
126 | - _doing_it_wrong( $function, $message, $version ); |
|
127 | - } |
|
120 | + $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | + |
|
122 | + if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | + do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | + error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | + } else { |
|
126 | + _doing_it_wrong( $function, $message, $version ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false |
39 | - ), |
|
39 | + ), |
|
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | - 'type' => 'text', |
|
45 | - 'desc_tip' => true, |
|
46 | - 'default' => '', |
|
47 | - 'placeholder' => __('1','invoicing'), |
|
48 | - 'advanced' => false |
|
49 | - ), |
|
50 | - |
|
51 | - 'item' => array( |
|
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | - 'type' => 'text', |
|
55 | - 'desc_tip' => true, |
|
56 | - 'default' => '', |
|
57 | - 'placeholder' => __('1','invoicing'), |
|
58 | - 'advanced' => false |
|
59 | - ), |
|
42 | + 'title' => __( 'Form', 'invoicing' ), |
|
43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | + 'type' => 'text', |
|
45 | + 'desc_tip' => true, |
|
46 | + 'default' => '', |
|
47 | + 'placeholder' => __('1','invoicing'), |
|
48 | + 'advanced' => false |
|
49 | + ), |
|
50 | + |
|
51 | + 'item' => array( |
|
52 | + 'title' => __( 'Items', 'invoicing' ), |
|
53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | + 'type' => 'text', |
|
55 | + 'desc_tip' => true, |
|
56 | + 'default' => '', |
|
57 | + 'placeholder' => __('1','invoicing'), |
|
58 | + 'advanced' => false |
|
59 | + ), |
|
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | - 'type' => 'text', |
|
65 | - 'desc_tip' => true, |
|
66 | - 'default' => '', |
|
67 | - 'advanced' => false |
|
68 | - ) |
|
62 | + 'title' => __( 'Button', 'invoicing' ), |
|
63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | + 'type' => 'text', |
|
65 | + 'desc_tip' => true, |
|
66 | + 'default' => '', |
|
67 | + 'advanced' => false |
|
68 | + ) |
|
69 | 69 | |
70 | 70 | ) |
71 | 71 | |
@@ -75,95 +75,95 @@ discard block |
||
75 | 75 | parent::__construct( $options ); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * The Super block output function. |
|
80 | - * |
|
81 | - * @param array $args |
|
82 | - * @param array $widget_args |
|
83 | - * @param string $content |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
78 | + /** |
|
79 | + * The Super block output function. |
|
80 | + * |
|
81 | + * @param array $args |
|
82 | + * @param array $widget_args |
|
83 | + * @param string $content |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
88 | 88 | |
89 | - // Is the shortcode set up correctly? |
|
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | - return aui()->alert( |
|
92 | - array( |
|
93 | - 'type' => 'warning', |
|
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - // Payment form or button? |
|
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
102 | - } else { |
|
103 | - return $this->handle_buy_item( $args ); |
|
104 | - } |
|
105 | - |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Displaying a payment form |
|
110 | - * |
|
111 | - * @return string |
|
112 | - */ |
|
89 | + // Is the shortcode set up correctly? |
|
90 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | + return aui()->alert( |
|
92 | + array( |
|
93 | + 'type' => 'warning', |
|
94 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + // Payment form or button? |
|
100 | + if ( ! empty( $args['form'] ) ) { |
|
101 | + return $this->handle_payment_form( $args ); |
|
102 | + } else { |
|
103 | + return $this->handle_buy_item( $args ); |
|
104 | + } |
|
105 | + |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Displaying a payment form |
|
110 | + * |
|
111 | + * @return string |
|
112 | + */ |
|
113 | 113 | protected function handle_payment_form( $args = array() ) { |
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
116 | - ob_start(); |
|
117 | - getpaid_display_payment_form( $args['form'] ); |
|
118 | - return ob_get_clean(); |
|
119 | - } |
|
115 | + if ( empty( $args['button'] ) ) { |
|
116 | + ob_start(); |
|
117 | + getpaid_display_payment_form( $args['form'] ); |
|
118 | + return ob_get_clean(); |
|
119 | + } |
|
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | - } |
|
121 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Displays a payment form button. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Displays a payment form button. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | protected function payment_form_button( $form, $button ) { |
130 | - return getpaid_get_payment_button( $button, $form ); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Selling an item |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
130 | + return getpaid_get_payment_button( $button, $form ); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Selling an item |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | 138 | protected function handle_buy_item( $args = array() ) { |
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
142 | - } |
|
140 | + if ( empty( $args['button'] ) ) { |
|
141 | + return $this->buy_item_form( $args['item'] ); |
|
142 | + } |
|
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Displays a buy item form. |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Displays a buy item form. |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | 153 | protected function buy_item_form( $item ) { |
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
155 | - ob_start(); |
|
156 | - getpaid_display_item_payment_form( $items ); |
|
157 | - return ob_get_clean(); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Displays a buy item button. |
|
162 | - * |
|
163 | - * @return string |
|
164 | - */ |
|
154 | + $items = getpaid_convert_items_to_array( $item ); |
|
155 | + ob_start(); |
|
156 | + getpaid_display_item_payment_form( $items ); |
|
157 | + return ob_get_clean(); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Displays a buy item button. |
|
162 | + * |
|
163 | + * @return string |
|
164 | + */ |
|
165 | 165 | protected function buy_item_button( $item, $button ) { |
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
166 | + return getpaid_get_payment_button( $button, null, $item ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -14,62 +14,62 @@ discard block |
||
14 | 14 | class GetPaid_Admin { |
15 | 15 | |
16 | 16 | /** |
17 | - * Local path to this plugins admin directory |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $admin_path; |
|
22 | - |
|
23 | - /** |
|
24 | - * Web path to this plugins admin directory |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
17 | + * Local path to this plugins admin directory |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $admin_path; |
|
22 | + |
|
23 | + /** |
|
24 | + * Web path to this plugins admin directory |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | 28 | public $admin_url; |
29 | 29 | |
30 | 30 | /** |
31 | - * Class constructor. |
|
32 | - */ |
|
33 | - public function __construct(){ |
|
31 | + * Class constructor. |
|
32 | + */ |
|
33 | + public function __construct(){ |
|
34 | 34 | |
35 | 35 | $this->admin_path = plugin_dir_path( __FILE__ ); |
36 | 36 | $this->admin_url = plugins_url( '/', __FILE__ ); |
37 | 37 | |
38 | 38 | if ( is_admin() ) { |
39 | - $this->init_admin_hooks(); |
|
39 | + $this->init_admin_hooks(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | - * Init action and filter hooks |
|
46 | - * |
|
47 | - */ |
|
48 | - private function init_admin_hooks() { |
|
45 | + * Init action and filter hooks |
|
46 | + * |
|
47 | + */ |
|
48 | + private function init_admin_hooks() { |
|
49 | 49 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
50 | 50 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
51 | 51 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
52 | 52 | add_action( 'admin_init', array( $this, 'activation_redirect') ); |
53 | 53 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
54 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
55 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
56 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
57 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
54 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
55 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
56 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
57 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | - * Register admin scripts |
|
63 | - * |
|
64 | - */ |
|
65 | - public function enqeue_scripts() { |
|
62 | + * Register admin scripts |
|
63 | + * |
|
64 | + */ |
|
65 | + public function enqeue_scripts() { |
|
66 | 66 | global $current_screen, $pagenow; |
67 | 67 | |
68 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
69 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
68 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
69 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
70 | 70 | |
71 | 71 | if ( ! empty( $current_screen->post_type ) ) { |
72 | - $page = $current_screen->post_type; |
|
72 | + $page = $current_screen->post_type; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // General styles. |
@@ -93,30 +93,30 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Payment form scripts. |
96 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
96 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
97 | 97 | $this->load_payment_form_scripts(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | if ( $page == 'wpinv-subscriptions' ) { |
101 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
102 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
103 | - } |
|
101 | + wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
102 | + wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
103 | + } |
|
104 | 104 | |
105 | - if ( $page == 'wpinv-reports' ) { |
|
106 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
107 | - } |
|
105 | + if ( $page == 'wpinv-reports' ) { |
|
106 | + wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
107 | + } |
|
108 | 108 | |
109 | - if ( $page == 'wpinv-subscriptions' ) { |
|
110 | - wp_enqueue_script( 'postbox' ); |
|
111 | - } |
|
109 | + if ( $page == 'wpinv-subscriptions' ) { |
|
110 | + wp_enqueue_script( 'postbox' ); |
|
111 | + } |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Returns admin js translations. |
|
117 | - * |
|
118 | - */ |
|
119 | - protected function get_admin_i18() { |
|
116 | + * Returns admin js translations. |
|
117 | + * |
|
118 | + */ |
|
119 | + protected function get_admin_i18() { |
|
120 | 120 | global $post; |
121 | 121 | |
122 | 122 | return array( |
@@ -157,32 +157,32 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | - * Loads payment form js. |
|
161 | - * |
|
162 | - */ |
|
163 | - protected function load_payment_form_scripts() { |
|
160 | + * Loads payment form js. |
|
161 | + * |
|
162 | + */ |
|
163 | + protected function load_payment_form_scripts() { |
|
164 | 164 | global $post; |
165 | 165 | |
166 | 166 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
167 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
168 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
167 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
168 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
169 | 169 | |
170 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
171 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
170 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
171 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
172 | 172 | |
173 | - wp_localize_script( |
|
173 | + wp_localize_script( |
|
174 | 174 | 'wpinv-admin-payment-form-script', |
175 | 175 | 'wpinvPaymentFormAdmin', |
176 | 176 | array( |
177 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
178 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
179 | - 'currency' => wpinv_currency_symbol(), |
|
180 | - 'position' => wpinv_currency_position(), |
|
181 | - 'decimals' => (int) wpinv_decimals(), |
|
182 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
183 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
184 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
185 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
177 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
178 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
179 | + 'currency' => wpinv_currency_symbol(), |
|
180 | + 'position' => wpinv_currency_position(), |
|
181 | + 'decimals' => (int) wpinv_decimals(), |
|
182 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
183 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
184 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
185 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
186 | 186 | ) |
187 | 187 | ); |
188 | 188 | |
@@ -191,20 +191,20 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | - * Add our classes to admin pages. |
|
194 | + * Add our classes to admin pages. |
|
195 | 195 | * |
196 | 196 | * @param string $classes |
197 | 197 | * @return string |
198 | - * |
|
199 | - */ |
|
198 | + * |
|
199 | + */ |
|
200 | 200 | public function admin_body_class( $classes ) { |
201 | - global $pagenow, $post, $current_screen; |
|
201 | + global $pagenow, $post, $current_screen; |
|
202 | 202 | |
203 | 203 | |
204 | 204 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
205 | 205 | |
206 | 206 | if ( ! empty( $current_screen->post_type ) ) { |
207 | - $page = $current_screen->post_type; |
|
207 | + $page = $current_screen->post_type; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -215,27 +215,27 @@ discard block |
||
215 | 215 | $classes .= ' wpinv-cpt wpinv'; |
216 | 216 | } |
217 | 217 | |
218 | - if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) { |
|
219 | - $classes .= ' wpi-editable-n'; |
|
220 | - } |
|
218 | + if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) { |
|
219 | + $classes .= ' wpi-editable-n'; |
|
220 | + } |
|
221 | 221 | |
222 | - return $classes; |
|
222 | + return $classes; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | - * Maybe show the AyeCode Connect Notice. |
|
227 | - */ |
|
228 | - public function init_ayecode_connect_helper(){ |
|
226 | + * Maybe show the AyeCode Connect Notice. |
|
227 | + */ |
|
228 | + public function init_ayecode_connect_helper(){ |
|
229 | 229 | |
230 | 230 | new AyeCode_Connect_Helper( |
231 | 231 | array( |
232 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
233 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
234 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
235 | - 'connect_button' => __("Connect Site","invoicing"), |
|
236 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
237 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
238 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
232 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
233 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
234 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
235 | + 'connect_button' => __("Connect Site","invoicing"), |
|
236 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
237 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
238 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
239 | 239 | ), |
240 | 240 | array( 'wpi-addons' ) |
241 | 241 | ); |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function activation_redirect() { |
249 | 249 | |
250 | - // Bail if no activation redirect. |
|
251 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
252 | - return; |
|
253 | - } |
|
250 | + // Bail if no activation redirect. |
|
251 | + if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
252 | + return; |
|
253 | + } |
|
254 | 254 | |
255 | - // Delete the redirect transient. |
|
256 | - delete_transient( '_wpinv_activation_redirect' ); |
|
255 | + // Delete the redirect transient. |
|
256 | + delete_transient( '_wpinv_activation_redirect' ); |
|
257 | 257 | |
258 | - // Bail if activating from network, or bulk |
|
259 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
260 | - return; |
|
261 | - } |
|
258 | + // Bail if activating from network, or bulk |
|
259 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
260 | + return; |
|
261 | + } |
|
262 | 262 | |
263 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
264 | - exit; |
|
263 | + wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
264 | + exit; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -276,150 +276,150 @@ discard block |
||
276 | 276 | |
277 | 277 | } |
278 | 278 | |
279 | - /** |
|
279 | + /** |
|
280 | 280 | * Sends a payment reminder to a customer. |
281 | - * |
|
282 | - * @param array $args |
|
281 | + * |
|
282 | + * @param array $args |
|
283 | 283 | */ |
284 | 284 | public function send_customer_invoice( $args ) { |
285 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
285 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
286 | 286 | |
287 | - if ( $sent ) { |
|
288 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
289 | - } else { |
|
290 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
291 | - } |
|
287 | + if ( $sent ) { |
|
288 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
289 | + } else { |
|
290 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
291 | + } |
|
292 | 292 | |
293 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
294 | - exit; |
|
295 | - } |
|
293 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
294 | + exit; |
|
295 | + } |
|
296 | 296 | |
297 | - /** |
|
297 | + /** |
|
298 | 298 | * Sends a payment reminder to a customer. |
299 | - * |
|
300 | - * @param array $args |
|
299 | + * |
|
300 | + * @param array $args |
|
301 | 301 | */ |
302 | 302 | public function send_customer_payment_reminder( $args ) { |
303 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
303 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
304 | 304 | |
305 | - if ( $sent ) { |
|
306 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
307 | - } else { |
|
308 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
309 | - } |
|
305 | + if ( $sent ) { |
|
306 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
307 | + } else { |
|
308 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
309 | + } |
|
310 | 310 | |
311 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
312 | - exit; |
|
313 | - } |
|
311 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
312 | + exit; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | /** |
316 | - * Returns an array of admin notices. |
|
317 | - * |
|
318 | - * @since 1.0.19 |
|
316 | + * Returns an array of admin notices. |
|
317 | + * |
|
318 | + * @since 1.0.19 |
|
319 | 319 | * @return array |
320 | - */ |
|
321 | - public function get_notices() { |
|
322 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
320 | + */ |
|
321 | + public function get_notices() { |
|
322 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
323 | 323 | return is_array( $notices ) ? $notices : array(); |
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Clears all admin notices |
|
328 | - * |
|
329 | - * @access public |
|
330 | - * @since 1.0.19 |
|
331 | - */ |
|
332 | - public function clear_notices() { |
|
333 | - delete_option( 'wpinv_admin_notices' ); |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Saves a new admin notice |
|
338 | - * |
|
339 | - * @access public |
|
340 | - * @since 1.0.19 |
|
341 | - */ |
|
342 | - public function save_notice( $type, $message ) { |
|
343 | - $notices = $this->get_notices(); |
|
344 | - |
|
345 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
346 | - $notices[ $type ] = array(); |
|
347 | - } |
|
348 | - |
|
349 | - $notices[ $type ][] = $message; |
|
350 | - |
|
351 | - update_option( 'wpinv_admin_notices', $notices ); |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Displays a success notice |
|
356 | - * |
|
357 | - * @param string $msg The message to qeue. |
|
358 | - * @access public |
|
359 | - * @since 1.0.19 |
|
360 | - */ |
|
361 | - public function show_success( $msg ) { |
|
362 | - $this->save_notice( 'success', $msg ); |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Displays a error notice |
|
367 | - * |
|
368 | - * @access public |
|
369 | - * @param string $msg The message to qeue. |
|
370 | - * @since 1.0.19 |
|
371 | - */ |
|
372 | - public function show_error( $msg ) { |
|
373 | - $this->save_notice( 'error', $msg ); |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Displays a warning notice |
|
378 | - * |
|
379 | - * @access public |
|
380 | - * @param string $msg The message to qeue. |
|
381 | - * @since 1.0.19 |
|
382 | - */ |
|
383 | - public function show_warning( $msg ) { |
|
384 | - $this->save_notice( 'warning', $msg ); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Displays a info notice |
|
389 | - * |
|
390 | - * @access public |
|
391 | - * @param string $msg The message to qeue. |
|
392 | - * @since 1.0.19 |
|
393 | - */ |
|
394 | - public function show_info( $msg ) { |
|
395 | - $this->save_notice( 'info', $msg ); |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * Show notices |
|
400 | - * |
|
401 | - * @access public |
|
402 | - * @since 1.0.19 |
|
403 | - */ |
|
404 | - public function show_notices() { |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Clears all admin notices |
|
328 | + * |
|
329 | + * @access public |
|
330 | + * @since 1.0.19 |
|
331 | + */ |
|
332 | + public function clear_notices() { |
|
333 | + delete_option( 'wpinv_admin_notices' ); |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Saves a new admin notice |
|
338 | + * |
|
339 | + * @access public |
|
340 | + * @since 1.0.19 |
|
341 | + */ |
|
342 | + public function save_notice( $type, $message ) { |
|
343 | + $notices = $this->get_notices(); |
|
344 | + |
|
345 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
346 | + $notices[ $type ] = array(); |
|
347 | + } |
|
348 | + |
|
349 | + $notices[ $type ][] = $message; |
|
350 | + |
|
351 | + update_option( 'wpinv_admin_notices', $notices ); |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Displays a success notice |
|
356 | + * |
|
357 | + * @param string $msg The message to qeue. |
|
358 | + * @access public |
|
359 | + * @since 1.0.19 |
|
360 | + */ |
|
361 | + public function show_success( $msg ) { |
|
362 | + $this->save_notice( 'success', $msg ); |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Displays a error notice |
|
367 | + * |
|
368 | + * @access public |
|
369 | + * @param string $msg The message to qeue. |
|
370 | + * @since 1.0.19 |
|
371 | + */ |
|
372 | + public function show_error( $msg ) { |
|
373 | + $this->save_notice( 'error', $msg ); |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Displays a warning notice |
|
378 | + * |
|
379 | + * @access public |
|
380 | + * @param string $msg The message to qeue. |
|
381 | + * @since 1.0.19 |
|
382 | + */ |
|
383 | + public function show_warning( $msg ) { |
|
384 | + $this->save_notice( 'warning', $msg ); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Displays a info notice |
|
389 | + * |
|
390 | + * @access public |
|
391 | + * @param string $msg The message to qeue. |
|
392 | + * @since 1.0.19 |
|
393 | + */ |
|
394 | + public function show_info( $msg ) { |
|
395 | + $this->save_notice( 'info', $msg ); |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * Show notices |
|
400 | + * |
|
401 | + * @access public |
|
402 | + * @since 1.0.19 |
|
403 | + */ |
|
404 | + public function show_notices() { |
|
405 | 405 | |
406 | 406 | $notices = $this->get_notices(); |
407 | 407 | $this->clear_notices(); |
408 | 408 | |
409 | - foreach ( $notices as $type => $messages ) { |
|
409 | + foreach ( $notices as $type => $messages ) { |
|
410 | 410 | |
411 | - if ( ! is_array( $messages ) ) { |
|
412 | - continue; |
|
413 | - } |
|
411 | + if ( ! is_array( $messages ) ) { |
|
412 | + continue; |
|
413 | + } |
|
414 | 414 | |
415 | 415 | $type = sanitize_key( $type ); |
416 | - foreach ( $messages as $message ) { |
|
416 | + foreach ( $messages as $message ) { |
|
417 | 417 | $message = wp_kses_post( $message ); |
418 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
418 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | } |
422 | 422 | |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | 425 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -175,122 +175,122 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
179 | 179 | |
180 | - // Setup possible parts |
|
181 | - $templates = array(); |
|
182 | - if ( isset( $name ) ) |
|
183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
184 | - $templates[] = $slug . '.php'; |
|
180 | + // Setup possible parts |
|
181 | + $templates = array(); |
|
182 | + if ( isset( $name ) ) |
|
183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
184 | + $templates[] = $slug . '.php'; |
|
185 | 185 | |
186 | - // Allow template parts to be filtered |
|
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
186 | + // Allow template parts to be filtered |
|
187 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | 188 | |
189 | - // Return the part that is found |
|
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
189 | + // Return the part that is found |
|
190 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
194 | - // No file found yet |
|
195 | - $located = false; |
|
194 | + // No file found yet |
|
195 | + $located = false; |
|
196 | 196 | |
197 | - // Try to find a template file |
|
198 | - foreach ( (array)$template_names as $template_name ) { |
|
197 | + // Try to find a template file |
|
198 | + foreach ( (array)$template_names as $template_name ) { |
|
199 | 199 | |
200 | - // Continue if template is empty |
|
201 | - if ( empty( $template_name ) ) |
|
202 | - continue; |
|
200 | + // Continue if template is empty |
|
201 | + if ( empty( $template_name ) ) |
|
202 | + continue; |
|
203 | 203 | |
204 | - // Trim off any slashes from the template name |
|
205 | - $template_name = ltrim( $template_name, '/' ); |
|
204 | + // Trim off any slashes from the template name |
|
205 | + $template_name = ltrim( $template_name, '/' ); |
|
206 | 206 | |
207 | - // try locating this template file by looping through the template paths |
|
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
207 | + // try locating this template file by looping through the template paths |
|
208 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
211 | - $located = $template_path . $template_name; |
|
212 | - break; |
|
213 | - } |
|
214 | - } |
|
210 | + if( file_exists( $template_path . $template_name ) ) { |
|
211 | + $located = $template_path . $template_name; |
|
212 | + break; |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
217 | - break; |
|
218 | - } |
|
219 | - } |
|
216 | + if( !empty( $located ) ) { |
|
217 | + break; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | + load_template( $located, $require_once ); |
|
223 | 223 | |
224 | - return $located; |
|
224 | + return $located; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | function wpinv_get_theme_template_paths() { |
228 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
228 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
229 | 229 | |
230 | - $file_paths = array( |
|
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
233 | - 100 => wpinv_get_templates_dir() |
|
234 | - ); |
|
230 | + $file_paths = array( |
|
231 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
233 | + 100 => wpinv_get_templates_dir() |
|
234 | + ); |
|
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
237 | 237 | |
238 | - // sort the file paths based on priority |
|
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
238 | + // sort the file paths based on priority |
|
239 | + ksort( $file_paths, SORT_NUMERIC ); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map( 'trailingslashit', $file_paths ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | - $pages = array(); |
|
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
246 | + $pages = array(); |
|
247 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | - return; |
|
254 | - } |
|
252 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | + return; |
|
254 | + } |
|
255 | 255 | |
256 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
256 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
257 | 257 | } |
258 | 258 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
259 | 259 | |
260 | 260 | function wpinv_add_body_classes( $class ) { |
261 | - $classes = (array)$class; |
|
261 | + $classes = (array)$class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
264 | - $classes[] = 'wpinv-checkout'; |
|
265 | - $classes[] = 'wpinv-page'; |
|
266 | - } |
|
263 | + if( wpinv_is_checkout() ) { |
|
264 | + $classes[] = 'wpinv-checkout'; |
|
265 | + $classes[] = 'wpinv-page'; |
|
266 | + } |
|
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
269 | - $classes[] = 'wpinv-success'; |
|
270 | - $classes[] = 'wpinv-page'; |
|
271 | - } |
|
268 | + if( wpinv_is_success_page() ) { |
|
269 | + $classes[] = 'wpinv-success'; |
|
270 | + $classes[] = 'wpinv-page'; |
|
271 | + } |
|
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
274 | - $classes[] = 'wpinv-failed-transaction'; |
|
275 | - $classes[] = 'wpinv-page'; |
|
276 | - } |
|
273 | + if( wpinv_is_failed_transaction_page() ) { |
|
274 | + $classes[] = 'wpinv-failed-transaction'; |
|
275 | + $classes[] = 'wpinv-page'; |
|
276 | + } |
|
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
279 | - $classes[] = 'wpinv-history'; |
|
280 | - $classes[] = 'wpinv-page'; |
|
281 | - } |
|
278 | + if( wpinv_is_invoice_history_page() ) { |
|
279 | + $classes[] = 'wpinv-history'; |
|
280 | + $classes[] = 'wpinv-page'; |
|
281 | + } |
|
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
284 | - $classes[] = 'wpinv-subscription'; |
|
285 | - $classes[] = 'wpinv-page'; |
|
286 | - } |
|
283 | + if( wpinv_is_subscriptions_history_page() ) { |
|
284 | + $classes[] = 'wpinv-subscription'; |
|
285 | + $classes[] = 'wpinv-page'; |
|
286 | + } |
|
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
289 | - $classes[] = 'wpinv-test-mode'; |
|
290 | - $classes[] = 'wpinv-page'; |
|
291 | - } |
|
288 | + if( wpinv_is_test_mode() ) { |
|
289 | + $classes[] = 'wpinv-test-mode'; |
|
290 | + $classes[] = 'wpinv-page'; |
|
291 | + } |
|
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique( $classes ); |
|
294 | 294 | } |
295 | 295 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
296 | 296 | |
@@ -992,21 +992,21 @@ discard block |
||
992 | 992 | |
993 | 993 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
994 | 994 | |
995 | - // Remove unavailable tags. |
|
995 | + // Remove unavailable tags. |
|
996 | 996 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
997 | 997 | |
998 | 998 | // Clean up white space. |
999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
999 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1000 | 1000 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
1001 | 1001 | |
1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1003 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1004 | 1004 | |
1005 | 1005 | // Add html breaks. |
1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1006 | + $formatted_address = implode( $separator, $formatted_address ); |
|
1007 | 1007 | |
1008 | - // We're done! |
|
1009 | - return $formatted_address; |
|
1008 | + // We're done! |
|
1009 | + return $formatted_address; |
|
1010 | 1010 | |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_empty_cart_message() { |
1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1211 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1498,10 +1498,10 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | if ( 0 == count( $form->get_items() ) ) { |
1500 | 1500 | echo aui()->alert( |
1501 | - array( |
|
1502 | - 'type' => 'warning', |
|
1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1504 | - ) |
|
1501 | + array( |
|
1502 | + 'type' => 'warning', |
|
1503 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1504 | + ) |
|
1505 | 1505 | ); |
1506 | 1506 | return; |
1507 | 1507 | } |
@@ -1517,21 +1517,21 @@ discard block |
||
1517 | 1517 | $invoice = wpinv_get_invoice( $invoice_id ); |
1518 | 1518 | |
1519 | 1519 | if ( empty( $invoice ) ) { |
1520 | - echo aui()->alert( |
|
1521 | - array( |
|
1522 | - 'type' => 'warning', |
|
1523 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | - ) |
|
1520 | + echo aui()->alert( |
|
1521 | + array( |
|
1522 | + 'type' => 'warning', |
|
1523 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | + ) |
|
1525 | 1525 | ); |
1526 | 1526 | return; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | if ( $invoice->is_paid() ) { |
1530 | - echo aui()->alert( |
|
1531 | - array( |
|
1532 | - 'type' => 'warning', |
|
1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1534 | - ) |
|
1530 | + echo aui()->alert( |
|
1531 | + array( |
|
1532 | + 'type' => 'warning', |
|
1533 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1534 | + ) |
|
1535 | 1535 | ); |
1536 | 1536 | return; |
1537 | 1537 | } |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - if ( ! empty( $items ) ) { |
|
1597 | + if ( ! empty( $items ) ) { |
|
1598 | 1598 | $items = esc_attr( $items ); |
1599 | 1599 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
1600 | 1600 | } |
@@ -14,70 +14,70 @@ discard block |
||
14 | 14 | class WPInv_Ajax { |
15 | 15 | |
16 | 16 | /** |
17 | - * Hook in ajax handlers. |
|
18 | - */ |
|
19 | - public static function init() { |
|
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | - self::add_ajax_events(); |
|
17 | + * Hook in ajax handlers. |
|
18 | + */ |
|
19 | + public static function init() { |
|
20 | + add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | + add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | + self::add_ajax_events(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Set GetPaid AJAX constant and headers. |
|
27 | - */ |
|
28 | - public static function define_ajax() { |
|
29 | - |
|
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | - } |
|
36 | - $GLOBALS['wpdb']->hide_errors(); |
|
37 | - } |
|
26 | + * Set GetPaid AJAX constant and headers. |
|
27 | + */ |
|
28 | + public static function define_ajax() { |
|
29 | + |
|
30 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | + getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | + getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | + if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | + } |
|
36 | + $GLOBALS['wpdb']->hide_errors(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Send headers for GetPaid Ajax Requests. |
|
43 | - * |
|
44 | - * @since 1.0.18 |
|
45 | - */ |
|
46 | - private static function wpinv_ajax_headers() { |
|
47 | - if ( ! headers_sent() ) { |
|
48 | - send_origin_headers(); |
|
49 | - send_nosniff_header(); |
|
50 | - nocache_headers(); |
|
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
54 | - } |
|
42 | + * Send headers for GetPaid Ajax Requests. |
|
43 | + * |
|
44 | + * @since 1.0.18 |
|
45 | + */ |
|
46 | + private static function wpinv_ajax_headers() { |
|
47 | + if ( ! headers_sent() ) { |
|
48 | + send_origin_headers(); |
|
49 | + send_nosniff_header(); |
|
50 | + nocache_headers(); |
|
51 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | + header( 'X-Robots-Tag: noindex' ); |
|
53 | + status_header( 200 ); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Check for GetPaid Ajax request and fire action. |
|
59 | - */ |
|
60 | - public static function do_wpinv_ajax() { |
|
61 | - global $wp_query; |
|
58 | + * Check for GetPaid Ajax request and fire action. |
|
59 | + */ |
|
60 | + public static function do_wpinv_ajax() { |
|
61 | + global $wp_query; |
|
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | - } |
|
63 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | + $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get( 'wpinv-ajax' ); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
70 | - self::wpinv_ajax_headers(); |
|
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
73 | - wp_die(); |
|
74 | - } |
|
69 | + if ( $action ) { |
|
70 | + self::wpinv_ajax_headers(); |
|
71 | + $action = sanitize_text_field( $action ); |
|
72 | + do_action( 'wpinv_ajax_' . $action ); |
|
73 | + wp_die(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Hook in ajax methods. |
|
80 | - */ |
|
79 | + * Hook in ajax methods. |
|
80 | + */ |
|
81 | 81 | public static function add_ajax_events() { |
82 | 82 | |
83 | 83 | // array( 'event' => is_frontend ) |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | // Is the request set up correctly? |
263 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
264 | - echo aui()->alert( |
|
265 | - array( |
|
266 | - 'type' => 'warning', |
|
267 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
268 | - ) |
|
263 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
264 | + echo aui()->alert( |
|
265 | + array( |
|
266 | + 'type' => 'warning', |
|
267 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
268 | + ) |
|
269 | 269 | ); |
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Payment form or button? |
274 | - if ( ! empty( $_GET['form'] ) ) { |
|
274 | + if ( ! empty( $_GET['form'] ) ) { |
|
275 | 275 | getpaid_display_payment_form( $_GET['form'] ); |
276 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
277 | - getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
276 | + } else if( ! empty( $_GET['invoice'] ) ) { |
|
277 | + getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
278 | 278 | } else { |
279 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
280 | - getpaid_display_item_payment_form( $items ); |
|
279 | + $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
280 | + getpaid_display_item_payment_form( $items ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | exit; |
@@ -13,128 +13,128 @@ |
||
13 | 13 | class GetPaid_Payment_Forms { |
14 | 14 | |
15 | 15 | /** |
16 | - * Class constructor |
|
17 | - * |
|
18 | - */ |
|
19 | - public function __construct() { |
|
20 | - |
|
21 | - // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
22 | - add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
23 | - add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
24 | - |
|
25 | - // Sync form amount whenever invoice statuses change. |
|
26 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
27 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
28 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
29 | - |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Increments a form's revenue whenever there is a payment. |
|
34 | - * |
|
35 | - * @param WPInv_Invoice $invoice |
|
36 | - */ |
|
37 | - public function increment_form_revenue( $invoice ) { |
|
38 | - |
|
39 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
40 | - if ( $form->get_id() ) { |
|
41 | - $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
42 | - $form->save(); |
|
43 | - } |
|
44 | - |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Decreases form revenue whenever invoice payment changes. |
|
49 | - * |
|
50 | - * @param WPInv_Invoice $invoice |
|
51 | - */ |
|
52 | - public function decrease_form_revenue( $invoice ) { |
|
53 | - |
|
54 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
55 | - if ( $form->get_id() ) { |
|
56 | - $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
57 | - $form->save(); |
|
58 | - } |
|
59 | - |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Updates a form's failed amount. |
|
64 | - * |
|
65 | - * @param WPInv_Invoice $invoice |
|
66 | - * @param string $from |
|
67 | - * @param string $to |
|
68 | - */ |
|
69 | - public function update_form_failed_amount( $invoice, $from, $to ) { |
|
70 | - |
|
71 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
72 | - if ( $form->get_id() ) { |
|
73 | - return; |
|
74 | - } |
|
75 | - |
|
76 | - if ( 'wpi-failed' == $from ) { |
|
77 | - $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
78 | - $form->save(); |
|
79 | - } |
|
80 | - |
|
81 | - if ( 'wpi-failed' == $to ) { |
|
82 | - $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
83 | - $form->save(); |
|
84 | - } |
|
85 | - |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Updates a form's refunded amount. |
|
90 | - * |
|
91 | - * @param WPInv_Invoice $invoice |
|
92 | - * @param string $from |
|
93 | - * @param string $to |
|
94 | - */ |
|
95 | - public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
96 | - |
|
97 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
98 | - if ( $form->get_id() ) { |
|
99 | - return; |
|
100 | - } |
|
101 | - |
|
102 | - if ( 'wpi-refunded' == $from ) { |
|
103 | - $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
104 | - $form->save(); |
|
105 | - } |
|
106 | - |
|
107 | - if ( 'wpi-refunded' == $to ) { |
|
108 | - $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
109 | - $form->save(); |
|
110 | - } |
|
111 | - |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Updates a form's cancelled amount. |
|
116 | - * |
|
117 | - * @param WPInv_Invoice $invoice |
|
118 | - * @param string $from |
|
119 | - * @param string $to |
|
120 | - */ |
|
121 | - public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
122 | - |
|
123 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
124 | - if ( $form->get_id() ) { |
|
125 | - return; |
|
126 | - } |
|
127 | - |
|
128 | - if ( 'wpi-cancelled' == $from ) { |
|
129 | - $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
130 | - $form->save(); |
|
131 | - } |
|
132 | - |
|
133 | - if ( 'wpi-cancelled' == $to ) { |
|
134 | - $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
135 | - $form->save(); |
|
136 | - } |
|
137 | - |
|
138 | - } |
|
16 | + * Class constructor |
|
17 | + * |
|
18 | + */ |
|
19 | + public function __construct() { |
|
20 | + |
|
21 | + // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
22 | + add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
23 | + add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
24 | + |
|
25 | + // Sync form amount whenever invoice statuses change. |
|
26 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
27 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
28 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
29 | + |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Increments a form's revenue whenever there is a payment. |
|
34 | + * |
|
35 | + * @param WPInv_Invoice $invoice |
|
36 | + */ |
|
37 | + public function increment_form_revenue( $invoice ) { |
|
38 | + |
|
39 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
40 | + if ( $form->get_id() ) { |
|
41 | + $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
42 | + $form->save(); |
|
43 | + } |
|
44 | + |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Decreases form revenue whenever invoice payment changes. |
|
49 | + * |
|
50 | + * @param WPInv_Invoice $invoice |
|
51 | + */ |
|
52 | + public function decrease_form_revenue( $invoice ) { |
|
53 | + |
|
54 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
55 | + if ( $form->get_id() ) { |
|
56 | + $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
57 | + $form->save(); |
|
58 | + } |
|
59 | + |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Updates a form's failed amount. |
|
64 | + * |
|
65 | + * @param WPInv_Invoice $invoice |
|
66 | + * @param string $from |
|
67 | + * @param string $to |
|
68 | + */ |
|
69 | + public function update_form_failed_amount( $invoice, $from, $to ) { |
|
70 | + |
|
71 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
72 | + if ( $form->get_id() ) { |
|
73 | + return; |
|
74 | + } |
|
75 | + |
|
76 | + if ( 'wpi-failed' == $from ) { |
|
77 | + $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
78 | + $form->save(); |
|
79 | + } |
|
80 | + |
|
81 | + if ( 'wpi-failed' == $to ) { |
|
82 | + $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
83 | + $form->save(); |
|
84 | + } |
|
85 | + |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Updates a form's refunded amount. |
|
90 | + * |
|
91 | + * @param WPInv_Invoice $invoice |
|
92 | + * @param string $from |
|
93 | + * @param string $to |
|
94 | + */ |
|
95 | + public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
96 | + |
|
97 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
98 | + if ( $form->get_id() ) { |
|
99 | + return; |
|
100 | + } |
|
101 | + |
|
102 | + if ( 'wpi-refunded' == $from ) { |
|
103 | + $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
104 | + $form->save(); |
|
105 | + } |
|
106 | + |
|
107 | + if ( 'wpi-refunded' == $to ) { |
|
108 | + $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
109 | + $form->save(); |
|
110 | + } |
|
111 | + |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Updates a form's cancelled amount. |
|
116 | + * |
|
117 | + * @param WPInv_Invoice $invoice |
|
118 | + * @param string $from |
|
119 | + * @param string $to |
|
120 | + */ |
|
121 | + public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
122 | + |
|
123 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
124 | + if ( $form->get_id() ) { |
|
125 | + return; |
|
126 | + } |
|
127 | + |
|
128 | + if ( 'wpi-cancelled' == $from ) { |
|
129 | + $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
130 | + $form->save(); |
|
131 | + } |
|
132 | + |
|
133 | + if ( 'wpi-cancelled' == $to ) { |
|
134 | + $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
135 | + $form->save(); |
|
136 | + } |
|
137 | + |
|
138 | + } |
|
139 | 139 | |
140 | 140 | } |