@@ -6,4 +6,4 @@ |
||
6 | 6 | * @since 2.8.32 |
7 | 7 | */ |
8 | 8 | |
9 | -__( 'My String', 'invoicing' ); |
|
9 | +__('My String', 'invoicing'); |
@@ -14,95 +14,95 @@ 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 | - */ |
|
28 | - public $admin_url; |
|
29 | - |
|
30 | - /** |
|
31 | - * Reports components. |
|
32 | - * |
|
33 | - * @var GetPaid_Reports |
|
34 | - */ |
|
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 | + public $admin_url; |
|
29 | + |
|
30 | + /** |
|
31 | + * Reports components. |
|
32 | + * |
|
33 | + * @var GetPaid_Reports |
|
34 | + */ |
|
35 | 35 | public $reports; |
36 | 36 | |
37 | 37 | /** |
38 | - * Class constructor. |
|
39 | - */ |
|
40 | - public function __construct() { |
|
38 | + * Class constructor. |
|
39 | + */ |
|
40 | + public function __construct() { |
|
41 | 41 | |
42 | 42 | $this->admin_path = plugin_dir_path( __FILE__ ); |
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
44 | - $this->reports = new GetPaid_Reports(); |
|
43 | + $this->admin_url = plugins_url( '/', __FILE__ ); |
|
44 | + $this->reports = new GetPaid_Reports(); |
|
45 | 45 | |
46 | 46 | if ( is_admin() ) { |
47 | - $this->init_admin_hooks(); |
|
47 | + $this->init_admin_hooks(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | - * Init action and filter hooks |
|
54 | - * |
|
55 | - */ |
|
56 | - private function init_admin_hooks() { |
|
53 | + * Init action and filter hooks |
|
54 | + * |
|
55 | + */ |
|
56 | + private function init_admin_hooks() { |
|
57 | 57 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
58 | 58 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
59 | 59 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
60 | 60 | add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
61 | 61 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | + add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | + add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | + add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | + add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | + add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
70 | 70 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
71 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | - add_action( 'getpaid_authenticated_admin_action_translate_db_texts', array( $this, 'tool_translate_db_texts' ) ); |
|
78 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
79 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
80 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
81 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
82 | - |
|
83 | - // Setup/welcome |
|
84 | - if ( ! empty( $_GET['page'] ) ) { |
|
85 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
86 | - case 'gp-setup': |
|
87 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
88 | - break; |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Register admin scripts |
|
96 | - * |
|
97 | - */ |
|
98 | - public function enqeue_scripts() { |
|
71 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | + add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | + add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | + add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | + add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | + add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | + add_action( 'getpaid_authenticated_admin_action_translate_db_texts', array( $this, 'tool_translate_db_texts' ) ); |
|
78 | + add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
79 | + add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
80 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
81 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
82 | + |
|
83 | + // Setup/welcome |
|
84 | + if ( ! empty( $_GET['page'] ) ) { |
|
85 | + switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
86 | + case 'gp-setup': |
|
87 | + include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
88 | + break; |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Register admin scripts |
|
96 | + * |
|
97 | + */ |
|
98 | + public function enqeue_scripts() { |
|
99 | 99 | global $current_screen, $pagenow; |
100 | 100 | |
101 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
102 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
101 | + $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
102 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
103 | 103 | |
104 | 104 | if ( ! empty( $current_screen->post_type ) ) { |
105 | - $page = $current_screen->post_type; |
|
105 | + $page = $current_screen->post_type; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // General styles. |
@@ -123,53 +123,53 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | // Payment form scripts. |
126 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
126 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
127 | 127 | $this->load_payment_form_scripts(); |
128 | 128 | } |
129 | 129 | |
130 | - if ( $page == 'wpinv-subscriptions' ) { |
|
131 | - wp_enqueue_script( 'postbox' ); |
|
132 | - } |
|
130 | + if ( $page == 'wpinv-subscriptions' ) { |
|
131 | + wp_enqueue_script( 'postbox' ); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Returns admin js translations. |
|
138 | - * |
|
139 | - */ |
|
140 | - protected function get_admin_i18() { |
|
137 | + * Returns admin js translations. |
|
138 | + * |
|
139 | + */ |
|
140 | + protected function get_admin_i18() { |
|
141 | 141 | global $post; |
142 | 142 | |
143 | - $date_range = array( |
|
144 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
145 | - ); |
|
143 | + $date_range = array( |
|
144 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
145 | + ); |
|
146 | 146 | |
147 | - if ( $date_range['period'] == 'custom' ) { |
|
147 | + if ( $date_range['period'] == 'custom' ) { |
|
148 | 148 | |
149 | - if ( isset( $_GET['from'] ) ) { |
|
150 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
151 | - } |
|
149 | + if ( isset( $_GET['from'] ) ) { |
|
150 | + $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
151 | + } |
|
152 | 152 | |
153 | - if ( isset( $_GET['to'] ) ) { |
|
154 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
155 | - } |
|
153 | + if ( isset( $_GET['to'] ) ) { |
|
154 | + $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $i18n = array( |
159 | 159 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
160 | 160 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
161 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
162 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
163 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
164 | - 'date_range' => $date_range, |
|
161 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
162 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
163 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
164 | + 'date_range' => $date_range, |
|
165 | 165 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
166 | 166 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
167 | 167 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
168 | 168 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
169 | 169 | 'tax' => wpinv_tax_amount(), |
170 | 170 | 'discount' => 0, |
171 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
172 | - 'currency' => wpinv_get_currency(), |
|
171 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
172 | + 'currency' => wpinv_get_currency(), |
|
173 | 173 | 'currency_pos' => wpinv_currency_position(), |
174 | 174 | 'thousand_sep' => wpinv_thousands_separator(), |
175 | 175 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -189,117 +189,117 @@ discard block |
||
189 | 189 | 'item_description' => __( 'Item Description', 'invoicing' ), |
190 | 190 | 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
191 | 191 | 'discount_description' => __( 'Discount Description', 'invoicing' ), |
192 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
193 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
194 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
195 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
196 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
192 | + 'searching' => __( 'Searching', 'invoicing' ), |
|
193 | + 'loading' => __( 'Loading...', 'invoicing' ), |
|
194 | + 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
195 | + 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
196 | + 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
197 | 197 | ); |
198 | 198 | |
199 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
199 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
200 | 200 | |
201 | - $invoice = new WPInv_Invoice( $post ); |
|
202 | - $i18n['save_invoice'] = sprintf( |
|
203 | - __( 'Save %s', 'invoicing' ), |
|
204 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
205 | - ); |
|
201 | + $invoice = new WPInv_Invoice( $post ); |
|
202 | + $i18n['save_invoice'] = sprintf( |
|
203 | + __( 'Save %s', 'invoicing' ), |
|
204 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
205 | + ); |
|
206 | 206 | |
207 | - $i18n['invoice_description'] = sprintf( |
|
208 | - __( '%s Description', 'invoicing' ), |
|
209 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
210 | - ); |
|
207 | + $i18n['invoice_description'] = sprintf( |
|
208 | + __( '%s Description', 'invoicing' ), |
|
209 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
210 | + ); |
|
211 | 211 | |
212 | - } |
|
213 | - return $i18n; |
|
214 | - } |
|
212 | + } |
|
213 | + return $i18n; |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Change the admin footer text on GetPaid admin pages. |
|
218 | - * |
|
219 | - * @since 2.0.0 |
|
220 | - * @param string $footer_text |
|
221 | - * @return string |
|
222 | - */ |
|
223 | - public function admin_footer_text( $footer_text ) { |
|
224 | - global $current_screen; |
|
216 | + /** |
|
217 | + * Change the admin footer text on GetPaid admin pages. |
|
218 | + * |
|
219 | + * @since 2.0.0 |
|
220 | + * @param string $footer_text |
|
221 | + * @return string |
|
222 | + */ |
|
223 | + public function admin_footer_text( $footer_text ) { |
|
224 | + global $current_screen; |
|
225 | 225 | |
226 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
226 | + $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
227 | 227 | |
228 | 228 | if ( ! empty( $current_screen->post_type ) ) { |
229 | - $page = $current_screen->post_type; |
|
229 | + $page = $current_screen->post_type; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | // General styles. |
233 | 233 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
234 | 234 | |
235 | - // Change the footer text |
|
236 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
235 | + // Change the footer text |
|
236 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
237 | 237 | |
238 | - $rating_url = esc_url( |
|
239 | - wp_nonce_url( |
|
240 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
241 | - 'getpaid-nonce', |
|
242 | - 'getpaid-nonce' |
|
238 | + $rating_url = esc_url( |
|
239 | + wp_nonce_url( |
|
240 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
241 | + 'getpaid-nonce', |
|
242 | + 'getpaid-nonce' |
|
243 | 243 | ) |
244 | - ); |
|
244 | + ); |
|
245 | 245 | |
246 | - $footer_text = sprintf( |
|
247 | - /* translators: %s: five stars */ |
|
248 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
249 | - "<a href='$rating_url'>★★★★★</a>" |
|
250 | - ); |
|
246 | + $footer_text = sprintf( |
|
247 | + /* translators: %s: five stars */ |
|
248 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
249 | + "<a href='$rating_url'>★★★★★</a>" |
|
250 | + ); |
|
251 | 251 | |
252 | - } else { |
|
252 | + } else { |
|
253 | 253 | |
254 | - $footer_text = sprintf( |
|
255 | - /* translators: %s: GetPaid */ |
|
256 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
257 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
258 | - ); |
|
254 | + $footer_text = sprintf( |
|
255 | + /* translators: %s: GetPaid */ |
|
256 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
257 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
258 | + ); |
|
259 | 259 | |
260 | - } |
|
260 | + } |
|
261 | 261 | } |
262 | 262 | |
263 | - return $footer_text; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Redirects to wp.org to rate the plugin. |
|
268 | - * |
|
269 | - * @since 2.0.0 |
|
270 | - */ |
|
271 | - public function redirect_to_wordpress_rating_page() { |
|
272 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
273 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
274 | - exit; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Loads payment form js. |
|
279 | - * |
|
280 | - */ |
|
281 | - protected function load_payment_form_scripts() { |
|
263 | + return $footer_text; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Redirects to wp.org to rate the plugin. |
|
268 | + * |
|
269 | + * @since 2.0.0 |
|
270 | + */ |
|
271 | + public function redirect_to_wordpress_rating_page() { |
|
272 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
273 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
274 | + exit; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Loads payment form js. |
|
279 | + * |
|
280 | + */ |
|
281 | + protected function load_payment_form_scripts() { |
|
282 | 282 | global $post; |
283 | 283 | |
284 | 284 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
285 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
286 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
285 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
286 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
287 | 287 | |
288 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION ); |
|
288 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION ); |
|
289 | 289 | |
290 | - wp_localize_script( |
|
290 | + wp_localize_script( |
|
291 | 291 | 'wpinv-admin-payment-form-script', |
292 | 292 | 'wpinvPaymentFormAdmin', |
293 | 293 | array( |
294 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
296 | - 'currency' => wpinv_currency_symbol(), |
|
297 | - 'position' => wpinv_currency_position(), |
|
298 | - 'decimals' => (int) wpinv_decimals(), |
|
299 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
300 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
301 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
302 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
294 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
296 | + 'currency' => wpinv_currency_symbol(), |
|
297 | + 'position' => wpinv_currency_position(), |
|
298 | + 'decimals' => (int) wpinv_decimals(), |
|
299 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
300 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
301 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
302 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * Add our classes to admin pages. |
|
311 | + * Add our classes to admin pages. |
|
312 | 312 | * |
313 | 313 | * @param string $classes |
314 | 314 | * @return string |
315 | - * |
|
316 | - */ |
|
315 | + * |
|
316 | + */ |
|
317 | 317 | public function admin_body_class( $classes ) { |
318 | - global $pagenow, $post, $current_screen; |
|
318 | + global $pagenow, $post, $current_screen; |
|
319 | 319 | |
320 | 320 | $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
321 | 321 | |
322 | 322 | if ( ! empty( $current_screen->post_type ) ) { |
323 | - $page = $current_screen->post_type; |
|
323 | + $page = $current_screen->post_type; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -329,70 +329,70 @@ discard block |
||
329 | 329 | |
330 | 330 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
331 | 331 | $classes .= ' wpinv-cpt wpinv'; |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
334 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
335 | 335 | $classes .= ' getpaid-is-invoice-cpt'; |
336 | 336 | } |
337 | 337 | |
338 | - return $classes; |
|
338 | + return $classes; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Maybe show the AyeCode Connect Notice. |
|
343 | - */ |
|
344 | - public function init_ayecode_connect_helper() { |
|
342 | + * Maybe show the AyeCode Connect Notice. |
|
343 | + */ |
|
344 | + public function init_ayecode_connect_helper() { |
|
345 | 345 | |
346 | - // Register with the deactivation survey class. |
|
347 | - AyeCode_Deactivation_Survey::instance( |
|
346 | + // Register with the deactivation survey class. |
|
347 | + AyeCode_Deactivation_Survey::instance( |
|
348 | 348 | array( |
349 | - 'slug' => 'invoicing', |
|
350 | - 'version' => WPINV_VERSION, |
|
351 | - 'support_url' => 'https://wpgetpaid.com/support/', |
|
352 | - 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
353 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
349 | + 'slug' => 'invoicing', |
|
350 | + 'version' => WPINV_VERSION, |
|
351 | + 'support_url' => 'https://wpgetpaid.com/support/', |
|
352 | + 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
353 | + 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | 357 | new AyeCode_Connect_Helper( |
358 | 358 | array( |
359 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
359 | + 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | + 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | + 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | + 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | + 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | + 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | + 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
366 | 366 | ), |
367 | 367 | array( 'wpi-addons' ) |
368 | 368 | ); |
369 | 369 | |
370 | 370 | } |
371 | 371 | |
372 | - /** |
|
373 | - * Redirect users to settings on activation. |
|
374 | - * |
|
375 | - * @return void |
|
376 | - */ |
|
377 | - public function activation_redirect() { |
|
372 | + /** |
|
373 | + * Redirect users to settings on activation. |
|
374 | + * |
|
375 | + * @return void |
|
376 | + */ |
|
377 | + public function activation_redirect() { |
|
378 | 378 | |
379 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
379 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
380 | 380 | |
381 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
382 | - return; |
|
383 | - } |
|
381 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
382 | + return; |
|
383 | + } |
|
384 | 384 | |
385 | - // Bail if activating from network, or bulk |
|
386 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
387 | - return; |
|
388 | - } |
|
385 | + // Bail if activating from network, or bulk |
|
386 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
387 | + return; |
|
388 | + } |
|
389 | 389 | |
390 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
390 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
391 | 391 | |
392 | 392 | wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
393 | 393 | exit; |
394 | 394 | |
395 | - } |
|
395 | + } |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Fires an admin action after verifying that a user can fire them. |
@@ -405,581 +405,581 @@ discard block |
||
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | - /** |
|
408 | + /** |
|
409 | 409 | * Duplicate invoice. |
410 | - * |
|
411 | - * @param array $args |
|
410 | + * |
|
411 | + * @param array $args |
|
412 | 412 | */ |
413 | 413 | public function duplicate_invoice( $args ) { |
414 | 414 | |
415 | - if ( empty( $args['invoice_id'] ) ) { |
|
416 | - return; |
|
417 | - } |
|
415 | + if ( empty( $args['invoice_id'] ) ) { |
|
416 | + return; |
|
417 | + } |
|
418 | 418 | |
419 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
419 | + $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
420 | 420 | |
421 | - if ( ! $invoice->exists() ) { |
|
422 | - return; |
|
423 | - } |
|
421 | + if ( ! $invoice->exists() ) { |
|
422 | + return; |
|
423 | + } |
|
424 | 424 | |
425 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
426 | - $new_invoice->save(); |
|
425 | + $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
426 | + $new_invoice->save(); |
|
427 | 427 | |
428 | - if ( $new_invoice->exists() ) { |
|
428 | + if ( $new_invoice->exists() ) { |
|
429 | 429 | |
430 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
430 | + getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
431 | 431 | |
432 | - wp_safe_redirect( |
|
433 | - add_query_arg( |
|
434 | - array( |
|
435 | - 'action' => 'edit', |
|
436 | - 'post' => $new_invoice->get_id(), |
|
437 | - ), |
|
438 | - admin_url( 'post.php' ) |
|
439 | - ) |
|
440 | - ); |
|
441 | - exit; |
|
432 | + wp_safe_redirect( |
|
433 | + add_query_arg( |
|
434 | + array( |
|
435 | + 'action' => 'edit', |
|
436 | + 'post' => $new_invoice->get_id(), |
|
437 | + ), |
|
438 | + admin_url( 'post.php' ) |
|
439 | + ) |
|
440 | + ); |
|
441 | + exit; |
|
442 | 442 | |
443 | - } |
|
443 | + } |
|
444 | 444 | |
445 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
445 | + getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
446 | 446 | |
447 | - } |
|
447 | + } |
|
448 | 448 | |
449 | - /** |
|
449 | + /** |
|
450 | 450 | * Refund an invoice. |
451 | - * |
|
452 | - * @param array $args |
|
451 | + * |
|
452 | + * @param array $args |
|
453 | 453 | */ |
454 | 454 | public function refund_invoice( $args ) { |
455 | 455 | |
456 | - if ( empty( $args['invoice_id'] ) ) { |
|
457 | - return; |
|
458 | - } |
|
459 | - |
|
460 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
461 | - |
|
462 | - if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
463 | - return; |
|
464 | - } |
|
465 | - |
|
466 | - $invoice->refund(); |
|
467 | - |
|
468 | - // Refund remotely. |
|
469 | - if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | - do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
471 | - } |
|
472 | - |
|
473 | - // Cancel subscriptions. |
|
474 | - if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
476 | - |
|
477 | - if ( ! empty( $subscriptions ) ) { |
|
478 | - if ( ! is_array( $subscriptions ) ) { |
|
479 | - $subscriptions = array( $subscriptions ); |
|
480 | - } |
|
481 | - |
|
482 | - foreach ( $subscriptions as $subscription ) { |
|
483 | - $subscription->cancel(); |
|
484 | - $invoice->add_system_note( |
|
485 | - sprintf( |
|
486 | - // translators: %s: subscription ID. |
|
487 | - __( 'Subscription #%s cancelled', 'invoicing' ), |
|
488 | - $subscription->get_id() |
|
489 | - ) |
|
490 | - ); |
|
491 | - } |
|
492 | - } |
|
493 | - } |
|
494 | - |
|
495 | - // Add notice. |
|
496 | - $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
497 | - |
|
498 | - // Redirect. |
|
499 | - wp_safe_redirect( |
|
500 | - remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
501 | - ); |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
456 | + if ( empty( $args['invoice_id'] ) ) { |
|
457 | + return; |
|
458 | + } |
|
459 | + |
|
460 | + $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
461 | + |
|
462 | + if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
463 | + return; |
|
464 | + } |
|
465 | + |
|
466 | + $invoice->refund(); |
|
467 | + |
|
468 | + // Refund remotely. |
|
469 | + if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | + do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
471 | + } |
|
472 | + |
|
473 | + // Cancel subscriptions. |
|
474 | + if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
476 | + |
|
477 | + if ( ! empty( $subscriptions ) ) { |
|
478 | + if ( ! is_array( $subscriptions ) ) { |
|
479 | + $subscriptions = array( $subscriptions ); |
|
480 | + } |
|
481 | + |
|
482 | + foreach ( $subscriptions as $subscription ) { |
|
483 | + $subscription->cancel(); |
|
484 | + $invoice->add_system_note( |
|
485 | + sprintf( |
|
486 | + // translators: %s: subscription ID. |
|
487 | + __( 'Subscription #%s cancelled', 'invoicing' ), |
|
488 | + $subscription->get_id() |
|
489 | + ) |
|
490 | + ); |
|
491 | + } |
|
492 | + } |
|
493 | + } |
|
494 | + |
|
495 | + // Add notice. |
|
496 | + $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
497 | + |
|
498 | + // Redirect. |
|
499 | + wp_safe_redirect( |
|
500 | + remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
501 | + ); |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | 505 | * Sends a payment reminder to a customer. |
506 | - * |
|
507 | - * @param array $args |
|
506 | + * |
|
507 | + * @param array $args |
|
508 | 508 | */ |
509 | 509 | public function duplicate_payment_form( $args ) { |
510 | 510 | |
511 | - if ( empty( $args['form_id'] ) ) { |
|
512 | - return; |
|
513 | - } |
|
514 | - |
|
515 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
511 | + if ( empty( $args['form_id'] ) ) { |
|
512 | + return; |
|
513 | + } |
|
516 | 514 | |
517 | - if ( ! $form->exists() ) { |
|
518 | - return; |
|
519 | - } |
|
515 | + $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
520 | 516 | |
521 | - $new_form = new GetPaid_Payment_Form(); |
|
522 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
526 | - $new_form->save(); |
|
517 | + if ( ! $form->exists() ) { |
|
518 | + return; |
|
519 | + } |
|
527 | 520 | |
528 | - if ( $new_form->exists() ) { |
|
529 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
531 | - } else { |
|
532 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
534 | - } |
|
521 | + $new_form = new GetPaid_Payment_Form(); |
|
522 | + $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | + $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | + $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | + $new_form->set_items( $form->get_items( 'edit' ) ); |
|
526 | + $new_form->save(); |
|
527 | + |
|
528 | + if ( $new_form->exists() ) { |
|
529 | + $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | + $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
531 | + } else { |
|
532 | + $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | + $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
534 | + } |
|
535 | 535 | |
536 | - wp_redirect( $url ); |
|
537 | - exit; |
|
538 | - } |
|
536 | + wp_redirect( $url ); |
|
537 | + exit; |
|
538 | + } |
|
539 | 539 | |
540 | - /** |
|
540 | + /** |
|
541 | 541 | * Resets form stats. |
542 | - * |
|
543 | - * @param array $args |
|
542 | + * |
|
543 | + * @param array $args |
|
544 | 544 | */ |
545 | 545 | public function reset_form_stats( $args ) { |
546 | 546 | |
547 | - if ( empty( $args['form_id'] ) ) { |
|
548 | - return; |
|
549 | - } |
|
547 | + if ( empty( $args['form_id'] ) ) { |
|
548 | + return; |
|
549 | + } |
|
550 | 550 | |
551 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
551 | + $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
552 | 552 | |
553 | - if ( ! $form->exists() ) { |
|
554 | - return; |
|
555 | - } |
|
553 | + if ( ! $form->exists() ) { |
|
554 | + return; |
|
555 | + } |
|
556 | 556 | |
557 | - $form->set_earned( 0 ); |
|
558 | - $form->set_refunded( 0 ); |
|
559 | - $form->set_cancelled( 0 ); |
|
560 | - $form->set_failed( 0 ); |
|
561 | - $form->save(); |
|
557 | + $form->set_earned( 0 ); |
|
558 | + $form->set_refunded( 0 ); |
|
559 | + $form->set_cancelled( 0 ); |
|
560 | + $form->set_failed( 0 ); |
|
561 | + $form->save(); |
|
562 | 562 | |
563 | - $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
563 | + $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
564 | 564 | |
565 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
566 | - exit; |
|
567 | - } |
|
565 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
566 | + exit; |
|
567 | + } |
|
568 | 568 | |
569 | - /** |
|
569 | + /** |
|
570 | 570 | * Sends a payment reminder to a customer. |
571 | - * |
|
572 | - * @param array $args |
|
571 | + * |
|
572 | + * @param array $args |
|
573 | 573 | */ |
574 | 574 | public function send_customer_invoice( $args ) { |
575 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
577 | - exit; |
|
578 | - } |
|
575 | + getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
577 | + exit; |
|
578 | + } |
|
579 | 579 | |
580 | - /** |
|
580 | + /** |
|
581 | 581 | * Sends a payment reminder to a customer. |
582 | - * |
|
583 | - * @param array $args |
|
582 | + * |
|
583 | + * @param array $args |
|
584 | 584 | */ |
585 | 585 | public function send_customer_payment_reminder( $args ) { |
586 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
586 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
587 | 587 | |
588 | - if ( $sent ) { |
|
589 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
590 | - } else { |
|
591 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
592 | - } |
|
588 | + if ( $sent ) { |
|
589 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
590 | + } else { |
|
591 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
592 | + } |
|
593 | 593 | |
594 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
595 | - exit; |
|
596 | - } |
|
594 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
595 | + exit; |
|
596 | + } |
|
597 | 597 | |
598 | - /** |
|
598 | + /** |
|
599 | 599 | * Resets tax rates. |
600 | - * |
|
600 | + * |
|
601 | 601 | */ |
602 | 602 | public function admin_reset_tax_rates() { |
603 | 603 | |
604 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
606 | - exit; |
|
604 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
606 | + exit; |
|
607 | 607 | |
608 | - } |
|
608 | + } |
|
609 | 609 | |
610 | - /** |
|
610 | + /** |
|
611 | 611 | * Resets admin pages. |
612 | - * |
|
612 | + * |
|
613 | 613 | */ |
614 | 614 | public function admin_create_missing_pages() { |
615 | - $installer = new GetPaid_Installer(); |
|
616 | - $installer->create_pages(); |
|
617 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
619 | - exit; |
|
620 | - } |
|
621 | - |
|
622 | - /** |
|
623 | - * Refreshes the permalinks. |
|
624 | - */ |
|
625 | - public function admin_refresh_permalinks() { |
|
626 | - flush_rewrite_rules(); |
|
627 | - $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
629 | - exit; |
|
630 | - } |
|
631 | - |
|
632 | - /** |
|
615 | + $installer = new GetPaid_Installer(); |
|
616 | + $installer->create_pages(); |
|
617 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
619 | + exit; |
|
620 | + } |
|
621 | + |
|
622 | + /** |
|
623 | + * Refreshes the permalinks. |
|
624 | + */ |
|
625 | + public function admin_refresh_permalinks() { |
|
626 | + flush_rewrite_rules(); |
|
627 | + $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
629 | + exit; |
|
630 | + } |
|
631 | + |
|
632 | + /** |
|
633 | 633 | * Creates missing admin tables. |
634 | - * |
|
634 | + * |
|
635 | 635 | */ |
636 | 636 | public function admin_create_missing_tables() { |
637 | - global $wpdb; |
|
637 | + global $wpdb; |
|
638 | 638 | |
639 | - GetPaid_Installer::create_db_tables(); |
|
640 | - GetPaid_Installer::migrate_old_customers(); |
|
639 | + GetPaid_Installer::create_db_tables(); |
|
640 | + GetPaid_Installer::migrate_old_customers(); |
|
641 | 641 | |
642 | - if ( '' !== $wpdb->last_error ) { |
|
643 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
644 | - } else { |
|
645 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
646 | - } |
|
642 | + if ( '' !== $wpdb->last_error ) { |
|
643 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
644 | + } else { |
|
645 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
646 | + } |
|
647 | 647 | |
648 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
649 | - exit; |
|
650 | - } |
|
648 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
649 | + exit; |
|
650 | + } |
|
651 | 651 | |
652 | - /** |
|
652 | + /** |
|
653 | 653 | * Migrates old invoices to the new database tables. |
654 | - * |
|
654 | + * |
|
655 | 655 | */ |
656 | 656 | public function admin_migrate_old_invoices() { |
657 | 657 | |
658 | - // Migrate the invoices. |
|
659 | - $installer = new GetPaid_Installer(); |
|
660 | - $installer->migrate_old_invoices(); |
|
658 | + // Migrate the invoices. |
|
659 | + $installer = new GetPaid_Installer(); |
|
660 | + $installer->migrate_old_invoices(); |
|
661 | 661 | |
662 | - // Show an admin message. |
|
663 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
662 | + // Show an admin message. |
|
663 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
664 | 664 | |
665 | - // Redirect the admin. |
|
666 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
667 | - exit; |
|
665 | + // Redirect the admin. |
|
666 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
667 | + exit; |
|
668 | 668 | |
669 | - } |
|
669 | + } |
|
670 | 670 | |
671 | - /** |
|
671 | + /** |
|
672 | 672 | * Download customers. |
673 | - * |
|
673 | + * |
|
674 | 674 | */ |
675 | 675 | public function admin_download_customers() { |
676 | 676 | |
677 | - $output = fopen( 'php://output', 'w' ); |
|
677 | + $output = fopen( 'php://output', 'w' ); |
|
678 | 678 | |
679 | - if ( false === $output ) { |
|
680 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
681 | - } |
|
679 | + if ( false === $output ) { |
|
680 | + wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
681 | + } |
|
682 | 682 | |
683 | - header( 'Content-Type:text/csv' ); |
|
684 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
683 | + header( 'Content-Type:text/csv' ); |
|
684 | + header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
685 | 685 | |
686 | - /** @var GetPaid_Customer[] $customers */ |
|
687 | - $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | - $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
686 | + /** @var GetPaid_Customer[] $customers */ |
|
687 | + $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | + $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
689 | 689 | |
690 | - // Output the csv column headers. |
|
691 | - fputcsv( $output, $columns ); |
|
690 | + // Output the csv column headers. |
|
691 | + fputcsv( $output, $columns ); |
|
692 | 692 | |
693 | - // Loop through |
|
694 | - foreach ( $customers as $customer ) { |
|
693 | + // Loop through |
|
694 | + foreach ( $customers as $customer ) { |
|
695 | 695 | |
696 | - $row = array(); |
|
696 | + $row = array(); |
|
697 | 697 | |
698 | - foreach ( $columns as $column ) { |
|
699 | - $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
700 | - } |
|
698 | + foreach ( $columns as $column ) { |
|
699 | + $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
700 | + } |
|
701 | 701 | |
702 | - fputcsv( $output, $row ); |
|
703 | - } |
|
702 | + fputcsv( $output, $row ); |
|
703 | + } |
|
704 | 704 | |
705 | - fclose( $output ); |
|
706 | - exit; |
|
705 | + fclose( $output ); |
|
706 | + exit; |
|
707 | 707 | |
708 | - } |
|
708 | + } |
|
709 | 709 | |
710 | - /** |
|
710 | + /** |
|
711 | 711 | * Installs a plugin. |
712 | - * |
|
713 | - * @param array $data |
|
712 | + * |
|
713 | + * @param array $data |
|
714 | 714 | */ |
715 | 715 | public function admin_install_plugin( $data ) { |
716 | 716 | |
717 | - if ( ! empty( $data['plugins'] ) ) { |
|
718 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
719 | - wp_cache_flush(); |
|
717 | + if ( ! empty( $data['plugins'] ) ) { |
|
718 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
719 | + wp_cache_flush(); |
|
720 | 720 | |
721 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | - $installed = $upgrader->install( $plugin_zip ); |
|
721 | + foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | + $installed = $upgrader->install( $plugin_zip ); |
|
725 | 725 | |
726 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | - activate_plugin( $file, '', false, true ); |
|
728 | - } else { |
|
729 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
730 | - } |
|
726 | + if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | + activate_plugin( $file, '', false, true ); |
|
728 | + } else { |
|
729 | + wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
730 | + } |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | - wp_safe_redirect( $redirect ); |
|
736 | - exit; |
|
734 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | + wp_safe_redirect( $redirect ); |
|
736 | + exit; |
|
737 | 737 | |
738 | - } |
|
738 | + } |
|
739 | 739 | |
740 | - /** |
|
740 | + /** |
|
741 | 741 | * Connects a gateway. |
742 | - * |
|
743 | - * @param array $data |
|
742 | + * |
|
743 | + * @param array $data |
|
744 | 744 | */ |
745 | 745 | public function admin_connect_gateway( $data ) { |
746 | 746 | |
747 | - if ( ! empty( $data['plugin'] ) ) { |
|
747 | + if ( ! empty( $data['plugin'] ) ) { |
|
748 | 748 | |
749 | - $gateway = sanitize_key( $data['plugin'] ); |
|
750 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
749 | + $gateway = sanitize_key( $data['plugin'] ); |
|
750 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
751 | 751 | |
752 | - if ( ! empty( $connect_url ) ) { |
|
753 | - wp_redirect( $connect_url ); |
|
754 | - exit; |
|
755 | - } |
|
752 | + if ( ! empty( $connect_url ) ) { |
|
753 | + wp_redirect( $connect_url ); |
|
754 | + exit; |
|
755 | + } |
|
756 | 756 | |
757 | - if ( 'stripe' == $data['plugin'] ) { |
|
758 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
759 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
760 | - wp_cache_flush(); |
|
757 | + if ( 'stripe' == $data['plugin'] ) { |
|
758 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
759 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
760 | + wp_cache_flush(); |
|
761 | 761 | |
762 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | - $upgrader->install( $plugin_zip ); |
|
766 | - } |
|
762 | + if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | + $upgrader->install( $plugin_zip ); |
|
766 | + } |
|
767 | 767 | |
768 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
769 | - } |
|
768 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
769 | + } |
|
770 | 770 | |
771 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | - if ( ! empty( $connect_url ) ) { |
|
773 | - wp_redirect( $connect_url ); |
|
774 | - exit; |
|
775 | - } |
|
771 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | + if ( ! empty( $connect_url ) ) { |
|
773 | + wp_redirect( $connect_url ); |
|
774 | + exit; |
|
775 | + } |
|
776 | 776 | } |
777 | 777 | |
778 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | - wp_safe_redirect( $redirect ); |
|
780 | - exit; |
|
778 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | + wp_safe_redirect( $redirect ); |
|
780 | + exit; |
|
781 | 781 | |
782 | - } |
|
782 | + } |
|
783 | 783 | |
784 | - /** |
|
784 | + /** |
|
785 | 785 | * Recalculates discounts. |
786 | - * |
|
786 | + * |
|
787 | 787 | */ |
788 | 788 | public function admin_recalculate_discounts() { |
789 | - global $wpdb; |
|
789 | + global $wpdb; |
|
790 | 790 | |
791 | - // Fetch all invoices that have discount codes. |
|
792 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
793 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
791 | + // Fetch all invoices that have discount codes. |
|
792 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
793 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
794 | 794 | |
795 | - foreach ( $invoices as $invoice ) { |
|
795 | + foreach ( $invoices as $invoice ) { |
|
796 | 796 | |
797 | - $invoice = new WPInv_Invoice( $invoice ); |
|
797 | + $invoice = new WPInv_Invoice( $invoice ); |
|
798 | 798 | |
799 | - if ( ! $invoice->exists() ) { |
|
800 | - continue; |
|
801 | - } |
|
799 | + if ( ! $invoice->exists() ) { |
|
800 | + continue; |
|
801 | + } |
|
802 | 802 | |
803 | - // Abort if the discount does not exist or does not apply here. |
|
804 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | - if ( ! $discount->exists() ) { |
|
806 | - continue; |
|
807 | - } |
|
803 | + // Abort if the discount does not exist or does not apply here. |
|
804 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | + if ( ! $discount->exists() ) { |
|
806 | + continue; |
|
807 | + } |
|
808 | 808 | |
809 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
810 | - $invoice->recalculate_total(); |
|
809 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
810 | + $invoice->recalculate_total(); |
|
811 | 811 | |
812 | - if ( $invoice->get_total_discount() > 0 ) { |
|
813 | - $invoice->save(); |
|
814 | - } |
|
812 | + if ( $invoice->get_total_discount() > 0 ) { |
|
813 | + $invoice->save(); |
|
814 | + } |
|
815 | 815 | } |
816 | 816 | |
817 | - // Show an admin message. |
|
818 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
817 | + // Show an admin message. |
|
818 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
819 | 819 | |
820 | - // Redirect the admin. |
|
821 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
822 | - exit; |
|
820 | + // Redirect the admin. |
|
821 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
822 | + exit; |
|
823 | 823 | |
824 | - } |
|
824 | + } |
|
825 | 825 | |
826 | - /** |
|
827 | - * Load dynamic strings in to file to translate via po editor |
|
828 | - * |
|
829 | - * @since 2.8.32 |
|
830 | - * |
|
831 | - * @global null|object $wp_filesystem WP_Filesystem object. |
|
832 | - * |
|
833 | - * @return bool True if file created otherwise false |
|
834 | - */ |
|
826 | + /** |
|
827 | + * Load dynamic strings in to file to translate via po editor |
|
828 | + * |
|
829 | + * @since 2.8.32 |
|
830 | + * |
|
831 | + * @global null|object $wp_filesystem WP_Filesystem object. |
|
832 | + * |
|
833 | + * @return bool True if file created otherwise false |
|
834 | + */ |
|
835 | 835 | public function tool_translate_db_texts() { |
836 | - $language_file = wp_normalize_path( WPINV_PLUGIN_DIR . 'db-language.php' ); |
|
837 | - |
|
838 | - if ( getpaid_sync_db_text_translation() ) { |
|
839 | - // Success |
|
840 | - $this->show_success( wp_sprintf( __( 'Strings are added in the file <b>%s</b> for translation.', 'invoicing' ), $language_file ) ); |
|
841 | - } else { |
|
842 | - // Failure |
|
843 | - $this->show_error( wp_sprintf( __( 'There was a problem creating the file <b>%s</b>. Please check file permissions.', 'invoicing' ), $language_file ) ); |
|
844 | - } |
|
836 | + $language_file = wp_normalize_path( WPINV_PLUGIN_DIR . 'db-language.php' ); |
|
837 | + |
|
838 | + if ( getpaid_sync_db_text_translation() ) { |
|
839 | + // Success |
|
840 | + $this->show_success( wp_sprintf( __( 'Strings are added in the file <b>%s</b> for translation.', 'invoicing' ), $language_file ) ); |
|
841 | + } else { |
|
842 | + // Failure |
|
843 | + $this->show_error( wp_sprintf( __( 'There was a problem creating the file <b>%s</b>. Please check file permissions.', 'invoicing' ), $language_file ) ); |
|
844 | + } |
|
845 | 845 | |
846 | - // Redirect the admin. |
|
847 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
846 | + // Redirect the admin. |
|
847 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
848 | 848 | |
849 | - exit; |
|
850 | - } |
|
849 | + exit; |
|
850 | + } |
|
851 | 851 | |
852 | 852 | /** |
853 | - * Returns an array of admin notices. |
|
854 | - * |
|
855 | - * @since 1.0.19 |
|
853 | + * Returns an array of admin notices. |
|
854 | + * |
|
855 | + * @since 1.0.19 |
|
856 | 856 | * @return array |
857 | - */ |
|
858 | - public function get_notices() { |
|
859 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
857 | + */ |
|
858 | + public function get_notices() { |
|
859 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
860 | 860 | return is_array( $notices ) ? $notices : array(); |
861 | - } |
|
861 | + } |
|
862 | 862 | |
863 | - /** |
|
864 | - * Checks if we have any admin notices. |
|
865 | - * |
|
866 | - * @since 2.0.4 |
|
863 | + /** |
|
864 | + * Checks if we have any admin notices. |
|
865 | + * |
|
866 | + * @since 2.0.4 |
|
867 | 867 | * @return array |
868 | - */ |
|
869 | - public function has_notices() { |
|
870 | - return count( $this->get_notices() ) > 0; |
|
871 | - } |
|
872 | - |
|
873 | - /** |
|
874 | - * Clears all admin notices |
|
875 | - * |
|
876 | - * @access public |
|
877 | - * @since 1.0.19 |
|
878 | - */ |
|
879 | - public function clear_notices() { |
|
880 | - delete_option( 'wpinv_admin_notices' ); |
|
881 | - } |
|
882 | - |
|
883 | - /** |
|
884 | - * Saves a new admin notice |
|
885 | - * |
|
886 | - * @access public |
|
887 | - * @since 1.0.19 |
|
888 | - */ |
|
889 | - public function save_notice( $type, $message ) { |
|
890 | - $notices = $this->get_notices(); |
|
891 | - |
|
892 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
893 | - $notices[ $type ] = array(); |
|
894 | - } |
|
895 | - |
|
896 | - $notices[ $type ][] = $message; |
|
897 | - |
|
898 | - update_option( 'wpinv_admin_notices', $notices ); |
|
899 | - } |
|
900 | - |
|
901 | - /** |
|
902 | - * Displays a success notice |
|
903 | - * |
|
904 | - * @param string $msg The message to qeue. |
|
905 | - * @access public |
|
906 | - * @since 1.0.19 |
|
907 | - */ |
|
908 | - public function show_success( $msg ) { |
|
909 | - $this->save_notice( 'success', $msg ); |
|
910 | - } |
|
911 | - |
|
912 | - /** |
|
913 | - * Displays a error notice |
|
914 | - * |
|
915 | - * @access public |
|
916 | - * @param string $msg The message to qeue. |
|
917 | - * @since 1.0.19 |
|
918 | - */ |
|
919 | - public function show_error( $msg ) { |
|
920 | - $this->save_notice( 'error', $msg ); |
|
921 | - } |
|
922 | - |
|
923 | - /** |
|
924 | - * Displays a warning notice |
|
925 | - * |
|
926 | - * @access public |
|
927 | - * @param string $msg The message to qeue. |
|
928 | - * @since 1.0.19 |
|
929 | - */ |
|
930 | - public function show_warning( $msg ) { |
|
931 | - $this->save_notice( 'warning', $msg ); |
|
932 | - } |
|
933 | - |
|
934 | - /** |
|
935 | - * Displays a info notice |
|
936 | - * |
|
937 | - * @access public |
|
938 | - * @param string $msg The message to qeue. |
|
939 | - * @since 1.0.19 |
|
940 | - */ |
|
941 | - public function show_info( $msg ) { |
|
942 | - $this->save_notice( 'info', $msg ); |
|
943 | - } |
|
944 | - |
|
945 | - /** |
|
946 | - * Show notices |
|
947 | - * |
|
948 | - * @access public |
|
949 | - * @since 1.0.19 |
|
950 | - */ |
|
951 | - public function show_notices() { |
|
868 | + */ |
|
869 | + public function has_notices() { |
|
870 | + return count( $this->get_notices() ) > 0; |
|
871 | + } |
|
872 | + |
|
873 | + /** |
|
874 | + * Clears all admin notices |
|
875 | + * |
|
876 | + * @access public |
|
877 | + * @since 1.0.19 |
|
878 | + */ |
|
879 | + public function clear_notices() { |
|
880 | + delete_option( 'wpinv_admin_notices' ); |
|
881 | + } |
|
882 | + |
|
883 | + /** |
|
884 | + * Saves a new admin notice |
|
885 | + * |
|
886 | + * @access public |
|
887 | + * @since 1.0.19 |
|
888 | + */ |
|
889 | + public function save_notice( $type, $message ) { |
|
890 | + $notices = $this->get_notices(); |
|
891 | + |
|
892 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
893 | + $notices[ $type ] = array(); |
|
894 | + } |
|
895 | + |
|
896 | + $notices[ $type ][] = $message; |
|
897 | + |
|
898 | + update_option( 'wpinv_admin_notices', $notices ); |
|
899 | + } |
|
900 | + |
|
901 | + /** |
|
902 | + * Displays a success notice |
|
903 | + * |
|
904 | + * @param string $msg The message to qeue. |
|
905 | + * @access public |
|
906 | + * @since 1.0.19 |
|
907 | + */ |
|
908 | + public function show_success( $msg ) { |
|
909 | + $this->save_notice( 'success', $msg ); |
|
910 | + } |
|
911 | + |
|
912 | + /** |
|
913 | + * Displays a error notice |
|
914 | + * |
|
915 | + * @access public |
|
916 | + * @param string $msg The message to qeue. |
|
917 | + * @since 1.0.19 |
|
918 | + */ |
|
919 | + public function show_error( $msg ) { |
|
920 | + $this->save_notice( 'error', $msg ); |
|
921 | + } |
|
922 | + |
|
923 | + /** |
|
924 | + * Displays a warning notice |
|
925 | + * |
|
926 | + * @access public |
|
927 | + * @param string $msg The message to qeue. |
|
928 | + * @since 1.0.19 |
|
929 | + */ |
|
930 | + public function show_warning( $msg ) { |
|
931 | + $this->save_notice( 'warning', $msg ); |
|
932 | + } |
|
933 | + |
|
934 | + /** |
|
935 | + * Displays a info notice |
|
936 | + * |
|
937 | + * @access public |
|
938 | + * @param string $msg The message to qeue. |
|
939 | + * @since 1.0.19 |
|
940 | + */ |
|
941 | + public function show_info( $msg ) { |
|
942 | + $this->save_notice( 'info', $msg ); |
|
943 | + } |
|
944 | + |
|
945 | + /** |
|
946 | + * Show notices |
|
947 | + * |
|
948 | + * @access public |
|
949 | + * @since 1.0.19 |
|
950 | + */ |
|
951 | + public function show_notices() { |
|
952 | 952 | |
953 | 953 | $notices = $this->get_notices(); |
954 | 954 | $this->clear_notices(); |
955 | 955 | |
956 | - foreach ( $notices as $type => $messages ) { |
|
956 | + foreach ( $notices as $type => $messages ) { |
|
957 | 957 | |
958 | - if ( ! is_array( $messages ) ) { |
|
959 | - continue; |
|
960 | - } |
|
958 | + if ( ! is_array( $messages ) ) { |
|
959 | + continue; |
|
960 | + } |
|
961 | 961 | |
962 | 962 | $type = esc_attr( $type ); |
963 | - foreach ( $messages as $message ) { |
|
964 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
963 | + foreach ( $messages as $message ) { |
|
964 | + echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | |
968 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
969 | - |
|
970 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
971 | - $url = wp_nonce_url( |
|
972 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
973 | - 'getpaid-nonce', |
|
974 | - 'getpaid-nonce' |
|
975 | - ); |
|
976 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
977 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
978 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
979 | - break; |
|
980 | - } |
|
968 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
969 | + |
|
970 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
971 | + $url = wp_nonce_url( |
|
972 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
973 | + 'getpaid-nonce', |
|
974 | + 'getpaid-nonce' |
|
975 | + ); |
|
976 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
977 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
978 | + echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
979 | + break; |
|
980 | + } |
|
981 | 981 | } |
982 | 982 | |
983 | - } |
|
983 | + } |
|
984 | 984 | |
985 | 985 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The main admin class. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | 41 | |
42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
44 | 44 | $this->reports = new GetPaid_Reports(); |
45 | 45 | |
46 | - if ( is_admin() ) { |
|
46 | + if (is_admin()) { |
|
47 | 47 | $this->init_admin_hooks(); |
48 | 48 | } |
49 | 49 | |
@@ -54,37 +54,37 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | private function init_admin_hooks() { |
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
|
58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
60 | - add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
|
61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
|
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | - add_action( 'getpaid_authenticated_admin_action_translate_db_texts', array( $this, 'tool_translate_db_texts' ) ); |
|
78 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
79 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
80 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
81 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9); |
|
58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
64 | + add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form')); |
|
65 | + add_action('getpaid_authenticated_admin_action_reset_form_stats', array($this, 'reset_form_stats')); |
|
66 | + add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice')); |
|
67 | + add_action('getpaid_authenticated_admin_action_refund_invoice', array($this, 'refund_invoice')); |
|
68 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
69 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
70 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
71 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
72 | + add_action('getpaid_authenticated_admin_action_refresh_permalinks', array($this, 'admin_refresh_permalinks')); |
|
73 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
74 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
75 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
76 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
77 | + add_action('getpaid_authenticated_admin_action_translate_db_texts', array($this, 'tool_translate_db_texts')); |
|
78 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
79 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
80 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
81 | + do_action('getpaid_init_admin_hooks', $this); |
|
82 | 82 | |
83 | 83 | // Setup/welcome |
84 | - if ( ! empty( $_GET['page'] ) ) { |
|
85 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
84 | + if (!empty($_GET['page'])) { |
|
85 | + switch (sanitize_text_field($_GET['page'])) { |
|
86 | 86 | case 'gp-setup': |
87 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
87 | + include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'; |
|
88 | 88 | break; |
89 | 89 | } |
90 | 90 | } |
@@ -98,37 +98,37 @@ discard block |
||
98 | 98 | public function enqeue_scripts() { |
99 | 99 | global $current_screen, $pagenow; |
100 | 100 | |
101 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
101 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
102 | 102 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
103 | 103 | |
104 | - if ( ! empty( $current_screen->post_type ) ) { |
|
104 | + if (!empty($current_screen->post_type)) { |
|
105 | 105 | $page = $current_screen->post_type; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // General styles. |
109 | - if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) { |
|
109 | + if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) { |
|
110 | 110 | |
111 | 111 | // Styles. |
112 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
113 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
114 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
112 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
113 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
114 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
115 | 115 | |
116 | 116 | // Scripts. |
117 | - wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
117 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
118 | 118 | |
119 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
120 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
121 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
119 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
120 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
121 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Payment form scripts. |
126 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
126 | + if ('wpi_payment_form' == $page && $editing) { |
|
127 | 127 | $this->load_payment_form_scripts(); |
128 | 128 | } |
129 | 129 | |
130 | - if ( $page == 'wpinv-subscriptions' ) { |
|
131 | - wp_enqueue_script( 'postbox' ); |
|
130 | + if ($page == 'wpinv-subscriptions') { |
|
131 | + wp_enqueue_script('postbox'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | } |
@@ -141,31 +141,31 @@ discard block |
||
141 | 141 | global $post; |
142 | 142 | |
143 | 143 | $date_range = array( |
144 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
144 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days', |
|
145 | 145 | ); |
146 | 146 | |
147 | - if ( $date_range['period'] == 'custom' ) { |
|
147 | + if ($date_range['period'] == 'custom') { |
|
148 | 148 | |
149 | - if ( isset( $_GET['from'] ) ) { |
|
150 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
149 | + if (isset($_GET['from'])) { |
|
150 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( isset( $_GET['to'] ) ) { |
|
154 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
153 | + if (isset($_GET['to'])) { |
|
154 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | $i18n = array( |
159 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
160 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
161 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
162 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
163 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
159 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
160 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
161 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
162 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
163 | + 'rest_root' => esc_url_raw(rest_url()), |
|
164 | 164 | 'date_range' => $date_range, |
165 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
166 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
167 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
168 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
165 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
166 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
167 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
168 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
169 | 169 | 'tax' => wpinv_tax_amount(), |
170 | 170 | 'discount' => 0, |
171 | 171 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -174,39 +174,39 @@ discard block |
||
174 | 174 | 'thousand_sep' => wpinv_thousands_separator(), |
175 | 175 | 'decimal_sep' => wpinv_decimal_separator(), |
176 | 176 | 'decimals' => wpinv_decimals(), |
177 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
178 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
179 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
180 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
181 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
182 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
183 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
184 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
185 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
186 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
187 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
188 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
189 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
190 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
191 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
192 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
193 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
194 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
195 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
196 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
177 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
178 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
179 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
180 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
181 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
182 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
183 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
184 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
185 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
186 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
187 | + 'action_edit' => __('Edit', 'invoicing'), |
|
188 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
189 | + 'item_description' => __('Item Description', 'invoicing'), |
|
190 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
191 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
192 | + 'searching' => __('Searching', 'invoicing'), |
|
193 | + 'loading' => __('Loading...', 'invoicing'), |
|
194 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
195 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
196 | + 'graphs' => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())), |
|
197 | 197 | ); |
198 | 198 | |
199 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
199 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
200 | 200 | |
201 | - $invoice = new WPInv_Invoice( $post ); |
|
201 | + $invoice = new WPInv_Invoice($post); |
|
202 | 202 | $i18n['save_invoice'] = sprintf( |
203 | - __( 'Save %s', 'invoicing' ), |
|
204 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
203 | + __('Save %s', 'invoicing'), |
|
204 | + ucfirst($invoice->get_invoice_quote_type()) |
|
205 | 205 | ); |
206 | 206 | |
207 | 207 | $i18n['invoice_description'] = sprintf( |
208 | - __( '%s Description', 'invoicing' ), |
|
209 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
208 | + __('%s Description', 'invoicing'), |
|
209 | + ucfirst($invoice->get_invoice_quote_type()) |
|
210 | 210 | ); |
211 | 211 | |
212 | 212 | } |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | * @param string $footer_text |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function admin_footer_text( $footer_text ) { |
|
223 | + public function admin_footer_text($footer_text) { |
|
224 | 224 | global $current_screen; |
225 | 225 | |
226 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
226 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
227 | 227 | |
228 | - if ( ! empty( $current_screen->post_type ) ) { |
|
228 | + if (!empty($current_screen->post_type)) { |
|
229 | 229 | $page = $current_screen->post_type; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // General styles. |
233 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
233 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
234 | 234 | |
235 | 235 | // Change the footer text |
236 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
236 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
237 | 237 | |
238 | - $rating_url = esc_url( |
|
238 | + $rating_url = esc_url( |
|
239 | 239 | wp_nonce_url( |
240 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
240 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
241 | 241 | 'getpaid-nonce', |
242 | 242 | 'getpaid-nonce' |
243 | 243 | ) |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | $footer_text = sprintf( |
247 | 247 | /* translators: %s: five stars */ |
248 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
248 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
249 | 249 | "<a href='$rating_url'>★★★★★</a>" |
250 | 250 | ); |
251 | 251 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | $footer_text = sprintf( |
255 | 255 | /* translators: %s: GetPaid */ |
256 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
256 | + __('Thank you for using %s!', 'invoicing'), |
|
257 | 257 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
258 | 258 | ); |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @since 2.0.0 |
270 | 270 | */ |
271 | 271 | public function redirect_to_wordpress_rating_page() { |
272 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
273 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
272 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
273 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
274 | 274 | exit; |
275 | 275 | } |
276 | 276 | |
@@ -281,29 +281,29 @@ discard block |
||
281 | 281 | protected function load_payment_form_scripts() { |
282 | 282 | global $post; |
283 | 283 | |
284 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
285 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
286 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
284 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
285 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
286 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
287 | 287 | |
288 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION ); |
|
288 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), WPINV_VERSION); |
|
289 | 289 | |
290 | 290 | wp_localize_script( |
291 | 291 | 'wpinv-admin-payment-form-script', |
292 | 292 | 'wpinvPaymentFormAdmin', |
293 | 293 | array( |
294 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
294 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
295 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
296 | 296 | 'currency' => wpinv_currency_symbol(), |
297 | 297 | 'position' => wpinv_currency_position(), |
298 | 298 | 'decimals' => (int) wpinv_decimals(), |
299 | 299 | 'thousands_sep' => wpinv_thousands_separator(), |
300 | 300 | 'decimals_sep' => wpinv_decimal_separator(), |
301 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
301 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
302 | 302 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
306 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
306 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | |
@@ -314,24 +314,24 @@ discard block |
||
314 | 314 | * @return string |
315 | 315 | * |
316 | 316 | */ |
317 | - public function admin_body_class( $classes ) { |
|
317 | + public function admin_body_class($classes) { |
|
318 | 318 | global $pagenow, $post, $current_screen; |
319 | 319 | |
320 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
320 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
321 | 321 | |
322 | - if ( ! empty( $current_screen->post_type ) ) { |
|
322 | + if (!empty($current_screen->post_type)) { |
|
323 | 323 | $page = $current_screen->post_type; |
324 | 324 | } |
325 | 325 | |
326 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
327 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
326 | + if (false !== stripos($page, 'wpi')) { |
|
327 | + $classes .= ' wpi-' . sanitize_key($page); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
330 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
331 | 331 | $classes .= ' wpinv-cpt wpinv'; |
332 | 332 | } |
333 | 333 | |
334 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
334 | + if (getpaid_is_invoice_post_type($page)) { |
|
335 | 335 | $classes .= ' getpaid-is-invoice-cpt'; |
336 | 336 | } |
337 | 337 | |
@@ -350,21 +350,21 @@ discard block |
||
350 | 350 | 'version' => WPINV_VERSION, |
351 | 351 | 'support_url' => 'https://wpgetpaid.com/support/', |
352 | 352 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
353 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
353 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | 357 | new AyeCode_Connect_Helper( |
358 | 358 | array( |
359 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
359 | + 'connect_title' => __('WP Invoicing - an AyeCode product!', 'invoicing'), |
|
360 | + 'connect_external' => __('Please confirm you wish to connect your site?', 'invoicing'), |
|
361 | + 'connect' => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'), |
|
362 | + 'connect_button' => __('Connect Site', 'invoicing'), |
|
363 | + 'connecting_button' => __('Connecting...', 'invoicing'), |
|
364 | + 'error_localhost' => __('This service will only work with a live domain, not a localhost.', 'invoicing'), |
|
365 | + 'error' => __('Something went wrong, please refresh and try again.', 'invoicing'), |
|
366 | 366 | ), |
367 | - array( 'wpi-addons' ) |
|
367 | + array('wpi-addons') |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | } |
@@ -376,20 +376,20 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function activation_redirect() { |
378 | 378 | |
379 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
379 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
380 | 380 | |
381 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
381 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // Bail if activating from network, or bulk |
386 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
386 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
387 | 387 | return; |
388 | 388 | } |
389 | 389 | |
390 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
390 | + update_option('wpinv_redirected_to_settings', 1); |
|
391 | 391 | |
392 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
392 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
393 | 393 | exit; |
394 | 394 | |
395 | 395 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | * Fires an admin action after verifying that a user can fire them. |
399 | 399 | */ |
400 | 400 | public function maybe_do_admin_action() { |
401 | - if ( isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) && wpinv_current_user_can( sanitize_text_field( $_REQUEST['getpaid-admin-action'] ), $_REQUEST ) ) { |
|
402 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
401 | + if (isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce') && wpinv_current_user_can(sanitize_text_field($_REQUEST['getpaid-admin-action']), $_REQUEST)) { |
|
402 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
403 | 403 | |
404 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
404 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -410,24 +410,24 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param array $args |
412 | 412 | */ |
413 | - public function duplicate_invoice( $args ) { |
|
413 | + public function duplicate_invoice($args) { |
|
414 | 414 | |
415 | - if ( empty( $args['invoice_id'] ) ) { |
|
415 | + if (empty($args['invoice_id'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
419 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
420 | 420 | |
421 | - if ( ! $invoice->exists() ) { |
|
421 | + if (!$invoice->exists()) { |
|
422 | 422 | return; |
423 | 423 | } |
424 | 424 | |
425 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
425 | + $new_invoice = getpaid_duplicate_invoice($invoice); |
|
426 | 426 | $new_invoice->save(); |
427 | 427 | |
428 | - if ( $new_invoice->exists() ) { |
|
428 | + if ($new_invoice->exists()) { |
|
429 | 429 | |
430 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
430 | + getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'invoicing')); |
|
431 | 431 | |
432 | 432 | wp_safe_redirect( |
433 | 433 | add_query_arg( |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | 'action' => 'edit', |
436 | 436 | 'post' => $new_invoice->get_id(), |
437 | 437 | ), |
438 | - admin_url( 'post.php' ) |
|
438 | + admin_url('post.php') |
|
439 | 439 | ) |
440 | 440 | ); |
441 | 441 | exit; |
442 | 442 | |
443 | 443 | } |
444 | 444 | |
445 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
445 | + getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'invoicing')); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -451,40 +451,40 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @param array $args |
453 | 453 | */ |
454 | - public function refund_invoice( $args ) { |
|
454 | + public function refund_invoice($args) { |
|
455 | 455 | |
456 | - if ( empty( $args['invoice_id'] ) ) { |
|
456 | + if (empty($args['invoice_id'])) { |
|
457 | 457 | return; |
458 | 458 | } |
459 | 459 | |
460 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
460 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
461 | 461 | |
462 | - if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
462 | + if (!$invoice->exists() || $invoice->is_refunded()) { |
|
463 | 463 | return; |
464 | 464 | } |
465 | 465 | |
466 | 466 | $invoice->refund(); |
467 | 467 | |
468 | 468 | // Refund remotely. |
469 | - if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | - do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
469 | + if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds') && !empty($args['getpaid_refund_remote'])) { |
|
470 | + do_action('getpaid_refund_invoice_remotely', $invoice); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Cancel subscriptions. |
474 | - if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
474 | + if (!empty($args['getpaid_cancel_subscription'])) { |
|
475 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
476 | 476 | |
477 | - if ( ! empty( $subscriptions ) ) { |
|
478 | - if ( ! is_array( $subscriptions ) ) { |
|
479 | - $subscriptions = array( $subscriptions ); |
|
477 | + if (!empty($subscriptions)) { |
|
478 | + if (!is_array($subscriptions)) { |
|
479 | + $subscriptions = array($subscriptions); |
|
480 | 480 | } |
481 | 481 | |
482 | - foreach ( $subscriptions as $subscription ) { |
|
482 | + foreach ($subscriptions as $subscription) { |
|
483 | 483 | $subscription->cancel(); |
484 | 484 | $invoice->add_system_note( |
485 | 485 | sprintf( |
486 | 486 | // translators: %s: subscription ID. |
487 | - __( 'Subscription #%s cancelled', 'invoicing' ), |
|
487 | + __('Subscription #%s cancelled', 'invoicing'), |
|
488 | 488 | $subscription->get_id() |
489 | 489 | ) |
490 | 490 | ); |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | // Add notice. |
496 | - $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
496 | + $this->show_success(__('Invoice refunded successfully.', 'invoicing')); |
|
497 | 497 | |
498 | 498 | // Redirect. |
499 | 499 | wp_safe_redirect( |
500 | - remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
500 | + remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote')) |
|
501 | 501 | ); |
502 | 502 | } |
503 | 503 | |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @param array $args |
508 | 508 | */ |
509 | - public function duplicate_payment_form( $args ) { |
|
509 | + public function duplicate_payment_form($args) { |
|
510 | 510 | |
511 | - if ( empty( $args['form_id'] ) ) { |
|
511 | + if (empty($args['form_id'])) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | |
515 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
515 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
516 | 516 | |
517 | - if ( ! $form->exists() ) { |
|
517 | + if (!$form->exists()) { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | $new_form = new GetPaid_Payment_Form(); |
522 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
522 | + $new_form->set_author($form->get_author('edit')); |
|
523 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
524 | + $new_form->set_elements($form->get_elements('edit')); |
|
525 | + $new_form->set_items($form->get_items('edit')); |
|
526 | 526 | $new_form->save(); |
527 | 527 | |
528 | - if ( $new_form->exists() ) { |
|
529 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
528 | + if ($new_form->exists()) { |
|
529 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
530 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
531 | 531 | } else { |
532 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
532 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
533 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
534 | 534 | } |
535 | 535 | |
536 | - wp_redirect( $url ); |
|
536 | + wp_redirect($url); |
|
537 | 537 | exit; |
538 | 538 | } |
539 | 539 | |
@@ -542,27 +542,27 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @param array $args |
544 | 544 | */ |
545 | - public function reset_form_stats( $args ) { |
|
545 | + public function reset_form_stats($args) { |
|
546 | 546 | |
547 | - if ( empty( $args['form_id'] ) ) { |
|
547 | + if (empty($args['form_id'])) { |
|
548 | 548 | return; |
549 | 549 | } |
550 | 550 | |
551 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
551 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
552 | 552 | |
553 | - if ( ! $form->exists() ) { |
|
553 | + if (!$form->exists()) { |
|
554 | 554 | return; |
555 | 555 | } |
556 | 556 | |
557 | - $form->set_earned( 0 ); |
|
558 | - $form->set_refunded( 0 ); |
|
559 | - $form->set_cancelled( 0 ); |
|
560 | - $form->set_failed( 0 ); |
|
557 | + $form->set_earned(0); |
|
558 | + $form->set_refunded(0); |
|
559 | + $form->set_cancelled(0); |
|
560 | + $form->set_failed(0); |
|
561 | 561 | $form->save(); |
562 | 562 | |
563 | - $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
563 | + $this->show_success(__('Form stats reset successfully', 'invoicing')); |
|
564 | 564 | |
565 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
565 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'))); |
|
566 | 566 | exit; |
567 | 567 | } |
568 | 568 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @param array $args |
573 | 573 | */ |
574 | - public function send_customer_invoice( $args ) { |
|
575 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
574 | + public function send_customer_invoice($args) { |
|
575 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
576 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
577 | 577 | exit; |
578 | 578 | } |
579 | 579 | |
@@ -582,16 +582,16 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @param array $args |
584 | 584 | */ |
585 | - public function send_customer_payment_reminder( $args ) { |
|
586 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
585 | + public function send_customer_payment_reminder($args) { |
|
586 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
587 | 587 | |
588 | - if ( $sent ) { |
|
589 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
588 | + if ($sent) { |
|
589 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
590 | 590 | } else { |
591 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
591 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
592 | 592 | } |
593 | 593 | |
594 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
594 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
595 | 595 | exit; |
596 | 596 | } |
597 | 597 | |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | */ |
602 | 602 | public function admin_reset_tax_rates() { |
603 | 603 | |
604 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
604 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
605 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
606 | 606 | exit; |
607 | 607 | |
608 | 608 | } |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | public function admin_create_missing_pages() { |
615 | 615 | $installer = new GetPaid_Installer(); |
616 | 616 | $installer->create_pages(); |
617 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
617 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
618 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
619 | 619 | exit; |
620 | 620 | } |
621 | 621 | |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function admin_refresh_permalinks() { |
626 | 626 | flush_rewrite_rules(); |
627 | - $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
627 | + $this->show_success(__('Permalinks refreshed.', 'invoicing')); |
|
628 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
629 | 629 | exit; |
630 | 630 | } |
631 | 631 | |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | GetPaid_Installer::create_db_tables(); |
640 | 640 | GetPaid_Installer::migrate_old_customers(); |
641 | 641 | |
642 | - if ( '' !== $wpdb->last_error ) { |
|
643 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
642 | + if ('' !== $wpdb->last_error) { |
|
643 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
644 | 644 | } else { |
645 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
645 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
646 | 646 | } |
647 | 647 | |
648 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
648 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
649 | 649 | exit; |
650 | 650 | } |
651 | 651 | |
@@ -660,10 +660,10 @@ discard block |
||
660 | 660 | $installer->migrate_old_invoices(); |
661 | 661 | |
662 | 662 | // Show an admin message. |
663 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
663 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
664 | 664 | |
665 | 665 | // Redirect the admin. |
666 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
666 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
667 | 667 | exit; |
668 | 668 | |
669 | 669 | } |
@@ -674,35 +674,35 @@ discard block |
||
674 | 674 | */ |
675 | 675 | public function admin_download_customers() { |
676 | 676 | |
677 | - $output = fopen( 'php://output', 'w' ); |
|
677 | + $output = fopen('php://output', 'w'); |
|
678 | 678 | |
679 | - if ( false === $output ) { |
|
680 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
679 | + if (false === $output) { |
|
680 | + wp_die(esc_html__('Unsupported server', 'invoicing'), 500); |
|
681 | 681 | } |
682 | 682 | |
683 | - header( 'Content-Type:text/csv' ); |
|
684 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
683 | + header('Content-Type:text/csv'); |
|
684 | + header('Content-Disposition:attachment;filename=customers.csv'); |
|
685 | 685 | |
686 | 686 | /** @var GetPaid_Customer[] $customers */ |
687 | - $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | - $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
687 | + $customers = getpaid_get_customers(array('number' => -1)); |
|
688 | + $columns = array_keys(GetPaid_Customer_Data_Store::get_database_fields()); |
|
689 | 689 | |
690 | 690 | // Output the csv column headers. |
691 | - fputcsv( $output, $columns ); |
|
691 | + fputcsv($output, $columns); |
|
692 | 692 | |
693 | 693 | // Loop through |
694 | - foreach ( $customers as $customer ) { |
|
694 | + foreach ($customers as $customer) { |
|
695 | 695 | |
696 | - $row = array(); |
|
696 | + $row = array(); |
|
697 | 697 | |
698 | - foreach ( $columns as $column ) { |
|
699 | - $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
698 | + foreach ($columns as $column) { |
|
699 | + $row[] = (string) maybe_serialize($customer->get($column, 'edit')); |
|
700 | 700 | } |
701 | 701 | |
702 | - fputcsv( $output, $row ); |
|
702 | + fputcsv($output, $row); |
|
703 | 703 | } |
704 | 704 | |
705 | - fclose( $output ); |
|
705 | + fclose($output); |
|
706 | 706 | exit; |
707 | 707 | |
708 | 708 | } |
@@ -712,27 +712,27 @@ discard block |
||
712 | 712 | * |
713 | 713 | * @param array $data |
714 | 714 | */ |
715 | - public function admin_install_plugin( $data ) { |
|
715 | + public function admin_install_plugin($data) { |
|
716 | 716 | |
717 | - if ( ! empty( $data['plugins'] ) ) { |
|
717 | + if (!empty($data['plugins'])) { |
|
718 | 718 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
719 | 719 | wp_cache_flush(); |
720 | 720 | |
721 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | - $installed = $upgrader->install( $plugin_zip ); |
|
721 | + foreach ($data['plugins'] as $slug => $file) { |
|
722 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
723 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
724 | + $installed = $upgrader->install($plugin_zip); |
|
725 | 725 | |
726 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | - activate_plugin( $file, '', false, true ); |
|
726 | + if (!is_wp_error($installed) && $installed) { |
|
727 | + activate_plugin($file, '', false, true); |
|
728 | 728 | } else { |
729 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
729 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | - wp_safe_redirect( $redirect ); |
|
734 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
735 | + wp_safe_redirect($redirect); |
|
736 | 736 | exit; |
737 | 737 | |
738 | 738 | } |
@@ -742,41 +742,41 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @param array $data |
744 | 744 | */ |
745 | - public function admin_connect_gateway( $data ) { |
|
745 | + public function admin_connect_gateway($data) { |
|
746 | 746 | |
747 | - if ( ! empty( $data['plugin'] ) ) { |
|
747 | + if (!empty($data['plugin'])) { |
|
748 | 748 | |
749 | - $gateway = sanitize_key( $data['plugin'] ); |
|
750 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
749 | + $gateway = sanitize_key($data['plugin']); |
|
750 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
751 | 751 | |
752 | - if ( ! empty( $connect_url ) ) { |
|
753 | - wp_redirect( $connect_url ); |
|
752 | + if (!empty($connect_url)) { |
|
753 | + wp_redirect($connect_url); |
|
754 | 754 | exit; |
755 | 755 | } |
756 | 756 | |
757 | - if ( 'stripe' == $data['plugin'] ) { |
|
757 | + if ('stripe' == $data['plugin']) { |
|
758 | 758 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
759 | 759 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
760 | 760 | wp_cache_flush(); |
761 | 761 | |
762 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | - $upgrader->install( $plugin_zip ); |
|
762 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
763 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
764 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
765 | + $upgrader->install($plugin_zip); |
|
766 | 766 | } |
767 | 767 | |
768 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
768 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
769 | 769 | } |
770 | 770 | |
771 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | - if ( ! empty( $connect_url ) ) { |
|
773 | - wp_redirect( $connect_url ); |
|
771 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
772 | + if (!empty($connect_url)) { |
|
773 | + wp_redirect($connect_url); |
|
774 | 774 | exit; |
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
778 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | - wp_safe_redirect( $redirect ); |
|
778 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
779 | + wp_safe_redirect($redirect); |
|
780 | 780 | exit; |
781 | 781 | |
782 | 782 | } |
@@ -790,35 +790,35 @@ discard block |
||
790 | 790 | |
791 | 791 | // Fetch all invoices that have discount codes. |
792 | 792 | $table = $wpdb->prefix . 'getpaid_invoices'; |
793 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
793 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
794 | 794 | |
795 | - foreach ( $invoices as $invoice ) { |
|
795 | + foreach ($invoices as $invoice) { |
|
796 | 796 | |
797 | - $invoice = new WPInv_Invoice( $invoice ); |
|
797 | + $invoice = new WPInv_Invoice($invoice); |
|
798 | 798 | |
799 | - if ( ! $invoice->exists() ) { |
|
799 | + if (!$invoice->exists()) { |
|
800 | 800 | continue; |
801 | 801 | } |
802 | 802 | |
803 | 803 | // Abort if the discount does not exist or does not apply here. |
804 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | - if ( ! $discount->exists() ) { |
|
804 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
805 | + if (!$discount->exists()) { |
|
806 | 806 | continue; |
807 | 807 | } |
808 | 808 | |
809 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
809 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
810 | 810 | $invoice->recalculate_total(); |
811 | 811 | |
812 | - if ( $invoice->get_total_discount() > 0 ) { |
|
812 | + if ($invoice->get_total_discount() > 0) { |
|
813 | 813 | $invoice->save(); |
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | 817 | // Show an admin message. |
818 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
818 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
819 | 819 | |
820 | 820 | // Redirect the admin. |
821 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
821 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
822 | 822 | exit; |
823 | 823 | |
824 | 824 | } |
@@ -833,18 +833,18 @@ discard block |
||
833 | 833 | * @return bool True if file created otherwise false |
834 | 834 | */ |
835 | 835 | public function tool_translate_db_texts() { |
836 | - $language_file = wp_normalize_path( WPINV_PLUGIN_DIR . 'db-language.php' ); |
|
836 | + $language_file = wp_normalize_path(WPINV_PLUGIN_DIR . 'db-language.php'); |
|
837 | 837 | |
838 | - if ( getpaid_sync_db_text_translation() ) { |
|
838 | + if (getpaid_sync_db_text_translation()) { |
|
839 | 839 | // Success |
840 | - $this->show_success( wp_sprintf( __( 'Strings are added in the file <b>%s</b> for translation.', 'invoicing' ), $language_file ) ); |
|
840 | + $this->show_success(wp_sprintf(__('Strings are added in the file <b>%s</b> for translation.', 'invoicing'), $language_file)); |
|
841 | 841 | } else { |
842 | 842 | // Failure |
843 | - $this->show_error( wp_sprintf( __( 'There was a problem creating the file <b>%s</b>. Please check file permissions.', 'invoicing' ), $language_file ) ); |
|
843 | + $this->show_error(wp_sprintf(__('There was a problem creating the file <b>%s</b>. Please check file permissions.', 'invoicing'), $language_file)); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | // Redirect the admin. |
847 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
847 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
848 | 848 | |
849 | 849 | exit; |
850 | 850 | } |
@@ -856,8 +856,8 @@ discard block |
||
856 | 856 | * @return array |
857 | 857 | */ |
858 | 858 | public function get_notices() { |
859 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
860 | - return is_array( $notices ) ? $notices : array(); |
|
859 | + $notices = get_option('wpinv_admin_notices'); |
|
860 | + return is_array($notices) ? $notices : array(); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | * @return array |
868 | 868 | */ |
869 | 869 | public function has_notices() { |
870 | - return count( $this->get_notices() ) > 0; |
|
870 | + return count($this->get_notices()) > 0; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | * @since 1.0.19 |
878 | 878 | */ |
879 | 879 | public function clear_notices() { |
880 | - delete_option( 'wpinv_admin_notices' ); |
|
880 | + delete_option('wpinv_admin_notices'); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -886,16 +886,16 @@ discard block |
||
886 | 886 | * @access public |
887 | 887 | * @since 1.0.19 |
888 | 888 | */ |
889 | - public function save_notice( $type, $message ) { |
|
889 | + public function save_notice($type, $message) { |
|
890 | 890 | $notices = $this->get_notices(); |
891 | 891 | |
892 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
893 | - $notices[ $type ] = array(); |
|
892 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
893 | + $notices[$type] = array(); |
|
894 | 894 | } |
895 | 895 | |
896 | - $notices[ $type ][] = $message; |
|
896 | + $notices[$type][] = $message; |
|
897 | 897 | |
898 | - update_option( 'wpinv_admin_notices', $notices ); |
|
898 | + update_option('wpinv_admin_notices', $notices); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | * @access public |
906 | 906 | * @since 1.0.19 |
907 | 907 | */ |
908 | - public function show_success( $msg ) { |
|
909 | - $this->save_notice( 'success', $msg ); |
|
908 | + public function show_success($msg) { |
|
909 | + $this->save_notice('success', $msg); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @param string $msg The message to qeue. |
917 | 917 | * @since 1.0.19 |
918 | 918 | */ |
919 | - public function show_error( $msg ) { |
|
920 | - $this->save_notice( 'error', $msg ); |
|
919 | + public function show_error($msg) { |
|
920 | + $this->save_notice('error', $msg); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -927,8 +927,8 @@ discard block |
||
927 | 927 | * @param string $msg The message to qeue. |
928 | 928 | * @since 1.0.19 |
929 | 929 | */ |
930 | - public function show_warning( $msg ) { |
|
931 | - $this->save_notice( 'warning', $msg ); |
|
930 | + public function show_warning($msg) { |
|
931 | + $this->save_notice('warning', $msg); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | /** |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | * @param string $msg The message to qeue. |
939 | 939 | * @since 1.0.19 |
940 | 940 | */ |
941 | - public function show_info( $msg ) { |
|
942 | - $this->save_notice( 'info', $msg ); |
|
941 | + public function show_info($msg) { |
|
942 | + $this->save_notice('info', $msg); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | /** |
@@ -953,29 +953,29 @@ discard block |
||
953 | 953 | $notices = $this->get_notices(); |
954 | 954 | $this->clear_notices(); |
955 | 955 | |
956 | - foreach ( $notices as $type => $messages ) { |
|
956 | + foreach ($notices as $type => $messages) { |
|
957 | 957 | |
958 | - if ( ! is_array( $messages ) ) { |
|
958 | + if (!is_array($messages)) { |
|
959 | 959 | continue; |
960 | 960 | } |
961 | 961 | |
962 | - $type = esc_attr( $type ); |
|
963 | - foreach ( $messages as $message ) { |
|
964 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
962 | + $type = esc_attr($type); |
|
963 | + foreach ($messages as $message) { |
|
964 | + echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>"); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | |
968 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
968 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
969 | 969 | |
970 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
971 | - $url = wp_nonce_url( |
|
972 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
970 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
971 | + $url = wp_nonce_url( |
|
972 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
973 | 973 | 'getpaid-nonce', |
974 | 974 | 'getpaid-nonce' |
975 | 975 | ); |
976 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
977 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
978 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
976 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
977 | + $message2 = __('Generate Pages', 'invoicing'); |
|
978 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
979 | 979 | break; |
980 | 980 | } |
981 | 981 | } |
@@ -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 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -144,22 +144,22 @@ discard block |
||
144 | 144 | * |
145 | 145 | */ |
146 | 146 | function wpinv_register_settings() { |
147 | - do_action( 'getpaid_before_register_settings' ); |
|
147 | + do_action('getpaid_before_register_settings'); |
|
148 | 148 | |
149 | 149 | // Loop through all tabs. |
150 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
150 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
151 | 151 | |
152 | 152 | // In each tab, loop through sections. |
153 | - foreach ( $sections as $section => $settings ) { |
|
153 | + foreach ($sections as $section => $settings) { |
|
154 | 154 | |
155 | 155 | // Check for backwards compatibility |
156 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
157 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
156 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
157 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
158 | 158 | $section = 'main'; |
159 | 159 | $settings = $sections; |
160 | 160 | } |
161 | 161 | |
162 | - do_action( "getpaid_register_{$tab}_{$section}" ); |
|
162 | + do_action("getpaid_register_{$tab}_{$section}"); |
|
163 | 163 | |
164 | 164 | // Register the setting section. |
165 | 165 | add_settings_section( |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | 'wpinv_settings_' . $tab . '_' . $section |
170 | 170 | ); |
171 | 171 | |
172 | - foreach ( $settings as $option ) { |
|
173 | - if ( ! empty( $option['id'] ) ) { |
|
174 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
172 | + foreach ($settings as $option) { |
|
173 | + if (!empty($option['id'])) { |
|
174 | + wpinv_register_settings_option($tab, $section, $option); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | |
183 | - do_action( 'getpaid_after_register_settings' ); |
|
183 | + do_action('getpaid_after_register_settings'); |
|
184 | 184 | } |
185 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
185 | +add_action('admin_init', 'wpinv_register_settings'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Register a single settings option. |
@@ -192,49 +192,49 @@ discard block |
||
192 | 192 | * @param string $option |
193 | 193 | * |
194 | 194 | */ |
195 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
195 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
196 | 196 | |
197 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
197 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
198 | 198 | $cb = "wpinv_{$option['type']}_callback"; |
199 | 199 | $section = "wpinv_settings_{$tab}_$section"; |
200 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
200 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
201 | 201 | |
202 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
203 | - $tip = wpinv_clean( $option['desc'] ); |
|
202 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
203 | + $tip = wpinv_clean($option['desc']); |
|
204 | 204 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
205 | - unset( $option['desc'] ); |
|
205 | + unset($option['desc']); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // Loop through all tabs. |
209 | 209 | add_settings_field( |
210 | 210 | 'wpinv_settings[' . $option['id'] . ']', |
211 | 211 | $name, |
212 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
212 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
213 | 213 | $section, |
214 | 214 | $section, |
215 | 215 | array( |
216 | 216 | 'section' => $section, |
217 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
218 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
217 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
218 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
219 | 219 | 'name' => $name, |
220 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
221 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
222 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
223 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
224 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
225 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
226 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
227 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
228 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
229 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
230 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
231 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
232 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
233 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
234 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
235 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
236 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
237 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
220 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
221 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
222 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
223 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
224 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
225 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
226 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
227 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
228 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
229 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
230 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
231 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
232 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
233 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
234 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
235 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
236 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
237 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return array |
247 | 247 | */ |
248 | 248 | function wpinv_get_registered_settings() { |
249 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
249 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return array |
256 | 256 | */ |
257 | 257 | function getpaid_get_integration_settings() { |
258 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
258 | + return apply_filters('getpaid_integration_settings', array()); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -263,153 +263,153 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array |
265 | 265 | */ |
266 | -function wpinv_settings_sanitize( $input = array() ) { |
|
266 | +function wpinv_settings_sanitize($input = array()) { |
|
267 | 267 | |
268 | 268 | $wpinv_options = wpinv_get_options(); |
269 | 269 | $raw_referrer = wp_get_raw_referer(); |
270 | 270 | |
271 | - if ( empty( $raw_referrer ) ) { |
|
272 | - return array_merge( $wpinv_options, $input ); |
|
271 | + if (empty($raw_referrer)) { |
|
272 | + return array_merge($wpinv_options, $input); |
|
273 | 273 | } |
274 | 274 | |
275 | - wp_parse_str( $raw_referrer, $referrer ); |
|
275 | + wp_parse_str($raw_referrer, $referrer); |
|
276 | 276 | |
277 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
278 | - return array_merge( $wpinv_options, $input ); |
|
277 | + if (in_array('gp-setup', $referrer)) { |
|
278 | + return array_merge($wpinv_options, $input); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | $settings = wpinv_get_registered_settings(); |
282 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
283 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
282 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
283 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
284 | 284 | |
285 | 285 | $input = $input ? $input : array(); |
286 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
287 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
286 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
287 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
288 | 288 | |
289 | 289 | // Loop through each setting being saved and pass it through a sanitization filter |
290 | - foreach ( $input as $key => $value ) { |
|
290 | + foreach ($input as $key => $value) { |
|
291 | 291 | |
292 | 292 | // Get the setting type (checkbox, select, etc) |
293 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
293 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
294 | 294 | |
295 | - if ( $type ) { |
|
295 | + if ($type) { |
|
296 | 296 | // Field type specific filter |
297 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
297 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | // General filter |
301 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
301 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
302 | 302 | |
303 | 303 | // Key specific filter. |
304 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
304 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | // Loop through the whitelist and unset any that are empty for the tab being saved |
308 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
309 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
308 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
309 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
310 | 310 | |
311 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
311 | + $found_settings = array_merge($main_settings, $section_settings); |
|
312 | 312 | |
313 | - if ( ! empty( $found_settings ) ) { |
|
314 | - foreach ( $found_settings as $key => $value ) { |
|
313 | + if (!empty($found_settings)) { |
|
314 | + foreach ($found_settings as $key => $value) { |
|
315 | 315 | |
316 | 316 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
317 | - if ( is_numeric( $key ) ) { |
|
317 | + if (is_numeric($key)) { |
|
318 | 318 | $key = $value['id']; |
319 | 319 | } |
320 | 320 | |
321 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
322 | - unset( $wpinv_options[ $key ] ); |
|
321 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
322 | + unset($wpinv_options[$key]); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Merge our new settings with the existing |
328 | - $output = array_merge( $wpinv_options, $input ); |
|
328 | + $output = array_merge($wpinv_options, $input); |
|
329 | 329 | |
330 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
330 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
331 | 331 | |
332 | 332 | return $output; |
333 | 333 | } |
334 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
335 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
334 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
335 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
336 | 336 | |
337 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
338 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
337 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
338 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
339 | 339 | return $input; |
340 | 340 | } |
341 | 341 | |
342 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
342 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
343 | 343 | $tax_rates = array(); |
344 | 344 | |
345 | - foreach ( $new_rates as $rate ) { |
|
345 | + foreach ($new_rates as $rate) { |
|
346 | 346 | |
347 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
348 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
349 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
350 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
351 | - $rate['global'] = empty( $rate['state'] ); |
|
347 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
348 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
349 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
350 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
351 | + $rate['global'] = empty($rate['state']); |
|
352 | 352 | $tax_rates[] = $rate; |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
356 | + update_option('wpinv_tax_rates', $tax_rates); |
|
357 | 357 | |
358 | 358 | return $input; |
359 | 359 | } |
360 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
360 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
361 | 361 | |
362 | -function wpinv_settings_sanitize_tax_rules( $input ) { |
|
363 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
362 | +function wpinv_settings_sanitize_tax_rules($input) { |
|
363 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
364 | 364 | return $input; |
365 | 365 | } |
366 | 366 | |
367 | - if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) { |
|
367 | + if (empty($_POST['wpinv_tax_rules_nonce']) || !wp_verify_nonce($_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules')) { |
|
368 | 368 | return $input; |
369 | 369 | } |
370 | 370 | |
371 | - $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array(); |
|
371 | + $new_rules = !empty($_POST['tax_rules']) ? wp_kses_post_deep(array_values($_POST['tax_rules'])) : array(); |
|
372 | 372 | $tax_rules = array(); |
373 | 373 | |
374 | - foreach ( $new_rules as $rule ) { |
|
374 | + foreach ($new_rules as $rule) { |
|
375 | 375 | |
376 | - $rule['key'] = sanitize_title_with_dashes( $rule['key'] ); |
|
377 | - $rule['label'] = sanitize_text_field( $rule['label'] ); |
|
378 | - $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] ); |
|
376 | + $rule['key'] = sanitize_title_with_dashes($rule['key']); |
|
377 | + $rule['label'] = sanitize_text_field($rule['label']); |
|
378 | + $rule['tax_base'] = sanitize_text_field($rule['tax_base']); |
|
379 | 379 | $tax_rules[] = $rule; |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - update_option( 'wpinv_tax_rules', $tax_rules ); |
|
383 | + update_option('wpinv_tax_rules', $tax_rules); |
|
384 | 384 | |
385 | 385 | return $input; |
386 | 386 | } |
387 | -add_filter( 'wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules' ); |
|
387 | +add_filter('wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules'); |
|
388 | 388 | |
389 | 389 | function wpinv_get_settings_tabs() { |
390 | 390 | $tabs = array(); |
391 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
392 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
393 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
394 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
391 | + $tabs['general'] = __('General', 'invoicing'); |
|
392 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
393 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
394 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
395 | 395 | |
396 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
397 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
396 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
397 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
398 | 398 | } |
399 | 399 | |
400 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
401 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
402 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
400 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
401 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
402 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
403 | 403 | |
404 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
404 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
405 | 405 | } |
406 | 406 | |
407 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
407 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
408 | 408 | $tabs = false; |
409 | 409 | $sections = wpinv_get_registered_settings_sections(); |
410 | 410 | |
411 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
412 | - $tabs = $sections[ $tab ]; |
|
411 | + if ($tab && !empty($sections[$tab])) { |
|
412 | + $tabs = $sections[$tab]; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $tabs; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | function wpinv_get_registered_settings_sections() { |
419 | 419 | static $sections = false; |
420 | 420 | |
421 | - if ( false !== $sections ) { |
|
421 | + if (false !== $sections) { |
|
422 | 422 | return $sections; |
423 | 423 | } |
424 | 424 | |
@@ -426,90 +426,90 @@ discard block |
||
426 | 426 | 'general' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_general', |
428 | 428 | array( |
429 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
430 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
431 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
432 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
429 | + 'main' => __('General Settings', 'invoicing'), |
|
430 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
431 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
432 | + 'labels' => __('Label Texts', 'invoicing'), |
|
433 | 433 | ) |
434 | 434 | ), |
435 | 435 | 'gateways' => apply_filters( |
436 | 436 | 'wpinv_settings_sections_gateways', |
437 | 437 | array( |
438 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
438 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | 'taxes' => apply_filters( |
442 | 442 | 'wpinv_settings_sections_taxes', |
443 | 443 | array( |
444 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
445 | - 'rules' => __( 'Tax Rules', 'invoicing' ), |
|
446 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
447 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
444 | + 'main' => __('Tax Settings', 'invoicing'), |
|
445 | + 'rules' => __('Tax Rules', 'invoicing'), |
|
446 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
447 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | 'emails' => apply_filters( |
451 | 451 | 'wpinv_settings_sections_emails', |
452 | 452 | array( |
453 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
453 | + 'main' => __('Email Settings', 'invoicing'), |
|
454 | 454 | ) |
455 | 455 | ), |
456 | 456 | |
457 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
457 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
458 | 458 | |
459 | 459 | 'privacy' => apply_filters( |
460 | 460 | 'wpinv_settings_sections_privacy', |
461 | 461 | array( |
462 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
462 | + 'main' => __('Privacy policy', 'invoicing'), |
|
463 | 463 | ) |
464 | 464 | ), |
465 | 465 | 'misc' => apply_filters( |
466 | 466 | 'wpinv_settings_sections_misc', |
467 | 467 | array( |
468 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
469 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
468 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
469 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
470 | 470 | ) |
471 | 471 | ), |
472 | 472 | 'tools' => apply_filters( |
473 | 473 | 'wpinv_settings_sections_tools', |
474 | 474 | array( |
475 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
475 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | ); |
479 | 479 | |
480 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
480 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
481 | 481 | |
482 | 482 | return $sections; |
483 | 483 | } |
484 | 484 | |
485 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
485 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
486 | 486 | global $wpdb, $gp_tmpl_page_options; |
487 | 487 | |
488 | 488 | // Same function, lets not call it twice if we don't need to. |
489 | - if ( function_exists( 'sd_template_page_options' ) ) { |
|
489 | + if (function_exists('sd_template_page_options')) { |
|
490 | 490 | $args = array( |
491 | 491 | 'with_slug' => $with_slug, |
492 | 492 | 'default_label' => $default_label |
493 | 493 | ); |
494 | 494 | |
495 | - return sd_template_page_options( $args ); |
|
495 | + return sd_template_page_options($args); |
|
496 | 496 | } |
497 | 497 | |
498 | - if ( ! empty( $gp_tmpl_page_options ) ) { |
|
498 | + if (!empty($gp_tmpl_page_options)) { |
|
499 | 499 | return $gp_tmpl_page_options; |
500 | 500 | } |
501 | 501 | |
502 | 502 | $exclude_pages = array(); |
503 | - if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
503 | + if ($page_on_front = get_option('page_on_front')) { |
|
504 | 504 | $exclude_pages[] = $page_on_front; |
505 | 505 | } |
506 | 506 | |
507 | - if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
507 | + if ($page_for_posts = get_option('page_for_posts')) { |
|
508 | 508 | $exclude_pages[] = $page_for_posts; |
509 | 509 | } |
510 | 510 | |
511 | 511 | $exclude_pages_placeholders = ''; |
512 | - if ( ! empty( $exclude_pages ) ) { |
|
512 | + if (!empty($exclude_pages)) { |
|
513 | 513 | // Sanitize the array of excluded pages and implode it for the SQL query |
514 | 514 | $exclude_pages_placeholders = implode(',', array_fill(0, count($exclude_pages), '%d')); |
515 | 515 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | "; |
524 | 524 | |
525 | 525 | // Add the exclusion if there are pages to exclude |
526 | - if ( ! empty( $exclude_pages ) ) { |
|
526 | + if (!empty($exclude_pages)) { |
|
527 | 527 | $sql .= " AND ID NOT IN ($exclude_pages_placeholders)"; |
528 | 528 | } |
529 | 529 | |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | $sql .= " ORDER BY post_title ASC"; |
532 | 532 | |
533 | 533 | // Add a sanity limit |
534 | - $limit = absint( apply_filters('wpinv_get_pages_limit',500) ); |
|
534 | + $limit = absint(apply_filters('wpinv_get_pages_limit', 500)); |
|
535 | 535 | $sql .= " LIMIT " . absint($limit); |
536 | 536 | |
537 | 537 | // Prepare the SQL query to include the excluded pages only if we have placeholders |
538 | - $pages = $exclude_pages_placeholders ? $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) ) : $wpdb->get_results( $sql ); |
|
538 | + $pages = $exclude_pages_placeholders ? $wpdb->get_results($wpdb->prepare($sql, ...$exclude_pages)) : $wpdb->get_results($sql); |
|
539 | 539 | |
540 | 540 | $pages_options = array(); |
541 | 541 | |
542 | - if ( $pages ) { |
|
543 | - foreach ( $pages as $page ) { |
|
542 | + if ($pages) { |
|
543 | + foreach ($pages as $page) { |
|
544 | 544 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
545 | - $pages_options[ $page->ID ] = $title; |
|
545 | + $pages_options[$page->ID] = $title; |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
@@ -550,162 +550,162 @@ discard block |
||
550 | 550 | |
551 | 551 | $gp_tmpl_page_options = $pages_options; |
552 | 552 | |
553 | - if ( $default_label !== null && $default_label !== false ) { |
|
554 | - $pages_options = array( '' => $default_label ) + $pages_options; // Blank option |
|
553 | + if ($default_label !== null && $default_label !== false) { |
|
554 | + $pages_options = array('' => $default_label) + $pages_options; // Blank option |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return $pages_options; |
558 | 558 | } |
559 | 559 | |
560 | -function wpinv_header_callback( $args ) { |
|
561 | - if ( ! empty( $args['desc'] ) ) { |
|
562 | - echo wp_kses_post( $args['desc'] ); |
|
560 | +function wpinv_header_callback($args) { |
|
561 | + if (!empty($args['desc'])) { |
|
562 | + echo wp_kses_post($args['desc']); |
|
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
566 | -function wpinv_hidden_callback( $args ) { |
|
566 | +function wpinv_hidden_callback($args) { |
|
567 | 567 | |
568 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
569 | - $value = wpinv_get_option( $args['id'], $std ); |
|
568 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
569 | + $value = wpinv_get_option($args['id'], $std); |
|
570 | 570 | |
571 | - if ( isset( $args['set_value'] ) ) { |
|
571 | + if (isset($args['set_value'])) { |
|
572 | 572 | $value = $args['set_value']; |
573 | 573 | } |
574 | 574 | |
575 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
575 | + if (isset($args['faux']) && true === $args['faux']) { |
|
576 | 576 | $args['readonly'] = true; |
577 | - $name = ''; |
|
577 | + $name = ''; |
|
578 | 578 | } else { |
579 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
579 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
580 | 580 | } |
581 | 581 | |
582 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
582 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
587 | 587 | * Displays a checkbox settings callback. |
588 | 588 | */ |
589 | -function wpinv_checkbox_callback( $args ) { |
|
589 | +function wpinv_checkbox_callback($args) { |
|
590 | 590 | |
591 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
592 | - $std = wpinv_get_option( $args['id'], $std ); |
|
593 | - $id = esc_attr( $args['id'] ); |
|
591 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
592 | + $std = wpinv_get_option($args['id'], $std); |
|
593 | + $id = esc_attr($args['id']); |
|
594 | 594 | |
595 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
595 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
596 | 596 | ?> |
597 | 597 | <label> |
598 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" /> |
|
599 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
598 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox" /> |
|
599 | + <?php echo wp_kses_post($args['desc']); ?> |
|
600 | 600 | </label> |
601 | 601 | <?php |
602 | 602 | } |
603 | 603 | |
604 | -function wpinv_multicheck_callback( $args ) { |
|
604 | +function wpinv_multicheck_callback($args) { |
|
605 | 605 | |
606 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
607 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
606 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
607 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
608 | 608 | |
609 | - if ( ! empty( $args['options'] ) ) { |
|
609 | + if (!empty($args['options'])) { |
|
610 | 610 | |
611 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
612 | - $value = wpinv_get_option( $args['id'], $std ); |
|
611 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
612 | + $value = wpinv_get_option($args['id'], $std); |
|
613 | 613 | |
614 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
615 | - foreach ( $args['options'] as $key => $option ) : |
|
616 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
617 | - if ( in_array( $sanitize_key, $value ) ) { |
|
614 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
615 | + foreach ($args['options'] as $key => $option) : |
|
616 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
617 | + if (in_array($sanitize_key, $value)) { |
|
618 | 618 | $enabled = $sanitize_key; |
619 | 619 | } else { |
620 | 620 | $enabled = null; |
621 | 621 | } |
622 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
623 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
622 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
623 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
624 | 624 | endforeach; |
625 | 625 | echo '</div>'; |
626 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
626 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
630 | -function wpinv_payment_icons_callback( $args ) { |
|
630 | +function wpinv_payment_icons_callback($args) { |
|
631 | 631 | |
632 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
633 | - $value = wpinv_get_option( $args['id'], false ); |
|
632 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
633 | + $value = wpinv_get_option($args['id'], false); |
|
634 | 634 | |
635 | - if ( ! empty( $args['options'] ) ) { |
|
636 | - foreach ( $args['options'] as $key => $option ) { |
|
637 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
635 | + if (!empty($args['options'])) { |
|
636 | + foreach ($args['options'] as $key => $option) { |
|
637 | + $sanitize_key = wpinv_sanitize_key($key); |
|
638 | 638 | |
639 | - if ( empty( $value ) ) { |
|
639 | + if (empty($value)) { |
|
640 | 640 | $enabled = $option; |
641 | 641 | } else { |
642 | 642 | $enabled = null; |
643 | 643 | } |
644 | 644 | |
645 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
645 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
646 | 646 | |
647 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
647 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
648 | 648 | |
649 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
650 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
649 | + if (wpinv_string_is_image_url($key)) { |
|
650 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
651 | 651 | } else { |
652 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
652 | + $card = strtolower(str_replace(' ', '', $option)); |
|
653 | 653 | |
654 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
655 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
654 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
655 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
656 | 656 | } else { |
657 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
657 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
658 | 658 | $content_dir = WP_CONTENT_DIR; |
659 | 659 | |
660 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
660 | + if (function_exists('wp_normalize_path')) { |
|
661 | 661 | // Replaces backslashes with forward slashes for Windows systems |
662 | - $image = wp_normalize_path( $image ); |
|
663 | - $content_dir = wp_normalize_path( $content_dir ); |
|
662 | + $image = wp_normalize_path($image); |
|
663 | + $content_dir = wp_normalize_path($content_dir); |
|
664 | 664 | } |
665 | 665 | |
666 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
666 | + $image = str_replace($content_dir, content_url(), $image); |
|
667 | 667 | } |
668 | 668 | |
669 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
669 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
670 | 670 | } |
671 | - echo wp_kses_post( $option ) . '</label>'; |
|
671 | + echo wp_kses_post($option) . '</label>'; |
|
672 | 672 | } |
673 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
673 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
678 | 678 | * Displays a radio settings field. |
679 | 679 | */ |
680 | -function wpinv_radio_callback( $args ) { |
|
680 | +function wpinv_radio_callback($args) { |
|
681 | 681 | |
682 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
683 | - $std = wpinv_get_option( $args['id'], $std ); |
|
682 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
683 | + $std = wpinv_get_option($args['id'], $std); |
|
684 | 684 | ?> |
685 | 685 | <fieldset> |
686 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
687 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
686 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
687 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
688 | 688 | <li> |
689 | 689 | <label> |
690 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
691 | - <?php echo wp_kses_post( $option ); ?> |
|
690 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
691 | + <?php echo wp_kses_post($option); ?> |
|
692 | 692 | </label> |
693 | 693 | </li> |
694 | 694 | <?php endforeach; ?> |
695 | 695 | </ul> |
696 | 696 | </fieldset> |
697 | 697 | <?php |
698 | - getpaid_settings_description_callback( $args ); |
|
698 | + getpaid_settings_description_callback($args); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | 702 | * Displays a description if available. |
703 | 703 | */ |
704 | -function getpaid_settings_description_callback( $args ) { |
|
704 | +function getpaid_settings_description_callback($args) { |
|
705 | 705 | |
706 | - if ( ! empty( $args['desc'] ) ) { |
|
706 | + if (!empty($args['desc'])) { |
|
707 | 707 | $description = $args['desc']; |
708 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
708 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | } |
@@ -720,35 +720,35 @@ discard block |
||
720 | 720 | </tr> |
721 | 721 | <tr class="bsui"> |
722 | 722 | <td colspan="2" class="p-0"> |
723 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
723 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
724 | 724 | |
725 | 725 | <?php |
726 | 726 | } |
727 | 727 | |
728 | -function wpinv_gateway_select_callback( $args ) { |
|
728 | +function wpinv_gateway_select_callback($args) { |
|
729 | 729 | |
730 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
731 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
732 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
733 | - $value = wpinv_get_option( $args['id'], $std ); |
|
730 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
731 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
732 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
733 | + $value = wpinv_get_option($args['id'], $std); |
|
734 | 734 | |
735 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
735 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
736 | 736 | |
737 | - foreach ( $args['options'] as $key => $option ) : |
|
737 | + foreach ($args['options'] as $key => $option) : |
|
738 | 738 | |
739 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
739 | + echo '<option value="' . esc_attr($key) . '" '; |
|
740 | 740 | |
741 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
742 | - selected( $key, $args['selected'] ); |
|
741 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
742 | + selected($key, $args['selected']); |
|
743 | 743 | } else { |
744 | - selected( $key, $value ); |
|
744 | + selected($key, $value); |
|
745 | 745 | } |
746 | 746 | |
747 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
747 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
748 | 748 | endforeach; |
749 | 749 | |
750 | 750 | echo '</select>'; |
751 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
751 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
@@ -757,16 +757,16 @@ discard block |
||
757 | 757 | * @param array $args |
758 | 758 | * @return string |
759 | 759 | */ |
760 | -function wpinv_settings_attrs_helper( $args ) { |
|
760 | +function wpinv_settings_attrs_helper($args) { |
|
761 | 761 | |
762 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
763 | - $id = esc_attr( $args['id'] ); |
|
764 | - $value = is_scalar( $value ) ? $value : ''; |
|
762 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
763 | + $id = esc_attr($args['id']); |
|
764 | + $value = is_scalar($value) ? $value : ''; |
|
765 | 765 | |
766 | 766 | $attrs = array( |
767 | - 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
768 | - 'readonly' => ! empty( $args['faux'] ), |
|
769 | - 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
767 | + 'name' => !empty($args['faux']) ? false : "wpinv_settings[$id]", |
|
768 | + 'readonly' => !empty($args['faux']), |
|
769 | + 'value' => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value), |
|
770 | 770 | 'id' => 'wpinv-settings-' . $args['id'], |
771 | 771 | 'style' => $args['style'], |
772 | 772 | 'class' => $args['class'], |
@@ -774,20 +774,20 @@ discard block |
||
774 | 774 | 'data-placeholder' => $args['placeholder'], |
775 | 775 | ); |
776 | 776 | |
777 | - if ( ! empty( $args['onchange'] ) ) { |
|
777 | + if (!empty($args['onchange'])) { |
|
778 | 778 | $attrs['onchange'] = $args['onchange']; |
779 | 779 | } |
780 | 780 | |
781 | - foreach ( $attrs as $key => $value ) { |
|
781 | + foreach ($attrs as $key => $value) { |
|
782 | 782 | |
783 | - if ( false === $value ) { |
|
783 | + if (false === $value) { |
|
784 | 784 | continue; |
785 | 785 | } |
786 | 786 | |
787 | - if ( true === $value ) { |
|
788 | - echo ' ' . esc_attr( $key ); |
|
787 | + if (true === $value) { |
|
788 | + echo ' ' . esc_attr($key); |
|
789 | 789 | } else { |
790 | - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
790 | + echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | } |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | /** |
798 | 798 | * Displays a text input settings callback. |
799 | 799 | */ |
800 | -function wpinv_text_callback( $args ) { |
|
800 | +function wpinv_text_callback($args) { |
|
801 | 801 | |
802 | 802 | ?> |
803 | 803 | <label style="width: 100%;"> |
804 | - <input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
805 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
804 | + <input type="text" <?php wpinv_settings_attrs_helper($args); ?>> |
|
805 | + <?php getpaid_settings_description_callback($args); ?> |
|
806 | 806 | </label> |
807 | 807 | <?php |
808 | 808 | |
@@ -811,174 +811,174 @@ discard block |
||
811 | 811 | /** |
812 | 812 | * Displays a number input settings callback. |
813 | 813 | */ |
814 | -function wpinv_number_callback( $args ) { |
|
814 | +function wpinv_number_callback($args) { |
|
815 | 815 | |
816 | 816 | ?> |
817 | 817 | <label style="width: 100%;"> |
818 | - <input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
819 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
818 | + <input type="number" step="<?php echo esc_attr($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>> |
|
819 | + <?php getpaid_settings_description_callback($args); ?> |
|
820 | 820 | </label> |
821 | 821 | <?php |
822 | 822 | |
823 | 823 | } |
824 | 824 | |
825 | -function wpinv_textarea_callback( $args ) { |
|
825 | +function wpinv_textarea_callback($args) { |
|
826 | 826 | |
827 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
828 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
829 | - $value = wpinv_get_option( $args['id'], $std ); |
|
827 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
828 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
829 | + $value = wpinv_get_option($args['id'], $std); |
|
830 | 830 | |
831 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
832 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
831 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
832 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
833 | 833 | |
834 | - echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
835 | - echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
834 | + echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
835 | + echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | -function wpinv_password_callback( $args ) { |
|
839 | +function wpinv_password_callback($args) { |
|
840 | 840 | |
841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
842 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
843 | - $value = wpinv_get_option( $args['id'], $std ); |
|
841 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
842 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
843 | + $value = wpinv_get_option($args['id'], $std); |
|
844 | 844 | |
845 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
846 | - echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
847 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
845 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
846 | + echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
847 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
848 | 848 | |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_missing_callback( $args ) { |
|
851 | +function wpinv_missing_callback($args) { |
|
852 | 852 | printf( |
853 | - esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
854 | - '<strong>' . esc_html( $args['id'] ) . '</strong>' |
|
853 | + esc_html__('The callback function used for the %s setting is missing.', 'invoicing'), |
|
854 | + '<strong>' . esc_html($args['id']) . '</strong>' |
|
855 | 855 | ); |
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | 859 | * Displays a number input settings callback. |
860 | 860 | */ |
861 | -function wpinv_select_callback( $args ) { |
|
861 | +function wpinv_select_callback($args) { |
|
862 | 862 | |
863 | - $desc = wp_kses_post( $args['desc'] ); |
|
864 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
865 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
866 | - $value = wpinv_get_option( $args['id'], $value ); |
|
867 | - $rand = uniqid( 'random_id' ); |
|
863 | + $desc = wp_kses_post($args['desc']); |
|
864 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
865 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
866 | + $value = wpinv_get_option($args['id'], $value); |
|
867 | + $rand = uniqid('random_id'); |
|
868 | 868 | |
869 | 869 | ?> |
870 | 870 | <label style="width: 100%;"> |
871 | - <select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true"> |
|
872 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
873 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option> |
|
871 | + <select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true"> |
|
872 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
873 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option> |
|
874 | 874 | <?php endforeach; ?> |
875 | 875 | </select> |
876 | 876 | |
877 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
878 | - <a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
877 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
878 | + <a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
879 | 879 | <?php endif; ?> |
880 | 880 | |
881 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
882 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
883 | - <div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'> |
|
881 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
882 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
883 | + <div id='<?php echo esc_attr($rand); ?>' style='display:none;'> |
|
884 | 884 | <div> |
885 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
886 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea> |
|
887 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
888 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea> |
|
885 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
886 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea> |
|
887 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
888 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea> |
|
889 | 889 | </div> |
890 | 890 | </div> |
891 | 891 | <?php endif; ?> |
892 | 892 | |
893 | - <?php echo wp_kses_post( $desc ); ?> |
|
893 | + <?php echo wp_kses_post($desc); ?> |
|
894 | 894 | </label> |
895 | 895 | <?php |
896 | 896 | |
897 | 897 | } |
898 | 898 | |
899 | -function wpinv_color_select_callback( $args ) { |
|
899 | +function wpinv_color_select_callback($args) { |
|
900 | 900 | |
901 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
902 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
903 | - $value = wpinv_get_option( $args['id'], $std ); |
|
901 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
902 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
903 | + $value = wpinv_get_option($args['id'], $std); |
|
904 | 904 | |
905 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
905 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
906 | 906 | |
907 | - foreach ( $args['options'] as $option => $color ) { |
|
908 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
907 | + foreach ($args['options'] as $option => $color) { |
|
908 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | echo '</select>'; |
912 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
912 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | -function wpinv_rich_editor_callback( $args ) { |
|
916 | +function wpinv_rich_editor_callback($args) { |
|
917 | 917 | global $wp_version; |
918 | 918 | |
919 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
919 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
920 | 920 | |
921 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
922 | - $value = wpinv_get_option( $args['id'], $std ); |
|
921 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
922 | + $value = wpinv_get_option($args['id'], $std); |
|
923 | 923 | |
924 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
924 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
925 | 925 | $value = $std; |
926 | 926 | } |
927 | 927 | |
928 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
928 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
929 | 929 | |
930 | 930 | echo '<div class="getpaid-settings-editor-input">'; |
931 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
931 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
932 | 932 | wp_editor( |
933 | - stripslashes( $value ), |
|
934 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
933 | + stripslashes($value), |
|
934 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
935 | 935 | array( |
936 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
937 | - 'textarea_rows' => absint( $rows ), |
|
936 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
937 | + 'textarea_rows' => absint($rows), |
|
938 | 938 | 'media_buttons' => false, |
939 | 939 | ) |
940 | 940 | ); |
941 | 941 | } else { |
942 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
942 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
943 | 943 | } |
944 | 944 | |
945 | - echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
945 | + echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
946 | 946 | |
947 | 947 | } |
948 | 948 | |
949 | -function wpinv_upload_callback( $args ) { |
|
949 | +function wpinv_upload_callback($args) { |
|
950 | 950 | |
951 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
951 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
952 | 952 | |
953 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
954 | - $value = wpinv_get_option( $args['id'], $std ); |
|
953 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
954 | + $value = wpinv_get_option($args['id'], $std); |
|
955 | 955 | |
956 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
957 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
958 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
959 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
956 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
957 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
958 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>'; |
|
959 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
960 | 960 | |
961 | 961 | } |
962 | 962 | |
963 | -function wpinv_color_callback( $args ) { |
|
963 | +function wpinv_color_callback($args) { |
|
964 | 964 | |
965 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
966 | - $value = wpinv_get_option( $args['id'], $std ); |
|
967 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
965 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
966 | + $value = wpinv_get_option($args['id'], $std); |
|
967 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
968 | 968 | |
969 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
970 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
969 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
970 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
971 | 971 | |
972 | 972 | } |
973 | 973 | |
974 | -function wpinv_country_states_callback( $args ) { |
|
974 | +function wpinv_country_states_callback($args) { |
|
975 | 975 | |
976 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
977 | - $value = wpinv_get_option( $args['id'], $std ); |
|
976 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
977 | + $value = wpinv_get_option($args['id'], $std); |
|
978 | 978 | |
979 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
979 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
980 | 980 | |
981 | - if ( isset( $args['placeholder'] ) ) { |
|
981 | + if (isset($args['placeholder'])) { |
|
982 | 982 | $placeholder = $args['placeholder']; |
983 | 983 | } else { |
984 | 984 | $placeholder = ''; |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | $states = wpinv_get_country_states(); |
988 | 988 | |
989 | - $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2'; |
|
990 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
989 | + $class = empty($states) ? 'wpinv-no-states' : 'wpi_select2'; |
|
990 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
991 | 991 | |
992 | - foreach ( $states as $option => $name ) { |
|
993 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
992 | + foreach ($states as $option => $name) { |
|
993 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | echo '</select>'; |
997 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
997 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
998 | 998 | |
999 | 999 | } |
1000 | 1000 | |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | </tr> |
1009 | 1009 | <tr class="bsui"> |
1010 | 1010 | <td colspan="2" class="p-0"> |
1011 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
1011 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
1012 | 1012 | |
1013 | 1013 | <?php |
1014 | 1014 | |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | /** |
1018 | 1018 | * Displays a tax rate' edit row. |
1019 | 1019 | */ |
1020 | -function wpinv_tax_rate_callback( $tax_rate, $key ) { |
|
1020 | +function wpinv_tax_rate_callback($tax_rate, $key) { |
|
1021 | 1021 | |
1022 | - $key = sanitize_key( $key ); |
|
1023 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
1024 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
1022 | + $key = sanitize_key($key); |
|
1023 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
1024 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
1025 | 1025 | |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1035,187 +1035,187 @@ discard block |
||
1035 | 1035 | </tr> |
1036 | 1036 | <tr class="bsui"> |
1037 | 1037 | <td colspan="2" class="p-0"> |
1038 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rules-edit.php'; ?> |
|
1038 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rules-edit.php'; ?> |
|
1039 | 1039 | |
1040 | 1040 | <?php |
1041 | 1041 | |
1042 | 1042 | } |
1043 | 1043 | |
1044 | -function wpinv_tools_callback( $args ) { |
|
1044 | +function wpinv_tools_callback($args) { |
|
1045 | 1045 | ?> |
1046 | 1046 | </td><tr> |
1047 | 1047 | <td colspan="2" class="wpinv_tools_tdbox"> |
1048 | 1048 | <?php |
1049 | - if ( $args['desc'] ) { |
|
1049 | + if ($args['desc']) { |
|
1050 | 1050 | ?> |
1051 | -<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?> |
|
1052 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1051 | +<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?> |
|
1052 | + <?php do_action('wpinv_tools_before'); ?> |
|
1053 | 1053 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1054 | 1054 | <thead> |
1055 | 1055 | <tr> |
1056 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
1057 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
1058 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
1056 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
1057 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
1058 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
1059 | 1059 | </tr> |
1060 | 1060 | </thead> |
1061 | 1061 | |
1062 | 1062 | <tbody> |
1063 | 1063 | <tr> |
1064 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
1064 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
1065 | 1065 | <td> |
1066 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
1066 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
1067 | 1067 | </td> |
1068 | 1068 | <td> |
1069 | 1069 | <a href=" |
1070 | 1070 | <?php |
1071 | 1071 | echo esc_url( |
1072 | 1072 | wp_nonce_url( |
1073 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
1073 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
1074 | 1074 | 'getpaid-nonce', |
1075 | 1075 | 'getpaid-nonce' |
1076 | 1076 | ) |
1077 | 1077 | ); |
1078 | 1078 | ?> |
1079 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1079 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1080 | 1080 | </td> |
1081 | 1081 | </tr> |
1082 | 1082 | <tr> |
1083 | - <td><?php esc_html_e( 'Refresh Permalinks', 'invoicing' ); ?></td> |
|
1083 | + <td><?php esc_html_e('Refresh Permalinks', 'invoicing'); ?></td> |
|
1084 | 1084 | <td> |
1085 | - <small><?php esc_html_e( 'Might fix the page not found error when viewing an invoice.', 'invoicing' ); ?></small> |
|
1085 | + <small><?php esc_html_e('Might fix the page not found error when viewing an invoice.', 'invoicing'); ?></small> |
|
1086 | 1086 | </td> |
1087 | 1087 | <td> |
1088 | 1088 | <a href=" |
1089 | 1089 | <?php |
1090 | 1090 | echo esc_url( |
1091 | 1091 | wp_nonce_url( |
1092 | - add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ), |
|
1092 | + add_query_arg('getpaid-admin-action', 'refresh_permalinks'), |
|
1093 | 1093 | 'getpaid-nonce', |
1094 | 1094 | 'getpaid-nonce' |
1095 | 1095 | ) |
1096 | 1096 | ); |
1097 | 1097 | ?> |
1098 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1098 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1099 | 1099 | </td> |
1100 | 1100 | </tr> |
1101 | 1101 | <tr> |
1102 | - <td><?php esc_html_e( 'Repair Database Tables', 'invoicing' ); ?></td> |
|
1102 | + <td><?php esc_html_e('Repair Database Tables', 'invoicing'); ?></td> |
|
1103 | 1103 | <td> |
1104 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
1104 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
1105 | 1105 | </td> |
1106 | 1106 | <td> |
1107 | 1107 | <a href=" |
1108 | 1108 | <?php |
1109 | 1109 | echo esc_url( |
1110 | 1110 | wp_nonce_url( |
1111 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1111 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1112 | 1112 | 'getpaid-nonce', |
1113 | 1113 | 'getpaid-nonce' |
1114 | 1114 | ) |
1115 | 1115 | ); |
1116 | 1116 | ?> |
1117 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1117 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1118 | 1118 | </td> |
1119 | 1119 | </tr> |
1120 | 1120 | <tr> |
1121 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1121 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1122 | 1122 | <td> |
1123 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1123 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1124 | 1124 | </td> |
1125 | 1125 | <td> |
1126 | 1126 | <a href=" |
1127 | 1127 | <?php |
1128 | 1128 | echo esc_url( |
1129 | 1129 | wp_nonce_url( |
1130 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1130 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1131 | 1131 | 'getpaid-nonce', |
1132 | 1132 | 'getpaid-nonce' |
1133 | 1133 | ) |
1134 | 1134 | ); |
1135 | 1135 | ?> |
1136 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1136 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1137 | 1137 | </td> |
1138 | 1138 | </tr> |
1139 | 1139 | |
1140 | 1140 | <tr> |
1141 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1141 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1142 | 1142 | <td> |
1143 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1143 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1144 | 1144 | </td> |
1145 | 1145 | <td> |
1146 | 1146 | <a href=" |
1147 | 1147 | <?php |
1148 | 1148 | echo esc_url( |
1149 | 1149 | wp_nonce_url( |
1150 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1150 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1151 | 1151 | 'getpaid-nonce', |
1152 | 1152 | 'getpaid-nonce' |
1153 | 1153 | ) |
1154 | 1154 | ); |
1155 | 1155 | ?> |
1156 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1156 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1157 | 1157 | </td> |
1158 | 1158 | </tr> |
1159 | 1159 | |
1160 | 1160 | <tr> |
1161 | - <td><?php esc_html_e( 'Database Text Translation', 'invoicing' ); ?></td> |
|
1161 | + <td><?php esc_html_e('Database Text Translation', 'invoicing'); ?></td> |
|
1162 | 1162 | <td> |
1163 | - <small><?php esc_html_e( 'This tool will collect any strings stored in the database and put them in the file db-language.php, so those strings can be used to translate by translation tools.', 'invoicing' ); ?></small> |
|
1163 | + <small><?php esc_html_e('This tool will collect any strings stored in the database and put them in the file db-language.php, so those strings can be used to translate by translation tools.', 'invoicing'); ?></small> |
|
1164 | 1164 | </td> |
1165 | 1165 | <td> |
1166 | - <a href=" <?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'translate_db_texts' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1166 | + <a href=" <?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'translate_db_texts'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1167 | 1167 | </td> |
1168 | 1168 | </tr> |
1169 | 1169 | |
1170 | 1170 | <tr> |
1171 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1171 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1172 | 1172 | <td> |
1173 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1173 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1174 | 1174 | </td> |
1175 | 1175 | <td> |
1176 | 1176 | <a href=" |
1177 | 1177 | <?php |
1178 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1178 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1179 | 1179 | ?> |
1180 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1180 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1181 | 1181 | </td> |
1182 | 1182 | </tr> |
1183 | 1183 | |
1184 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1184 | + <?php do_action('wpinv_tools_row'); ?> |
|
1185 | 1185 | </tbody> |
1186 | 1186 | </table> |
1187 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1187 | + <?php do_action('wpinv_tools_after'); ?> |
|
1188 | 1188 | <?php |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | |
1192 | -function wpinv_descriptive_text_callback( $args ) { |
|
1193 | - echo wp_kses_post( $args['desc'] ); |
|
1192 | +function wpinv_descriptive_text_callback($args) { |
|
1193 | + echo wp_kses_post($args['desc']); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | -function wpinv_raw_html_callback( $args ) { |
|
1197 | - echo wp_kses( $args['desc'], getpaid_allowed_html() ); |
|
1196 | +function wpinv_raw_html_callback($args) { |
|
1197 | + echo wp_kses($args['desc'], getpaid_allowed_html()); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | -function wpinv_hook_callback( $args ) { |
|
1201 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1200 | +function wpinv_hook_callback($args) { |
|
1201 | + do_action('wpinv_' . $args['id'], $args); |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | function wpinv_set_settings_cap() { |
1205 | 1205 | return wpinv_get_capability(); |
1206 | 1206 | } |
1207 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1207 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1208 | 1208 | |
1209 | 1209 | |
1210 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1211 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1212 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1210 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1211 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1212 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1213 | 1213 | |
1214 | - if ( $old != $new ) { |
|
1215 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1214 | + if ($old != $new) { |
|
1215 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1216 | 1216 | } |
1217 | 1217 | } |
1218 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1218 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | /** |
@@ -1227,43 +1227,43 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return array |
1229 | 1229 | */ |
1230 | -function wpinv_get_email_merge_tags( $subscription = false ) { |
|
1230 | +function wpinv_get_email_merge_tags($subscription = false) { |
|
1231 | 1231 | $merge_tags = array( |
1232 | - '{site_title}' => __( 'Site Title', 'invoicing' ), |
|
1233 | - '{name}' => __( "Customer's full name", 'invoicing' ), |
|
1234 | - '{first_name}' => __( "Customer's first name", 'invoicing' ), |
|
1235 | - '{last_name}' => __( "Customer's last name", 'invoicing' ), |
|
1236 | - '{email}' => __( "Customer's email address", 'invoicing' ), |
|
1237 | - '{invoice_number}' => __( 'The invoice number', 'invoicing' ), |
|
1238 | - '{invoice_currency}' => __( 'The invoice currency', 'invoicing' ), |
|
1239 | - '{invoice_total}' => __( 'The invoice total', 'invoicing' ), |
|
1240 | - '{invoice_link}' => __( 'The invoice link', 'invoicing' ), |
|
1241 | - '{invoice_pay_link}' => __( 'The payment link', 'invoicing' ), |
|
1242 | - '{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ), |
|
1243 | - '{invoice_date}' => __( 'The date the invoice was created', 'invoicing' ), |
|
1244 | - '{invoice_due_date}' => __( 'The date the invoice is due', 'invoicing' ), |
|
1245 | - '{date}' => __( "Today's date", 'invoicing' ), |
|
1246 | - '{is_was}' => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ), |
|
1247 | - '{invoice_label}' => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ), |
|
1248 | - '{invoice_quote}' => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ), |
|
1249 | - '{invoice_description}' => __( 'The description of the invoice', 'invoicing' ), |
|
1232 | + '{site_title}' => __('Site Title', 'invoicing'), |
|
1233 | + '{name}' => __("Customer's full name", 'invoicing'), |
|
1234 | + '{first_name}' => __("Customer's first name", 'invoicing'), |
|
1235 | + '{last_name}' => __("Customer's last name", 'invoicing'), |
|
1236 | + '{email}' => __("Customer's email address", 'invoicing'), |
|
1237 | + '{invoice_number}' => __('The invoice number', 'invoicing'), |
|
1238 | + '{invoice_currency}' => __('The invoice currency', 'invoicing'), |
|
1239 | + '{invoice_total}' => __('The invoice total', 'invoicing'), |
|
1240 | + '{invoice_link}' => __('The invoice link', 'invoicing'), |
|
1241 | + '{invoice_pay_link}' => __('The payment link', 'invoicing'), |
|
1242 | + '{invoice_receipt_link}' => __('The receipt link', 'invoicing'), |
|
1243 | + '{invoice_date}' => __('The date the invoice was created', 'invoicing'), |
|
1244 | + '{invoice_due_date}' => __('The date the invoice is due', 'invoicing'), |
|
1245 | + '{date}' => __("Today's date", 'invoicing'), |
|
1246 | + '{is_was}' => __('If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing'), |
|
1247 | + '{invoice_label}' => __('Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing'), |
|
1248 | + '{invoice_quote}' => __('Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing'), |
|
1249 | + '{invoice_description}' => __('The description of the invoice', 'invoicing'), |
|
1250 | 1250 | ); |
1251 | 1251 | |
1252 | - if ( $subscription ) { |
|
1252 | + if ($subscription) { |
|
1253 | 1253 | $merge_tags = array_merge( |
1254 | 1254 | $merge_tags, |
1255 | 1255 | array( |
1256 | - '{subscription_renewal_date}' => __( 'The next renewal date of the subscription', 'invoicing' ), |
|
1257 | - '{subscription_created}' => __( "The subscription's creation date", 'invoicing' ), |
|
1258 | - '{subscription_status}' => __( "The subscription's status", 'invoicing' ), |
|
1259 | - '{subscription_profile_id}' => __( "The subscription's remote profile id", 'invoicing' ), |
|
1260 | - '{subscription_id}' => __( "The subscription's id", 'invoicing' ), |
|
1261 | - '{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ), |
|
1262 | - '{subscription_initial_amount}' => __( 'The initial amount of the subscription', 'invoicing' ), |
|
1263 | - '{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ), |
|
1264 | - '{subscription_bill_times}' => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ), |
|
1265 | - '{subscription_url}' => __( 'The URL to manage a subscription', 'invoicing' ), |
|
1266 | - '{subscription_name}' => __( 'The name of the recurring item', 'invoicing' ), |
|
1256 | + '{subscription_renewal_date}' => __('The next renewal date of the subscription', 'invoicing'), |
|
1257 | + '{subscription_created}' => __("The subscription's creation date", 'invoicing'), |
|
1258 | + '{subscription_status}' => __("The subscription's status", 'invoicing'), |
|
1259 | + '{subscription_profile_id}' => __("The subscription's remote profile id", 'invoicing'), |
|
1260 | + '{subscription_id}' => __("The subscription's id", 'invoicing'), |
|
1261 | + '{subscription_recurring_amount}' => __('The renewal amount of the subscription', 'invoicing'), |
|
1262 | + '{subscription_initial_amount}' => __('The initial amount of the subscription', 'invoicing'), |
|
1263 | + '{subscription_recurring_period}' => __('The recurring period of the subscription (e.g 1 year)', 'invoicing'), |
|
1264 | + '{subscription_bill_times}' => __('The maximum number of times the subscription can be renewed', 'invoicing'), |
|
1265 | + '{subscription_url}' => __('The URL to manage a subscription', 'invoicing'), |
|
1266 | + '{subscription_name}' => __('The name of the recurring item', 'invoicing'), |
|
1267 | 1267 | ) |
1268 | 1268 | ); |
1269 | 1269 | } |
@@ -1279,25 +1279,25 @@ discard block |
||
1279 | 1279 | * |
1280 | 1280 | * @return string |
1281 | 1281 | */ |
1282 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1283 | - $merge_tags = wpinv_get_email_merge_tags( $subscription ); |
|
1282 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1283 | + $merge_tags = wpinv_get_email_merge_tags($subscription); |
|
1284 | 1284 | |
1285 | 1285 | $output = '<div class="bsui">'; |
1286 | 1286 | |
1287 | 1287 | $link = sprintf( |
1288 | 1288 | '<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>', |
1289 | - esc_html__( 'View available merge tags.', 'invoicing' ) |
|
1289 | + esc_html__('View available merge tags.', 'invoicing') |
|
1290 | 1290 | ); |
1291 | 1291 | |
1292 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1292 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1293 | 1293 | |
1294 | 1294 | $output .= "$description $link"; |
1295 | 1295 | |
1296 | 1296 | $output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">'; |
1297 | - $output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>'; |
|
1297 | + $output .= '<p class="mb-2">' . esc_html__('The following wildcards can be used in email subjects, heading and content:', 'invoicing') . '</p>'; |
|
1298 | 1298 | |
1299 | 1299 | $output .= '<ul class="p-0 m-0">'; |
1300 | - foreach($merge_tags as $tag => $tag_description) { |
|
1300 | + foreach ($merge_tags as $tag => $tag_description) { |
|
1301 | 1301 | $output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> — $tag_description</li>"; |
1302 | 1302 | } |
1303 | 1303 |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway { |
14 | 14 | |
15 | 15 | /** |
16 | - * Payment method id. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Payment method id. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id = 'bank_transfer'; |
21 | 21 | |
22 | - /** |
|
23 | - * An array of features that this gateway supports. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected $supports = array( |
|
28 | - 'subscription', |
|
29 | - 'addons', |
|
30 | - 'single_subscription_group', |
|
31 | - 'multiple_subscription_groups', |
|
32 | - 'subscription_date_change', |
|
33 | - 'subscription_bill_times_change', |
|
34 | - ); |
|
22 | + /** |
|
23 | + * An array of features that this gateway supports. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected $supports = array( |
|
28 | + 'subscription', |
|
29 | + 'addons', |
|
30 | + 'single_subscription_group', |
|
31 | + 'multiple_subscription_groups', |
|
32 | + 'subscription_date_change', |
|
33 | + 'subscription_bill_times_change', |
|
34 | + ); |
|
35 | + |
|
36 | + /** |
|
37 | + * Payment method order. |
|
38 | + * |
|
39 | + * @var int |
|
40 | + */ |
|
41 | + public $order = 8; |
|
42 | + |
|
43 | + /** |
|
44 | + * Bank transfer instructions. |
|
45 | + */ |
|
46 | + public $instructions; |
|
35 | 47 | |
36 | 48 | /** |
37 | - * Payment method order. |
|
38 | - * |
|
39 | - * @var int |
|
40 | - */ |
|
41 | - public $order = 8; |
|
42 | - |
|
43 | - /** |
|
44 | - * Bank transfer instructions. |
|
45 | - */ |
|
46 | - public $instructions; |
|
47 | - |
|
48 | - /** |
|
49 | - * Locale array. |
|
50 | - */ |
|
51 | - public $locale; |
|
49 | + * Locale array. |
|
50 | + */ |
|
51 | + public $locale; |
|
52 | 52 | |
53 | 53 | /** |
54 | - * Class constructor. |
|
55 | - */ |
|
56 | - public function __construct() { |
|
54 | + * Class constructor. |
|
55 | + */ |
|
56 | + public function __construct() { |
|
57 | 57 | parent::__construct(); |
58 | 58 | |
59 | 59 | $this->title = __( 'Direct bank transfer', 'invoicing' ); |
@@ -61,43 +61,43 @@ discard block |
||
61 | 61 | $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
62 | 62 | $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
63 | 63 | |
64 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
65 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
66 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
67 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
68 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 ); |
|
69 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
70 | - |
|
71 | - add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
72 | - add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
73 | - add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Check gateway supports for subscription. |
|
78 | - * |
|
79 | - * @since 2.8.24 |
|
80 | - * |
|
81 | - * @param bool $supports True if supports else False. |
|
82 | - * @return bool True if supports else False. |
|
83 | - */ |
|
84 | - public function supports_subscription( $supports ) { |
|
85 | - if ( $supports && (int) $this->get_option( 'no_subscription' ) ) { |
|
86 | - $supports = false; |
|
87 | - } |
|
88 | - |
|
89 | - return $supports; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Process Payment. |
|
94 | - * |
|
95 | - * @param WPInv_Invoice $invoice Invoice. |
|
96 | - * @param array $submission_data Posted checkout fields. |
|
97 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
64 | + add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
65 | + add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
66 | + add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
67 | + add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
68 | + add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 ); |
|
69 | + add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
70 | + |
|
71 | + add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
72 | + add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
73 | + add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Check gateway supports for subscription. |
|
78 | + * |
|
79 | + * @since 2.8.24 |
|
80 | + * |
|
81 | + * @param bool $supports True if supports else False. |
|
82 | + * @return bool True if supports else False. |
|
83 | + */ |
|
84 | + public function supports_subscription( $supports ) { |
|
85 | + if ( $supports && (int) $this->get_option( 'no_subscription' ) ) { |
|
86 | + $supports = false; |
|
87 | + } |
|
88 | + |
|
89 | + return $supports; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Process Payment. |
|
94 | + * |
|
95 | + * @param WPInv_Invoice $invoice Invoice. |
|
96 | + * @param array $submission_data Posted checkout fields. |
|
97 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
101 | 101 | |
102 | 102 | // Add a transaction id. |
103 | 103 | $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) ); |
@@ -118,66 +118,66 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * Output for the order received page. |
|
122 | - * |
|
123 | - * @param WPInv_Invoice $invoice Invoice. |
|
124 | - */ |
|
125 | - public function thankyou_page( $invoice ) { |
|
121 | + * Output for the order received page. |
|
122 | + * |
|
123 | + * @param WPInv_Invoice $invoice Invoice. |
|
124 | + */ |
|
125 | + public function thankyou_page( $invoice ) { |
|
126 | 126 | |
127 | 127 | if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
128 | 128 | |
129 | - echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
129 | + echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
130 | 130 | |
131 | 131 | if ( ! empty( $this->instructions ) ) { |
132 | 132 | echo wp_kses_post( wpautop( wptexturize( __( wp_unslash( $this->instructions ), 'invoicing' ) ) ) ); |
133 | - } |
|
133 | + } |
|
134 | 134 | |
135 | - $this->bank_details( $invoice ); |
|
135 | + $this->bank_details( $invoice ); |
|
136 | 136 | |
137 | - echo '</div>'; |
|
137 | + echo '</div>'; |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | - } |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | - * Add content to the WPI emails. |
|
145 | - * |
|
146 | - * @param WPInv_Invoice $invoice Invoice. |
|
147 | - * @param string $email_type Email format: plain text or HTML. |
|
148 | - * @param bool $sent_to_admin Sent to admin. |
|
149 | - */ |
|
150 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
144 | + * Add content to the WPI emails. |
|
145 | + * |
|
146 | + * @param WPInv_Invoice $invoice Invoice. |
|
147 | + * @param string $email_type Email format: plain text or HTML. |
|
148 | + * @param bool $sent_to_admin Sent to admin. |
|
149 | + */ |
|
150 | + public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
151 | 151 | |
152 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
152 | + if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
153 | 153 | |
154 | - echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
154 | + echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
155 | 155 | |
156 | - if ( $this->instructions ) { |
|
157 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
156 | + if ( $this->instructions ) { |
|
157 | + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
158 | 158 | } |
159 | 159 | |
160 | - $this->bank_details( $invoice ); |
|
160 | + $this->bank_details( $invoice ); |
|
161 | 161 | |
162 | - echo '</div>'; |
|
162 | + echo '</div>'; |
|
163 | 163 | |
164 | - } |
|
164 | + } |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Get bank details and place into a list format. |
|
170 | - * |
|
171 | - * @param WPInv_Invoice $invoice Invoice. |
|
172 | - */ |
|
173 | - protected function bank_details( $invoice ) { |
|
169 | + * Get bank details and place into a list format. |
|
170 | + * |
|
171 | + * @param WPInv_Invoice $invoice Invoice. |
|
172 | + */ |
|
173 | + protected function bank_details( $invoice ) { |
|
174 | 174 | |
175 | - // Get the invoice country and country $locale. |
|
176 | - $country = $invoice->get_country(); |
|
177 | - $locale = $this->get_country_locale(); |
|
175 | + // Get the invoice country and country $locale. |
|
176 | + $country = $invoice->get_country(); |
|
177 | + $locale = $this->get_country_locale(); |
|
178 | 178 | |
179 | - // Get shortcode label in the $locale array and use appropriate one. |
|
180 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
179 | + // Get shortcode label in the $locale array and use appropriate one. |
|
180 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
181 | 181 | |
182 | 182 | $bank_fields = array( |
183 | 183 | 'ac_name' => __( 'Account Name', 'invoicing' ), |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | |
197 | 197 | if ( ! empty( $value ) ) { |
198 | 198 | $bank_info[ $field ] = array( |
199 | - 'label' => $label, |
|
200 | - 'value' => $value, |
|
201 | - ); |
|
199 | + 'label' => $label, |
|
200 | + 'value' => $value, |
|
201 | + ); |
|
202 | 202 | } |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | 205 | $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice ); |
206 | 206 | |
@@ -208,177 +208,177 @@ discard block |
||
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
211 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
212 | + |
|
213 | + echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
214 | + |
|
215 | + foreach ( $bank_info as $key => $data ) { |
|
216 | + echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
217 | + } |
|
218 | + |
|
219 | + echo '</table>'; |
|
220 | + |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Get country locale if localized. |
|
225 | + * |
|
226 | + * @return array |
|
227 | + */ |
|
228 | + public function get_country_locale() { |
|
229 | + |
|
230 | + if ( empty( $this->locale ) ) { |
|
231 | + |
|
232 | + // Locale information to be used - only those that are not 'Sort Code'. |
|
233 | + $this->locale = apply_filters( |
|
234 | + 'getpaid_get_bank_transfer_locale', |
|
235 | + array( |
|
236 | + 'AU' => array( |
|
237 | + 'sortcode' => array( |
|
238 | + 'label' => __( 'BSB', 'invoicing' ), |
|
239 | + ), |
|
240 | + ), |
|
241 | + 'CA' => array( |
|
242 | + 'sortcode' => array( |
|
243 | + 'label' => __( 'Bank transit number', 'invoicing' ), |
|
244 | + ), |
|
245 | + ), |
|
246 | + 'IN' => array( |
|
247 | + 'sortcode' => array( |
|
248 | + 'label' => __( 'IFSC', 'invoicing' ), |
|
249 | + ), |
|
250 | + ), |
|
251 | + 'IT' => array( |
|
252 | + 'sortcode' => array( |
|
253 | + 'label' => __( 'Branch sort', 'invoicing' ), |
|
254 | + ), |
|
255 | + ), |
|
256 | + 'NZ' => array( |
|
257 | + 'sortcode' => array( |
|
258 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
259 | + ), |
|
260 | + ), |
|
261 | + 'SE' => array( |
|
262 | + 'sortcode' => array( |
|
263 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
264 | + ), |
|
265 | + ), |
|
266 | + 'US' => array( |
|
267 | + 'sortcode' => array( |
|
268 | + 'label' => __( 'Routing number', 'invoicing' ), |
|
269 | + ), |
|
270 | + ), |
|
271 | + 'ZA' => array( |
|
272 | + 'sortcode' => array( |
|
273 | + 'label' => __( 'Branch code', 'invoicing' ), |
|
274 | + ), |
|
275 | + ), |
|
276 | + ) |
|
277 | + ); |
|
278 | + |
|
279 | + } |
|
280 | + |
|
281 | + return $this->locale; |
|
282 | + |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * Filters the gateway settings. |
|
287 | + * |
|
288 | + * @param array $admin_settings |
|
289 | + */ |
|
290 | + public function admin_settings( $admin_settings ) { |
|
291 | + $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
292 | + $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
293 | + |
|
294 | + $_settings = array(); |
|
295 | + |
|
296 | + foreach ( $admin_settings as $key => $setting ) { |
|
297 | + $_settings[ $key ] = $setting; |
|
298 | + |
|
299 | + if ( $key == 'bank_transfer_active' ) { |
|
300 | + // Enable/disable subscriptions setting. |
|
301 | + $_settings['bank_transfer_no_subscription'] = array( |
|
302 | + 'id' => 'bank_transfer_no_subscription', |
|
303 | + 'type' => 'checkbox', |
|
304 | + 'name' => __( 'Disable Subscriptions', 'invoicing' ), |
|
305 | + 'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ), |
|
306 | + 'std' => 0 |
|
307 | + ); |
|
308 | + } |
|
309 | + } |
|
310 | + |
|
311 | + $admin_settings = $_settings; |
|
312 | + |
|
313 | + $locale = $this->get_country_locale(); |
|
314 | + |
|
315 | + // Get sortcode label in the $locale array and use appropriate one. |
|
316 | + $country = wpinv_default_billing_country(); |
|
317 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
318 | + |
|
319 | + $admin_settings['bank_transfer_ac_name'] = array( |
|
320 | + 'type' => 'text', |
|
321 | + 'id' => 'bank_transfer_ac_name', |
|
322 | + 'name' => __( 'Account Name', 'invoicing' ), |
|
323 | + ); |
|
324 | + |
|
325 | + $admin_settings['bank_transfer_ac_no'] = array( |
|
326 | + 'type' => 'text', |
|
327 | + 'id' => 'bank_transfer_ac_no', |
|
328 | + 'name' => __( 'Account Number', 'invoicing' ), |
|
329 | + ); |
|
330 | + |
|
331 | + $admin_settings['bank_transfer_bank_name'] = array( |
|
332 | + 'type' => 'text', |
|
333 | + 'id' => 'bank_transfer_bank_name', |
|
334 | + 'name' => __( 'Bank Name', 'invoicing' ), |
|
335 | + ); |
|
212 | 336 | |
213 | - echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
337 | + $admin_settings['bank_transfer_ifsc'] = array( |
|
338 | + 'type' => 'text', |
|
339 | + 'id' => 'bank_transfer_ifsc', |
|
340 | + 'name' => __( 'IFSC Code', 'invoicing' ), |
|
341 | + ); |
|
342 | + |
|
343 | + $admin_settings['bank_transfer_iban'] = array( |
|
344 | + 'type' => 'text', |
|
345 | + 'id' => 'bank_transfer_iban', |
|
346 | + 'name' => __( 'IBAN', 'invoicing' ), |
|
347 | + ); |
|
348 | + |
|
349 | + $admin_settings['bank_transfer_bic'] = array( |
|
350 | + 'type' => 'text', |
|
351 | + 'id' => 'bank_transfer_bic', |
|
352 | + 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
353 | + ); |
|
214 | 354 | |
215 | - foreach ( $bank_info as $key => $data ) { |
|
216 | - echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
217 | - } |
|
355 | + $admin_settings['bank_transfer_sort_code'] = array( |
|
356 | + 'type' => 'text', |
|
357 | + 'id' => 'bank_transfer_sort_code', |
|
358 | + 'name' => $sortcode, |
|
359 | + ); |
|
218 | 360 | |
219 | - echo '</table>'; |
|
361 | + $admin_settings['bank_transfer_info'] = array( |
|
362 | + 'id' => 'bank_transfer_info', |
|
363 | + 'name' => __( 'Instructions', 'invoicing' ), |
|
364 | + 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
365 | + 'type' => 'textarea', |
|
366 | + 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
367 | + 'cols' => 50, |
|
368 | + 'rows' => 5, |
|
369 | + ); |
|
220 | 370 | |
371 | + return $admin_settings; |
|
221 | 372 | } |
222 | 373 | |
223 | 374 | /** |
224 | - * Get country locale if localized. |
|
225 | - * |
|
226 | - * @return array |
|
227 | - */ |
|
228 | - public function get_country_locale() { |
|
229 | - |
|
230 | - if ( empty( $this->locale ) ) { |
|
231 | - |
|
232 | - // Locale information to be used - only those that are not 'Sort Code'. |
|
233 | - $this->locale = apply_filters( |
|
234 | - 'getpaid_get_bank_transfer_locale', |
|
235 | - array( |
|
236 | - 'AU' => array( |
|
237 | - 'sortcode' => array( |
|
238 | - 'label' => __( 'BSB', 'invoicing' ), |
|
239 | - ), |
|
240 | - ), |
|
241 | - 'CA' => array( |
|
242 | - 'sortcode' => array( |
|
243 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
244 | - ), |
|
245 | - ), |
|
246 | - 'IN' => array( |
|
247 | - 'sortcode' => array( |
|
248 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
249 | - ), |
|
250 | - ), |
|
251 | - 'IT' => array( |
|
252 | - 'sortcode' => array( |
|
253 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
254 | - ), |
|
255 | - ), |
|
256 | - 'NZ' => array( |
|
257 | - 'sortcode' => array( |
|
258 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
259 | - ), |
|
260 | - ), |
|
261 | - 'SE' => array( |
|
262 | - 'sortcode' => array( |
|
263 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
264 | - ), |
|
265 | - ), |
|
266 | - 'US' => array( |
|
267 | - 'sortcode' => array( |
|
268 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
269 | - ), |
|
270 | - ), |
|
271 | - 'ZA' => array( |
|
272 | - 'sortcode' => array( |
|
273 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
274 | - ), |
|
275 | - ), |
|
276 | - ) |
|
277 | - ); |
|
278 | - |
|
279 | - } |
|
280 | - |
|
281 | - return $this->locale; |
|
282 | - |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * Filters the gateway settings. |
|
287 | - * |
|
288 | - * @param array $admin_settings |
|
289 | - */ |
|
290 | - public function admin_settings( $admin_settings ) { |
|
291 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
292 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
293 | - |
|
294 | - $_settings = array(); |
|
295 | - |
|
296 | - foreach ( $admin_settings as $key => $setting ) { |
|
297 | - $_settings[ $key ] = $setting; |
|
298 | - |
|
299 | - if ( $key == 'bank_transfer_active' ) { |
|
300 | - // Enable/disable subscriptions setting. |
|
301 | - $_settings['bank_transfer_no_subscription'] = array( |
|
302 | - 'id' => 'bank_transfer_no_subscription', |
|
303 | - 'type' => 'checkbox', |
|
304 | - 'name' => __( 'Disable Subscriptions', 'invoicing' ), |
|
305 | - 'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ), |
|
306 | - 'std' => 0 |
|
307 | - ); |
|
308 | - } |
|
309 | - } |
|
310 | - |
|
311 | - $admin_settings = $_settings; |
|
312 | - |
|
313 | - $locale = $this->get_country_locale(); |
|
314 | - |
|
315 | - // Get sortcode label in the $locale array and use appropriate one. |
|
316 | - $country = wpinv_default_billing_country(); |
|
317 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
318 | - |
|
319 | - $admin_settings['bank_transfer_ac_name'] = array( |
|
320 | - 'type' => 'text', |
|
321 | - 'id' => 'bank_transfer_ac_name', |
|
322 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
323 | - ); |
|
324 | - |
|
325 | - $admin_settings['bank_transfer_ac_no'] = array( |
|
326 | - 'type' => 'text', |
|
327 | - 'id' => 'bank_transfer_ac_no', |
|
328 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
329 | - ); |
|
330 | - |
|
331 | - $admin_settings['bank_transfer_bank_name'] = array( |
|
332 | - 'type' => 'text', |
|
333 | - 'id' => 'bank_transfer_bank_name', |
|
334 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
335 | - ); |
|
336 | - |
|
337 | - $admin_settings['bank_transfer_ifsc'] = array( |
|
338 | - 'type' => 'text', |
|
339 | - 'id' => 'bank_transfer_ifsc', |
|
340 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
341 | - ); |
|
342 | - |
|
343 | - $admin_settings['bank_transfer_iban'] = array( |
|
344 | - 'type' => 'text', |
|
345 | - 'id' => 'bank_transfer_iban', |
|
346 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
347 | - ); |
|
348 | - |
|
349 | - $admin_settings['bank_transfer_bic'] = array( |
|
350 | - 'type' => 'text', |
|
351 | - 'id' => 'bank_transfer_bic', |
|
352 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
353 | - ); |
|
354 | - |
|
355 | - $admin_settings['bank_transfer_sort_code'] = array( |
|
356 | - 'type' => 'text', |
|
357 | - 'id' => 'bank_transfer_sort_code', |
|
358 | - 'name' => $sortcode, |
|
359 | - ); |
|
360 | - |
|
361 | - $admin_settings['bank_transfer_info'] = array( |
|
362 | - 'id' => 'bank_transfer_info', |
|
363 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
364 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
365 | - 'type' => 'textarea', |
|
366 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
367 | - 'cols' => 50, |
|
368 | - 'rows' => 5, |
|
369 | - ); |
|
370 | - |
|
371 | - return $admin_settings; |
|
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Processes invoice addons. |
|
376 | - * |
|
377 | - * @param WPInv_Invoice $invoice |
|
378 | - * @param GetPaid_Form_Item[] $items |
|
379 | - * @return WPInv_Invoice |
|
380 | - */ |
|
381 | - public function process_addons( $invoice, $items ) { |
|
375 | + * Processes invoice addons. |
|
376 | + * |
|
377 | + * @param WPInv_Invoice $invoice |
|
378 | + * @param GetPaid_Form_Item[] $items |
|
379 | + * @return WPInv_Invoice |
|
380 | + */ |
|
381 | + public function process_addons( $invoice, $items ) { |
|
382 | 382 | |
383 | 383 | foreach ( $items as $item ) { |
384 | 384 | $invoice->add_item( $item ); |
@@ -386,98 +386,98 @@ discard block |
||
386 | 386 | |
387 | 387 | $invoice->recalculate_total(); |
388 | 388 | $invoice->save(); |
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * (Maybe) renews a bank transfer subscription profile. |
|
393 | - * |
|
394 | - * |
|
395 | - * @param WPInv_Subscription $subscription |
|
396 | - */ |
|
397 | - public function maybe_renew_subscription( $subscription, $parent_invoice ) { |
|
398 | - // Ensure its our subscription && it's active. |
|
399 | - if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
400 | - add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
401 | - |
|
402 | - $invoice = $subscription->create_payment(); |
|
403 | - |
|
404 | - if ( ! empty( $invoice ) ) { |
|
405 | - $is_logged_in = is_user_logged_in(); |
|
406 | - |
|
407 | - // Cron run. |
|
408 | - if ( ! $is_logged_in ) { |
|
409 | - $note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) ); |
|
410 | - |
|
411 | - $invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in ); |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - /** |
|
420 | - * Process a bank transfer payment. |
|
421 | - * |
|
422 | - * |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * (Maybe) renews a bank transfer subscription profile. |
|
393 | + * |
|
394 | + * |
|
395 | + * @param WPInv_Subscription $subscription |
|
396 | + */ |
|
397 | + public function maybe_renew_subscription( $subscription, $parent_invoice ) { |
|
398 | + // Ensure its our subscription && it's active. |
|
399 | + if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
400 | + add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
401 | + |
|
402 | + $invoice = $subscription->create_payment(); |
|
403 | + |
|
404 | + if ( ! empty( $invoice ) ) { |
|
405 | + $is_logged_in = is_user_logged_in(); |
|
406 | + |
|
407 | + // Cron run. |
|
408 | + if ( ! $is_logged_in ) { |
|
409 | + $note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) ); |
|
410 | + |
|
411 | + $invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in ); |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + /** |
|
420 | + * Process a bank transfer payment. |
|
421 | + * |
|
422 | + * |
|
423 | 423 | * @param WPInv_Invoice $invoice |
424 | - */ |
|
425 | - public function invoice_paid( $invoice ) { |
|
426 | - |
|
427 | - // Abort if not paid by bank transfer. |
|
428 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
429 | - return; |
|
430 | - } |
|
431 | - |
|
432 | - // Is it a parent payment? |
|
433 | - if ( 0 == $invoice->get_parent_id() ) { |
|
434 | - |
|
435 | - // (Maybe) activate subscriptions. |
|
436 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
437 | - |
|
438 | - if ( ! empty( $subscriptions ) ) { |
|
439 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
440 | - |
|
441 | - foreach ( $subscriptions as $subscription ) { |
|
442 | - if ( $subscription->exists() ) { |
|
443 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
444 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
445 | - |
|
446 | - $subscription->set_next_renewal_date( $expiry ); |
|
447 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
448 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
449 | - $subscription->activate(); |
|
450 | - } |
|
451 | - } |
|
452 | - } |
|
453 | - } else { |
|
454 | - |
|
455 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
456 | - |
|
457 | - // Renew the subscription. |
|
458 | - if ( $subscription && $subscription->exists() ) { |
|
459 | - $subscription->add_payment( array(), $invoice ); |
|
460 | - $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
461 | - } |
|
462 | - } |
|
424 | + */ |
|
425 | + public function invoice_paid( $invoice ) { |
|
426 | + |
|
427 | + // Abort if not paid by bank transfer. |
|
428 | + if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
429 | + return; |
|
430 | + } |
|
431 | + |
|
432 | + // Is it a parent payment? |
|
433 | + if ( 0 == $invoice->get_parent_id() ) { |
|
434 | + |
|
435 | + // (Maybe) activate subscriptions. |
|
436 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
437 | + |
|
438 | + if ( ! empty( $subscriptions ) ) { |
|
439 | + $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
440 | + |
|
441 | + foreach ( $subscriptions as $subscription ) { |
|
442 | + if ( $subscription->exists() ) { |
|
443 | + $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
444 | + $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
445 | + |
|
446 | + $subscription->set_next_renewal_date( $expiry ); |
|
447 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
448 | + $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
449 | + $subscription->activate(); |
|
450 | + } |
|
451 | + } |
|
452 | + } |
|
453 | + } else { |
|
454 | + |
|
455 | + $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
456 | + |
|
457 | + // Renew the subscription. |
|
458 | + if ( $subscription && $subscription->exists() ) { |
|
459 | + $subscription->add_payment( array(), $invoice ); |
|
460 | + $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
461 | + } |
|
462 | + } |
|
463 | 463 | |
464 | 464 | } |
465 | 465 | |
466 | - /** |
|
467 | - * Force created from payment false to allow email for auto renewal generation invoice. |
|
468 | - * |
|
469 | - * @since 2.8.11 |
|
470 | - * |
|
471 | - * @param bool $is_payment_form_invoice True when invoice created via payment form else false. |
|
472 | - * @param int $invoice Invoice ID. |
|
473 | - * @return bool True when invoice created via payment form else false. |
|
474 | - */ |
|
475 | - public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) { |
|
476 | - if ( $is_payment_form_invoice ) { |
|
477 | - $is_payment_form_invoice = false; |
|
478 | - } |
|
479 | - |
|
480 | - return $is_payment_form_invoice; |
|
481 | - } |
|
466 | + /** |
|
467 | + * Force created from payment false to allow email for auto renewal generation invoice. |
|
468 | + * |
|
469 | + * @since 2.8.11 |
|
470 | + * |
|
471 | + * @param bool $is_payment_form_invoice True when invoice created via payment form else false. |
|
472 | + * @param int $invoice Invoice ID. |
|
473 | + * @return bool True when invoice created via payment form else false. |
|
474 | + */ |
|
475 | + public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) { |
|
476 | + if ( $is_payment_form_invoice ) { |
|
477 | + $is_payment_form_invoice = false; |
|
478 | + } |
|
479 | + |
|
480 | + return $is_payment_form_invoice; |
|
481 | + } |
|
482 | 482 | |
483 | 483 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Bank transfer Payment Gateway class. |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | public function __construct() { |
57 | 57 | parent::__construct(); |
58 | 58 | |
59 | - $this->title = __( 'Direct bank transfer', 'invoicing' ); |
|
60 | - $this->method_title = __( 'Bank transfer', 'invoicing' ); |
|
61 | - $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
|
62 | - $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
|
63 | - |
|
64 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
65 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
66 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
67 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
68 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 ); |
|
69 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
70 | - |
|
71 | - add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
72 | - add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
73 | - add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
59 | + $this->title = __('Direct bank transfer', 'invoicing'); |
|
60 | + $this->method_title = __('Bank transfer', 'invoicing'); |
|
61 | + $this->checkout_button_text = __('Proceed', 'invoicing'); |
|
62 | + $this->instructions = apply_filters('wpinv_bank_instructions', $this->get_option('info')); |
|
63 | + |
|
64 | + add_action('wpinv_receipt_end', array($this, 'thankyou_page')); |
|
65 | + add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40); |
|
66 | + add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11); |
|
67 | + add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3); |
|
68 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'), 12, 2); |
|
69 | + add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20); |
|
70 | + |
|
71 | + add_filter('wpinv_' . $this->id . '_support_subscription', array($this, 'supports_subscription'), 20, 1); |
|
72 | + add_filter('getpaid_' . $this->id . '_support_subscription', array($this, 'supports_subscription'), 20, 1); |
|
73 | + add_filter('getpaid_' . $this->id . '_supports_subscription', array($this, 'supports_subscription'), 20, 1); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @param bool $supports True if supports else False. |
82 | 82 | * @return bool True if supports else False. |
83 | 83 | */ |
84 | - public function supports_subscription( $supports ) { |
|
85 | - if ( $supports && (int) $this->get_option( 'no_subscription' ) ) { |
|
84 | + public function supports_subscription($supports) { |
|
85 | + if ($supports && (int) $this->get_option('no_subscription')) { |
|
86 | 86 | $supports = false; |
87 | 87 | } |
88 | 88 | |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
98 | 98 | * @return array |
99 | 99 | */ |
100 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
100 | + public function process_payment($invoice, $submission_data, $submission) { |
|
101 | 101 | |
102 | 102 | // Add a transaction id. |
103 | - $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) ); |
|
103 | + $invoice->set_transaction_id($invoice->generate_key('bt_')); |
|
104 | 104 | |
105 | 105 | // Set it as pending payment. |
106 | - if ( ! $invoice->needs_payment() ) { |
|
106 | + if (!$invoice->needs_payment()) { |
|
107 | 107 | $invoice->mark_paid(); |
108 | - } elseif ( ! $invoice->is_paid() ) { |
|
109 | - $invoice->set_status( 'wpi-onhold' ); |
|
108 | + } elseif (!$invoice->is_paid()) { |
|
109 | + $invoice->set_status('wpi-onhold'); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Save it. |
113 | 113 | $invoice->save(); |
114 | 114 | |
115 | 115 | // Send to the success page. |
116 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
116 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param WPInv_Invoice $invoice Invoice. |
124 | 124 | */ |
125 | - public function thankyou_page( $invoice ) { |
|
125 | + public function thankyou_page($invoice) { |
|
126 | 126 | |
127 | - if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
127 | + if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
128 | 128 | |
129 | 129 | echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
130 | 130 | |
131 | - if ( ! empty( $this->instructions ) ) { |
|
132 | - echo wp_kses_post( wpautop( wptexturize( __( wp_unslash( $this->instructions ), 'invoicing' ) ) ) ); |
|
131 | + if (!empty($this->instructions)) { |
|
132 | + echo wp_kses_post(wpautop(wptexturize(__(wp_unslash($this->instructions), 'invoicing')))); |
|
133 | 133 | } |
134 | 134 | |
135 | - $this->bank_details( $invoice ); |
|
135 | + $this->bank_details($invoice); |
|
136 | 136 | |
137 | 137 | echo '</div>'; |
138 | 138 | |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * @param string $email_type Email format: plain text or HTML. |
148 | 148 | * @param bool $sent_to_admin Sent to admin. |
149 | 149 | */ |
150 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
150 | + public function email_instructions($invoice, $email_type, $sent_to_admin) { |
|
151 | 151 | |
152 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
152 | + if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
153 | 153 | |
154 | 154 | echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
155 | 155 | |
156 | - if ( $this->instructions ) { |
|
157 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
156 | + if ($this->instructions) { |
|
157 | + echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL); |
|
158 | 158 | } |
159 | 159 | |
160 | - $this->bank_details( $invoice ); |
|
160 | + $this->bank_details($invoice); |
|
161 | 161 | |
162 | 162 | echo '</div>'; |
163 | 163 | |
@@ -170,50 +170,50 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param WPInv_Invoice $invoice Invoice. |
172 | 172 | */ |
173 | - protected function bank_details( $invoice ) { |
|
173 | + protected function bank_details($invoice) { |
|
174 | 174 | |
175 | 175 | // Get the invoice country and country $locale. |
176 | 176 | $country = $invoice->get_country(); |
177 | 177 | $locale = $this->get_country_locale(); |
178 | 178 | |
179 | 179 | // Get shortcode label in the $locale array and use appropriate one. |
180 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
180 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
181 | 181 | |
182 | 182 | $bank_fields = array( |
183 | - 'ac_name' => __( 'Account Name', 'invoicing' ), |
|
184 | - 'ac_no' => __( 'Account Number', 'invoicing' ), |
|
185 | - 'bank_name' => __( 'Bank Name', 'invoicing' ), |
|
186 | - 'ifsc' => __( 'IFSC code', 'invoicing' ), |
|
187 | - 'iban' => __( 'IBAN', 'invoicing' ), |
|
188 | - 'bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
183 | + 'ac_name' => __('Account Name', 'invoicing'), |
|
184 | + 'ac_no' => __('Account Number', 'invoicing'), |
|
185 | + 'bank_name' => __('Bank Name', 'invoicing'), |
|
186 | + 'ifsc' => __('IFSC code', 'invoicing'), |
|
187 | + 'iban' => __('IBAN', 'invoicing'), |
|
188 | + 'bic' => __('BIC/Swift code', 'invoicing'), |
|
189 | 189 | 'sort_code' => $sortcode, |
190 | 190 | ); |
191 | 191 | |
192 | 192 | $bank_info = array(); |
193 | 193 | |
194 | - foreach ( $bank_fields as $field => $label ) { |
|
195 | - $value = $this->get_option( $field ); |
|
194 | + foreach ($bank_fields as $field => $label) { |
|
195 | + $value = $this->get_option($field); |
|
196 | 196 | |
197 | - if ( ! empty( $value ) ) { |
|
198 | - $bank_info[ $field ] = array( |
|
197 | + if (!empty($value)) { |
|
198 | + $bank_info[$field] = array( |
|
199 | 199 | 'label' => $label, |
200 | 200 | 'value' => $value, |
201 | 201 | ); |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice ); |
|
205 | + $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice); |
|
206 | 206 | |
207 | - if ( empty( $bank_info ) ) { |
|
207 | + if (empty($bank_info)) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
211 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL; |
|
212 | 212 | |
213 | 213 | echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
214 | 214 | |
215 | - foreach ( $bank_info as $key => $data ) { |
|
216 | - echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
215 | + foreach ($bank_info as $key => $data) { |
|
216 | + echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . '</td></tr>' . PHP_EOL; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | echo '</table>'; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function get_country_locale() { |
229 | 229 | |
230 | - if ( empty( $this->locale ) ) { |
|
230 | + if (empty($this->locale)) { |
|
231 | 231 | |
232 | 232 | // Locale information to be used - only those that are not 'Sort Code'. |
233 | 233 | $this->locale = apply_filters( |
@@ -235,42 +235,42 @@ discard block |
||
235 | 235 | array( |
236 | 236 | 'AU' => array( |
237 | 237 | 'sortcode' => array( |
238 | - 'label' => __( 'BSB', 'invoicing' ), |
|
238 | + 'label' => __('BSB', 'invoicing'), |
|
239 | 239 | ), |
240 | 240 | ), |
241 | 241 | 'CA' => array( |
242 | 242 | 'sortcode' => array( |
243 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
243 | + 'label' => __('Bank transit number', 'invoicing'), |
|
244 | 244 | ), |
245 | 245 | ), |
246 | 246 | 'IN' => array( |
247 | 247 | 'sortcode' => array( |
248 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
248 | + 'label' => __('IFSC', 'invoicing'), |
|
249 | 249 | ), |
250 | 250 | ), |
251 | 251 | 'IT' => array( |
252 | 252 | 'sortcode' => array( |
253 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
253 | + 'label' => __('Branch sort', 'invoicing'), |
|
254 | 254 | ), |
255 | 255 | ), |
256 | 256 | 'NZ' => array( |
257 | 257 | 'sortcode' => array( |
258 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
258 | + 'label' => __('Bank code', 'invoicing'), |
|
259 | 259 | ), |
260 | 260 | ), |
261 | 261 | 'SE' => array( |
262 | 262 | 'sortcode' => array( |
263 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
263 | + 'label' => __('Bank code', 'invoicing'), |
|
264 | 264 | ), |
265 | 265 | ), |
266 | 266 | 'US' => array( |
267 | 267 | 'sortcode' => array( |
268 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
268 | + 'label' => __('Routing number', 'invoicing'), |
|
269 | 269 | ), |
270 | 270 | ), |
271 | 271 | 'ZA' => array( |
272 | 272 | 'sortcode' => array( |
273 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
273 | + 'label' => __('Branch code', 'invoicing'), |
|
274 | 274 | ), |
275 | 275 | ), |
276 | 276 | ) |
@@ -287,22 +287,22 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param array $admin_settings |
289 | 289 | */ |
290 | - public function admin_settings( $admin_settings ) { |
|
291 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
292 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
290 | + public function admin_settings($admin_settings) { |
|
291 | + $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'); |
|
292 | + $admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing'); |
|
293 | 293 | |
294 | 294 | $_settings = array(); |
295 | 295 | |
296 | - foreach ( $admin_settings as $key => $setting ) { |
|
297 | - $_settings[ $key ] = $setting; |
|
296 | + foreach ($admin_settings as $key => $setting) { |
|
297 | + $_settings[$key] = $setting; |
|
298 | 298 | |
299 | - if ( $key == 'bank_transfer_active' ) { |
|
299 | + if ($key == 'bank_transfer_active') { |
|
300 | 300 | // Enable/disable subscriptions setting. |
301 | 301 | $_settings['bank_transfer_no_subscription'] = array( |
302 | 302 | 'id' => 'bank_transfer_no_subscription', |
303 | 303 | 'type' => 'checkbox', |
304 | - 'name' => __( 'Disable Subscriptions', 'invoicing' ), |
|
305 | - 'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ), |
|
304 | + 'name' => __('Disable Subscriptions', 'invoicing'), |
|
305 | + 'desc' => __('Tick to disable support for recurring items.', 'invoicing'), |
|
306 | 306 | 'std' => 0 |
307 | 307 | ); |
308 | 308 | } |
@@ -310,46 +310,46 @@ discard block |
||
310 | 310 | |
311 | 311 | $admin_settings = $_settings; |
312 | 312 | |
313 | - $locale = $this->get_country_locale(); |
|
313 | + $locale = $this->get_country_locale(); |
|
314 | 314 | |
315 | 315 | // Get sortcode label in the $locale array and use appropriate one. |
316 | 316 | $country = wpinv_default_billing_country(); |
317 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
317 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
318 | 318 | |
319 | 319 | $admin_settings['bank_transfer_ac_name'] = array( |
320 | 320 | 'type' => 'text', |
321 | 321 | 'id' => 'bank_transfer_ac_name', |
322 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
322 | + 'name' => __('Account Name', 'invoicing'), |
|
323 | 323 | ); |
324 | 324 | |
325 | 325 | $admin_settings['bank_transfer_ac_no'] = array( |
326 | 326 | 'type' => 'text', |
327 | 327 | 'id' => 'bank_transfer_ac_no', |
328 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
328 | + 'name' => __('Account Number', 'invoicing'), |
|
329 | 329 | ); |
330 | 330 | |
331 | 331 | $admin_settings['bank_transfer_bank_name'] = array( |
332 | 332 | 'type' => 'text', |
333 | 333 | 'id' => 'bank_transfer_bank_name', |
334 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
334 | + 'name' => __('Bank Name', 'invoicing'), |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | $admin_settings['bank_transfer_ifsc'] = array( |
338 | 338 | 'type' => 'text', |
339 | 339 | 'id' => 'bank_transfer_ifsc', |
340 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
340 | + 'name' => __('IFSC Code', 'invoicing'), |
|
341 | 341 | ); |
342 | 342 | |
343 | 343 | $admin_settings['bank_transfer_iban'] = array( |
344 | 344 | 'type' => 'text', |
345 | 345 | 'id' => 'bank_transfer_iban', |
346 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
346 | + 'name' => __('IBAN', 'invoicing'), |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | $admin_settings['bank_transfer_bic'] = array( |
350 | 350 | 'type' => 'text', |
351 | 351 | 'id' => 'bank_transfer_bic', |
352 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
352 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
353 | 353 | ); |
354 | 354 | |
355 | 355 | $admin_settings['bank_transfer_sort_code'] = array( |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | |
361 | 361 | $admin_settings['bank_transfer_info'] = array( |
362 | 362 | 'id' => 'bank_transfer_info', |
363 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
364 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
363 | + 'name' => __('Instructions', 'invoicing'), |
|
364 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
365 | 365 | 'type' => 'textarea', |
366 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
366 | + 'std' => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'), |
|
367 | 367 | 'cols' => 50, |
368 | 368 | 'rows' => 5, |
369 | 369 | ); |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | * @param GetPaid_Form_Item[] $items |
379 | 379 | * @return WPInv_Invoice |
380 | 380 | */ |
381 | - public function process_addons( $invoice, $items ) { |
|
381 | + public function process_addons($invoice, $items) { |
|
382 | 382 | |
383 | - foreach ( $items as $item ) { |
|
384 | - $invoice->add_item( $item ); |
|
383 | + foreach ($items as $item) { |
|
384 | + $invoice->add_item($item); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | $invoice->recalculate_total(); |
@@ -394,25 +394,25 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @param WPInv_Subscription $subscription |
396 | 396 | */ |
397 | - public function maybe_renew_subscription( $subscription, $parent_invoice ) { |
|
397 | + public function maybe_renew_subscription($subscription, $parent_invoice) { |
|
398 | 398 | // Ensure its our subscription && it's active. |
399 | - if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
400 | - add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
399 | + if (!empty($parent_invoice) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status('active trialling')) { |
|
400 | + add_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2); |
|
401 | 401 | |
402 | 402 | $invoice = $subscription->create_payment(); |
403 | 403 | |
404 | - if ( ! empty( $invoice ) ) { |
|
404 | + if (!empty($invoice)) { |
|
405 | 405 | $is_logged_in = is_user_logged_in(); |
406 | 406 | |
407 | 407 | // Cron run. |
408 | - if ( ! $is_logged_in ) { |
|
409 | - $note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) ); |
|
408 | + if (!$is_logged_in) { |
|
409 | + $note = wp_sprintf(__('Renewal %1$s created with the status "%2$s".', 'invoicing'), $invoice->get_invoice_quote_type(), wpinv_status_nicename($invoice->get_status(), $invoice)); |
|
410 | 410 | |
411 | - $invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in ); |
|
411 | + $invoice->add_note($note, false, $is_logged_in, !$is_logged_in); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | - remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
415 | + remove_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -422,42 +422,42 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @param WPInv_Invoice $invoice |
424 | 424 | */ |
425 | - public function invoice_paid( $invoice ) { |
|
425 | + public function invoice_paid($invoice) { |
|
426 | 426 | |
427 | 427 | // Abort if not paid by bank transfer. |
428 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
428 | + if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) { |
|
429 | 429 | return; |
430 | 430 | } |
431 | 431 | |
432 | 432 | // Is it a parent payment? |
433 | - if ( 0 == $invoice->get_parent_id() ) { |
|
433 | + if (0 == $invoice->get_parent_id()) { |
|
434 | 434 | |
435 | 435 | // (Maybe) activate subscriptions. |
436 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
436 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
437 | 437 | |
438 | - if ( ! empty( $subscriptions ) ) { |
|
439 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
438 | + if (!empty($subscriptions)) { |
|
439 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
440 | 440 | |
441 | - foreach ( $subscriptions as $subscription ) { |
|
442 | - if ( $subscription->exists() ) { |
|
443 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
444 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
441 | + foreach ($subscriptions as $subscription) { |
|
442 | + if ($subscription->exists()) { |
|
443 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
444 | + $expiry = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
445 | 445 | |
446 | - $subscription->set_next_renewal_date( $expiry ); |
|
447 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
448 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
446 | + $subscription->set_next_renewal_date($expiry); |
|
447 | + $subscription->set_date_created(current_time('mysql')); |
|
448 | + $subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id()); |
|
449 | 449 | $subscription->activate(); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | 453 | } else { |
454 | 454 | |
455 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
455 | + $subscription = getpaid_get_subscription($invoice->get_subscription_id()); |
|
456 | 456 | |
457 | 457 | // Renew the subscription. |
458 | - if ( $subscription && $subscription->exists() ) { |
|
459 | - $subscription->add_payment( array(), $invoice ); |
|
460 | - $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
458 | + if ($subscription && $subscription->exists()) { |
|
459 | + $subscription->add_payment(array(), $invoice); |
|
460 | + $subscription->renew(strtotime($invoice->get_date_created())); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param int $invoice Invoice ID. |
473 | 473 | * @return bool True when invoice created via payment form else false. |
474 | 474 | */ |
475 | - public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) { |
|
476 | - if ( $is_payment_form_invoice ) { |
|
475 | + public function force_is_payment_form_invoice($is_payment_form_invoice, $invoice) { |
|
476 | + if ($is_payment_form_invoice) { |
|
477 | 477 | $is_payment_form_invoice = false; |
478 | 478 | } |
479 | 479 |
@@ -31,16 +31,16 @@ 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 | /** |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
53 | 53 | $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
54 | + $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | + $page_id = absint( $page_id ); |
|
56 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | + $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | + $ret = $ret ? is_page( $ret ) : false; |
|
69 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | function wpinv_send_to_failed_page( $args = null ) { |
108 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
108 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
109 | 109 | |
110 | 110 | if ( ! empty( $args ) ) { |
111 | 111 | // Check for backward compatibility |
@@ -126,58 +126,58 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | function wpinv_get_checkout_uri( $args = array() ) { |
129 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
130 | - $uri = isset( $uri ) ? get_permalink( $uri ) : null; |
|
129 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
130 | + $uri = isset( $uri ) ? get_permalink( $uri ) : null; |
|
131 | 131 | |
132 | - if ( ! empty( $args ) ) { |
|
133 | - // Check for backward compatibility |
|
134 | - if ( is_string( $args ) ) { |
|
135 | - $args = str_replace( '?', '', $args ); |
|
132 | + if ( ! empty( $args ) ) { |
|
133 | + // Check for backward compatibility |
|
134 | + if ( is_string( $args ) ) { |
|
135 | + $args = str_replace( '?', '', $args ); |
|
136 | 136 | } |
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args( $args ); |
|
139 | 139 | |
140 | - $uri = add_query_arg( $args, $uri ); |
|
141 | - } |
|
140 | + $uri = add_query_arg( $args, $uri ); |
|
141 | + } |
|
142 | 142 | |
143 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
143 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
144 | 144 | |
145 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
145 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
146 | 146 | |
147 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
148 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
149 | - } |
|
147 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
148 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
149 | + } |
|
150 | 150 | |
151 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
151 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | function wpinv_get_success_page_url( $query_string = null ) { |
155 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
156 | - $success_page = get_permalink( $success_page ); |
|
155 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
156 | + $success_page = get_permalink( $success_page ); |
|
157 | 157 | |
158 | - if ( $query_string ) { |
|
159 | - $success_page .= $query_string; |
|
158 | + if ( $query_string ) { |
|
159 | + $success_page .= $query_string; |
|
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
162 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
166 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
166 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
168 | 168 | |
169 | - if ( $extras ) { |
|
170 | - $uri .= $extras; |
|
169 | + if ( $extras ) { |
|
170 | + $uri .= $extras; |
|
171 | 171 | } |
172 | 172 | |
173 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
173 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_is_failed_transaction_page() { |
177 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
178 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
177 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
178 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
179 | 179 | |
180 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
180 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -257,36 +257,36 @@ discard block |
||
257 | 257 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
258 | 258 | |
259 | 259 | if ( $require_billing_details ) { |
260 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
261 | - $required_fields['first_name'] = array( |
|
262 | - 'error_id' => 'invalid_first_name', |
|
263 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ), |
|
264 | - ); |
|
265 | - } |
|
266 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
267 | - $required_fields['address'] = array( |
|
268 | - 'error_id' => 'invalid_address', |
|
269 | - 'error_message' => __( 'Please enter your address', 'invoicing' ), |
|
270 | - ); |
|
271 | - } |
|
272 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
273 | - $required_fields['city'] = array( |
|
274 | - 'error_id' => 'invalid_city', |
|
275 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ), |
|
276 | - ); |
|
277 | - } |
|
278 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
279 | - $required_fields['state'] = array( |
|
280 | - 'error_id' => 'invalid_state', |
|
281 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ), |
|
282 | - ); |
|
283 | - } |
|
284 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
285 | - $required_fields['country'] = array( |
|
286 | - 'error_id' => 'invalid_country', |
|
287 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ), |
|
288 | - ); |
|
289 | - } |
|
260 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
261 | + $required_fields['first_name'] = array( |
|
262 | + 'error_id' => 'invalid_first_name', |
|
263 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ), |
|
264 | + ); |
|
265 | + } |
|
266 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
267 | + $required_fields['address'] = array( |
|
268 | + 'error_id' => 'invalid_address', |
|
269 | + 'error_message' => __( 'Please enter your address', 'invoicing' ), |
|
270 | + ); |
|
271 | + } |
|
272 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
273 | + $required_fields['city'] = array( |
|
274 | + 'error_id' => 'invalid_city', |
|
275 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ), |
|
276 | + ); |
|
277 | + } |
|
278 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
279 | + $required_fields['state'] = array( |
|
280 | + 'error_id' => 'invalid_state', |
|
281 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ), |
|
282 | + ); |
|
283 | + } |
|
284 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
285 | + $required_fields['country'] = array( |
|
286 | + 'error_id' => 'invalid_country', |
|
287 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ), |
|
288 | + ); |
|
289 | + } |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -501,42 +501,42 @@ discard block |
||
501 | 501 | * @return bool|WP_Filesystem The WP Filesystem object or false on failure. |
502 | 502 | */ |
503 | 503 | function getpaid_wp_filesystem() { |
504 | - if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
505 | - require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
506 | - } |
|
504 | + if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
505 | + require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
506 | + } |
|
507 | 507 | |
508 | - $access_type = get_filesystem_method(); |
|
508 | + $access_type = get_filesystem_method(); |
|
509 | 509 | |
510 | - if ( $access_type === 'direct' ) { |
|
511 | - /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
512 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
510 | + if ( $access_type === 'direct' ) { |
|
511 | + /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
512 | + $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
513 | 513 | |
514 | - /* Initialize the API */ |
|
515 | - if ( ! WP_Filesystem( $creds ) ) { |
|
516 | - /* Any problems and we exit */ |
|
517 | - return false; |
|
518 | - } |
|
514 | + /* Initialize the API */ |
|
515 | + if ( ! WP_Filesystem( $creds ) ) { |
|
516 | + /* Any problems and we exit */ |
|
517 | + return false; |
|
518 | + } |
|
519 | 519 | |
520 | - global $wp_filesystem; |
|
520 | + global $wp_filesystem; |
|
521 | 521 | |
522 | - return $wp_filesystem; |
|
523 | - /* Do our file manipulations below */ |
|
524 | - } else if ( defined( 'FTP_USER' ) ) { |
|
525 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
522 | + return $wp_filesystem; |
|
523 | + /* Do our file manipulations below */ |
|
524 | + } else if ( defined( 'FTP_USER' ) ) { |
|
525 | + $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
526 | 526 | |
527 | - /* Initialize the API */ |
|
528 | - if ( ! WP_Filesystem( $creds ) ) { |
|
529 | - /* Any problems and we exit */ |
|
530 | - return false; |
|
531 | - } |
|
527 | + /* Initialize the API */ |
|
528 | + if ( ! WP_Filesystem( $creds ) ) { |
|
529 | + /* Any problems and we exit */ |
|
530 | + return false; |
|
531 | + } |
|
532 | 532 | |
533 | - global $wp_filesystem; |
|
533 | + global $wp_filesystem; |
|
534 | 534 | |
535 | - return $wp_filesystem; |
|
536 | - } else { |
|
537 | - /* Don't have direct write access. Prompt user with our notice */ |
|
538 | - return false; |
|
539 | - } |
|
535 | + return $wp_filesystem; |
|
536 | + } else { |
|
537 | + /* Don't have direct write access. Prompt user with our notice */ |
|
538 | + return false; |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -547,65 +547,65 @@ discard block |
||
547 | 547 | * @return bool True if file created otherwise false |
548 | 548 | */ |
549 | 549 | function getpaid_sync_db_text_translation() { |
550 | - $wp_filesystem = getpaid_wp_filesystem(); |
|
550 | + $wp_filesystem = getpaid_wp_filesystem(); |
|
551 | 551 | |
552 | - $language_file = WPINV_PLUGIN_DIR . 'db-language.php'; |
|
552 | + $language_file = WPINV_PLUGIN_DIR . 'db-language.php'; |
|
553 | 553 | |
554 | - if ( is_file( $language_file ) && ! is_writable( $language_file ) ) { |
|
555 | - return false; |
|
556 | - } |
|
554 | + if ( is_file( $language_file ) && ! is_writable( $language_file ) ) { |
|
555 | + return false; |
|
556 | + } |
|
557 | 557 | |
558 | - if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) { |
|
559 | - return false; |
|
560 | - } |
|
558 | + if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) { |
|
559 | + return false; |
|
560 | + } |
|
561 | 561 | |
562 | - $head = array(); |
|
563 | - $head[] = "<?php"; |
|
564 | - $head[] = "/**"; |
|
565 | - $head[] = " * Contains strings for translation that stored in the database. Ex: Payment forms custom fields texts."; |
|
566 | - $head[] = " *"; |
|
567 | - $head[] = " * @package GetPaid"; |
|
568 | - $head[] = " * @since 2.8.32"; |
|
569 | - $head[] = " */"; |
|
570 | - $head[] = ""; |
|
571 | - $head[] = "__( 'My String', 'invoicing' );"; |
|
562 | + $head = array(); |
|
563 | + $head[] = "<?php"; |
|
564 | + $head[] = "/**"; |
|
565 | + $head[] = " * Contains strings for translation that stored in the database. Ex: Payment forms custom fields texts."; |
|
566 | + $head[] = " *"; |
|
567 | + $head[] = " * @package GetPaid"; |
|
568 | + $head[] = " * @since 2.8.32"; |
|
569 | + $head[] = " */"; |
|
570 | + $head[] = ""; |
|
571 | + $head[] = "__( 'My String', 'invoicing' );"; |
|
572 | 572 | |
573 | - $footer = array(); |
|
574 | - $footer[] = ""; |
|
575 | - $footer[] = ""; |
|
576 | - $footer[] = "/*** GetPaid " . WPINV_VERSION . " @ " . gmdate( 'Y-m-d H:i:s' ) . " ***/"; |
|
577 | - $footer[] = ""; |
|
573 | + $footer = array(); |
|
574 | + $footer[] = ""; |
|
575 | + $footer[] = ""; |
|
576 | + $footer[] = "/*** GetPaid " . WPINV_VERSION . " @ " . gmdate( 'Y-m-d H:i:s' ) . " ***/"; |
|
577 | + $footer[] = ""; |
|
578 | 578 | |
579 | - $contents = implode( PHP_EOL, $head ); |
|
579 | + $contents = implode( PHP_EOL, $head ); |
|
580 | 580 | |
581 | - $strings = getpaid_get_db_language_strings(); |
|
581 | + $strings = getpaid_get_db_language_strings(); |
|
582 | 582 | |
583 | - if ( ! empty( $strings ) ) { |
|
584 | - $is_wpml = getpaid_is_wpml(); |
|
583 | + if ( ! empty( $strings ) ) { |
|
584 | + $is_wpml = getpaid_is_wpml(); |
|
585 | 585 | |
586 | - foreach ( $strings as $string ) { |
|
587 | - if ( is_scalar( $string ) && $string != '' ) { |
|
588 | - do_action( 'getpaid_db_language_add_string', $string ); |
|
586 | + foreach ( $strings as $string ) { |
|
587 | + if ( is_scalar( $string ) && $string != '' ) { |
|
588 | + do_action( 'getpaid_db_language_add_string', $string ); |
|
589 | 589 | |
590 | - if ( $is_wpml ) { |
|
591 | - // Registers a individual text string for WPML translation. |
|
592 | - do_action( 'wpml_register_single_string', 'invoicing', '', $string ); |
|
593 | - } |
|
590 | + if ( $is_wpml ) { |
|
591 | + // Registers a individual text string for WPML translation. |
|
592 | + do_action( 'wpml_register_single_string', 'invoicing', '', $string ); |
|
593 | + } |
|
594 | 594 | |
595 | - $string = str_replace( "'", "\'", $string ); |
|
595 | + $string = str_replace( "'", "\'", $string ); |
|
596 | 596 | |
597 | - $contents .= PHP_EOL . "__( '" . $string . "', 'invoicing' );"; |
|
598 | - } |
|
599 | - } |
|
600 | - } |
|
597 | + $contents .= PHP_EOL . "__( '" . $string . "', 'invoicing' );"; |
|
598 | + } |
|
599 | + } |
|
600 | + } |
|
601 | 601 | |
602 | - $contents .= implode( PHP_EOL, $footer ); |
|
602 | + $contents .= implode( PHP_EOL, $footer ); |
|
603 | 603 | |
604 | - if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) { |
|
605 | - return true; |
|
606 | - } else { |
|
607 | - return false; |
|
608 | - } |
|
604 | + if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) { |
|
605 | + return true; |
|
606 | + } else { |
|
607 | + return false; |
|
608 | + } |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -617,103 +617,103 @@ discard block |
||
617 | 617 | * @return array Filtered strings. |
618 | 618 | */ |
619 | 619 | function getpaid_get_db_language_strings() { |
620 | - global $wpdb; |
|
621 | - |
|
622 | - $strings = array(); |
|
623 | - |
|
624 | - // Options |
|
625 | - $settings = wpinv_get_options(); |
|
626 | - |
|
627 | - $setting_keys = array( |
|
628 | - 'bank_transfer_info', |
|
629 | - 'vat_invoice_notice_label', |
|
630 | - 'vat_invoice_notice' |
|
631 | - ); |
|
632 | - |
|
633 | - /** |
|
634 | - * Filters the GetPaid option names that requires to add for translation. |
|
635 | - * |
|
636 | - * @since 2.8.32 |
|
637 | - * |
|
638 | - * @param array $setting_keys Array of setting keys. |
|
639 | - */ |
|
640 | - $setting_keys = apply_filters( 'getpaid_options_to_db_language_strings', $setting_keys ); |
|
641 | - |
|
642 | - $setting_keys = array_unique( $setting_keys ); |
|
643 | - |
|
644 | - if ( ! empty( $settings ) && ! empty( $setting_keys ) ) { |
|
645 | - foreach ( $setting_keys as $setting_key ) { |
|
646 | - if ( ! empty( $settings[ $setting_key ] ) && is_string( $settings[ $setting_key ] ) ) { |
|
647 | - $strings[] = wp_unslash( $settings[ $setting_key ] ); |
|
648 | - } |
|
649 | - } |
|
650 | - } |
|
651 | - |
|
652 | - // Payment forms |
|
653 | - $results = $wpdb->get_col( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
654 | - |
|
655 | - if ( ! empty( $results ) ) { |
|
656 | - $string_keys = array( 'label', 'placeholder', 'description', 'text', 'input_label', 'button_label' ); |
|
657 | - |
|
658 | - foreach ( $results as $meta_value ) { |
|
659 | - $fields = maybe_unserialize( $meta_value ); |
|
660 | - |
|
661 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
662 | - foreach ( $fields as $field ) { |
|
663 | - // Labels |
|
664 | - foreach ( $string_keys as $string_key ) { |
|
665 | - if ( ! empty( $field[ $string_key ] ) && is_string( $field[ $string_key ] ) ) { |
|
666 | - $strings[] = wp_unslash( $field[ $string_key ] ); |
|
667 | - } |
|
668 | - } |
|
669 | - |
|
670 | - // Address fields |
|
671 | - if ( ! empty( $field['fields'] ) && ! empty( $field['fields'] ) ) { |
|
672 | - foreach ( $field['fields'] as $sub_field ) { |
|
673 | - foreach ( $string_keys as $string_key ) { |
|
674 | - if ( ! empty( $sub_field[ $string_key ] ) && is_string( $sub_field[ $string_key ] ) ) { |
|
675 | - $strings[] = wp_unslash( $sub_field[ $string_key ] ); |
|
676 | - } |
|
677 | - } |
|
678 | - } |
|
679 | - } |
|
680 | - |
|
681 | - // Options |
|
682 | - if ( ! empty( $field['options'] ) ) { |
|
683 | - $options = array(); |
|
684 | - |
|
685 | - if ( is_array( $field['options'] ) ) { |
|
686 | - $options = $field['options']; |
|
687 | - } else if ( is_string( $field['options'] ) ) { |
|
688 | - $options = getpaid_convert_price_string_to_options( $field['options'], false ); |
|
689 | - $options = ! empty( $options ) ? array_values( $options ) : array(); |
|
690 | - } |
|
691 | - |
|
692 | - if ( ! empty( $options ) ) { |
|
693 | - foreach( $options as $option ) { |
|
694 | - if ( ! empty( $option ) && is_string( $option ) ) { |
|
695 | - $strings[] = wp_unslash( $option ); |
|
696 | - } |
|
697 | - } |
|
698 | - } |
|
699 | - } |
|
700 | - } |
|
701 | - } |
|
702 | - } |
|
703 | - } |
|
704 | - |
|
705 | - /** |
|
706 | - * Filter the database strings to add for translation. |
|
707 | - * |
|
708 | - * @since 2.8.32 |
|
709 | - * |
|
710 | - * @param array $strings Array of strings. |
|
711 | - */ |
|
712 | - $strings = apply_filters( 'getpaid_db_language_strings', $strings ); |
|
713 | - |
|
714 | - $strings = array_unique( $strings ); |
|
715 | - |
|
716 | - return $strings; |
|
620 | + global $wpdb; |
|
621 | + |
|
622 | + $strings = array(); |
|
623 | + |
|
624 | + // Options |
|
625 | + $settings = wpinv_get_options(); |
|
626 | + |
|
627 | + $setting_keys = array( |
|
628 | + 'bank_transfer_info', |
|
629 | + 'vat_invoice_notice_label', |
|
630 | + 'vat_invoice_notice' |
|
631 | + ); |
|
632 | + |
|
633 | + /** |
|
634 | + * Filters the GetPaid option names that requires to add for translation. |
|
635 | + * |
|
636 | + * @since 2.8.32 |
|
637 | + * |
|
638 | + * @param array $setting_keys Array of setting keys. |
|
639 | + */ |
|
640 | + $setting_keys = apply_filters( 'getpaid_options_to_db_language_strings', $setting_keys ); |
|
641 | + |
|
642 | + $setting_keys = array_unique( $setting_keys ); |
|
643 | + |
|
644 | + if ( ! empty( $settings ) && ! empty( $setting_keys ) ) { |
|
645 | + foreach ( $setting_keys as $setting_key ) { |
|
646 | + if ( ! empty( $settings[ $setting_key ] ) && is_string( $settings[ $setting_key ] ) ) { |
|
647 | + $strings[] = wp_unslash( $settings[ $setting_key ] ); |
|
648 | + } |
|
649 | + } |
|
650 | + } |
|
651 | + |
|
652 | + // Payment forms |
|
653 | + $results = $wpdb->get_col( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
654 | + |
|
655 | + if ( ! empty( $results ) ) { |
|
656 | + $string_keys = array( 'label', 'placeholder', 'description', 'text', 'input_label', 'button_label' ); |
|
657 | + |
|
658 | + foreach ( $results as $meta_value ) { |
|
659 | + $fields = maybe_unserialize( $meta_value ); |
|
660 | + |
|
661 | + if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
662 | + foreach ( $fields as $field ) { |
|
663 | + // Labels |
|
664 | + foreach ( $string_keys as $string_key ) { |
|
665 | + if ( ! empty( $field[ $string_key ] ) && is_string( $field[ $string_key ] ) ) { |
|
666 | + $strings[] = wp_unslash( $field[ $string_key ] ); |
|
667 | + } |
|
668 | + } |
|
669 | + |
|
670 | + // Address fields |
|
671 | + if ( ! empty( $field['fields'] ) && ! empty( $field['fields'] ) ) { |
|
672 | + foreach ( $field['fields'] as $sub_field ) { |
|
673 | + foreach ( $string_keys as $string_key ) { |
|
674 | + if ( ! empty( $sub_field[ $string_key ] ) && is_string( $sub_field[ $string_key ] ) ) { |
|
675 | + $strings[] = wp_unslash( $sub_field[ $string_key ] ); |
|
676 | + } |
|
677 | + } |
|
678 | + } |
|
679 | + } |
|
680 | + |
|
681 | + // Options |
|
682 | + if ( ! empty( $field['options'] ) ) { |
|
683 | + $options = array(); |
|
684 | + |
|
685 | + if ( is_array( $field['options'] ) ) { |
|
686 | + $options = $field['options']; |
|
687 | + } else if ( is_string( $field['options'] ) ) { |
|
688 | + $options = getpaid_convert_price_string_to_options( $field['options'], false ); |
|
689 | + $options = ! empty( $options ) ? array_values( $options ) : array(); |
|
690 | + } |
|
691 | + |
|
692 | + if ( ! empty( $options ) ) { |
|
693 | + foreach( $options as $option ) { |
|
694 | + if ( ! empty( $option ) && is_string( $option ) ) { |
|
695 | + $strings[] = wp_unslash( $option ); |
|
696 | + } |
|
697 | + } |
|
698 | + } |
|
699 | + } |
|
700 | + } |
|
701 | + } |
|
702 | + } |
|
703 | + } |
|
704 | + |
|
705 | + /** |
|
706 | + * Filter the database strings to add for translation. |
|
707 | + * |
|
708 | + * @since 2.8.32 |
|
709 | + * |
|
710 | + * @param array $strings Array of strings. |
|
711 | + */ |
|
712 | + $strings = apply_filters( 'getpaid_db_language_strings', $strings ); |
|
713 | + |
|
714 | + $strings = array_unique( $strings ); |
|
715 | + |
|
716 | + return $strings; |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | /** |
@@ -724,9 +724,9 @@ discard block |
||
724 | 724 | * @return bool True if active else false. |
725 | 725 | */ |
726 | 726 | function getpaid_is_wpml() { |
727 | - if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress', false ) && function_exists( 'icl_object_id' ) ) { |
|
728 | - return true; |
|
729 | - } |
|
727 | + if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress', false ) && function_exists( 'icl_object_id' ) ) { |
|
728 | + return true; |
|
729 | + } |
|
730 | 730 | |
731 | - return false; |
|
731 | + return false; |
|
732 | 732 | } |
733 | 733 | \ No newline at end of file |
@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( ! $is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( ! $is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,156 +49,156 @@ discard block |
||
49 | 49 | * @param string $post_type The post type or invoice type. |
50 | 50 | * @return string The history page URL. |
51 | 51 | */ |
52 | -function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
|
53 | - $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
|
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
52 | +function wpinv_get_history_page_uri($post_type = 'wpi_invoice') { |
|
53 | + $post_type = sanitize_key(str_replace('wpi_', '', $post_type)); |
|
54 | + $page_id = wpinv_get_option("{$post_type}_history_page", 0); |
|
55 | + $page_id = absint($page_id); |
|
56 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option('success_page', false); |
|
61 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
73 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
74 | - $ret = $ret ? is_page( $ret ) : false; |
|
75 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
73 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
74 | + $ret = $ret ? is_page($ret) : false; |
|
75 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Redirects a user the success page. |
80 | 80 | */ |
81 | -function wpinv_send_to_success_page( $args = array() ) { |
|
81 | +function wpinv_send_to_success_page($args = array()) { |
|
82 | 82 | |
83 | - $args = wp_parse_args( $args ); |
|
83 | + $args = wp_parse_args($args); |
|
84 | 84 | |
85 | - if ( ! empty( $args['invoice_key'] ) ) { |
|
86 | - $invoice = wpinv_get_invoice( $args['invoice_key'] ); |
|
85 | + if (!empty($args['invoice_key'])) { |
|
86 | + $invoice = wpinv_get_invoice($args['invoice_key']); |
|
87 | 87 | |
88 | - if ( $invoice && $invoice->exists() ) { |
|
88 | + if ($invoice && $invoice->exists()) { |
|
89 | 89 | $success_page = $invoice->get_receipt_url(); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - if ( empty( $success_page ) ) { |
|
93 | + if (empty($success_page)) { |
|
94 | 94 | $success_page = wpinv_get_success_page_uri(); |
95 | 95 | } |
96 | 96 | |
97 | - $args['wpinv-notice'] = current( array_keys( wpinv_get_errors() ) ); |
|
97 | + $args['wpinv-notice'] = current(array_keys(wpinv_get_errors())); |
|
98 | 98 | |
99 | - $redirect = add_query_arg( $args, $success_page ); |
|
99 | + $redirect = add_query_arg($args, $success_page); |
|
100 | 100 | |
101 | - $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args, $success_page ); |
|
101 | + $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args, $success_page); |
|
102 | 102 | |
103 | - wp_redirect( $redirect ); |
|
103 | + wp_redirect($redirect); |
|
104 | 104 | exit; |
105 | 105 | } |
106 | 106 | |
107 | -function wpinv_send_to_failed_page( $args = null ) { |
|
107 | +function wpinv_send_to_failed_page($args = null) { |
|
108 | 108 | $redirect = wpinv_get_failed_transaction_uri(); |
109 | 109 | |
110 | - if ( ! empty( $args ) ) { |
|
110 | + if (!empty($args)) { |
|
111 | 111 | // Check for backward compatibility |
112 | - if ( is_string( $args ) ) { |
|
113 | - $args = str_replace( '?', '', $args ); |
|
112 | + if (is_string($args)) { |
|
113 | + $args = str_replace('?', '', $args); |
|
114 | 114 | } |
115 | 115 | |
116 | - $args = wp_parse_args( $args ); |
|
116 | + $args = wp_parse_args($args); |
|
117 | 117 | |
118 | - $redirect = add_query_arg( $args, $redirect ); |
|
118 | + $redirect = add_query_arg($args, $redirect); |
|
119 | 119 | } |
120 | 120 | |
121 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
121 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
122 | 122 | |
123 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
124 | - wp_redirect( $redirect ); |
|
123 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
124 | + wp_redirect($redirect); |
|
125 | 125 | exit; |
126 | 126 | } |
127 | 127 | |
128 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
129 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
130 | - $uri = isset( $uri ) ? get_permalink( $uri ) : null; |
|
128 | +function wpinv_get_checkout_uri($args = array()) { |
|
129 | + $uri = wpinv_get_option('checkout_page', false); |
|
130 | + $uri = isset($uri) ? get_permalink($uri) : null; |
|
131 | 131 | |
132 | - if ( ! empty( $args ) ) { |
|
132 | + if (!empty($args)) { |
|
133 | 133 | // Check for backward compatibility |
134 | - if ( is_string( $args ) ) { |
|
135 | - $args = str_replace( '?', '', $args ); |
|
134 | + if (is_string($args)) { |
|
135 | + $args = str_replace('?', '', $args); |
|
136 | 136 | } |
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args($args); |
|
139 | 139 | |
140 | - $uri = add_query_arg( $args, $uri ); |
|
140 | + $uri = add_query_arg($args, $uri); |
|
141 | 141 | } |
142 | 142 | |
143 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
143 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
144 | 144 | |
145 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
145 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
146 | 146 | |
147 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
148 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
147 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
148 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
149 | 149 | } |
150 | 150 | |
151 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
151 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
152 | 152 | } |
153 | 153 | |
154 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
155 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
156 | - $success_page = get_permalink( $success_page ); |
|
154 | +function wpinv_get_success_page_url($query_string = null) { |
|
155 | + $success_page = wpinv_get_option('success_page', 0); |
|
156 | + $success_page = get_permalink($success_page); |
|
157 | 157 | |
158 | - if ( $query_string ) { |
|
158 | + if ($query_string) { |
|
159 | 159 | $success_page .= $query_string; |
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
162 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
163 | 163 | } |
164 | 164 | |
165 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
166 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
165 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
166 | + $uri = wpinv_get_option('failure_page', ''); |
|
167 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
168 | 168 | |
169 | - if ( $extras ) { |
|
169 | + if ($extras) { |
|
170 | 170 | $uri .= $extras; |
171 | 171 | } |
172 | 172 | |
173 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
173 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_is_failed_transaction_page() { |
177 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
178 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
177 | + $ret = wpinv_get_option('failure_page', false); |
|
178 | + $ret = isset($ret) ? is_page($ret) : false; |
|
179 | 179 | |
180 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
180 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
181 | 181 | } |
182 | 182 | |
183 | -function wpinv_transaction_query( $type = 'start' ) { |
|
183 | +function wpinv_transaction_query($type = 'start') { |
|
184 | 184 | global $wpdb; |
185 | 185 | |
186 | 186 | $wpdb->hide_errors(); |
187 | 187 | |
188 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
189 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
188 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
189 | + define('WPINV_USE_TRANSACTIONS', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
193 | - switch ( $type ) { |
|
192 | + if (WPINV_USE_TRANSACTIONS) { |
|
193 | + switch ($type) { |
|
194 | 194 | case 'commit': |
195 | - $wpdb->query( 'COMMIT' ); |
|
195 | + $wpdb->query('COMMIT'); |
|
196 | 196 | break; |
197 | 197 | case 'rollback': |
198 | - $wpdb->query( 'ROLLBACK' ); |
|
198 | + $wpdb->query('ROLLBACK'); |
|
199 | 199 | break; |
200 | 200 | default: |
201 | - $wpdb->query( 'START TRANSACTION' ); |
|
201 | + $wpdb->query('START TRANSACTION'); |
|
202 | 202 | break; |
203 | 203 | } |
204 | 204 | } |
@@ -207,146 +207,146 @@ discard block |
||
207 | 207 | function wpinv_get_prefix() { |
208 | 208 | $invoice_prefix = 'INV-'; |
209 | 209 | |
210 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
210 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | function wpinv_get_business_logo() { |
214 | - $business_logo = wpinv_get_option( 'logo' ); |
|
215 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
214 | + $business_logo = wpinv_get_option('logo'); |
|
215 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | function wpinv_get_business_name() { |
219 | - $name = wpinv_get_option( 'store_name', wpinv_get_blogname() ); |
|
219 | + $name = wpinv_get_option('store_name', wpinv_get_blogname()); |
|
220 | 220 | |
221 | - if ( empty( $name ) ) { |
|
221 | + if (empty($name)) { |
|
222 | 222 | $name = wpinv_get_blogname(); |
223 | 223 | } |
224 | 224 | |
225 | - return apply_filters( 'wpinv_get_business_name', $name ); |
|
225 | + return apply_filters('wpinv_get_business_name', $name); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_get_blogname() { |
229 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
229 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | function wpinv_get_admin_email() { |
233 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
234 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
233 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
234 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | function wpinv_get_business_website() { |
238 | - $business_website = home_url( '/' ); |
|
239 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
238 | + $business_website = home_url('/'); |
|
239 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
242 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
243 | 243 | $terms_text = ''; |
244 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
244 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_get_business_footer() { |
248 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
249 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
250 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
248 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
249 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
250 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | function wpinv_checkout_required_fields() { |
254 | 254 | $required_fields = array(); |
255 | 255 | |
256 | 256 | // Let payment gateways and other extensions determine if address fields should be required |
257 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
257 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
258 | 258 | |
259 | - if ( $require_billing_details ) { |
|
260 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
259 | + if ($require_billing_details) { |
|
260 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
261 | 261 | $required_fields['first_name'] = array( |
262 | 262 | 'error_id' => 'invalid_first_name', |
263 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ), |
|
263 | + 'error_message' => __('Please enter your first name', 'invoicing'), |
|
264 | 264 | ); |
265 | 265 | } |
266 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
266 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
267 | 267 | $required_fields['address'] = array( |
268 | 268 | 'error_id' => 'invalid_address', |
269 | - 'error_message' => __( 'Please enter your address', 'invoicing' ), |
|
269 | + 'error_message' => __('Please enter your address', 'invoicing'), |
|
270 | 270 | ); |
271 | 271 | } |
272 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
272 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
273 | 273 | $required_fields['city'] = array( |
274 | 274 | 'error_id' => 'invalid_city', |
275 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ), |
|
275 | + 'error_message' => __('Please enter your billing city', 'invoicing'), |
|
276 | 276 | ); |
277 | 277 | } |
278 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
278 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
279 | 279 | $required_fields['state'] = array( |
280 | 280 | 'error_id' => 'invalid_state', |
281 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ), |
|
281 | + 'error_message' => __('Please enter billing state / province', 'invoicing'), |
|
282 | 282 | ); |
283 | 283 | } |
284 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
284 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
285 | 285 | $required_fields['country'] = array( |
286 | 286 | 'error_id' => 'invalid_country', |
287 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ), |
|
287 | + 'error_message' => __('Please select your billing country', 'invoicing'), |
|
288 | 288 | ); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
292 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | function wpinv_is_ssl_enforced() { |
296 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
297 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
296 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
297 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | function wpinv_schedule_event_twicedaily() { |
301 | 301 | wpinv_email_payment_reminders(); |
302 | 302 | } |
303 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
303 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
304 | 304 | |
305 | 305 | function wpinv_require_login_to_checkout() { |
306 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
307 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
306 | + $return = wpinv_get_option('login_to_checkout', false); |
|
307 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
308 | 308 | } |
309 | 309 | |
310 | -function wpinv_sequential_number_active( $type = '' ) { |
|
311 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
312 | - if ( null !== $check ) { |
|
310 | +function wpinv_sequential_number_active($type = '') { |
|
311 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
312 | + if (null !== $check) { |
|
313 | 313 | return $check; |
314 | 314 | } |
315 | 315 | |
316 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
316 | + return wpinv_get_option('sequential_invoice_number'); |
|
317 | 317 | } |
318 | 318 | |
319 | -function wpinv_switch_to_locale( $locale = null ) { |
|
319 | +function wpinv_switch_to_locale($locale = null) { |
|
320 | 320 | global $invoicing, $wpi_switch_locale; |
321 | 321 | |
322 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
323 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
322 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
323 | + $locale = empty($locale) ? get_locale() : $locale; |
|
324 | 324 | |
325 | - switch_to_locale( $locale ); |
|
325 | + switch_to_locale($locale); |
|
326 | 326 | |
327 | 327 | $wpi_switch_locale = $locale; |
328 | 328 | |
329 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
329 | + add_filter('plugin_locale', 'get_locale'); |
|
330 | 330 | |
331 | 331 | $invoicing->load_textdomain(); |
332 | 332 | |
333 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
333 | + do_action('wpinv_switch_to_locale', $locale); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_restore_locale() { |
338 | 338 | global $invoicing, $wpi_switch_locale; |
339 | 339 | |
340 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
340 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
341 | 341 | restore_previous_locale(); |
342 | 342 | |
343 | 343 | $wpi_switch_locale = null; |
344 | 344 | |
345 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
345 | + remove_filter('plugin_locale', 'get_locale'); |
|
346 | 346 | |
347 | 347 | $invoicing->load_textdomain(); |
348 | 348 | |
349 | - do_action( 'wpinv_restore_locale' ); |
|
349 | + do_action('wpinv_restore_locale'); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -354,26 +354,26 @@ discard block |
||
354 | 354 | * Returns the default form's id. |
355 | 355 | */ |
356 | 356 | function wpinv_get_default_payment_form() { |
357 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
357 | + $form = get_option('wpinv_default_payment_form'); |
|
358 | 358 | |
359 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
359 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
360 | 360 | $form = wp_insert_post( |
361 | 361 | array( |
362 | 362 | 'post_type' => 'wpi_payment_form', |
363 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
363 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
364 | 364 | 'post_status' => 'publish', |
365 | 365 | 'meta_input' => array( |
366 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
366 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
367 | 367 | 'wpinv_form_items' => array(), |
368 | 368 | ), |
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | |
372 | - update_option( 'wpinv_default_payment_form', $form ); |
|
372 | + update_option('wpinv_default_payment_form', $form); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // WPML support. |
376 | - return (int) wpinv_translate_post_id( $form ); |
|
376 | + return (int) wpinv_translate_post_id($form); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @param int $post_id |
383 | 383 | */ |
384 | -function wpinv_translate_post_id( $post_id ) { |
|
384 | +function wpinv_translate_post_id($post_id) { |
|
385 | 385 | |
386 | 386 | // Abort if no post id is given. |
387 | - if ( empty( $post_id ) ) { |
|
387 | + if (empty($post_id)) { |
|
388 | 388 | return $post_id; |
389 | 389 | } |
390 | 390 | |
391 | 391 | // WPML. |
392 | - $post_id = apply_filters( 'wpml_object_id', $post_id, 'wpi_payment_form', true ); |
|
392 | + $post_id = apply_filters('wpml_object_id', $post_id, 'wpi_payment_form', true); |
|
393 | 393 | |
394 | 394 | // Polylang. |
395 | - if ( function_exists( 'pll_get_post' ) ) { |
|
396 | - $translated = pll_get_post( $post_id ); |
|
395 | + if (function_exists('pll_get_post')) { |
|
396 | + $translated = pll_get_post($post_id); |
|
397 | 397 | |
398 | - if ( ! empty( $translated ) ) { |
|
398 | + if (!empty($translated)) { |
|
399 | 399 | $post_id = $translated; |
400 | 400 | } |
401 | 401 | } |
@@ -408,19 +408,19 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param int $payment_form |
410 | 410 | */ |
411 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
411 | +function getpaid_get_payment_form_elements($payment_form) { |
|
412 | 412 | |
413 | - if ( empty( $payment_form ) ) { |
|
414 | - return wpinv_get_data( 'sample-payment-form' ); |
|
413 | + if (empty($payment_form)) { |
|
414 | + return wpinv_get_data('sample-payment-form'); |
|
415 | 415 | } |
416 | 416 | |
417 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
417 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
418 | 418 | |
419 | - if ( is_array( $form_elements ) ) { |
|
419 | + if (is_array($form_elements)) { |
|
420 | 420 | return $form_elements; |
421 | 421 | } |
422 | 422 | |
423 | - return wpinv_get_data( 'sample-payment-form' ); |
|
423 | + return wpinv_get_data('sample-payment-form'); |
|
424 | 424 | |
425 | 425 | } |
426 | 426 | |
@@ -429,65 +429,65 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @param int $payment_form |
431 | 431 | */ |
432 | -function gepaid_get_form_items( $id ) { |
|
433 | - $form = new GetPaid_Payment_Form( $id ); |
|
432 | +function gepaid_get_form_items($id) { |
|
433 | + $form = new GetPaid_Payment_Form($id); |
|
434 | 434 | |
435 | 435 | // Is this a default form? |
436 | - if ( $form->is_default() ) { |
|
436 | + if ($form->is_default()) { |
|
437 | 437 | return array(); |
438 | 438 | } |
439 | 439 | |
440 | - return $form->get_items( 'view', 'arrays' ); |
|
440 | + return $form->get_items('view', 'arrays'); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
444 | 444 | * Trims each line in a paragraph. |
445 | 445 | * |
446 | 446 | */ |
447 | -function gepaid_trim_lines( $content ) { |
|
448 | - return implode( "\n", array_map( 'trim', explode( "\n", $content ) ) ); |
|
447 | +function gepaid_trim_lines($content) { |
|
448 | + return implode("\n", array_map('trim', explode("\n", $content))); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
452 | -function wpinv_add_elementor_widget_categories( $elements_manager ) { |
|
452 | +function wpinv_add_elementor_widget_categories($elements_manager) { |
|
453 | 453 | $elements_manager->add_category( |
454 | 454 | 'getpaid', |
455 | 455 | array( |
456 | - 'title' => esc_html__( 'GetPaid', 'invoicing' ), |
|
456 | + 'title' => esc_html__('GetPaid', 'invoicing'), |
|
457 | 457 | 'icon' => 'fa fa-plug', |
458 | 458 | ) |
459 | 459 | ); |
460 | 460 | } |
461 | -add_filter( 'elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories' ); |
|
461 | +add_filter('elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories'); |
|
462 | 462 | |
463 | -function wpinv_alter_elementor_widget_config( $config ) { |
|
463 | +function wpinv_alter_elementor_widget_config($config) { |
|
464 | 464 | |
465 | - if ( ! empty( $config['initial_document']['widgets'] ) ) { |
|
466 | - foreach ( $config['initial_document']['widgets'] as $key => $widget ) { |
|
467 | - if ( substr( $key, 0, 16 ) === 'wp-widget-wpinv_' || $key === 'wp-widget-getpaid' ) { |
|
468 | - $config['initial_document']['widgets'][ $key ]['categories'][] = 'getpaid'; |
|
469 | - $config['initial_document']['widgets'][ $key ]['hide_on_search'] = false; |
|
470 | - $config['initial_document']['widgets'][ $key ]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i> |
|
465 | + if (!empty($config['initial_document']['widgets'])) { |
|
466 | + foreach ($config['initial_document']['widgets'] as $key => $widget) { |
|
467 | + if (substr($key, 0, 16) === 'wp-widget-wpinv_' || $key === 'wp-widget-getpaid') { |
|
468 | + $config['initial_document']['widgets'][$key]['categories'][] = 'getpaid'; |
|
469 | + $config['initial_document']['widgets'][$key]['hide_on_search'] = false; |
|
470 | + $config['initial_document']['widgets'][$key]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i> |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | 475 | return $config; |
476 | 476 | } |
477 | -add_filter( 'elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config' ); |
|
477 | +add_filter('elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config'); |
|
478 | 478 | |
479 | 479 | function wpinv_get_report_graphs() { |
480 | 480 | |
481 | 481 | return apply_filters( |
482 | 482 | 'getpaid_report_graphs', |
483 | 483 | array( |
484 | - 'sales' => __( 'Earnings', 'invoicing' ), |
|
485 | - 'refunds' => __( 'Refunds', 'invoicing' ), |
|
486 | - 'tax' => __( 'Taxes', 'invoicing' ), |
|
487 | - 'fees' => __( 'Fees', 'invoicing' ), |
|
488 | - 'discount' => __( 'Discounts', 'invoicing' ), |
|
489 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
490 | - 'items' => __( 'Purchased Items', 'invoicing' ), |
|
484 | + 'sales' => __('Earnings', 'invoicing'), |
|
485 | + 'refunds' => __('Refunds', 'invoicing'), |
|
486 | + 'tax' => __('Taxes', 'invoicing'), |
|
487 | + 'fees' => __('Fees', 'invoicing'), |
|
488 | + 'discount' => __('Discounts', 'invoicing'), |
|
489 | + 'invoices' => __('Invoices', 'invoicing'), |
|
490 | + 'items' => __('Purchased Items', 'invoicing'), |
|
491 | 491 | ) |
492 | 492 | ); |
493 | 493 | |
@@ -501,18 +501,18 @@ discard block |
||
501 | 501 | * @return bool|WP_Filesystem The WP Filesystem object or false on failure. |
502 | 502 | */ |
503 | 503 | function getpaid_wp_filesystem() { |
504 | - if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
505 | - require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
504 | + if (!function_exists('get_filesystem_method')) { |
|
505 | + require_once(ABSPATH . "/wp-admin/includes/file.php"); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | $access_type = get_filesystem_method(); |
509 | 509 | |
510 | - if ( $access_type === 'direct' ) { |
|
510 | + if ($access_type === 'direct') { |
|
511 | 511 | /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
512 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
512 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
513 | 513 | |
514 | 514 | /* Initialize the API */ |
515 | - if ( ! WP_Filesystem( $creds ) ) { |
|
515 | + if (!WP_Filesystem($creds)) { |
|
516 | 516 | /* Any problems and we exit */ |
517 | 517 | return false; |
518 | 518 | } |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | |
522 | 522 | return $wp_filesystem; |
523 | 523 | /* Do our file manipulations below */ |
524 | - } else if ( defined( 'FTP_USER' ) ) { |
|
525 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
524 | + } else if (defined('FTP_USER')) { |
|
525 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
526 | 526 | |
527 | 527 | /* Initialize the API */ |
528 | - if ( ! WP_Filesystem( $creds ) ) { |
|
528 | + if (!WP_Filesystem($creds)) { |
|
529 | 529 | /* Any problems and we exit */ |
530 | 530 | return false; |
531 | 531 | } |
@@ -551,11 +551,11 @@ discard block |
||
551 | 551 | |
552 | 552 | $language_file = WPINV_PLUGIN_DIR . 'db-language.php'; |
553 | 553 | |
554 | - if ( is_file( $language_file ) && ! is_writable( $language_file ) ) { |
|
554 | + if (is_file($language_file) && !is_writable($language_file)) { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | 557 | |
558 | - if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) { |
|
558 | + if (!is_file($language_file) && !is_writable(dirname($language_file))) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
@@ -573,35 +573,35 @@ discard block |
||
573 | 573 | $footer = array(); |
574 | 574 | $footer[] = ""; |
575 | 575 | $footer[] = ""; |
576 | - $footer[] = "/*** GetPaid " . WPINV_VERSION . " @ " . gmdate( 'Y-m-d H:i:s' ) . " ***/"; |
|
576 | + $footer[] = "/*** GetPaid " . WPINV_VERSION . " @ " . gmdate('Y-m-d H:i:s') . " ***/"; |
|
577 | 577 | $footer[] = ""; |
578 | 578 | |
579 | - $contents = implode( PHP_EOL, $head ); |
|
579 | + $contents = implode(PHP_EOL, $head); |
|
580 | 580 | |
581 | 581 | $strings = getpaid_get_db_language_strings(); |
582 | 582 | |
583 | - if ( ! empty( $strings ) ) { |
|
583 | + if (!empty($strings)) { |
|
584 | 584 | $is_wpml = getpaid_is_wpml(); |
585 | 585 | |
586 | - foreach ( $strings as $string ) { |
|
587 | - if ( is_scalar( $string ) && $string != '' ) { |
|
588 | - do_action( 'getpaid_db_language_add_string', $string ); |
|
586 | + foreach ($strings as $string) { |
|
587 | + if (is_scalar($string) && $string != '') { |
|
588 | + do_action('getpaid_db_language_add_string', $string); |
|
589 | 589 | |
590 | - if ( $is_wpml ) { |
|
590 | + if ($is_wpml) { |
|
591 | 591 | // Registers a individual text string for WPML translation. |
592 | - do_action( 'wpml_register_single_string', 'invoicing', '', $string ); |
|
592 | + do_action('wpml_register_single_string', 'invoicing', '', $string); |
|
593 | 593 | } |
594 | 594 | |
595 | - $string = str_replace( "'", "\'", $string ); |
|
595 | + $string = str_replace("'", "\'", $string); |
|
596 | 596 | |
597 | 597 | $contents .= PHP_EOL . "__( '" . $string . "', 'invoicing' );"; |
598 | 598 | } |
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | - $contents .= implode( PHP_EOL, $footer ); |
|
602 | + $contents .= implode(PHP_EOL, $footer); |
|
603 | 603 | |
604 | - if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) { |
|
604 | + if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) { |
|
605 | 605 | return true; |
606 | 606 | } else { |
607 | 607 | return false; |
@@ -637,62 +637,62 @@ discard block |
||
637 | 637 | * |
638 | 638 | * @param array $setting_keys Array of setting keys. |
639 | 639 | */ |
640 | - $setting_keys = apply_filters( 'getpaid_options_to_db_language_strings', $setting_keys ); |
|
640 | + $setting_keys = apply_filters('getpaid_options_to_db_language_strings', $setting_keys); |
|
641 | 641 | |
642 | - $setting_keys = array_unique( $setting_keys ); |
|
642 | + $setting_keys = array_unique($setting_keys); |
|
643 | 643 | |
644 | - if ( ! empty( $settings ) && ! empty( $setting_keys ) ) { |
|
645 | - foreach ( $setting_keys as $setting_key ) { |
|
646 | - if ( ! empty( $settings[ $setting_key ] ) && is_string( $settings[ $setting_key ] ) ) { |
|
647 | - $strings[] = wp_unslash( $settings[ $setting_key ] ); |
|
644 | + if (!empty($settings) && !empty($setting_keys)) { |
|
645 | + foreach ($setting_keys as $setting_key) { |
|
646 | + if (!empty($settings[$setting_key]) && is_string($settings[$setting_key])) { |
|
647 | + $strings[] = wp_unslash($settings[$setting_key]); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
652 | 652 | // Payment forms |
653 | - $results = $wpdb->get_col( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
653 | + $results = $wpdb->get_col("SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'"); |
|
654 | 654 | |
655 | - if ( ! empty( $results ) ) { |
|
656 | - $string_keys = array( 'label', 'placeholder', 'description', 'text', 'input_label', 'button_label' ); |
|
655 | + if (!empty($results)) { |
|
656 | + $string_keys = array('label', 'placeholder', 'description', 'text', 'input_label', 'button_label'); |
|
657 | 657 | |
658 | - foreach ( $results as $meta_value ) { |
|
659 | - $fields = maybe_unserialize( $meta_value ); |
|
658 | + foreach ($results as $meta_value) { |
|
659 | + $fields = maybe_unserialize($meta_value); |
|
660 | 660 | |
661 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
662 | - foreach ( $fields as $field ) { |
|
661 | + if (!empty($fields) && is_array($fields)) { |
|
662 | + foreach ($fields as $field) { |
|
663 | 663 | // Labels |
664 | - foreach ( $string_keys as $string_key ) { |
|
665 | - if ( ! empty( $field[ $string_key ] ) && is_string( $field[ $string_key ] ) ) { |
|
666 | - $strings[] = wp_unslash( $field[ $string_key ] ); |
|
664 | + foreach ($string_keys as $string_key) { |
|
665 | + if (!empty($field[$string_key]) && is_string($field[$string_key])) { |
|
666 | + $strings[] = wp_unslash($field[$string_key]); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | // Address fields |
671 | - if ( ! empty( $field['fields'] ) && ! empty( $field['fields'] ) ) { |
|
672 | - foreach ( $field['fields'] as $sub_field ) { |
|
673 | - foreach ( $string_keys as $string_key ) { |
|
674 | - if ( ! empty( $sub_field[ $string_key ] ) && is_string( $sub_field[ $string_key ] ) ) { |
|
675 | - $strings[] = wp_unslash( $sub_field[ $string_key ] ); |
|
671 | + if (!empty($field['fields']) && !empty($field['fields'])) { |
|
672 | + foreach ($field['fields'] as $sub_field) { |
|
673 | + foreach ($string_keys as $string_key) { |
|
674 | + if (!empty($sub_field[$string_key]) && is_string($sub_field[$string_key])) { |
|
675 | + $strings[] = wp_unslash($sub_field[$string_key]); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | 681 | // Options |
682 | - if ( ! empty( $field['options'] ) ) { |
|
682 | + if (!empty($field['options'])) { |
|
683 | 683 | $options = array(); |
684 | 684 | |
685 | - if ( is_array( $field['options'] ) ) { |
|
685 | + if (is_array($field['options'])) { |
|
686 | 686 | $options = $field['options']; |
687 | - } else if ( is_string( $field['options'] ) ) { |
|
688 | - $options = getpaid_convert_price_string_to_options( $field['options'], false ); |
|
689 | - $options = ! empty( $options ) ? array_values( $options ) : array(); |
|
687 | + } else if (is_string($field['options'])) { |
|
688 | + $options = getpaid_convert_price_string_to_options($field['options'], false); |
|
689 | + $options = !empty($options) ? array_values($options) : array(); |
|
690 | 690 | } |
691 | 691 | |
692 | - if ( ! empty( $options ) ) { |
|
693 | - foreach( $options as $option ) { |
|
694 | - if ( ! empty( $option ) && is_string( $option ) ) { |
|
695 | - $strings[] = wp_unslash( $option ); |
|
692 | + if (!empty($options)) { |
|
693 | + foreach ($options as $option) { |
|
694 | + if (!empty($option) && is_string($option)) { |
|
695 | + $strings[] = wp_unslash($option); |
|
696 | 696 | } |
697 | 697 | } |
698 | 698 | } |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @param array $strings Array of strings. |
711 | 711 | */ |
712 | - $strings = apply_filters( 'getpaid_db_language_strings', $strings ); |
|
712 | + $strings = apply_filters('getpaid_db_language_strings', $strings); |
|
713 | 713 | |
714 | - $strings = array_unique( $strings ); |
|
714 | + $strings = array_unique($strings); |
|
715 | 715 | |
716 | 716 | return $strings; |
717 | 717 | } |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | * @return bool True if active else false. |
725 | 725 | */ |
726 | 726 | function getpaid_is_wpml() { |
727 | - if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress', false ) && function_exists( 'icl_object_id' ) ) { |
|
727 | + if (defined('ICL_SITEPRESS_VERSION') && !ICL_PLUGIN_INACTIVE && class_exists('SitePress', false) && function_exists('icl_object_id')) { |
|
728 | 728 | return true; |
729 | 729 | } |
730 | 730 |
@@ -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,125 +175,125 @@ 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'; |
|
180 | + // Setup possible parts |
|
181 | + $templates = array(); |
|
182 | + if ( isset( $name ) ) { |
|
183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
184 | 184 | } |
185 | - $templates[] = $slug . '.php'; |
|
185 | + $templates[] = $slug . '.php'; |
|
186 | 186 | |
187 | - // Allow template parts to be filtered |
|
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + // Allow template parts to be filtered |
|
188 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
189 | 189 | |
190 | - // Return the part that is found |
|
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + // Return the part that is found |
|
191 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
195 | - // No file found yet |
|
196 | - $located = false; |
|
195 | + // No file found yet |
|
196 | + $located = false; |
|
197 | 197 | |
198 | - // Try to find a template file |
|
199 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + // Try to find a template file |
|
199 | + foreach ( (array)$template_names as $template_name ) { |
|
200 | 200 | |
201 | - // Continue if template is empty |
|
202 | - if ( empty( $template_name ) ) { |
|
203 | - continue; |
|
201 | + // Continue if template is empty |
|
202 | + if ( empty( $template_name ) ) { |
|
203 | + continue; |
|
204 | 204 | } |
205 | 205 | |
206 | - // Trim off any slashes from the template name |
|
207 | - $template_name = ltrim( $template_name, '/' ); |
|
206 | + // Trim off any slashes from the template name |
|
207 | + $template_name = ltrim( $template_name, '/' ); |
|
208 | 208 | |
209 | - // try locating this template file by looping through the template paths |
|
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
209 | + // try locating this template file by looping through the template paths |
|
210 | + foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
213 | - $located = $template_path . $template_name; |
|
214 | - break; |
|
215 | - } |
|
216 | - } |
|
212 | + if ( file_exists( $template_path . $template_name ) ) { |
|
213 | + $located = $template_path . $template_name; |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
219 | - break; |
|
220 | - } |
|
221 | - } |
|
218 | + if ( ! empty( $located ) ) { |
|
219 | + break; |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | + load_template( $located, $require_once ); |
|
225 | 225 | } |
226 | 226 | |
227 | - return $located; |
|
227 | + return $located; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | function wpinv_get_theme_template_paths() { |
231 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
231 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
232 | 232 | |
233 | - $file_paths = array( |
|
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
236 | - 100 => wpinv_get_templates_dir(), |
|
237 | - ); |
|
233 | + $file_paths = array( |
|
234 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
236 | + 100 => wpinv_get_templates_dir(), |
|
237 | + ); |
|
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
240 | 240 | |
241 | - // sort the file paths based on priority |
|
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
241 | + // sort the file paths based on priority |
|
242 | + ksort( $file_paths, SORT_NUMERIC ); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map( 'trailingslashit', $file_paths ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | - $pages = array(); |
|
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
249 | + $pages = array(); |
|
250 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
256 | - return; |
|
257 | - } |
|
255 | + if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
256 | + return; |
|
257 | + } |
|
258 | 258 | |
259 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
259 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
260 | 260 | } |
261 | 261 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
262 | 262 | |
263 | 263 | function wpinv_add_body_classes( $class ) { |
264 | - $classes = (array)$class; |
|
264 | + $classes = (array)$class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
267 | - $classes[] = 'wpinv-checkout'; |
|
268 | - $classes[] = 'wpinv-page'; |
|
269 | - } |
|
266 | + if ( wpinv_is_checkout() ) { |
|
267 | + $classes[] = 'wpinv-checkout'; |
|
268 | + $classes[] = 'wpinv-page'; |
|
269 | + } |
|
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
272 | - $classes[] = 'wpinv-success'; |
|
273 | - $classes[] = 'wpinv-page'; |
|
274 | - } |
|
271 | + if ( wpinv_is_success_page() ) { |
|
272 | + $classes[] = 'wpinv-success'; |
|
273 | + $classes[] = 'wpinv-page'; |
|
274 | + } |
|
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
277 | - $classes[] = 'wpinv-failed-transaction'; |
|
278 | - $classes[] = 'wpinv-page'; |
|
279 | - } |
|
276 | + if ( wpinv_is_failed_transaction_page() ) { |
|
277 | + $classes[] = 'wpinv-failed-transaction'; |
|
278 | + $classes[] = 'wpinv-page'; |
|
279 | + } |
|
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
282 | - $classes[] = 'wpinv-history'; |
|
283 | - $classes[] = 'wpinv-page'; |
|
284 | - } |
|
281 | + if ( wpinv_is_invoice_history_page() ) { |
|
282 | + $classes[] = 'wpinv-history'; |
|
283 | + $classes[] = 'wpinv-page'; |
|
284 | + } |
|
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
287 | - $classes[] = 'wpinv-subscription'; |
|
288 | - $classes[] = 'wpinv-page'; |
|
289 | - } |
|
286 | + if ( wpinv_is_subscriptions_history_page() ) { |
|
287 | + $classes[] = 'wpinv-subscription'; |
|
288 | + $classes[] = 'wpinv-page'; |
|
289 | + } |
|
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
292 | - $classes[] = 'wpinv-test-mode'; |
|
293 | - $classes[] = 'wpinv-page'; |
|
294 | - } |
|
291 | + if ( wpinv_is_test_mode() ) { |
|
292 | + $classes[] = 'wpinv-test-mode'; |
|
293 | + $classes[] = 'wpinv-page'; |
|
294 | + } |
|
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique( $classes ); |
|
297 | 297 | } |
298 | 298 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
299 | 299 | |
@@ -467,16 +467,16 @@ discard block |
||
467 | 467 | |
468 | 468 | wpinv_html_select( |
469 | 469 | array( |
470 | - 'name' => $args['name'], |
|
471 | - 'selected' => $args['selected'], |
|
472 | - 'id' => $args['id'], |
|
473 | - 'class' => $args['class'], |
|
474 | - 'options' => $options, |
|
475 | - 'multiple' => $args['multiple'], |
|
476 | - 'placeholder' => $args['placeholder'], |
|
477 | - 'show_option_all' => $args['show_option_all'], |
|
478 | - 'show_option_none' => $args['show_option_none'], |
|
479 | - 'data' => $args['data'], |
|
470 | + 'name' => $args['name'], |
|
471 | + 'selected' => $args['selected'], |
|
472 | + 'id' => $args['id'], |
|
473 | + 'class' => $args['class'], |
|
474 | + 'options' => $options, |
|
475 | + 'multiple' => $args['multiple'], |
|
476 | + 'placeholder' => $args['placeholder'], |
|
477 | + 'show_option_all' => $args['show_option_all'], |
|
478 | + 'show_option_none' => $args['show_option_none'], |
|
479 | + 'data' => $args['data'], |
|
480 | 480 | ) |
481 | 481 | ); |
482 | 482 | |
@@ -776,21 +776,21 @@ discard block |
||
776 | 776 | |
777 | 777 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
778 | 778 | |
779 | - // Remove unavailable tags. |
|
779 | + // Remove unavailable tags. |
|
780 | 780 | $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
781 | 781 | |
782 | 782 | // Clean up white space. |
783 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
783 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
784 | 784 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
785 | 785 | |
786 | 786 | // Break newlines apart and remove empty lines/trim commas and white space. |
787 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
787 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
788 | 788 | |
789 | 789 | // Add html breaks. |
790 | - $formatted_address = implode( $separator, $formatted_address ); |
|
790 | + $formatted_address = implode( $separator, $formatted_address ); |
|
791 | 791 | |
792 | - // We're done! |
|
793 | - return $formatted_address; |
|
792 | + // We're done! |
|
793 | + return $formatted_address; |
|
794 | 794 | |
795 | 795 | } |
796 | 796 | |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | function getpaid_display_invoice_subscriptions( $invoice ) { |
837 | 837 | |
838 | 838 | // Subscriptions. |
839 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
839 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
840 | 840 | |
841 | 841 | if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
842 | 842 | return; |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | function wpinv_empty_cart_message() { |
1055 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1055 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1250,9 +1250,9 @@ discard block |
||
1250 | 1250 | |
1251 | 1251 | if ( 0 == count( $form->get_items() ) ) { |
1252 | 1252 | aui()->alert( |
1253 | - array( |
|
1254 | - 'type' => 'warning', |
|
1255 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1253 | + array( |
|
1254 | + 'type' => 'warning', |
|
1255 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1256 | 1256 | ), |
1257 | 1257 | true |
1258 | 1258 | ); |
@@ -1275,10 +1275,10 @@ discard block |
||
1275 | 1275 | $invoice = wpinv_get_invoice( $invoice_id ); |
1276 | 1276 | |
1277 | 1277 | if ( empty( $invoice ) ) { |
1278 | - aui()->alert( |
|
1279 | - array( |
|
1280 | - 'type' => 'warning', |
|
1281 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1278 | + aui()->alert( |
|
1279 | + array( |
|
1280 | + 'type' => 'warning', |
|
1281 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1282 | 1282 | ), |
1283 | 1283 | true |
1284 | 1284 | ); |
@@ -1286,10 +1286,10 @@ discard block |
||
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | if ( $invoice->is_paid() ) { |
1289 | - aui()->alert( |
|
1290 | - array( |
|
1291 | - 'type' => 'warning', |
|
1292 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1289 | + aui()->alert( |
|
1290 | + array( |
|
1291 | + 'type' => 'warning', |
|
1292 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1293 | 1293 | ), |
1294 | 1294 | true |
1295 | 1295 | ); |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - if ( ! empty( $items ) ) { |
|
1357 | + if ( ! empty( $items ) ) { |
|
1358 | 1358 | $items = esc_attr( $items ); |
1359 | 1359 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1360 | 1360 | } |
@@ -1554,21 +1554,21 @@ discard block |
||
1554 | 1554 | |
1555 | 1555 | return aui()->select( |
1556 | 1556 | array( |
1557 | - 'options' => $states, |
|
1558 | - 'name' => esc_attr( $field_name ), |
|
1559 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1560 | - 'value' => sanitize_text_field( $state ), |
|
1561 | - 'placeholder' => $placeholder, |
|
1562 | - 'required' => $required, |
|
1563 | - 'label' => wp_kses_post( $label ), |
|
1564 | - 'label_type' => 'vertical', |
|
1565 | - 'help_text' => $help_text, |
|
1566 | - 'class' => 'getpaid-address-field wpinv_state', |
|
1567 | - 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1568 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1569 | - 'extra_attributes' => array( |
|
1570 | - 'autocomplete' => 'address-level1', |
|
1571 | - ), |
|
1557 | + 'options' => $states, |
|
1558 | + 'name' => esc_attr( $field_name ), |
|
1559 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1560 | + 'value' => sanitize_text_field( $state ), |
|
1561 | + 'placeholder' => $placeholder, |
|
1562 | + 'required' => $required, |
|
1563 | + 'label' => wp_kses_post( $label ), |
|
1564 | + 'label_type' => 'vertical', |
|
1565 | + 'help_text' => $help_text, |
|
1566 | + 'class' => 'getpaid-address-field wpinv_state', |
|
1567 | + 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1568 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1569 | + 'extra_attributes' => array( |
|
1570 | + 'autocomplete' => 'address-level1', |
|
1571 | + ), |
|
1572 | 1572 | ), |
1573 | 1573 | $echo |
1574 | 1574 | ); |
@@ -1664,36 +1664,36 @@ discard block |
||
1664 | 1664 | * @return array Array of custom fields. |
1665 | 1665 | */ |
1666 | 1666 | function getpaid_get_payment_form_custom_fields() { |
1667 | - global $wpdb, $payment_form_meta_fields; |
|
1667 | + global $wpdb, $payment_form_meta_fields; |
|
1668 | 1668 | |
1669 | - if ( ! empty( $payment_form_meta_fields ) ) { |
|
1670 | - return $payment_form_meta_fields; |
|
1671 | - } |
|
1669 | + if ( ! empty( $payment_form_meta_fields ) ) { |
|
1670 | + return $payment_form_meta_fields; |
|
1671 | + } |
|
1672 | 1672 | |
1673 | - $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
1673 | + $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
1674 | 1674 | |
1675 | - $meta_fields = array(); |
|
1675 | + $meta_fields = array(); |
|
1676 | 1676 | |
1677 | - if ( ! empty( $results ) ) { |
|
1678 | - foreach ( $results as $row ) { |
|
1679 | - $fields = maybe_unserialize( $row->meta_value ); |
|
1677 | + if ( ! empty( $results ) ) { |
|
1678 | + foreach ( $results as $row ) { |
|
1679 | + $fields = maybe_unserialize( $row->meta_value ); |
|
1680 | 1680 | |
1681 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
1682 | - foreach ( $fields as $field ) { |
|
1683 | - $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : ''; |
|
1681 | + if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
1682 | + foreach ( $fields as $field ) { |
|
1683 | + $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : ''; |
|
1684 | 1684 | |
1685 | - if ( $label ) { |
|
1686 | - $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) ); |
|
1687 | - $meta_fields[ $field_key ] = $label; |
|
1688 | - } |
|
1689 | - } |
|
1690 | - } |
|
1691 | - } |
|
1692 | - } |
|
1685 | + if ( $label ) { |
|
1686 | + $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) ); |
|
1687 | + $meta_fields[ $field_key ] = $label; |
|
1688 | + } |
|
1689 | + } |
|
1690 | + } |
|
1691 | + } |
|
1692 | + } |
|
1693 | 1693 | |
1694 | - $payment_form_meta_fields = $meta_fields; |
|
1694 | + $payment_form_meta_fields = $meta_fields; |
|
1695 | 1695 | |
1696 | - return $meta_fields; |
|
1696 | + return $meta_fields; |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | /** |
@@ -1704,22 +1704,22 @@ discard block |
||
1704 | 1704 | * @return bool True if site uses Gutenberg else False. |
1705 | 1705 | */ |
1706 | 1706 | function getpaid_is_gutenberg() { |
1707 | - global $wp_version; |
|
1707 | + global $wp_version; |
|
1708 | 1708 | |
1709 | - $is_gutenberg = true; |
|
1709 | + $is_gutenberg = true; |
|
1710 | 1710 | |
1711 | - // If less than v5. |
|
1712 | - if ( version_compare( $wp_version, '5.0.0', '<' ) ) { |
|
1713 | - $is_gutenberg = false; |
|
1714 | - } |
|
1711 | + // If less than v5. |
|
1712 | + if ( version_compare( $wp_version, '5.0.0', '<' ) ) { |
|
1713 | + $is_gutenberg = false; |
|
1714 | + } |
|
1715 | 1715 | |
1716 | - if ( class_exists( 'Classic_Editor' ) ) { |
|
1717 | - $is_gutenberg = false; // Classic Editor plugin is active. |
|
1718 | - } else if ( getpaid_is_classicpress() ) { |
|
1719 | - $is_gutenberg = false; // Site is using ClassicPress. |
|
1720 | - } |
|
1716 | + if ( class_exists( 'Classic_Editor' ) ) { |
|
1717 | + $is_gutenberg = false; // Classic Editor plugin is active. |
|
1718 | + } else if ( getpaid_is_classicpress() ) { |
|
1719 | + $is_gutenberg = false; // Site is using ClassicPress. |
|
1720 | + } |
|
1721 | 1721 | |
1722 | - return $is_gutenberg; |
|
1722 | + return $is_gutenberg; |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | /** |
@@ -1730,13 +1730,13 @@ discard block |
||
1730 | 1730 | * @return bool True if site uses ClassicPress else False. |
1731 | 1731 | */ |
1732 | 1732 | function getpaid_is_classicpress() { |
1733 | - if ( function_exists( 'classicpress_version' ) ) { |
|
1734 | - $is_classicpress = true; |
|
1735 | - } else { |
|
1736 | - $is_classicpress = false; |
|
1737 | - } |
|
1733 | + if ( function_exists( 'classicpress_version' ) ) { |
|
1734 | + $is_classicpress = true; |
|
1735 | + } else { |
|
1736 | + $is_classicpress = false; |
|
1737 | + } |
|
1738 | 1738 | |
1739 | - return $is_classicpress; |
|
1739 | + return $is_classicpress; |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | /** |
@@ -1748,20 +1748,20 @@ discard block |
||
1748 | 1748 | * @param @bool $blocks True to use blocks. |
1749 | 1749 | * @return string Page content. |
1750 | 1750 | */ |
1751 | - function getpaid_page_content_checkout( $filtered = false, $blocks = false ) { |
|
1752 | - if ( $blocks ) { |
|
1753 | - $content = "<!-- wp:invoicing/wpinv-checkout-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_checkout title='' ]\"} --> |
|
1751 | + function getpaid_page_content_checkout( $filtered = false, $blocks = false ) { |
|
1752 | + if ( $blocks ) { |
|
1753 | + $content = "<!-- wp:invoicing/wpinv-checkout-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_checkout title='' ]\"} --> |
|
1754 | 1754 | <div class=\"wp-block-invoicing-wpinv-checkout-widget\"></div> |
1755 | 1755 | <!-- /wp:invoicing/wpinv-checkout-widget -->"; |
1756 | - } else { |
|
1757 | - $content = "[wpinv_checkout]"; |
|
1758 | - } |
|
1756 | + } else { |
|
1757 | + $content = "[wpinv_checkout]"; |
|
1758 | + } |
|
1759 | 1759 | |
1760 | - if ( $filtered ) { |
|
1761 | - $content = apply_filters( 'getpaid_page_default_content_checkout', $content, $blocks ); |
|
1762 | - } |
|
1760 | + if ( $filtered ) { |
|
1761 | + $content = apply_filters( 'getpaid_page_default_content_checkout', $content, $blocks ); |
|
1762 | + } |
|
1763 | 1763 | |
1764 | - return $content; |
|
1764 | + return $content; |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | /** |
@@ -1773,20 +1773,20 @@ discard block |
||
1773 | 1773 | * @param @bool $blocks True to use blocks. |
1774 | 1774 | * @return string Page content. |
1775 | 1775 | */ |
1776 | - function getpaid_page_content_invoice_history( $filtered = false, $blocks = false ) { |
|
1777 | - if ( $blocks ) { |
|
1778 | - $content = "<!-- wp:invoicing/wpinv-history-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_history title='' ]\"} --> |
|
1776 | + function getpaid_page_content_invoice_history( $filtered = false, $blocks = false ) { |
|
1777 | + if ( $blocks ) { |
|
1778 | + $content = "<!-- wp:invoicing/wpinv-history-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_history title='' ]\"} --> |
|
1779 | 1779 | <div class=\"wp-block-invoicing-wpinv-history-widget\"></div> |
1780 | 1780 | <!-- /wp:invoicing/wpinv-history-widget -->"; |
1781 | - } else { |
|
1782 | - $content = "[wpinv_history]"; |
|
1783 | - } |
|
1781 | + } else { |
|
1782 | + $content = "[wpinv_history]"; |
|
1783 | + } |
|
1784 | 1784 | |
1785 | - if ( $filtered ) { |
|
1786 | - $content = apply_filters( 'getpaid_page_default_content_invoice_history', $content, $blocks ); |
|
1787 | - } |
|
1785 | + if ( $filtered ) { |
|
1786 | + $content = apply_filters( 'getpaid_page_default_content_invoice_history', $content, $blocks ); |
|
1787 | + } |
|
1788 | 1788 | |
1789 | - return $content; |
|
1789 | + return $content; |
|
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | /** |
@@ -1798,20 +1798,20 @@ discard block |
||
1798 | 1798 | * @param @bool $blocks True to use blocks. |
1799 | 1799 | * @return string Page content. |
1800 | 1800 | */ |
1801 | - function getpaid_page_content_receipt( $filtered = false, $blocks = false ) { |
|
1802 | - if ( $blocks ) { |
|
1803 | - $content = "<!-- wp:invoicing/wpinv-receipt-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_receipt title='' ]\"} --> |
|
1801 | + function getpaid_page_content_receipt( $filtered = false, $blocks = false ) { |
|
1802 | + if ( $blocks ) { |
|
1803 | + $content = "<!-- wp:invoicing/wpinv-receipt-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_receipt title='' ]\"} --> |
|
1804 | 1804 | <div class=\"wp-block-invoicing-wpinv-receipt-widget\"></div> |
1805 | 1805 | <!-- /wp:invoicing/wpinv-receipt-widget -->"; |
1806 | - } else { |
|
1807 | - $content = "[wpinv_receipt]"; |
|
1808 | - } |
|
1806 | + } else { |
|
1807 | + $content = "[wpinv_receipt]"; |
|
1808 | + } |
|
1809 | 1809 | |
1810 | - if ( $filtered ) { |
|
1811 | - $content = apply_filters( 'getpaid_page_default_content_receipt', $content, $blocks ); |
|
1812 | - } |
|
1810 | + if ( $filtered ) { |
|
1811 | + $content = apply_filters( 'getpaid_page_default_content_receipt', $content, $blocks ); |
|
1812 | + } |
|
1813 | 1813 | |
1814 | - return $content; |
|
1814 | + return $content; |
|
1815 | 1815 | } |
1816 | 1816 | |
1817 | 1817 | /** |
@@ -1823,20 +1823,20 @@ discard block |
||
1823 | 1823 | * @param @bool $blocks True to use blocks. |
1824 | 1824 | * @return string Page content. |
1825 | 1825 | */ |
1826 | - function getpaid_page_content_failure( $filtered = false, $blocks = false ) { |
|
1827 | - if ( $blocks ) { |
|
1828 | - $content = "<!-- wp:html --> |
|
1826 | + function getpaid_page_content_failure( $filtered = false, $blocks = false ) { |
|
1827 | + if ( $blocks ) { |
|
1828 | + $content = "<!-- wp:html --> |
|
1829 | 1829 | " . __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ) . " |
1830 | 1830 | <!-- /wp:html -->"; |
1831 | - } else { |
|
1832 | - $content = __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ); |
|
1833 | - } |
|
1831 | + } else { |
|
1832 | + $content = __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ); |
|
1833 | + } |
|
1834 | 1834 | |
1835 | - if ( $filtered ) { |
|
1836 | - $content = apply_filters( 'getpaid_page_default_content_failure', $content, $blocks ); |
|
1837 | - } |
|
1835 | + if ( $filtered ) { |
|
1836 | + $content = apply_filters( 'getpaid_page_default_content_failure', $content, $blocks ); |
|
1837 | + } |
|
1838 | 1838 | |
1839 | - return $content; |
|
1839 | + return $content; |
|
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | /** |
@@ -1848,20 +1848,20 @@ discard block |
||
1848 | 1848 | * @param @bool $blocks True to use blocks. |
1849 | 1849 | * @return string Page content. |
1850 | 1850 | */ |
1851 | - function getpaid_page_content_subscriptions( $filtered = false, $blocks = false ) { |
|
1852 | - if ( $blocks ) { |
|
1853 | - $content = "<!-- wp:invoicing/wpinv-subscriptions-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_subscriptions title='' ]\"} --> |
|
1851 | + function getpaid_page_content_subscriptions( $filtered = false, $blocks = false ) { |
|
1852 | + if ( $blocks ) { |
|
1853 | + $content = "<!-- wp:invoicing/wpinv-subscriptions-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_subscriptions title='' ]\"} --> |
|
1854 | 1854 | <div class=\"wp-block-invoicing-wpinv-subscriptions-widget\"></div> |
1855 | 1855 | <!-- /wp:invoicing/wpinv-subscriptions-widget -->"; |
1856 | - } else { |
|
1857 | - $content = "[wpinv_subscriptions]"; |
|
1858 | - } |
|
1856 | + } else { |
|
1857 | + $content = "[wpinv_subscriptions]"; |
|
1858 | + } |
|
1859 | 1859 | |
1860 | - if ( $filtered ) { |
|
1861 | - $content = apply_filters( 'getpaid_page_default_content_subscriptions', $content, $blocks ); |
|
1862 | - } |
|
1860 | + if ( $filtered ) { |
|
1861 | + $content = apply_filters( 'getpaid_page_default_content_subscriptions', $content, $blocks ); |
|
1862 | + } |
|
1863 | 1863 | |
1864 | - return $content; |
|
1864 | + return $content; |
|
1865 | 1865 | } |
1866 | 1866 | |
1867 | 1867 | /** |
@@ -1874,21 +1874,21 @@ discard block |
||
1874 | 1874 | * @return array Returns options array. |
1875 | 1875 | */ |
1876 | 1876 | function getpaid_parse_field_options( $options, $translated = true ) { |
1877 | - $orig_options = $options; |
|
1877 | + $orig_options = $options; |
|
1878 | 1878 | |
1879 | - $options = array(); |
|
1879 | + $options = array(); |
|
1880 | 1880 | |
1881 | - if ( ! empty( $orig_options ) ) { |
|
1882 | - foreach ( $orig_options as $key => $value ) { |
|
1883 | - if ( $value && is_string( $value ) ) { |
|
1884 | - $label = $translated ? __( wp_unslash( $value ), 'invoicing' ) : $value; |
|
1885 | - } else { |
|
1886 | - $label = $value; |
|
1887 | - } |
|
1881 | + if ( ! empty( $orig_options ) ) { |
|
1882 | + foreach ( $orig_options as $key => $value ) { |
|
1883 | + if ( $value && is_string( $value ) ) { |
|
1884 | + $label = $translated ? __( wp_unslash( $value ), 'invoicing' ) : $value; |
|
1885 | + } else { |
|
1886 | + $label = $value; |
|
1887 | + } |
|
1888 | 1888 | |
1889 | - $options[ $value ] = $label; |
|
1890 | - } |
|
1891 | - } |
|
1889 | + $options[ $value ] = $label; |
|
1890 | + } |
|
1891 | + } |
|
1892 | 1892 | |
1893 | - return apply_filters( 'getpaid_parse_field_options', $options, $orig_options, $translated ); |
|
1893 | + return apply_filters( 'getpaid_parse_field_options', $options, $orig_options, $translated ); |
|
1894 | 1894 | } |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
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 ); |
|
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); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -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 | /** |
@@ -170,58 +170,58 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) { |
|
182 | + if (isset($name)) { |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | } |
185 | 185 | $templates[] = $slug . '.php'; |
186 | 186 | |
187 | 187 | // Allow template parts to be filtered |
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
189 | 189 | |
190 | 190 | // Return the part that is found |
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
195 | 195 | // No file found yet |
196 | 196 | $located = false; |
197 | 197 | |
198 | 198 | // Try to find a template file |
199 | - foreach ( (array)$template_names as $template_name ) { |
|
199 | + foreach ((array) $template_names as $template_name) { |
|
200 | 200 | |
201 | 201 | // Continue if template is empty |
202 | - if ( empty( $template_name ) ) { |
|
202 | + if (empty($template_name)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Trim off any slashes from the template name |
207 | - $template_name = ltrim( $template_name, '/' ); |
|
207 | + $template_name = ltrim($template_name, '/'); |
|
208 | 208 | |
209 | 209 | // try locating this template file by looping through the template paths |
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
212 | + if (file_exists($template_path . $template_name)) { |
|
213 | 213 | $located = $template_path . $template_name; |
214 | 214 | break; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
218 | + if (!empty($located)) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ((true == $load) && !empty($located)) { |
|
224 | + load_template($located, $require_once); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
232 | 232 | |
233 | 233 | $file_paths = array( |
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
236 | 236 | 100 => wpinv_get_templates_dir(), |
237 | 237 | ); |
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
240 | 240 | |
241 | 241 | // sort the file paths based on priority |
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
242 | + ksort($file_paths, SORT_NUMERIC); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map('trailingslashit', $file_paths); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | 249 | $pages = array(); |
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
250 | + $pages[] = wpinv_get_option('success_page'); |
|
251 | + $pages[] = wpinv_get_option('failure_page'); |
|
252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
260 | 260 | } |
261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
262 | 262 | |
263 | -function wpinv_add_body_classes( $class ) { |
|
264 | - $classes = (array)$class; |
|
263 | +function wpinv_add_body_classes($class) { |
|
264 | + $classes = (array) $class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
266 | + if (wpinv_is_checkout()) { |
|
267 | 267 | $classes[] = 'wpinv-checkout'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
271 | + if (wpinv_is_success_page()) { |
|
272 | 272 | $classes[] = 'wpinv-success'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
276 | + if (wpinv_is_failed_transaction_page()) { |
|
277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
281 | + if (wpinv_is_invoice_history_page()) { |
|
282 | 282 | $classes[] = 'wpinv-history'; |
283 | 283 | $classes[] = 'wpinv-page'; |
284 | 284 | } |
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
286 | + if (wpinv_is_subscriptions_history_page()) { |
|
287 | 287 | $classes[] = 'wpinv-subscription'; |
288 | 288 | $classes[] = 'wpinv-page'; |
289 | 289 | } |
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
291 | + if (wpinv_is_test_mode()) { |
|
292 | 292 | $classes[] = 'wpinv-test-mode'; |
293 | 293 | $classes[] = 'wpinv-page'; |
294 | 294 | } |
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique($classes); |
|
297 | 297 | } |
298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
299 | 299 | |
300 | -function wpinv_html_select( $args = array() ) { |
|
300 | +function wpinv_html_select($args = array()) { |
|
301 | 301 | $defaults = array( |
302 | 302 | 'options' => array(), |
303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | 'selected' => 0, |
307 | 307 | 'placeholder' => null, |
308 | 308 | 'multiple' => false, |
309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
311 | 311 | 'data' => array(), |
312 | 312 | 'onchange' => null, |
313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
315 | 315 | 'readonly' => false, |
316 | 316 | ); |
317 | 317 | |
318 | - $args = wp_parse_args( $args, $defaults ); |
|
318 | + $args = wp_parse_args($args, $defaults); |
|
319 | 319 | |
320 | 320 | $attrs = array( |
321 | 321 | 'name' => $args['name'], |
322 | 322 | 'id' => $args['id'], |
323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
327 | - 'required' => ! empty( $args['required'] ), |
|
328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
324 | + 'multiple' => !empty($args['multiple']), |
|
325 | + 'readonly' => !empty($args['readonly']), |
|
326 | + 'disabled' => !empty($args['disabled']), |
|
327 | + 'required' => !empty($args['required']), |
|
328 | + 'onchange' => !empty($args['onchange']), |
|
329 | 329 | ); |
330 | 330 | |
331 | - if ( $args['placeholder'] ) { |
|
331 | + if ($args['placeholder']) { |
|
332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
333 | 333 | } |
334 | 334 | |
335 | - if ( $args['onchange'] ) { |
|
335 | + if ($args['onchange']) { |
|
336 | 336 | $attrs['onchange'] = $args['onchange']; |
337 | 337 | } |
338 | 338 | |
339 | - foreach ( $args['data'] as $key => $value ) { |
|
339 | + foreach ($args['data'] as $key => $value) { |
|
340 | 340 | $attrs["data-$key"] = $value; |
341 | 341 | } |
342 | 342 | |
343 | 343 | echo '<select '; |
344 | 344 | |
345 | - foreach ( $attrs as $attr => $value ) { |
|
345 | + foreach ($attrs as $attr => $value) { |
|
346 | 346 | |
347 | - if ( false === $value ) { |
|
347 | + if (false === $value) { |
|
348 | 348 | continue; |
349 | 349 | } |
350 | 350 | |
351 | - if ( true === $value ) { |
|
352 | - echo ' ' . esc_attr( $attr ); |
|
351 | + if (true === $value) { |
|
352 | + echo ' ' . esc_attr($attr); |
|
353 | 353 | } else { |
354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | 359 | echo '>'; |
360 | 360 | |
361 | - if ( $args['show_option_all'] ) { |
|
362 | - if ( $args['multiple'] ) { |
|
363 | - $selected = in_array( 0, $args['selected'] ); |
|
361 | + if ($args['show_option_all']) { |
|
362 | + if ($args['multiple']) { |
|
363 | + $selected = in_array(0, $args['selected']); |
|
364 | 364 | } else { |
365 | - $selected = empty( $args['selected'] ); |
|
365 | + $selected = empty($args['selected']); |
|
366 | 366 | } |
367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $args['options'] ) ) { |
|
370 | + if (!empty($args['options'])) { |
|
371 | 371 | |
372 | - if ( $args['show_option_none'] ) { |
|
373 | - if ( $args['multiple'] ) { |
|
374 | - $selected = in_array( '', $args['selected'], true ); |
|
372 | + if ($args['show_option_none']) { |
|
373 | + if ($args['multiple']) { |
|
374 | + $selected = in_array('', $args['selected'], true); |
|
375 | 375 | } else { |
376 | 376 | $selected = $args['selected'] === ''; |
377 | 377 | } |
378 | 378 | |
379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
380 | 380 | } |
381 | 381 | |
382 | - foreach ( $args['options'] as $key => $option ) { |
|
382 | + foreach ($args['options'] as $key => $option) { |
|
383 | 383 | |
384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
385 | - $selected = in_array( $key, $args['selected'], true ); |
|
384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
385 | + $selected = in_array($key, $args['selected'], true); |
|
386 | 386 | } else { |
387 | 387 | $selected = $args['selected'] === $key; |
388 | 388 | } |
389 | 389 | |
390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | } |
397 | 397 | |
398 | -function wpinv_item_dropdown( $args = array() ) { |
|
398 | +function wpinv_item_dropdown($args = array()) { |
|
399 | 399 | $defaults = array( |
400 | 400 | 'name' => 'wpi_item', |
401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | 'multiple' => false, |
404 | 404 | 'selected' => 0, |
405 | 405 | 'number' => -1, |
406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
407 | - 'data' => array( 'search-type' => 'item' ), |
|
406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
407 | + 'data' => array('search-type' => 'item'), |
|
408 | 408 | 'show_option_all' => false, |
409 | 409 | 'show_option_none' => false, |
410 | 410 | 'show_recurring' => false, |
411 | 411 | ); |
412 | 412 | |
413 | - $args = wp_parse_args( $args, $defaults ); |
|
413 | + $args = wp_parse_args($args, $defaults); |
|
414 | 414 | |
415 | 415 | $item_args = array( |
416 | 416 | 'post_type' => 'wpi_item', |
@@ -428,40 +428,40 @@ discard block |
||
428 | 428 | ), |
429 | 429 | ); |
430 | 430 | |
431 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
431 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
432 | 432 | |
433 | - $items = get_posts( $item_args ); |
|
433 | + $items = get_posts($item_args); |
|
434 | 434 | $options = array(); |
435 | - if ( $items ) { |
|
436 | - foreach ( $items as $item ) { |
|
437 | - $title = esc_html( $item->post_title ); |
|
435 | + if ($items) { |
|
436 | + foreach ($items as $item) { |
|
437 | + $title = esc_html($item->post_title); |
|
438 | 438 | |
439 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
440 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
439 | + if (!empty($args['show_recurring'])) { |
|
440 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
441 | 441 | } |
442 | 442 | |
443 | - $options[ absint( $item->ID ) ] = $title; |
|
443 | + $options[absint($item->ID)] = $title; |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | 447 | // This ensures that any selected items are included in the drop down |
448 | - if ( is_array( $args['selected'] ) ) { |
|
449 | - foreach ( $args['selected'] as $item ) { |
|
450 | - if ( ! in_array( $item, $options ) ) { |
|
451 | - $title = get_the_title( $item ); |
|
452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
453 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
448 | + if (is_array($args['selected'])) { |
|
449 | + foreach ($args['selected'] as $item) { |
|
450 | + if (!in_array($item, $options)) { |
|
451 | + $title = get_the_title($item); |
|
452 | + if (!empty($args['show_recurring'])) { |
|
453 | + $title .= wpinv_get_item_suffix($item, false); |
|
454 | 454 | } |
455 | - $options[ $item ] = $title; |
|
455 | + $options[$item] = $title; |
|
456 | 456 | } |
457 | 457 | } |
458 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
459 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
460 | - $title = get_the_title( $args['selected'] ); |
|
461 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
462 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
458 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
459 | + if (!in_array($args['selected'], $options)) { |
|
460 | + $title = get_the_title($args['selected']); |
|
461 | + if (!empty($args['show_recurring'])) { |
|
462 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
463 | 463 | } |
464 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
464 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | ); |
498 | 498 | |
499 | 499 | $options = array(); |
500 | - if ( $items ) { |
|
501 | - foreach ( $items as $item ) { |
|
502 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
500 | + if ($items) { |
|
501 | + foreach ($items as $item) { |
|
502 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | return $options; |
507 | 507 | } |
508 | 508 | |
509 | -function wpinv_html_checkbox( $args = array() ) { |
|
509 | +function wpinv_html_checkbox($args = array()) { |
|
510 | 510 | $defaults = array( |
511 | 511 | 'name' => null, |
512 | 512 | 'current' => null, |
@@ -517,17 +517,17 @@ discard block |
||
517 | 517 | ), |
518 | 518 | ); |
519 | 519 | |
520 | - $args = wp_parse_args( $args, $defaults ); |
|
520 | + $args = wp_parse_args($args, $defaults); |
|
521 | 521 | |
522 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
522 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
523 | 523 | $attr = ''; |
524 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
524 | + if (!empty($args['options']['disabled'])) { |
|
525 | 525 | $attr .= ' disabled="disabled"'; |
526 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
526 | + } elseif (!empty($args['options']['readonly'])) { |
|
527 | 527 | $attr .= ' readonly'; |
528 | 528 | } |
529 | 529 | |
530 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
530 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
531 | 531 | |
532 | 532 | return $output; |
533 | 533 | } |
@@ -535,34 +535,34 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * Displays a hidden field. |
537 | 537 | */ |
538 | -function getpaid_hidden_field( $name, $value ) { |
|
539 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
538 | +function getpaid_hidden_field($name, $value) { |
|
539 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
543 | 543 | * Displays a submit field. |
544 | 544 | */ |
545 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
546 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
545 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
546 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
547 | 547 | } |
548 | 548 | |
549 | -function wpinv_html_text( $args = array() ) { |
|
549 | +function wpinv_html_text($args = array()) { |
|
550 | 550 | // Backwards compatibility |
551 | - if ( func_num_args() > 1 ) { |
|
551 | + if (func_num_args() > 1) { |
|
552 | 552 | $args = func_get_args(); |
553 | 553 | |
554 | 554 | $name = $args[0]; |
555 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
556 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
557 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
555 | + $value = isset($args[1]) ? $args[1] : ''; |
|
556 | + $label = isset($args[2]) ? $args[2] : ''; |
|
557 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $defaults = array( |
561 | 561 | 'id' => '', |
562 | - 'name' => isset( $name ) ? $name : 'text', |
|
563 | - 'value' => isset( $value ) ? $value : null, |
|
564 | - 'label' => isset( $label ) ? $label : null, |
|
565 | - 'desc' => isset( $desc ) ? $desc : null, |
|
562 | + 'name' => isset($name) ? $name : 'text', |
|
563 | + 'value' => isset($value) ? $value : null, |
|
564 | + 'label' => isset($label) ? $label : null, |
|
565 | + 'desc' => isset($desc) ? $desc : null, |
|
566 | 566 | 'placeholder' => '', |
567 | 567 | 'class' => 'regular-text', |
568 | 568 | 'disabled' => false, |
@@ -572,41 +572,41 @@ discard block |
||
572 | 572 | 'data' => false, |
573 | 573 | ); |
574 | 574 | |
575 | - $args = wp_parse_args( $args, $defaults ); |
|
575 | + $args = wp_parse_args($args, $defaults); |
|
576 | 576 | |
577 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
577 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
578 | 578 | $options = ''; |
579 | - if ( $args['required'] ) { |
|
579 | + if ($args['required']) { |
|
580 | 580 | $options .= ' required="required"'; |
581 | 581 | } |
582 | - if ( $args['readonly'] ) { |
|
582 | + if ($args['readonly']) { |
|
583 | 583 | $options .= ' readonly'; |
584 | 584 | } |
585 | - if ( $args['readonly'] ) { |
|
585 | + if ($args['readonly']) { |
|
586 | 586 | $options .= ' readonly'; |
587 | 587 | } |
588 | 588 | |
589 | 589 | $data = ''; |
590 | - if ( ! empty( $args['data'] ) ) { |
|
591 | - foreach ( $args['data'] as $key => $value ) { |
|
592 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
590 | + if (!empty($args['data'])) { |
|
591 | + foreach ($args['data'] as $key => $value) { |
|
592 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | |
596 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
597 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
598 | - if ( ! empty( $args['desc'] ) ) { |
|
599 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
596 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
597 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
598 | + if (!empty($args['desc'])) { |
|
599 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
600 | 600 | } |
601 | 601 | |
602 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
602 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
603 | 603 | |
604 | 604 | $output .= '</span>'; |
605 | 605 | |
606 | 606 | return $output; |
607 | 607 | } |
608 | 608 | |
609 | -function wpinv_html_textarea( $args = array() ) { |
|
609 | +function wpinv_html_textarea($args = array()) { |
|
610 | 610 | $defaults = array( |
611 | 611 | 'name' => 'textarea', |
612 | 612 | 'value' => null, |
@@ -617,31 +617,31 @@ discard block |
||
617 | 617 | 'placeholder' => '', |
618 | 618 | ); |
619 | 619 | |
620 | - $args = wp_parse_args( $args, $defaults ); |
|
620 | + $args = wp_parse_args($args, $defaults); |
|
621 | 621 | |
622 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
622 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
623 | 623 | $disabled = ''; |
624 | - if ( $args['disabled'] ) { |
|
624 | + if ($args['disabled']) { |
|
625 | 625 | $disabled = ' disabled="disabled"'; |
626 | 626 | } |
627 | 627 | |
628 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
629 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
630 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
628 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
629 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
630 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
631 | 631 | |
632 | - if ( ! empty( $args['desc'] ) ) { |
|
633 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
632 | + if (!empty($args['desc'])) { |
|
633 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
634 | 634 | } |
635 | 635 | $output .= '</span>'; |
636 | 636 | |
637 | 637 | return $output; |
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
640 | +function wpinv_html_ajax_user_search($args = array()) { |
|
641 | 641 | $defaults = array( |
642 | 642 | 'name' => 'user_id', |
643 | 643 | 'value' => null, |
644 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
644 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
645 | 645 | 'label' => null, |
646 | 646 | 'desc' => null, |
647 | 647 | 'class' => '', |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | 'data' => false, |
651 | 651 | ); |
652 | 652 | |
653 | - $args = wp_parse_args( $args, $defaults ); |
|
653 | + $args = wp_parse_args($args, $defaults); |
|
654 | 654 | |
655 | 655 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
656 | 656 | |
657 | 657 | $output = '<span class="wpinv_user_search_wrap">'; |
658 | - $output .= wpinv_html_text( $args ); |
|
659 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
658 | + $output .= wpinv_html_text($args); |
|
659 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
660 | 660 | $output .= '</span>'; |
661 | 661 | |
662 | 662 | return $output; |
@@ -667,44 +667,44 @@ discard block |
||
667 | 667 | * |
668 | 668 | * @param string $template the template that is currently being used. |
669 | 669 | */ |
670 | -function wpinv_template( $template ) { |
|
670 | +function wpinv_template($template) { |
|
671 | 671 | global $post; |
672 | 672 | |
673 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
673 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
674 | 674 | |
675 | 675 | // If the user can view this invoice, display it. |
676 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
676 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
677 | 677 | |
678 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
678 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
679 | 679 | |
680 | 680 | // Else display an error message. |
681 | 681 | } else { |
682 | 682 | |
683 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
683 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
684 | 684 | |
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
688 | 688 | return $template; |
689 | 689 | } |
690 | -add_filter( 'template_include', 'wpinv_template', 1000, 1 ); |
|
690 | +add_filter('template_include', 'wpinv_template', 1000, 1); |
|
691 | 691 | |
692 | 692 | function wpinv_get_business_address() { |
693 | 693 | $business_address = wpinv_store_address(); |
694 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
694 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
695 | 695 | |
696 | 696 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
697 | 697 | |
698 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
698 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | 702 | * Displays the company address. |
703 | 703 | */ |
704 | 704 | function wpinv_display_from_address() { |
705 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
705 | + wpinv_get_template('invoice/company-address.php'); |
|
706 | 706 | } |
707 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
707 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
708 | 708 | |
709 | 709 | /** |
710 | 710 | * Generates a watermark text for an invoice. |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice $invoice |
713 | 713 | * @return string |
714 | 714 | */ |
715 | -function wpinv_watermark( $invoice ) { |
|
716 | - $watermark = wpinv_get_watermark( $invoice ); |
|
717 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
715 | +function wpinv_watermark($invoice) { |
|
716 | + $watermark = wpinv_get_watermark($invoice); |
|
717 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -723,37 +723,37 @@ discard block |
||
723 | 723 | * @param WPInv_Invoice $invoice |
724 | 724 | * @return string |
725 | 725 | */ |
726 | -function wpinv_get_watermark( $invoice ) { |
|
726 | +function wpinv_get_watermark($invoice) { |
|
727 | 727 | return $invoice->get_status_nicename(); |
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | 731 | * @deprecated |
732 | 732 | */ |
733 | -function wpinv_display_invoice_details( $invoice ) { |
|
734 | - return getpaid_invoice_meta( $invoice ); |
|
733 | +function wpinv_display_invoice_details($invoice) { |
|
734 | + return getpaid_invoice_meta($invoice); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
738 | 738 | * Displays invoice meta. |
739 | 739 | */ |
740 | -function getpaid_invoice_meta( $invoice ) { |
|
740 | +function getpaid_invoice_meta($invoice) { |
|
741 | 741 | |
742 | - $invoice = new WPInv_Invoice( $invoice ); |
|
742 | + $invoice = new WPInv_Invoice($invoice); |
|
743 | 743 | |
744 | 744 | // Ensure that we have an invoice. |
745 | - if ( 0 == $invoice->get_id() ) { |
|
745 | + if (0 == $invoice->get_id()) { |
|
746 | 746 | return; |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Get the invoice meta. |
750 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
750 | + $meta = getpaid_get_invoice_meta($invoice); |
|
751 | 751 | |
752 | 752 | // Display the meta. |
753 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
753 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
754 | 754 | |
755 | 755 | } |
756 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
756 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
757 | 757 | |
758 | 758 | /** |
759 | 759 | * Retrieves the address markup to use on Invoices. |
@@ -765,29 +765,29 @@ discard block |
||
765 | 765 | * @param string $separator How to separate address lines. |
766 | 766 | * @return string |
767 | 767 | */ |
768 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
768 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
769 | 769 | |
770 | 770 | // Retrieve the address markup... |
771 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
772 | - $format = wpinv_get_full_address_format( $country ); |
|
771 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
772 | + $format = wpinv_get_full_address_format($country); |
|
773 | 773 | |
774 | 774 | // ... and the replacements. |
775 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
775 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
776 | 776 | |
777 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
777 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
778 | 778 | |
779 | 779 | // Remove unavailable tags. |
780 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
780 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
781 | 781 | |
782 | 782 | // Clean up white space. |
783 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
784 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
783 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
784 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
785 | 785 | |
786 | 786 | // Break newlines apart and remove empty lines/trim commas and white space. |
787 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
787 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
788 | 788 | |
789 | 789 | // Add html breaks. |
790 | - $formatted_address = implode( $separator, $formatted_address ); |
|
790 | + $formatted_address = implode($separator, $formatted_address); |
|
791 | 791 | |
792 | 792 | // We're done! |
793 | 793 | return $formatted_address; |
@@ -799,118 +799,118 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @param WPInv_Invoice $invoice |
801 | 801 | */ |
802 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
803 | - if ( ! empty( $invoice ) ) { |
|
804 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
802 | +function wpinv_display_to_address($invoice = 0) { |
|
803 | + if (!empty($invoice)) { |
|
804 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
805 | 805 | } |
806 | 806 | } |
807 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
807 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
808 | 808 | |
809 | 809 | |
810 | 810 | /** |
811 | 811 | * Displays invoice line items. |
812 | 812 | */ |
813 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
813 | +function wpinv_display_line_items($invoice_id = 0) { |
|
814 | 814 | |
815 | 815 | // Prepare the invoice. |
816 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
816 | + $invoice = new WPInv_Invoice($invoice_id); |
|
817 | 817 | |
818 | 818 | // Abort if there is no invoice. |
819 | - if ( 0 == $invoice->get_id() ) { |
|
819 | + if (0 == $invoice->get_id()) { |
|
820 | 820 | return; |
821 | 821 | } |
822 | 822 | |
823 | 823 | // Line item columns. |
824 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
825 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
824 | + $columns = getpaid_invoice_item_columns($invoice); |
|
825 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
826 | 826 | |
827 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
827 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
828 | 828 | } |
829 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
829 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
830 | 830 | |
831 | 831 | /** |
832 | 832 | * Displays invoice subscriptions. |
833 | 833 | * |
834 | 834 | * @param WPInv_Invoice $invoice |
835 | 835 | */ |
836 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
836 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
837 | 837 | |
838 | 838 | // Subscriptions. |
839 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
839 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
840 | 840 | |
841 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
841 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
842 | 842 | return; |
843 | 843 | } |
844 | 844 | |
845 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
845 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
846 | 846 | |
847 | 847 | // Display related subscriptions. |
848 | - if ( is_array( $subscriptions ) ) { |
|
849 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
850 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
848 | + if (is_array($subscriptions)) { |
|
849 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
850 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
851 | 851 | } |
852 | 852 | |
853 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
854 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
855 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
853 | + if ($main_subscription->get_total_payments() > 1) { |
|
854 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
855 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | } |
859 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
860 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
859 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
860 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
861 | 861 | |
862 | 862 | /** |
863 | 863 | * Displays invoice notices on invoices. |
864 | 864 | */ |
865 | 865 | function wpinv_display_invoice_notice() { |
866 | 866 | |
867 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
868 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
867 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
868 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
869 | 869 | |
870 | - if ( empty( $label ) && empty( $notice ) ) { |
|
870 | + if (empty($label) && empty($notice)) { |
|
871 | 871 | return; |
872 | 872 | } |
873 | 873 | |
874 | 874 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
875 | 875 | |
876 | - if ( ! empty( $label ) ) { |
|
877 | - echo "<h5>" . esc_html( __( wp_unslash( $label ), 'invoicing' ) ) . "</h5>"; |
|
876 | + if (!empty($label)) { |
|
877 | + echo "<h5>" . esc_html(__(wp_unslash($label), 'invoicing')) . "</h5>"; |
|
878 | 878 | } |
879 | 879 | |
880 | - if ( ! empty( $notice ) ) { |
|
881 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( __( wp_unslash( $notice ), 'invoicing' ) ) ) ) . '</small>'; |
|
880 | + if (!empty($notice)) { |
|
881 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize(__(wp_unslash($notice), 'invoicing')))) . '</small>'; |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | echo '</div>'; |
885 | 885 | } |
886 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
886 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
887 | 887 | |
888 | 888 | /** |
889 | 889 | * @param WPInv_Invoice $invoice |
890 | 890 | */ |
891 | -function wpinv_display_invoice_notes( $invoice ) { |
|
891 | +function wpinv_display_invoice_notes($invoice) { |
|
892 | 892 | |
893 | 893 | // Retrieve the notes. |
894 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
894 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
895 | 895 | |
896 | 896 | // Abort if we have non. |
897 | - if ( empty( $notes ) ) { |
|
897 | + if (empty($notes)) { |
|
898 | 898 | return; |
899 | 899 | } |
900 | 900 | |
901 | 901 | // Echo the note. |
902 | 902 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
903 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
903 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
904 | 904 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
905 | 905 | |
906 | - foreach ( $notes as $note ) { |
|
907 | - wpinv_get_invoice_note_line_item( $note ); |
|
906 | + foreach ($notes as $note) { |
|
907 | + wpinv_get_invoice_note_line_item($note); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | echo '</ul>'; |
911 | 911 | echo '</div>'; |
912 | 912 | } |
913 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
913 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
914 | 914 | |
915 | 915 | /** |
916 | 916 | * Loads scripts on our invoice templates. |
@@ -918,37 +918,37 @@ discard block |
||
918 | 918 | function wpinv_display_style() { |
919 | 919 | |
920 | 920 | // Make sure that all scripts have been loaded. |
921 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
922 | - do_action( 'wp_enqueue_scripts' ); |
|
921 | + if (!did_action('wp_enqueue_scripts')) { |
|
922 | + do_action('wp_enqueue_scripts'); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | // Add global styles. |
926 | - if ( wp_is_block_theme() ) { |
|
927 | - wp_print_styles( 'global-styles' ); |
|
926 | + if (wp_is_block_theme()) { |
|
927 | + wp_print_styles('global-styles'); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | // Register the invoices style. |
931 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
931 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
932 | 932 | |
933 | 933 | // Load required styles |
934 | - wp_print_styles( 'wpinv-single-style' ); |
|
935 | - wp_print_styles( 'ayecode-ui' ); |
|
934 | + wp_print_styles('wpinv-single-style'); |
|
935 | + wp_print_styles('ayecode-ui'); |
|
936 | 936 | |
937 | 937 | // Maybe load custom css. |
938 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
938 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
939 | 939 | |
940 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
941 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
942 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
940 | + if (isset($custom_css) && !empty($custom_css)) { |
|
941 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
942 | + $custom_css = str_replace('>', '>', $custom_css); |
|
943 | 943 | echo '<style type="text/css">'; |
944 | - echo wp_kses_post( $custom_css ); |
|
944 | + echo wp_kses_post($custom_css); |
|
945 | 945 | echo '</style>'; |
946 | 946 | } |
947 | 947 | |
948 | 948 | wp_site_icon(); |
949 | 949 | } |
950 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
951 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
950 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
951 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
952 | 952 | |
953 | 953 | |
954 | 954 | /** |
@@ -960,41 +960,41 @@ discard block |
||
960 | 960 | // Retrieve the current invoice. |
961 | 961 | $invoice_id = getpaid_get_current_invoice_id(); |
962 | 962 | |
963 | - if ( empty( $invoice_id ) ) { |
|
963 | + if (empty($invoice_id)) { |
|
964 | 964 | |
965 | 965 | return aui()->alert( |
966 | 966 | array( |
967 | 967 | 'type' => 'warning', |
968 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
968 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
969 | 969 | ) |
970 | 970 | ); |
971 | 971 | |
972 | 972 | } |
973 | 973 | |
974 | 974 | // Can the user view this invoice? |
975 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
975 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
976 | 976 | |
977 | 977 | return aui()->alert( |
978 | 978 | array( |
979 | 979 | 'type' => 'warning', |
980 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
980 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
981 | 981 | ) |
982 | 982 | ); |
983 | 983 | |
984 | 984 | } |
985 | 985 | |
986 | 986 | // Ensure that it is not yet paid for. |
987 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
987 | + $invoice = new WPInv_Invoice($invoice_id); |
|
988 | 988 | |
989 | 989 | // Maybe mark it as viewed. |
990 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
990 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
991 | 991 | |
992 | - if ( $invoice->is_paid() ) { |
|
992 | + if ($invoice->is_paid()) { |
|
993 | 993 | |
994 | 994 | return aui()->alert( |
995 | 995 | array( |
996 | 996 | 'type' => 'success', |
997 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
997 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
998 | 998 | ) |
999 | 999 | ); |
1000 | 1000 | |
@@ -1004,15 +1004,15 @@ discard block |
||
1004 | 1004 | $wpi_checkout_id = $invoice_id; |
1005 | 1005 | |
1006 | 1006 | // Retrieve appropriate payment form. |
1007 | - $payment_form = new GetPaid_Payment_Form( wpinv_translate_post_id( $invoice->get_meta( 'force_payment_form' ) ) ); |
|
1008 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1007 | + $payment_form = new GetPaid_Payment_Form(wpinv_translate_post_id($invoice->get_meta('force_payment_form'))); |
|
1008 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1009 | 1009 | |
1010 | - if ( ! $payment_form->exists() ) { |
|
1010 | + if (!$payment_form->exists()) { |
|
1011 | 1011 | |
1012 | 1012 | return aui()->alert( |
1013 | 1013 | array( |
1014 | 1014 | 'type' => 'warning', |
1015 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1015 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1016 | 1016 | ) |
1017 | 1017 | ); |
1018 | 1018 | |
@@ -1021,29 +1021,29 @@ discard block |
||
1021 | 1021 | // Set the invoice. |
1022 | 1022 | $payment_form->invoice = $invoice; |
1023 | 1023 | |
1024 | - if ( ! $payment_form->is_default() ) { |
|
1024 | + if (!$payment_form->is_default()) { |
|
1025 | 1025 | |
1026 | 1026 | $items = array(); |
1027 | 1027 | $item_ids = array(); |
1028 | 1028 | |
1029 | - foreach ( $invoice->get_items() as $item ) { |
|
1030 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1029 | + foreach ($invoice->get_items() as $item) { |
|
1030 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1031 | 1031 | $item_ids[] = $item->get_id(); |
1032 | 1032 | $items[] = $item; |
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | |
1036 | - foreach ( $payment_form->get_items() as $item ) { |
|
1037 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1036 | + foreach ($payment_form->get_items() as $item) { |
|
1037 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1038 | 1038 | $item_ids[] = $item->get_id(); |
1039 | 1039 | $items[] = $item; |
1040 | 1040 | } |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - $payment_form->set_items( $items ); |
|
1043 | + $payment_form->set_items($items); |
|
1044 | 1044 | |
1045 | 1045 | } else { |
1046 | - $payment_form->set_items( $invoice->get_items() ); |
|
1046 | + $payment_form->set_items($invoice->get_items()); |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | // Generate the html. |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | function wpinv_empty_cart_message() { |
1055 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1055 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1070,76 +1070,76 @@ discard block |
||
1070 | 1070 | true |
1071 | 1071 | ); |
1072 | 1072 | } |
1073 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1073 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1074 | 1074 | |
1075 | 1075 | /** |
1076 | 1076 | * Filters the receipt page. |
1077 | 1077 | */ |
1078 | -function wpinv_filter_success_page_content( $content ) { |
|
1078 | +function wpinv_filter_success_page_content($content) { |
|
1079 | 1079 | |
1080 | 1080 | // Maybe abort early. |
1081 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1081 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1082 | 1082 | return $content; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | // Ensure this is our page. |
1086 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1086 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1087 | 1087 | |
1088 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1089 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1088 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1089 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1090 | 1090 | |
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | return $content; |
1094 | 1094 | } |
1095 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1095 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1096 | 1096 | |
1097 | -function wpinv_invoice_link( $invoice_id ) { |
|
1098 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1097 | +function wpinv_invoice_link($invoice_id) { |
|
1098 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1099 | 1099 | |
1100 | - if ( empty( $invoice ) ) { |
|
1100 | + if (empty($invoice)) { |
|
1101 | 1101 | return null; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1104 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1105 | 1105 | |
1106 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1106 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1110 | - if ( empty( $note ) ) { |
|
1109 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1110 | + if (empty($note)) { |
|
1111 | 1111 | return null; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if ( is_int( $note ) ) { |
|
1115 | - $note = get_comment( $note ); |
|
1114 | + if (is_int($note)) { |
|
1115 | + $note = get_comment($note); |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1118 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1119 | 1119 | return null; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - $note_classes = array( 'note' ); |
|
1123 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1122 | + $note_classes = array('note'); |
|
1123 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1124 | 1124 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1125 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1126 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1125 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1126 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1127 | 1127 | |
1128 | 1128 | ob_start(); |
1129 | 1129 | ?> |
1130 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1130 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1131 | 1131 | <div class="note_content"> |
1132 | 1132 | |
1133 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
1133 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
1134 | 1134 | |
1135 | - <?php if ( ! is_admin() ) : ?> |
|
1135 | + <?php if (!is_admin()) : ?> |
|
1136 | 1136 | <em class="small form-text text-muted mt-0"> |
1137 | 1137 | <?php |
1138 | 1138 | printf( |
1139 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1140 | - esc_html( $note->comment_author ), |
|
1141 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1142 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1139 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1140 | + esc_html($note->comment_author), |
|
1141 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1142 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1143 | 1143 | ); |
1144 | 1144 | ?> |
1145 | 1145 | </em> |
@@ -1147,21 +1147,21 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | </div> |
1149 | 1149 | |
1150 | - <?php if ( is_admin() ) : ?> |
|
1150 | + <?php if (is_admin()) : ?> |
|
1151 | 1151 | |
1152 | 1152 | <p class="meta px-4 py-2"> |
1153 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1153 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1154 | 1154 | <?php |
1155 | 1155 | printf( |
1156 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1157 | - esc_html( $note->comment_author ), |
|
1158 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1159 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1156 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1157 | + esc_html($note->comment_author), |
|
1158 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1159 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1160 | 1160 | ); |
1161 | 1161 | ?> |
1162 | 1162 | </abbr> |
1163 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1164 | - <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
1163 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1164 | + <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
1165 | 1165 | <?php } ?> |
1166 | 1166 | </p> |
1167 | 1167 | |
@@ -1170,10 +1170,10 @@ discard block |
||
1170 | 1170 | </li> |
1171 | 1171 | <?php |
1172 | 1172 | $note_content = ob_get_clean(); |
1173 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1173 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1174 | 1174 | |
1175 | - if ( $echo ) { |
|
1176 | - echo wp_kses_post( $note_content ); |
|
1175 | + if ($echo) { |
|
1176 | + echo wp_kses_post($note_content); |
|
1177 | 1177 | } else { |
1178 | 1178 | return $note_content; |
1179 | 1179 | } |
@@ -1186,43 +1186,43 @@ discard block |
||
1186 | 1186 | * @return string |
1187 | 1187 | */ |
1188 | 1188 | function wpinv_get_policy_text() { |
1189 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1189 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1190 | 1190 | |
1191 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
1191 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1192 | 1192 | |
1193 | - if ( ! $privacy_page_id ) { |
|
1194 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1193 | + if (!$privacy_page_id) { |
|
1194 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1197 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1198 | 1198 | |
1199 | 1199 | $find_replace = array( |
1200 | 1200 | '[wpinv_privacy_policy]' => $privacy_link, |
1201 | 1201 | ); |
1202 | 1202 | |
1203 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1203 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1204 | 1204 | |
1205 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
1205 | + return wp_kses_post(wpautop($privacy_text)); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | function wpinv_oxygen_fix_conflict() { |
1209 | 1209 | global $ct_ignore_post_types; |
1210 | 1210 | |
1211 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1211 | + if (!is_array($ct_ignore_post_types)) { |
|
1212 | 1212 | $ct_ignore_post_types = array(); |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1215 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1216 | 1216 | |
1217 | - foreach ( $post_types as $post_type ) { |
|
1217 | + foreach ($post_types as $post_type) { |
|
1218 | 1218 | $ct_ignore_post_types[] = $post_type; |
1219 | 1219 | |
1220 | 1220 | // Ignore post type |
1221 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1221 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1225 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1224 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1225 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | /** |
@@ -1230,10 +1230,10 @@ discard block |
||
1230 | 1230 | * |
1231 | 1231 | * @param GetPaid_Payment_Form $form |
1232 | 1232 | */ |
1233 | -function getpaid_display_payment_form( $form ) { |
|
1233 | +function getpaid_display_payment_form($form) { |
|
1234 | 1234 | |
1235 | - if ( is_numeric( $form ) ) { |
|
1236 | - $form = new GetPaid_Payment_Form( wpinv_translate_post_id( $form ) ); |
|
1235 | + if (is_numeric($form)) { |
|
1236 | + $form = new GetPaid_Payment_Form(wpinv_translate_post_id($form)); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | $form->display(); |
@@ -1243,61 +1243,61 @@ discard block |
||
1243 | 1243 | /** |
1244 | 1244 | * Helper function to display a item payment form on the frontend. |
1245 | 1245 | */ |
1246 | -function getpaid_display_item_payment_form( $items ) { |
|
1246 | +function getpaid_display_item_payment_form($items) { |
|
1247 | 1247 | |
1248 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1249 | - $form->set_items( $items ); |
|
1248 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1249 | + $form->set_items($items); |
|
1250 | 1250 | |
1251 | - if ( 0 == count( $form->get_items() ) ) { |
|
1251 | + if (0 == count($form->get_items())) { |
|
1252 | 1252 | aui()->alert( |
1253 | 1253 | array( |
1254 | 1254 | 'type' => 'warning', |
1255 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1255 | + 'content' => __('No published items found', 'invoicing'), |
|
1256 | 1256 | ), |
1257 | 1257 | true |
1258 | 1258 | ); |
1259 | 1259 | return; |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1263 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1262 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1263 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1264 | 1264 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1265 | 1265 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1266 | 1266 | |
1267 | - $form->display( $extra_items ); |
|
1267 | + $form->display($extra_items); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
1271 | 1271 | * Helper function to display an invoice payment form on the frontend. |
1272 | 1272 | */ |
1273 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1273 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1274 | 1274 | |
1275 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1275 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1276 | 1276 | |
1277 | - if ( empty( $invoice ) ) { |
|
1277 | + if (empty($invoice)) { |
|
1278 | 1278 | aui()->alert( |
1279 | 1279 | array( |
1280 | 1280 | 'type' => 'warning', |
1281 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1281 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1282 | 1282 | ), |
1283 | 1283 | true |
1284 | 1284 | ); |
1285 | 1285 | return; |
1286 | 1286 | } |
1287 | 1287 | |
1288 | - if ( $invoice->is_paid() ) { |
|
1288 | + if ($invoice->is_paid()) { |
|
1289 | 1289 | aui()->alert( |
1290 | 1290 | array( |
1291 | 1291 | 'type' => 'warning', |
1292 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1292 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1293 | 1293 | ), |
1294 | 1294 | true |
1295 | 1295 | ); |
1296 | 1296 | return; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1300 | - $form->set_items( $invoice->get_items() ); |
|
1299 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1300 | + $form->set_items($invoice->get_items()); |
|
1301 | 1301 | |
1302 | 1302 | $form->display(); |
1303 | 1303 | } |
@@ -1305,24 +1305,24 @@ discard block |
||
1305 | 1305 | /** |
1306 | 1306 | * Helper function to convert item string to array. |
1307 | 1307 | */ |
1308 | -function getpaid_convert_items_to_array( $items ) { |
|
1309 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1308 | +function getpaid_convert_items_to_array($items) { |
|
1309 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1310 | 1310 | $prepared = array(); |
1311 | 1311 | |
1312 | - foreach ( $items as $item ) { |
|
1313 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1312 | + foreach ($items as $item) { |
|
1313 | + $data = array_map('trim', explode('|', $item)); |
|
1314 | 1314 | |
1315 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1315 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1316 | 1316 | continue; |
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | $quantity = 1; |
1320 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1320 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1321 | 1321 | $quantity = (float) $data[1]; |
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | // WPML support. |
1325 | - $prepared[ wpinv_translate_post_id( $data[0] ) ] = $quantity; |
|
1325 | + $prepared[wpinv_translate_post_id($data[0])] = $quantity; |
|
1326 | 1326 | |
1327 | 1327 | } |
1328 | 1328 | |
@@ -1332,13 +1332,13 @@ discard block |
||
1332 | 1332 | /** |
1333 | 1333 | * Helper function to convert item array to string. |
1334 | 1334 | */ |
1335 | -function getpaid_convert_items_to_string( $items ) { |
|
1335 | +function getpaid_convert_items_to_string($items) { |
|
1336 | 1336 | $prepared = array(); |
1337 | 1337 | |
1338 | - foreach ( $items as $item => $quantity ) { |
|
1338 | + foreach ($items as $item => $quantity) { |
|
1339 | 1339 | $prepared[] = "$item|$quantity"; |
1340 | 1340 | } |
1341 | - return implode( ',', $prepared ); |
|
1341 | + return implode(',', $prepared); |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | 1344 | /** |
@@ -1346,21 +1346,21 @@ discard block |
||
1346 | 1346 | * |
1347 | 1347 | * Provide a label and one of $form, $items or $invoice. |
1348 | 1348 | */ |
1349 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1350 | - $label = sanitize_text_field( $label ); |
|
1349 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1350 | + $label = sanitize_text_field($label); |
|
1351 | 1351 | |
1352 | - if ( ! empty( $form ) ) { |
|
1353 | - $form = esc_attr( $form ); |
|
1352 | + if (!empty($form)) { |
|
1353 | + $form = esc_attr($form); |
|
1354 | 1354 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - if ( ! empty( $items ) ) { |
|
1358 | - $items = esc_attr( $items ); |
|
1357 | + if (!empty($items)) { |
|
1358 | + $items = esc_attr($items); |
|
1359 | 1359 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if ( ! empty( $invoice ) ) { |
|
1363 | - $invoice = esc_attr( $invoice ); |
|
1362 | + if (!empty($invoice)) { |
|
1363 | + $invoice = esc_attr($invoice); |
|
1364 | 1364 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1365 | 1365 | } |
1366 | 1366 | |
@@ -1371,17 +1371,17 @@ discard block |
||
1371 | 1371 | * |
1372 | 1372 | * @param WPInv_Invoice $invoice |
1373 | 1373 | */ |
1374 | -function getpaid_the_invoice_description( $invoice ) { |
|
1374 | +function getpaid_the_invoice_description($invoice) { |
|
1375 | 1375 | $description = $invoice->get_description(); |
1376 | 1376 | |
1377 | - if ( empty( $description ) ) { |
|
1377 | + if (empty($description)) { |
|
1378 | 1378 | return; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - echo "<small class='getpaid-invoice-description text-dark pl-2 ps-2 form-text' style='margin-bottom:20px;border-left:2px solid #2196F3;display:block;padding-left:.5rem'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
1381 | + echo "<small class='getpaid-invoice-description text-dark pl-2 ps-2 form-text' style='margin-bottom:20px;border-left:2px solid #2196F3;display:block;padding-left:.5rem'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
1382 | 1382 | } |
1383 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1384 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1383 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1384 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1385 | 1385 | |
1386 | 1386 | /** |
1387 | 1387 | * Render element on a form. |
@@ -1389,86 +1389,86 @@ discard block |
||
1389 | 1389 | * @param array $element |
1390 | 1390 | * @param GetPaid_Payment_Form $form |
1391 | 1391 | */ |
1392 | -function getpaid_payment_form_element( $element, $form ) { |
|
1393 | - $translatable = array( 'text', 'label', 'placeholder', 'input_label', 'button_label', 'description' ); |
|
1392 | +function getpaid_payment_form_element($element, $form) { |
|
1393 | + $translatable = array('text', 'label', 'placeholder', 'input_label', 'button_label', 'description'); |
|
1394 | 1394 | |
1395 | - foreach ( $translatable as $string ) { |
|
1396 | - if ( ! empty( $element[ $string ] ) && is_scalar( $element[ $string ] ) ) { |
|
1397 | - $element[ $string ] = __( $element[ $string ], 'invoicing' ); |
|
1395 | + foreach ($translatable as $string) { |
|
1396 | + if (!empty($element[$string]) && is_scalar($element[$string])) { |
|
1397 | + $element[$string] = __($element[$string], 'invoicing'); |
|
1398 | 1398 | } |
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | // Set up the args. |
1402 | - $element_type = trim( $element['type'] ); |
|
1402 | + $element_type = trim($element['type']); |
|
1403 | 1403 | $element['form'] = $form; |
1404 | - extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1404 | + extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1405 | 1405 | |
1406 | 1406 | // Try to locate the appropriate template. |
1407 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1407 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1408 | 1408 | |
1409 | 1409 | // Abort if this is not our element. |
1410 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1410 | + if (empty($located) || !file_exists($located)) { |
|
1411 | 1411 | return; |
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | // Generate the class and id of the element. |
1415 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1416 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1415 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1416 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1417 | 1417 | |
1418 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
1419 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1418 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
1419 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1420 | 1420 | |
1421 | 1421 | $element_id = 'getpaid-' . $element_id; |
1422 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
1423 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
1422 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
1423 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | // Echo the opening wrapper. |
1427 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
1427 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
1428 | 1428 | |
1429 | 1429 | // Fires before displaying a given element type's content. |
1430 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1430 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1431 | 1431 | |
1432 | 1432 | // Include the template for the element. |
1433 | 1433 | include $located; |
1434 | 1434 | |
1435 | 1435 | // Fires after displaying a given element type's content. |
1436 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1436 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1437 | 1437 | |
1438 | 1438 | // Echo the closing wrapper. |
1439 | 1439 | echo '</div>'; |
1440 | 1440 | } |
1441 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1441 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1442 | 1442 | |
1443 | 1443 | /** |
1444 | 1444 | * Render an element's edit page. |
1445 | 1445 | * |
1446 | 1446 | * @param WP_Post $post |
1447 | 1447 | */ |
1448 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1448 | +function getpaid_payment_form_edit_element_template($post) { |
|
1449 | 1449 | |
1450 | 1450 | // Retrieve all elements. |
1451 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1451 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1452 | 1452 | |
1453 | - foreach ( $all_elements as $element ) { |
|
1453 | + foreach ($all_elements as $element) { |
|
1454 | 1454 | |
1455 | 1455 | // Try to locate the appropriate template. |
1456 | - $element = esc_attr( sanitize_key( $element ) ); |
|
1457 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1456 | + $element = esc_attr(sanitize_key($element)); |
|
1457 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1458 | 1458 | |
1459 | 1459 | // Continue if this is not our element. |
1460 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1460 | + if (empty($located) || !file_exists($located)) { |
|
1461 | 1461 | continue; |
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | // Include the template for the element. |
1465 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
1465 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
1466 | 1466 | include $located; |
1467 | 1467 | echo '</div>'; |
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | } |
1471 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1471 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1472 | 1472 | |
1473 | 1473 | /** |
1474 | 1474 | * Render an element's preview. |
@@ -1477,27 +1477,27 @@ discard block |
||
1477 | 1477 | function getpaid_payment_form_render_element_preview_template() { |
1478 | 1478 | |
1479 | 1479 | // Retrieve all elements. |
1480 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1480 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1481 | 1481 | |
1482 | - foreach ( $all_elements as $element ) { |
|
1482 | + foreach ($all_elements as $element) { |
|
1483 | 1483 | |
1484 | 1484 | // Try to locate the appropriate template. |
1485 | - $element = sanitize_key( $element ); |
|
1486 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1485 | + $element = sanitize_key($element); |
|
1486 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1487 | 1487 | |
1488 | 1488 | // Continue if this is not our element. |
1489 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1489 | + if (empty($located) || !file_exists($located)) { |
|
1490 | 1490 | continue; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | // Include the template for the element. |
1494 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
1494 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
1495 | 1495 | include $located; |
1496 | 1496 | echo '</div>'; |
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | } |
1500 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1500 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1501 | 1501 | |
1502 | 1502 | /** |
1503 | 1503 | * Shows a list of gateways that support recurring payments. |
@@ -1505,17 +1505,17 @@ discard block |
||
1505 | 1505 | function wpinv_get_recurring_gateways_text() { |
1506 | 1506 | $gateways = array(); |
1507 | 1507 | |
1508 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1509 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1510 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1508 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1509 | + if (wpinv_gateway_support_subscription($key)) { |
|
1510 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1511 | 1511 | } |
1512 | 1512 | } |
1513 | 1513 | |
1514 | - if ( empty( $gateways ) ) { |
|
1515 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
1514 | + if (empty($gateways)) { |
|
1515 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
1518 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
1519 | 1519 | |
1520 | 1520 | } |
1521 | 1521 | |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | * @return GetPaid_Template |
1526 | 1526 | */ |
1527 | 1527 | function getpaid_template() { |
1528 | - return getpaid()->get( 'template' ); |
|
1528 | + return getpaid()->get('template'); |
|
1529 | 1529 | } |
1530 | 1530 | |
1531 | 1531 | /** |
@@ -1534,8 +1534,8 @@ discard block |
||
1534 | 1534 | * @param array args |
1535 | 1535 | * @return string |
1536 | 1536 | */ |
1537 | -function getpaid_paginate_links( $args ) { |
|
1538 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1537 | +function getpaid_paginate_links($args) { |
|
1538 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | /** |
@@ -1545,22 +1545,22 @@ discard block |
||
1545 | 1545 | * @param string state |
1546 | 1546 | * @return string |
1547 | 1547 | */ |
1548 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
1548 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
1549 | 1549 | |
1550 | - $states = wpinv_get_country_states( $country ); |
|
1551 | - $uniqid = uniqid( '_' ); |
|
1550 | + $states = wpinv_get_country_states($country); |
|
1551 | + $uniqid = uniqid('_'); |
|
1552 | 1552 | |
1553 | - if ( ! empty( $states ) ) { |
|
1553 | + if (!empty($states)) { |
|
1554 | 1554 | |
1555 | 1555 | return aui()->select( |
1556 | 1556 | array( |
1557 | 1557 | 'options' => $states, |
1558 | - 'name' => esc_attr( $field_name ), |
|
1559 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1560 | - 'value' => sanitize_text_field( $state ), |
|
1558 | + 'name' => esc_attr($field_name), |
|
1559 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1560 | + 'value' => sanitize_text_field($state), |
|
1561 | 1561 | 'placeholder' => $placeholder, |
1562 | 1562 | 'required' => $required, |
1563 | - 'label' => wp_kses_post( $label ), |
|
1563 | + 'label' => wp_kses_post($label), |
|
1564 | 1564 | 'label_type' => 'vertical', |
1565 | 1565 | 'help_text' => $help_text, |
1566 | 1566 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1577,14 +1577,14 @@ discard block |
||
1577 | 1577 | |
1578 | 1578 | return aui()->input( |
1579 | 1579 | array( |
1580 | - 'name' => esc_attr( $field_name ), |
|
1581 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1580 | + 'name' => esc_attr($field_name), |
|
1581 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1582 | 1582 | 'placeholder' => $placeholder, |
1583 | 1583 | 'required' => $required, |
1584 | - 'label' => wp_kses_post( $label ), |
|
1584 | + 'label' => wp_kses_post($label), |
|
1585 | 1585 | 'label_type' => 'vertical', |
1586 | 1586 | 'help_text' => $help_text, |
1587 | - 'value' => sanitize_text_field( $state ), |
|
1587 | + 'value' => sanitize_text_field($state), |
|
1588 | 1588 | 'class' => 'getpaid-address-field wpinv_state', |
1589 | 1589 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1590 | 1590 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1603,16 +1603,16 @@ discard block |
||
1603 | 1603 | * @param array $element |
1604 | 1604 | * @return string |
1605 | 1605 | */ |
1606 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1606 | +function getpaid_get_form_element_grid_class($element) { |
|
1607 | 1607 | |
1608 | 1608 | $class = 'col-12'; |
1609 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1609 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1610 | 1610 | |
1611 | - if ( $width == 'half' ) { |
|
1611 | + if ($width == 'half') { |
|
1612 | 1612 | $class .= ' col-md-6'; |
1613 | 1613 | } |
1614 | 1614 | |
1615 | - if ( $width == 'third' ) { |
|
1615 | + if ($width == 'third') { |
|
1616 | 1616 | $class .= ' col-md-4'; |
1617 | 1617 | } |
1618 | 1618 | |
@@ -1627,15 +1627,15 @@ discard block |
||
1627 | 1627 | * |
1628 | 1628 | * @return string |
1629 | 1629 | */ |
1630 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1630 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1631 | 1631 | |
1632 | 1632 | return add_query_arg( |
1633 | 1633 | array( |
1634 | 1634 | 'getpaid_embed' => 1, |
1635 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1636 | - 'item' => $items ? urlencode( $items ) : false, |
|
1635 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1636 | + 'item' => $items ? urlencode($items) : false, |
|
1637 | 1637 | ), |
1638 | - home_url( 'index.php' ) |
|
1638 | + home_url('index.php') |
|
1639 | 1639 | ); |
1640 | 1640 | |
1641 | 1641 | } |
@@ -1645,16 +1645,16 @@ discard block |
||
1645 | 1645 | * |
1646 | 1646 | * @return string |
1647 | 1647 | */ |
1648 | -function getpaid_filter_embed_template( $template ) { |
|
1648 | +function getpaid_filter_embed_template($template) { |
|
1649 | 1649 | |
1650 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1651 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1650 | + if (isset($_GET['getpaid_embed'])) { |
|
1651 | + wpinv_get_template('payment-forms/embed.php'); |
|
1652 | 1652 | exit; |
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | return $template; |
1656 | 1656 | } |
1657 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1657 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
|
1658 | 1658 | |
1659 | 1659 | /** |
1660 | 1660 | * Get the payment forms custom fields. |
@@ -1666,25 +1666,25 @@ discard block |
||
1666 | 1666 | function getpaid_get_payment_form_custom_fields() { |
1667 | 1667 | global $wpdb, $payment_form_meta_fields; |
1668 | 1668 | |
1669 | - if ( ! empty( $payment_form_meta_fields ) ) { |
|
1669 | + if (!empty($payment_form_meta_fields)) { |
|
1670 | 1670 | return $payment_form_meta_fields; |
1671 | 1671 | } |
1672 | 1672 | |
1673 | - $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
1673 | + $results = $wpdb->get_results("SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'"); |
|
1674 | 1674 | |
1675 | 1675 | $meta_fields = array(); |
1676 | 1676 | |
1677 | - if ( ! empty( $results ) ) { |
|
1678 | - foreach ( $results as $row ) { |
|
1679 | - $fields = maybe_unserialize( $row->meta_value ); |
|
1677 | + if (!empty($results)) { |
|
1678 | + foreach ($results as $row) { |
|
1679 | + $fields = maybe_unserialize($row->meta_value); |
|
1680 | 1680 | |
1681 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
1682 | - foreach ( $fields as $field ) { |
|
1683 | - $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : ''; |
|
1681 | + if (!empty($fields) && is_array($fields)) { |
|
1682 | + foreach ($fields as $field) { |
|
1683 | + $label = !empty($field['add_meta']) && !empty($field['label']) ? wpinv_clean(wp_unslash($field['label'])) : ''; |
|
1684 | 1684 | |
1685 | - if ( $label ) { |
|
1686 | - $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) ); |
|
1687 | - $meta_fields[ $field_key ] = $label; |
|
1685 | + if ($label) { |
|
1686 | + $field_key = '_' . str_replace(array(' ', "'", '"', ','), array('_', '', '', '_'), getpaid_strtolower($label)); |
|
1687 | + $meta_fields[$field_key] = $label; |
|
1688 | 1688 | } |
1689 | 1689 | } |
1690 | 1690 | } |
@@ -1709,13 +1709,13 @@ discard block |
||
1709 | 1709 | $is_gutenberg = true; |
1710 | 1710 | |
1711 | 1711 | // If less than v5. |
1712 | - if ( version_compare( $wp_version, '5.0.0', '<' ) ) { |
|
1712 | + if (version_compare($wp_version, '5.0.0', '<')) { |
|
1713 | 1713 | $is_gutenberg = false; |
1714 | 1714 | } |
1715 | 1715 | |
1716 | - if ( class_exists( 'Classic_Editor' ) ) { |
|
1716 | + if (class_exists('Classic_Editor')) { |
|
1717 | 1717 | $is_gutenberg = false; // Classic Editor plugin is active. |
1718 | - } else if ( getpaid_is_classicpress() ) { |
|
1718 | + } else if (getpaid_is_classicpress()) { |
|
1719 | 1719 | $is_gutenberg = false; // Site is using ClassicPress. |
1720 | 1720 | } |
1721 | 1721 | |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | * @return bool True if site uses ClassicPress else False. |
1731 | 1731 | */ |
1732 | 1732 | function getpaid_is_classicpress() { |
1733 | - if ( function_exists( 'classicpress_version' ) ) { |
|
1733 | + if (function_exists('classicpress_version')) { |
|
1734 | 1734 | $is_classicpress = true; |
1735 | 1735 | } else { |
1736 | 1736 | $is_classicpress = false; |
@@ -1748,8 +1748,8 @@ discard block |
||
1748 | 1748 | * @param @bool $blocks True to use blocks. |
1749 | 1749 | * @return string Page content. |
1750 | 1750 | */ |
1751 | - function getpaid_page_content_checkout( $filtered = false, $blocks = false ) { |
|
1752 | - if ( $blocks ) { |
|
1751 | + function getpaid_page_content_checkout($filtered = false, $blocks = false) { |
|
1752 | + if ($blocks) { |
|
1753 | 1753 | $content = "<!-- wp:invoicing/wpinv-checkout-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_checkout title='' ]\"} --> |
1754 | 1754 | <div class=\"wp-block-invoicing-wpinv-checkout-widget\"></div> |
1755 | 1755 | <!-- /wp:invoicing/wpinv-checkout-widget -->"; |
@@ -1757,8 +1757,8 @@ discard block |
||
1757 | 1757 | $content = "[wpinv_checkout]"; |
1758 | 1758 | } |
1759 | 1759 | |
1760 | - if ( $filtered ) { |
|
1761 | - $content = apply_filters( 'getpaid_page_default_content_checkout', $content, $blocks ); |
|
1760 | + if ($filtered) { |
|
1761 | + $content = apply_filters('getpaid_page_default_content_checkout', $content, $blocks); |
|
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | return $content; |
@@ -1773,8 +1773,8 @@ discard block |
||
1773 | 1773 | * @param @bool $blocks True to use blocks. |
1774 | 1774 | * @return string Page content. |
1775 | 1775 | */ |
1776 | - function getpaid_page_content_invoice_history( $filtered = false, $blocks = false ) { |
|
1777 | - if ( $blocks ) { |
|
1776 | + function getpaid_page_content_invoice_history($filtered = false, $blocks = false) { |
|
1777 | + if ($blocks) { |
|
1778 | 1778 | $content = "<!-- wp:invoicing/wpinv-history-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_history title='' ]\"} --> |
1779 | 1779 | <div class=\"wp-block-invoicing-wpinv-history-widget\"></div> |
1780 | 1780 | <!-- /wp:invoicing/wpinv-history-widget -->"; |
@@ -1782,8 +1782,8 @@ discard block |
||
1782 | 1782 | $content = "[wpinv_history]"; |
1783 | 1783 | } |
1784 | 1784 | |
1785 | - if ( $filtered ) { |
|
1786 | - $content = apply_filters( 'getpaid_page_default_content_invoice_history', $content, $blocks ); |
|
1785 | + if ($filtered) { |
|
1786 | + $content = apply_filters('getpaid_page_default_content_invoice_history', $content, $blocks); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | return $content; |
@@ -1798,8 +1798,8 @@ discard block |
||
1798 | 1798 | * @param @bool $blocks True to use blocks. |
1799 | 1799 | * @return string Page content. |
1800 | 1800 | */ |
1801 | - function getpaid_page_content_receipt( $filtered = false, $blocks = false ) { |
|
1802 | - if ( $blocks ) { |
|
1801 | + function getpaid_page_content_receipt($filtered = false, $blocks = false) { |
|
1802 | + if ($blocks) { |
|
1803 | 1803 | $content = "<!-- wp:invoicing/wpinv-receipt-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_receipt title='' ]\"} --> |
1804 | 1804 | <div class=\"wp-block-invoicing-wpinv-receipt-widget\"></div> |
1805 | 1805 | <!-- /wp:invoicing/wpinv-receipt-widget -->"; |
@@ -1807,8 +1807,8 @@ discard block |
||
1807 | 1807 | $content = "[wpinv_receipt]"; |
1808 | 1808 | } |
1809 | 1809 | |
1810 | - if ( $filtered ) { |
|
1811 | - $content = apply_filters( 'getpaid_page_default_content_receipt', $content, $blocks ); |
|
1810 | + if ($filtered) { |
|
1811 | + $content = apply_filters('getpaid_page_default_content_receipt', $content, $blocks); |
|
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | return $content; |
@@ -1823,17 +1823,17 @@ discard block |
||
1823 | 1823 | * @param @bool $blocks True to use blocks. |
1824 | 1824 | * @return string Page content. |
1825 | 1825 | */ |
1826 | - function getpaid_page_content_failure( $filtered = false, $blocks = false ) { |
|
1827 | - if ( $blocks ) { |
|
1826 | + function getpaid_page_content_failure($filtered = false, $blocks = false) { |
|
1827 | + if ($blocks) { |
|
1828 | 1828 | $content = "<!-- wp:html --> |
1829 | -" . __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ) . " |
|
1829 | +" . __('Your transaction failed, please try again or contact site support.', 'invoicing') . " |
|
1830 | 1830 | <!-- /wp:html -->"; |
1831 | 1831 | } else { |
1832 | - $content = __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ); |
|
1832 | + $content = __('Your transaction failed, please try again or contact site support.', 'invoicing'); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | - if ( $filtered ) { |
|
1836 | - $content = apply_filters( 'getpaid_page_default_content_failure', $content, $blocks ); |
|
1835 | + if ($filtered) { |
|
1836 | + $content = apply_filters('getpaid_page_default_content_failure', $content, $blocks); |
|
1837 | 1837 | } |
1838 | 1838 | |
1839 | 1839 | return $content; |
@@ -1848,8 +1848,8 @@ discard block |
||
1848 | 1848 | * @param @bool $blocks True to use blocks. |
1849 | 1849 | * @return string Page content. |
1850 | 1850 | */ |
1851 | - function getpaid_page_content_subscriptions( $filtered = false, $blocks = false ) { |
|
1852 | - if ( $blocks ) { |
|
1851 | + function getpaid_page_content_subscriptions($filtered = false, $blocks = false) { |
|
1852 | + if ($blocks) { |
|
1853 | 1853 | $content = "<!-- wp:invoicing/wpinv-subscriptions-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_subscriptions title='' ]\"} --> |
1854 | 1854 | <div class=\"wp-block-invoicing-wpinv-subscriptions-widget\"></div> |
1855 | 1855 | <!-- /wp:invoicing/wpinv-subscriptions-widget -->"; |
@@ -1857,8 +1857,8 @@ discard block |
||
1857 | 1857 | $content = "[wpinv_subscriptions]"; |
1858 | 1858 | } |
1859 | 1859 | |
1860 | - if ( $filtered ) { |
|
1861 | - $content = apply_filters( 'getpaid_page_default_content_subscriptions', $content, $blocks ); |
|
1860 | + if ($filtered) { |
|
1861 | + $content = apply_filters('getpaid_page_default_content_subscriptions', $content, $blocks); |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | return $content; |
@@ -1873,22 +1873,22 @@ discard block |
||
1873 | 1873 | * @param bool $translated True if label needs to be translated. |
1874 | 1874 | * @return array Returns options array. |
1875 | 1875 | */ |
1876 | -function getpaid_parse_field_options( $options, $translated = true ) { |
|
1876 | +function getpaid_parse_field_options($options, $translated = true) { |
|
1877 | 1877 | $orig_options = $options; |
1878 | 1878 | |
1879 | 1879 | $options = array(); |
1880 | 1880 | |
1881 | - if ( ! empty( $orig_options ) ) { |
|
1882 | - foreach ( $orig_options as $key => $value ) { |
|
1883 | - if ( $value && is_string( $value ) ) { |
|
1884 | - $label = $translated ? __( wp_unslash( $value ), 'invoicing' ) : $value; |
|
1881 | + if (!empty($orig_options)) { |
|
1882 | + foreach ($orig_options as $key => $value) { |
|
1883 | + if ($value && is_string($value)) { |
|
1884 | + $label = $translated ? __(wp_unslash($value), 'invoicing') : $value; |
|
1885 | 1885 | } else { |
1886 | 1886 | $label = $value; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - $options[ $value ] = $label; |
|
1889 | + $options[$value] = $label; |
|
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | |
1893 | - return apply_filters( 'getpaid_parse_field_options', $options, $orig_options, $translated ); |
|
1893 | + return apply_filters('getpaid_parse_field_options', $options, $orig_options, $translated); |
|
1894 | 1894 | } |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | */ |
138 | 138 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
139 | 139 | |
140 | - $invoice_statuses = array( |
|
141 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
140 | + $invoice_statuses = array( |
|
141 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
142 | 142 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
143 | 143 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
144 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
145 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
146 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
144 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
145 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
146 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
147 | 147 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
148 | 148 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
149 | 149 | ); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $invoice = $invoice->get_post_type(); |
161 | 161 | } |
162 | 162 | |
163 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
163 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | * @return string |
279 | 279 | */ |
280 | 280 | function getpaid_get_price_format() { |
281 | - $currency_pos = wpinv_currency_position(); |
|
282 | - $format = '%1$s%2$s'; |
|
283 | - |
|
284 | - switch ( $currency_pos ) { |
|
285 | - case 'left': |
|
286 | - $format = '%1$s%2$s'; |
|
287 | - break; |
|
288 | - case 'right': |
|
289 | - $format = '%2$s%1$s'; |
|
290 | - break; |
|
291 | - case 'left_space': |
|
292 | - $format = '%1$s %2$s'; |
|
293 | - break; |
|
294 | - case 'right_space': |
|
295 | - $format = '%2$s %1$s'; |
|
296 | - break; |
|
297 | - } |
|
298 | - |
|
299 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
281 | + $currency_pos = wpinv_currency_position(); |
|
282 | + $format = '%1$s%2$s'; |
|
283 | + |
|
284 | + switch ( $currency_pos ) { |
|
285 | + case 'left': |
|
286 | + $format = '%1$s%2$s'; |
|
287 | + break; |
|
288 | + case 'right': |
|
289 | + $format = '%2$s%1$s'; |
|
290 | + break; |
|
291 | + case 'left_space': |
|
292 | + $format = '%1$s %2$s'; |
|
293 | + break; |
|
294 | + case 'right_space': |
|
295 | + $format = '%2$s %1$s'; |
|
296 | + break; |
|
297 | + } |
|
298 | + |
|
299 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -402,13 +402,13 @@ discard block |
||
402 | 402 | * @param mixed $value Value. |
403 | 403 | */ |
404 | 404 | function getpaid_maybe_define_constant( $name, $value ) { |
405 | - if ( ! defined( $name ) ) { |
|
406 | - define( $name, $value ); |
|
407 | - } |
|
405 | + if ( ! defined( $name ) ) { |
|
406 | + define( $name, $value ); |
|
407 | + } |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | function wpinv_get_php_arg_separator_output() { |
411 | - return ini_get( 'arg_separator.output' ); |
|
411 | + return ini_get( 'arg_separator.output' ); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | function wpinv_rgb_from_hex( $color ) { |
@@ -719,16 +719,16 @@ discard block |
||
719 | 719 | return wp_kses( |
720 | 720 | html_entity_decode( $var ), |
721 | 721 | array( |
722 | - 'br' => array(), |
|
723 | - 'em' => array(), |
|
724 | - 'strong' => array(), |
|
725 | - 'b' => array(), |
|
726 | - 'small' => array(), |
|
727 | - 'span' => array(), |
|
728 | - 'ul' => array(), |
|
729 | - 'li' => array(), |
|
730 | - 'ol' => array(), |
|
731 | - 'p' => array(), |
|
722 | + 'br' => array(), |
|
723 | + 'em' => array(), |
|
724 | + 'strong' => array(), |
|
725 | + 'b' => array(), |
|
726 | + 'small' => array(), |
|
727 | + 'span' => array(), |
|
728 | + 'ul' => array(), |
|
729 | + 'li' => array(), |
|
730 | + 'ol' => array(), |
|
731 | + 'p' => array(), |
|
732 | 732 | ) |
733 | 733 | ); |
734 | 734 | } |
@@ -779,11 +779,11 @@ discard block |
||
779 | 779 | $list = array(); |
780 | 780 | } |
781 | 781 | |
782 | - if ( ! is_array( $list ) ) { |
|
783 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
784 | - } |
|
782 | + if ( ! is_array( $list ) ) { |
|
783 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
784 | + } |
|
785 | 785 | |
786 | - return $list; |
|
786 | + return $list; |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -824,17 +824,17 @@ discard block |
||
824 | 824 | */ |
825 | 825 | function wpinv_clean( $var ) { |
826 | 826 | |
827 | - if ( is_array( $var ) ) { |
|
828 | - return array_map( 'wpinv_clean', $var ); |
|
827 | + if ( is_array( $var ) ) { |
|
828 | + return array_map( 'wpinv_clean', $var ); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | if ( is_object( $var ) ) { |
832 | - $object_vars = get_object_vars( $var ); |
|
833 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
834 | - $var->$property_name = wpinv_clean( $property_value ); |
|
832 | + $object_vars = get_object_vars( $var ); |
|
833 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
834 | + $var->$property_name = wpinv_clean( $property_value ); |
|
835 | 835 | } |
836 | 836 | return $var; |
837 | - } |
|
837 | + } |
|
838 | 838 | |
839 | 839 | return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
840 | 840 | } |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | */ |
848 | 848 | function getpaid_convert_price_string_to_options( $str, $translated = true ) { |
849 | 849 | |
850 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
850 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
851 | 851 | $options = array(); |
852 | 852 | |
853 | 853 | foreach ( $raw_options as $option ) { |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * @return string |
937 | 937 | */ |
938 | 938 | function getpaid_date_format() { |
939 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
939 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | * @return string |
946 | 946 | */ |
947 | 947 | function getpaid_time_format() { |
948 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
948 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -958,15 +958,15 @@ discard block |
||
958 | 958 | function getpaid_limit_length( $string, $limit ) { |
959 | 959 | $str_limit = $limit - 3; |
960 | 960 | |
961 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
962 | - if ( mb_strlen( $string ) > $limit ) { |
|
963 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
964 | - } |
|
965 | - } else { |
|
966 | - if ( strlen( $string ) > $limit ) { |
|
967 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
968 | - } |
|
969 | - } |
|
961 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
962 | + if ( mb_strlen( $string ) > $limit ) { |
|
963 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
964 | + } |
|
965 | + } else { |
|
966 | + if ( strlen( $string ) > $limit ) { |
|
967 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
968 | + } |
|
969 | + } |
|
970 | 970 | return $string; |
971 | 971 | |
972 | 972 | } |
@@ -1096,12 +1096,12 @@ discard block |
||
1096 | 1096 | $types = get_allowed_mime_types(); |
1097 | 1097 | |
1098 | 1098 | if ( isset( $types['htm|html'] ) ) { |
1099 | - unset( $types['htm|html'] ); |
|
1100 | - } |
|
1099 | + unset( $types['htm|html'] ); |
|
1100 | + } |
|
1101 | 1101 | |
1102 | 1102 | if ( isset( $types['js'] ) ) { |
1103 | - unset( $types['js'] ); |
|
1104 | - } |
|
1103 | + unset( $types['js'] ); |
|
1104 | + } |
|
1105 | 1105 | |
1106 | 1106 | return $types; |
1107 | 1107 | |
@@ -1157,11 +1157,11 @@ discard block |
||
1157 | 1157 | * @return string Returns converted string. |
1158 | 1158 | */ |
1159 | 1159 | function getpaid_strtolower( $string, $charset = 'UTF-8' ) { |
1160 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
1161 | - return mb_convert_case( $string, MB_CASE_LOWER, $charset ); |
|
1162 | - } else { |
|
1163 | - return strtolower( $string ); |
|
1164 | - } |
|
1160 | + if ( function_exists( 'mb_convert_case' ) ) { |
|
1161 | + return mb_convert_case( $string, MB_CASE_LOWER, $charset ); |
|
1162 | + } else { |
|
1163 | + return strtolower( $string ); |
|
1164 | + } |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | /** |
@@ -1174,9 +1174,9 @@ discard block |
||
1174 | 1174 | * @return string Returns converted string. |
1175 | 1175 | */ |
1176 | 1176 | function getpaid_strtoupper( $string, $charset = 'UTF-8' ) { |
1177 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
1178 | - return mb_convert_case( $string, MB_CASE_UPPER, $charset ); |
|
1179 | - } else { |
|
1180 | - return strtoupper( $string ); |
|
1181 | - } |
|
1177 | + if ( function_exists( 'mb_convert_case' ) ) { |
|
1178 | + return mb_convert_case( $string, MB_CASE_UPPER, $charset ); |
|
1179 | + } else { |
|
1180 | + return strtoupper( $string ); |
|
1181 | + } |
|
1182 | 1182 | } |
1183 | 1183 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | * @return float |
59 | 59 | */ |
60 | -function getpaid_standardize_amount( $amount ) { |
|
60 | +function getpaid_standardize_amount($amount) { |
|
61 | 61 | |
62 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
63 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
64 | - if ( is_numeric( $amount ) ) { |
|
65 | - return floatval( $amount ); |
|
62 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
63 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
64 | + if (is_numeric($amount)) { |
|
65 | + return floatval($amount); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // Cast the remaining to a float. |
69 | - return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) ); |
|
69 | + return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount)); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param string $amount The amount to sanitize. |
77 | 77 | */ |
78 | -function getpaid_unstandardize_amount( $amount ) { |
|
79 | - return str_replace( '.', wpinv_decimal_separator(), $amount ); |
|
78 | +function getpaid_unstandardize_amount($amount) { |
|
79 | + return str_replace('.', wpinv_decimal_separator(), $amount); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,24 +84,24 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param string $amount The amount to sanitize. |
86 | 86 | */ |
87 | -function wpinv_sanitize_amount( $amount ) { |
|
87 | +function wpinv_sanitize_amount($amount) { |
|
88 | 88 | |
89 | - if ( is_numeric( $amount ) ) { |
|
90 | - return floatval( $amount ); |
|
89 | + if (is_numeric($amount)) { |
|
90 | + return floatval($amount); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Separate the decimals and thousands. |
94 | - $amount = empty( $amount ) ? '0' : (string) $amount; |
|
95 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
94 | + $amount = empty($amount) ? '0' : (string) $amount; |
|
95 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
96 | 96 | |
97 | 97 | // Remove thousands. |
98 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
98 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
99 | 99 | |
100 | 100 | // Convert back to string. |
101 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
101 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
102 | 102 | |
103 | 103 | // Cast the remaining to a float. |
104 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
104 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
@@ -111,19 +111,19 @@ discard block |
||
111 | 111 | * @param float $amount |
112 | 112 | * @param float|string|int|null $decimals |
113 | 113 | */ |
114 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
114 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
115 | 115 | |
116 | - if ( $decimals === null ) { |
|
116 | + if ($decimals === null) { |
|
117 | 117 | $decimals = wpinv_decimals(); |
118 | 118 | } |
119 | 119 | |
120 | - if ( $use_sprintf ) { |
|
121 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
120 | + if ($use_sprintf) { |
|
121 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
122 | 122 | } else { |
123 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
123 | + $amount = round((float) $amount, absint($decimals)); |
|
124 | 124 | } |
125 | 125 | |
126 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
126 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -135,32 +135,32 @@ discard block |
||
135 | 135 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
136 | 136 | * @return array |
137 | 137 | */ |
138 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
138 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
139 | 139 | |
140 | 140 | $invoice_statuses = array( |
141 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
142 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
143 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
144 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
145 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
146 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
147 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
148 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
141 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
142 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
143 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
144 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
145 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
146 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
147 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
148 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
149 | 149 | ); |
150 | 150 | |
151 | - if ( $draft ) { |
|
152 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
151 | + if ($draft) { |
|
152 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( $trashed ) { |
|
156 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
155 | + if ($trashed) { |
|
156 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
159 | + if ($invoice instanceof WPInv_Invoice) { |
|
160 | 160 | $invoice = $invoice->get_post_type(); |
161 | 161 | } |
162 | 162 | |
163 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
163 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $status The raw status |
170 | 170 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
171 | 171 | */ |
172 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
173 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
174 | - $status = isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status; |
|
172 | +function wpinv_status_nicename($status, $invoice = false) { |
|
173 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
174 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
175 | 175 | |
176 | - return sanitize_text_field( $status ); |
|
176 | + return sanitize_text_field($status); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param string $current |
183 | 183 | */ |
184 | -function wpinv_get_currency( $current = '' ) { |
|
184 | +function wpinv_get_currency($current = '') { |
|
185 | 185 | |
186 | - if ( empty( $current ) ) { |
|
187 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
186 | + if (empty($current)) { |
|
187 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
188 | 188 | } |
189 | 189 | |
190 | - return trim( strtoupper( $current ) ); |
|
190 | + return trim(strtoupper($current)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -195,25 +195,25 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @param string|null $currency The currency code. Defaults to the default currency. |
197 | 197 | */ |
198 | -function wpinv_currency_symbol( $currency = null ) { |
|
198 | +function wpinv_currency_symbol($currency = null) { |
|
199 | 199 | |
200 | 200 | // Prepare the currency. |
201 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
201 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
202 | 202 | |
203 | 203 | // Fetch all symbols. |
204 | 204 | $symbols = wpinv_get_currency_symbols(); |
205 | 205 | |
206 | 206 | // Fetch this currencies symbol. |
207 | - $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : $currency; |
|
207 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
208 | 208 | |
209 | 209 | // Filter the symbol. |
210 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
210 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | function wpinv_currency_position() { |
214 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
214 | + $position = wpinv_get_option('currency_position', 'left'); |
|
215 | 215 | |
216 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
216 | + return apply_filters('wpinv_currency_position', $position); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param $string|null $current |
223 | 223 | */ |
224 | -function wpinv_thousands_separator( $current = null ) { |
|
224 | +function wpinv_thousands_separator($current = null) { |
|
225 | 225 | |
226 | - if ( null == $current ) { |
|
227 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
226 | + if (null == $current) { |
|
227 | + $current = wpinv_get_option('thousands_separator', ','); |
|
228 | 228 | } |
229 | 229 | |
230 | - return trim( $current ); |
|
230 | + return trim($current); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param $string|null $current |
237 | 237 | */ |
238 | -function wpinv_decimal_separator( $current = null ) { |
|
238 | +function wpinv_decimal_separator($current = null) { |
|
239 | 239 | |
240 | - if ( null == $current ) { |
|
241 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
240 | + if (null == $current) { |
|
241 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
242 | 242 | } |
243 | 243 | |
244 | - return trim( $current ); |
|
244 | + return trim($current); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,27 +249,27 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param $string|null $current |
251 | 251 | */ |
252 | -function wpinv_decimals( $current = null ) { |
|
252 | +function wpinv_decimals($current = null) { |
|
253 | 253 | |
254 | - if ( null == $current ) { |
|
255 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
254 | + if (null == $current) { |
|
255 | + $current = wpinv_get_option('decimals', 2); |
|
256 | 256 | } |
257 | 257 | |
258 | - return absint( $current ); |
|
258 | + return absint($current); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Retrieves a list of all supported currencies. |
263 | 263 | */ |
264 | 264 | function wpinv_get_currencies() { |
265 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
265 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Retrieves a list of all currency symbols. |
270 | 270 | */ |
271 | 271 | function wpinv_get_currency_symbols() { |
272 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
272 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $currency_pos = wpinv_currency_position(); |
282 | 282 | $format = '%1$s%2$s'; |
283 | 283 | |
284 | - switch ( $currency_pos ) { |
|
284 | + switch ($currency_pos) { |
|
285 | 285 | case 'left': |
286 | 286 | $format = '%1$s%2$s'; |
287 | 287 | break; |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | break; |
297 | 297 | } |
298 | 298 | |
299 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
299 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param string $currency Currency. |
307 | 307 | * @return string |
308 | 308 | */ |
309 | -function wpinv_the_price( $amount = 0, $currency = '' ) { |
|
310 | - echo wp_kses_post( wpinv_price( $amount, $currency ) ); |
|
309 | +function wpinv_the_price($amount = 0, $currency = '') { |
|
310 | + echo wp_kses_post(wpinv_price($amount, $currency)); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -317,25 +317,25 @@ discard block |
||
317 | 317 | * @param string $currency Currency. |
318 | 318 | * @return string |
319 | 319 | */ |
320 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
320 | +function wpinv_price($amount = 0, $currency = '') { |
|
321 | 321 | |
322 | 322 | // Backwards compatibility. |
323 | - $amount = wpinv_sanitize_amount( $amount ); |
|
323 | + $amount = wpinv_sanitize_amount($amount); |
|
324 | 324 | |
325 | 325 | // Prepare variables. |
326 | - $currency = wpinv_get_currency( $currency ); |
|
326 | + $currency = wpinv_get_currency($currency); |
|
327 | 327 | $amount = (float) $amount; |
328 | 328 | $unformatted_amount = $amount; |
329 | 329 | $negative = $amount < 0; |
330 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
331 | - $amount = wpinv_format_amount( $amount ); |
|
330 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
331 | + $amount = wpinv_format_amount($amount); |
|
332 | 332 | |
333 | 333 | // Format the amount. |
334 | 334 | $format = getpaid_get_price_format(); |
335 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
335 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
336 | 336 | |
337 | 337 | // Filter the formatting. |
338 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
338 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -346,25 +346,25 @@ discard block |
||
346 | 346 | * @param bool $calculate Whether or not to apply separators. |
347 | 347 | * @return string |
348 | 348 | */ |
349 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
349 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
350 | 350 | $thousands_sep = wpinv_thousands_separator(); |
351 | 351 | $decimal_sep = wpinv_decimal_separator(); |
352 | - $decimals = wpinv_decimals( $decimals ); |
|
353 | - $amount = wpinv_sanitize_amount( $amount ); |
|
352 | + $decimals = wpinv_decimals($decimals); |
|
353 | + $amount = wpinv_sanitize_amount($amount); |
|
354 | 354 | |
355 | - if ( $calculate ) { |
|
355 | + if ($calculate) { |
|
356 | 356 | return $amount; |
357 | 357 | } |
358 | 358 | |
359 | 359 | // Fomart the amount. |
360 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
360 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
361 | 361 | } |
362 | 362 | |
363 | -function wpinv_sanitize_key( $key ) { |
|
363 | +function wpinv_sanitize_key($key) { |
|
364 | 364 | $raw_key = $key; |
365 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
365 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
366 | 366 | |
367 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
367 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @param $str the file whose extension should be retrieved. |
374 | 374 | */ |
375 | -function wpinv_get_file_extension( $str ) { |
|
376 | - $filetype = wp_check_filetype( $str ); |
|
375 | +function wpinv_get_file_extension($str) { |
|
376 | + $filetype = wp_check_filetype($str); |
|
377 | 377 | return $filetype['ext']; |
378 | 378 | } |
379 | 379 | |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @param string $string |
384 | 384 | */ |
385 | -function wpinv_string_is_image_url( $string ) { |
|
386 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
387 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
385 | +function wpinv_string_is_image_url($string) { |
|
386 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
387 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
391 | 391 | * Returns the current URL. |
392 | 392 | */ |
393 | 393 | function wpinv_get_current_page_url() { |
394 | - return esc_url( add_query_arg( array() ) ); |
|
394 | + return esc_url(add_query_arg(array())); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -401,46 +401,46 @@ discard block |
||
401 | 401 | * @param string $name Constant name. |
402 | 402 | * @param mixed $value Value. |
403 | 403 | */ |
404 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
405 | - if ( ! defined( $name ) ) { |
|
406 | - define( $name, $value ); |
|
404 | +function getpaid_maybe_define_constant($name, $value) { |
|
405 | + if (!defined($name)) { |
|
406 | + define($name, $value); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
410 | 410 | function wpinv_get_php_arg_separator_output() { |
411 | - return ini_get( 'arg_separator.output' ); |
|
411 | + return ini_get('arg_separator.output'); |
|
412 | 412 | } |
413 | 413 | |
414 | -function wpinv_rgb_from_hex( $color ) { |
|
415 | - $color = str_replace( '#', '', $color ); |
|
414 | +function wpinv_rgb_from_hex($color) { |
|
415 | + $color = str_replace('#', '', $color); |
|
416 | 416 | |
417 | 417 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
418 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
419 | - if ( empty( $color ) ) { |
|
418 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
419 | + if (empty($color)) { |
|
420 | 420 | return null; |
421 | 421 | } |
422 | 422 | |
423 | - $color = str_split( $color ); |
|
423 | + $color = str_split($color); |
|
424 | 424 | |
425 | 425 | $rgb = array(); |
426 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
427 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
428 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
426 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
427 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
428 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
429 | 429 | |
430 | 430 | return $rgb; |
431 | 431 | } |
432 | 432 | |
433 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
434 | - $base = wpinv_rgb_from_hex( $color ); |
|
433 | +function wpinv_hex_darker($color, $factor = 30) { |
|
434 | + $base = wpinv_rgb_from_hex($color); |
|
435 | 435 | $color = '#'; |
436 | 436 | |
437 | - foreach ( $base as $k => $v ) { |
|
437 | + foreach ($base as $k => $v) { |
|
438 | 438 | $amount = $v / 100; |
439 | - $amount = round( $amount * $factor ); |
|
439 | + $amount = round($amount * $factor); |
|
440 | 440 | $new_decimal = $v - $amount; |
441 | 441 | |
442 | - $new_hex_component = dechex( $new_decimal ); |
|
443 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
442 | + $new_hex_component = dechex($new_decimal); |
|
443 | + if (strlen($new_hex_component) < 2) { |
|
444 | 444 | $new_hex_component = '0' . $new_hex_component; |
445 | 445 | } |
446 | 446 | $color .= $new_hex_component; |
@@ -449,18 +449,18 @@ discard block |
||
449 | 449 | return $color; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
453 | - $base = wpinv_rgb_from_hex( $color ); |
|
452 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
453 | + $base = wpinv_rgb_from_hex($color); |
|
454 | 454 | $color = '#'; |
455 | 455 | |
456 | - foreach ( $base as $k => $v ) { |
|
456 | + foreach ($base as $k => $v) { |
|
457 | 457 | $amount = 255 - $v; |
458 | 458 | $amount = $amount / 100; |
459 | - $amount = round( $amount * $factor ); |
|
459 | + $amount = round($amount * $factor); |
|
460 | 460 | $new_decimal = $v + $amount; |
461 | 461 | |
462 | - $new_hex_component = dechex( $new_decimal ); |
|
463 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
462 | + $new_hex_component = dechex($new_decimal); |
|
463 | + if (strlen($new_hex_component) < 2) { |
|
464 | 464 | $new_hex_component = '0' . $new_hex_component; |
465 | 465 | } |
466 | 466 | $color .= $new_hex_component; |
@@ -469,22 +469,22 @@ discard block |
||
469 | 469 | return $color; |
470 | 470 | } |
471 | 471 | |
472 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
473 | - $hex = str_replace( '#', '', $color ); |
|
472 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
473 | + $hex = str_replace('#', '', $color); |
|
474 | 474 | |
475 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
476 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
477 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
475 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
476 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
477 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
478 | 478 | |
479 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
479 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
480 | 480 | |
481 | 481 | return $brightness > 155 ? $dark : $light; |
482 | 482 | } |
483 | 483 | |
484 | -function wpinv_format_hex( $hex ) { |
|
485 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
484 | +function wpinv_format_hex($hex) { |
|
485 | + $hex = trim(str_replace('#', '', $hex)); |
|
486 | 486 | |
487 | - if ( strlen( $hex ) == 3 ) { |
|
487 | + if (strlen($hex) == 3) { |
|
488 | 488 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
489 | 489 | } |
490 | 490 | |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
505 | 505 | * @return string |
506 | 506 | */ |
507 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
508 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
509 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
507 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
508 | + if (function_exists('mb_strimwidth')) { |
|
509 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
510 | 510 | } |
511 | 511 | |
512 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
512 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -521,28 +521,28 @@ discard block |
||
521 | 521 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
522 | 522 | * @return int Returns the number of characters in string. |
523 | 523 | */ |
524 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
525 | - if ( function_exists( 'mb_strlen' ) ) { |
|
526 | - return mb_strlen( $str, $encoding ); |
|
524 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
525 | + if (function_exists('mb_strlen')) { |
|
526 | + return mb_strlen($str, $encoding); |
|
527 | 527 | } |
528 | 528 | |
529 | - return strlen( $str ); |
|
529 | + return strlen($str); |
|
530 | 530 | } |
531 | 531 | |
532 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
533 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
534 | - return mb_strtolower( $str, $encoding ); |
|
532 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
533 | + if (function_exists('mb_strtolower')) { |
|
534 | + return mb_strtolower($str, $encoding); |
|
535 | 535 | } |
536 | 536 | |
537 | - return strtolower( $str ); |
|
537 | + return strtolower($str); |
|
538 | 538 | } |
539 | 539 | |
540 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
541 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
542 | - return mb_strtoupper( $str, $encoding ); |
|
540 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
541 | + if (function_exists('mb_strtoupper')) { |
|
542 | + return mb_strtoupper($str, $encoding); |
|
543 | 543 | } |
544 | 544 | |
545 | - return strtoupper( $str ); |
|
545 | + return strtoupper($str); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
557 | 557 | * @return int Returns the position of the first occurrence of search in the string. |
558 | 558 | */ |
559 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
560 | - if ( function_exists( 'mb_strpos' ) ) { |
|
561 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
559 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
560 | + if (function_exists('mb_strpos')) { |
|
561 | + return mb_strpos($str, $find, $offset, $encoding); |
|
562 | 562 | } |
563 | 563 | |
564 | - return strpos( $str, $find, $offset ); |
|
564 | + return strpos($str, $find, $offset); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -575,12 +575,12 @@ discard block |
||
575 | 575 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
576 | 576 | * @return int Returns the position of the last occurrence of search. |
577 | 577 | */ |
578 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
579 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
580 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
578 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
579 | + if (function_exists('mb_strrpos')) { |
|
580 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
581 | 581 | } |
582 | 582 | |
583 | - return strrpos( $str, $find, $offset ); |
|
583 | + return strrpos($str, $find, $offset); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -595,16 +595,16 @@ discard block |
||
595 | 595 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
596 | 596 | * @return string |
597 | 597 | */ |
598 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
599 | - if ( function_exists( 'mb_substr' ) ) { |
|
600 | - if ( null === $length ) { |
|
601 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
598 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
599 | + if (function_exists('mb_substr')) { |
|
600 | + if (null === $length) { |
|
601 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
602 | 602 | } else { |
603 | - return mb_substr( $str, $start, $length, $encoding ); |
|
603 | + return mb_substr($str, $start, $length, $encoding); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
607 | - return substr( $str, $start, $length ); |
|
607 | + return substr($str, $start, $length); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -616,48 +616,48 @@ discard block |
||
616 | 616 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
617 | 617 | * @return string The width of string. |
618 | 618 | */ |
619 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
620 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
621 | - return mb_strwidth( $str, $encoding ); |
|
619 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
620 | + if (function_exists('mb_strwidth')) { |
|
621 | + return mb_strwidth($str, $encoding); |
|
622 | 622 | } |
623 | 623 | |
624 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
624 | + return wpinv_utf8_strlen($str, $encoding); |
|
625 | 625 | } |
626 | 626 | |
627 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
628 | - if ( function_exists( 'mb_strlen' ) ) { |
|
629 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
627 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
628 | + if (function_exists('mb_strlen')) { |
|
629 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
630 | 630 | $str_end = ''; |
631 | 631 | |
632 | - if ( $lower_str_end ) { |
|
633 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
632 | + if ($lower_str_end) { |
|
633 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
634 | 634 | } else { |
635 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
635 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | return $first_letter . $str_end; |
639 | 639 | } |
640 | 640 | |
641 | - return ucfirst( $str ); |
|
641 | + return ucfirst($str); |
|
642 | 642 | } |
643 | 643 | |
644 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
645 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
646 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
644 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
645 | + if (function_exists('mb_convert_case')) { |
|
646 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
647 | 647 | } |
648 | 648 | |
649 | - return ucwords( $str ); |
|
649 | + return ucwords($str); |
|
650 | 650 | } |
651 | 651 | |
652 | -function wpinv_period_in_days( $period, $unit ) { |
|
653 | - $period = absint( $period ); |
|
652 | +function wpinv_period_in_days($period, $unit) { |
|
653 | + $period = absint($period); |
|
654 | 654 | |
655 | - if ( $period > 0 ) { |
|
656 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
655 | + if ($period > 0) { |
|
656 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
657 | 657 | $period = $period * 7; |
658 | - } elseif ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
658 | + } elseif (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
659 | 659 | $period = $period * 30; |
660 | - } elseif ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
660 | + } elseif (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
661 | 661 | $period = $period * 365; |
662 | 662 | } |
663 | 663 | } |
@@ -665,14 +665,14 @@ discard block |
||
665 | 665 | return $period; |
666 | 666 | } |
667 | 667 | |
668 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
669 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
670 | - return cal_days_in_month( $calendar, $month, $year ); |
|
668 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
669 | + if (function_exists('cal_days_in_month')) { |
|
670 | + return cal_days_in_month($calendar, $month, $year); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | // Fallback in case the calendar extension is not loaded in PHP |
674 | 674 | // Only supports Gregorian calendar |
675 | - return gmdate( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
675 | + return gmdate('t', mktime(0, 0, 0, $month, 1, $year)); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | /** |
@@ -683,27 +683,27 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | -function wpi_help_tip( $tip, $allow_html = false, $is_vue = false, $echo = false ) { |
|
686 | +function wpi_help_tip($tip, $allow_html = false, $is_vue = false, $echo = false) { |
|
687 | 687 | |
688 | - if ( $allow_html ) { |
|
689 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
688 | + if ($allow_html) { |
|
689 | + $tip = wpi_sanitize_tooltip($tip); |
|
690 | 690 | } else { |
691 | - $tip = strip_tags( $tip ); |
|
691 | + $tip = strip_tags($tip); |
|
692 | 692 | } |
693 | 693 | |
694 | - if ( $is_vue ) { |
|
694 | + if ($is_vue) { |
|
695 | 695 | |
696 | - if ( $echo ) { |
|
697 | - echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
696 | + if ($echo) { |
|
697 | + echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
698 | 698 | } else { |
699 | - return '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
699 | + return '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | - if ( $echo ) { |
|
704 | - echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
703 | + if ($echo) { |
|
704 | + echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
705 | 705 | } else { |
706 | - return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>'; |
|
706 | + return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>'; |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | |
@@ -715,9 +715,9 @@ discard block |
||
715 | 715 | * @param string $var |
716 | 716 | * @return string |
717 | 717 | */ |
718 | -function wpi_sanitize_tooltip( $var ) { |
|
718 | +function wpi_sanitize_tooltip($var) { |
|
719 | 719 | return wp_kses( |
720 | - html_entity_decode( $var ), |
|
720 | + html_entity_decode($var), |
|
721 | 721 | array( |
722 | 722 | 'br' => array(), |
723 | 723 | 'em' => array(), |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | function wpinv_get_screen_ids() { |
742 | 742 | |
743 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
743 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
744 | 744 | |
745 | 745 | $screen_ids = array( |
746 | 746 | 'toplevel_page_' . $screen_id, |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | 'gp-setup', // setup wizard |
763 | 763 | ); |
764 | 764 | |
765 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
765 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | * @param array|string $list List of values. |
774 | 774 | * @return array Sanitized array of values. |
775 | 775 | */ |
776 | -function wpinv_parse_list( $list ) { |
|
776 | +function wpinv_parse_list($list) { |
|
777 | 777 | |
778 | - if ( empty( $list ) ) { |
|
778 | + if (empty($list)) { |
|
779 | 779 | $list = array(); |
780 | 780 | } |
781 | 781 | |
782 | - if ( ! is_array( $list ) ) { |
|
783 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
782 | + if (!is_array($list)) { |
|
783 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | return $list; |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | * @param string $key Type of data to fetch. |
795 | 795 | * @return mixed Fetched data. |
796 | 796 | */ |
797 | -function wpinv_get_data( $key ) { |
|
798 | - return apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
797 | +function wpinv_get_data($key) { |
|
798 | + return apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | * @param bool $first_empty Whether or not the first item in the list should be empty |
808 | 808 | * @return mixed Fetched data. |
809 | 809 | */ |
810 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
810 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
811 | 811 | |
812 | - if ( ! empty( $options ) && $first_empty ) { |
|
813 | - return array_merge( array( '' => '' ), $options ); |
|
812 | + if (!empty($options) && $first_empty) { |
|
813 | + return array_merge(array('' => ''), $options); |
|
814 | 814 | } |
815 | 815 | return $options; |
816 | 816 | |
@@ -822,21 +822,21 @@ discard block |
||
822 | 822 | * @param mixed $var Data to sanitize. |
823 | 823 | * @return string|array |
824 | 824 | */ |
825 | -function wpinv_clean( $var ) { |
|
825 | +function wpinv_clean($var) { |
|
826 | 826 | |
827 | - if ( is_array( $var ) ) { |
|
828 | - return array_map( 'wpinv_clean', $var ); |
|
827 | + if (is_array($var)) { |
|
828 | + return array_map('wpinv_clean', $var); |
|
829 | 829 | } |
830 | 830 | |
831 | - if ( is_object( $var ) ) { |
|
832 | - $object_vars = get_object_vars( $var ); |
|
833 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
834 | - $var->$property_name = wpinv_clean( $property_value ); |
|
831 | + if (is_object($var)) { |
|
832 | + $object_vars = get_object_vars($var); |
|
833 | + foreach ($object_vars as $property_name => $property_value) { |
|
834 | + $var->$property_name = wpinv_clean($property_value); |
|
835 | 835 | } |
836 | 836 | return $var; |
837 | 837 | } |
838 | 838 | |
839 | - return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
|
839 | + return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var; |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -845,43 +845,43 @@ discard block |
||
845 | 845 | * @param string $str Data to convert. |
846 | 846 | * @return string|array |
847 | 847 | */ |
848 | -function getpaid_convert_price_string_to_options( $str, $translated = true ) { |
|
848 | +function getpaid_convert_price_string_to_options($str, $translated = true) { |
|
849 | 849 | |
850 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
851 | - $options = array(); |
|
850 | + $raw_options = array_map('trim', explode(',', $str)); |
|
851 | + $options = array(); |
|
852 | 852 | |
853 | - foreach ( $raw_options as $option ) { |
|
853 | + foreach ($raw_options as $option) { |
|
854 | 854 | |
855 | - if ( '' == $option ) { |
|
855 | + if ('' == $option) { |
|
856 | 856 | continue; |
857 | 857 | } |
858 | 858 | |
859 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
859 | + $option = array_map('trim', explode('|', $option)); |
|
860 | 860 | |
861 | 861 | $price = null; |
862 | 862 | $label = null; |
863 | 863 | |
864 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
865 | - $label = $option[0]; |
|
864 | + if (isset($option[0]) && '' != $option[0]) { |
|
865 | + $label = $option[0]; |
|
866 | 866 | } |
867 | 867 | |
868 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
868 | + if (isset($option[1]) && '' != $option[1]) { |
|
869 | 869 | $price = $option[1]; |
870 | 870 | } |
871 | 871 | |
872 | - if ( ! isset( $price ) ) { |
|
872 | + if (!isset($price)) { |
|
873 | 873 | $price = $label; |
874 | 874 | } |
875 | 875 | |
876 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
876 | + if (!isset($price) || !is_numeric($price)) { |
|
877 | 877 | continue; |
878 | 878 | } |
879 | 879 | |
880 | - if ( ! isset( $label ) ) { |
|
880 | + if (!isset($label)) { |
|
881 | 881 | $label = $price; |
882 | 882 | } |
883 | 883 | |
884 | - $options[ "$label|$price" ] = $translated ? __( wp_unslash( $label ), 'invoicing' ) : $label; |
|
884 | + $options["$label|$price"] = $translated ? __(wp_unslash($label), 'invoicing') : $label; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | return $options; |
@@ -890,14 +890,14 @@ discard block |
||
890 | 890 | /** |
891 | 891 | * Returns the help tip. |
892 | 892 | */ |
893 | -function getpaid_get_help_tip( $tip, $additional_classes = '', $echo = false ) { |
|
893 | +function getpaid_get_help_tip($tip, $additional_classes = '', $echo = false) { |
|
894 | 894 | $classes = 'wpi-help-tip dashicons dashicons-editor-help ' . $additional_classes; |
895 | - $tip = esc_attr( $tip ); |
|
895 | + $tip = esc_attr($tip); |
|
896 | 896 | |
897 | - if ( $echo ) { |
|
898 | - echo '<span class="' . esc_attr( $classes ) . '" data-tip="' . esc_attr( $tip ) . '"></span>'; |
|
897 | + if ($echo) { |
|
898 | + echo '<span class="' . esc_attr($classes) . '" data-tip="' . esc_attr($tip) . '"></span>'; |
|
899 | 899 | } else { |
900 | - return '<span class="' . esc_attr( $classes ) . '" data-tip="' . esc_attr( $tip ) . '"></span>'; |
|
900 | + return '<span class="' . esc_attr($classes) . '" data-tip="' . esc_attr($tip) . '"></span>'; |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | } |
@@ -905,18 +905,18 @@ discard block |
||
905 | 905 | /** |
906 | 906 | * Formats a date |
907 | 907 | */ |
908 | -function getpaid_format_date( $date, $with_time = false ) { |
|
908 | +function getpaid_format_date($date, $with_time = false) { |
|
909 | 909 | |
910 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
910 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
911 | 911 | return ''; |
912 | 912 | } |
913 | 913 | |
914 | 914 | $format = getpaid_date_format(); |
915 | 915 | |
916 | - if ( $with_time ) { |
|
916 | + if ($with_time) { |
|
917 | 917 | $format .= ' ' . getpaid_time_format(); |
918 | 918 | } |
919 | - return date_i18n( $format, strtotime( $date ) ); |
|
919 | + return date_i18n($format, strtotime($date)); |
|
920 | 920 | |
921 | 921 | } |
922 | 922 | |
@@ -925,9 +925,9 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @return string |
927 | 927 | */ |
928 | -function getpaid_format_date_value( $date, $default = '—', $with_time = false ) { |
|
929 | - $date = getpaid_format_date( $date, $with_time ); |
|
930 | - return empty( $date ) ? $default : $date; |
|
928 | +function getpaid_format_date_value($date, $default = '—', $with_time = false) { |
|
929 | + $date = getpaid_format_date($date, $with_time); |
|
930 | + return empty($date) ? $default : $date; |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * @return string |
937 | 937 | */ |
938 | 938 | function getpaid_date_format() { |
939 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
939 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | * @return string |
946 | 946 | */ |
947 | 947 | function getpaid_time_format() { |
948 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
948 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -955,16 +955,16 @@ discard block |
||
955 | 955 | * @param integer $limit Limit size in characters. |
956 | 956 | * @return string |
957 | 957 | */ |
958 | -function getpaid_limit_length( $string, $limit ) { |
|
958 | +function getpaid_limit_length($string, $limit) { |
|
959 | 959 | $str_limit = $limit - 3; |
960 | 960 | |
961 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
962 | - if ( mb_strlen( $string ) > $limit ) { |
|
963 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
961 | + if (function_exists('mb_strimwidth')) { |
|
962 | + if (mb_strlen($string) > $limit) { |
|
963 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
964 | 964 | } |
965 | 965 | } else { |
966 | - if ( strlen( $string ) > $limit ) { |
|
967 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
966 | + if (strlen($string) > $limit) { |
|
967 | + $string = substr($string, 0, $str_limit) . '...'; |
|
968 | 968 | } |
969 | 969 | } |
970 | 970 | return $string; |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @since 1.0.19 |
979 | 979 | */ |
980 | 980 | function getpaid_api() { |
981 | - return getpaid()->get( 'api' ); |
|
981 | + return getpaid()->get('api'); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | * @since 1.0.19 |
989 | 989 | */ |
990 | 990 | function getpaid_post_types() { |
991 | - return getpaid()->get( 'post_types' ); |
|
991 | + return getpaid()->get('post_types'); |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | /** |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | * @since 1.0.19 |
999 | 999 | */ |
1000 | 1000 | function getpaid_session() { |
1001 | - return getpaid()->get( 'session' ); |
|
1001 | + return getpaid()->get('session'); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | /** |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | * @since 1.0.19 |
1009 | 1009 | */ |
1010 | 1010 | function getpaid_notes() { |
1011 | - return getpaid()->get( 'notes' ); |
|
1011 | + return getpaid()->get('notes'); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | * @return GetPaid_Admin |
1018 | 1018 | */ |
1019 | 1019 | function getpaid_admin() { |
1020 | - return getpaid()->get( 'admin' ); |
|
1020 | + return getpaid()->get('admin'); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1027,8 +1027,8 @@ discard block |
||
1027 | 1027 | * @param string $base the base url |
1028 | 1028 | * @return string |
1029 | 1029 | */ |
1030 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
1031 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
1030 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
1031 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | /** |
@@ -1036,11 +1036,11 @@ discard block |
||
1036 | 1036 | * |
1037 | 1037 | * @return string |
1038 | 1038 | */ |
1039 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
1039 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
1040 | 1040 | |
1041 | - $post_type = get_post_type_object( $post_type ); |
|
1041 | + $post_type = get_post_type_object($post_type); |
|
1042 | 1042 | |
1043 | - if ( ! is_object( $post_type ) ) { |
|
1043 | + if (!is_object($post_type)) { |
|
1044 | 1044 | return null; |
1045 | 1045 | } |
1046 | 1046 | |
@@ -1053,18 +1053,18 @@ discard block |
||
1053 | 1053 | * |
1054 | 1054 | * @return mixed|null |
1055 | 1055 | */ |
1056 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1056 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1057 | 1057 | |
1058 | - if ( ! is_array( $array ) ) { |
|
1058 | + if (!is_array($array)) { |
|
1059 | 1059 | return null; |
1060 | 1060 | } |
1061 | 1061 | |
1062 | - if ( ! empty( $secondary_key ) ) { |
|
1063 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1064 | - return getpaid_get_array_field( $array, $key ); |
|
1062 | + if (!empty($secondary_key)) { |
|
1063 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1064 | + return getpaid_get_array_field($array, $key); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1067 | + return isset($array[$key]) ? $array[$key] : null; |
|
1068 | 1068 | |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1073,12 +1073,12 @@ discard block |
||
1073 | 1073 | * |
1074 | 1074 | * @return array |
1075 | 1075 | */ |
1076 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1076 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1077 | 1077 | |
1078 | - foreach ( $defaults as $key => $value ) { |
|
1078 | + foreach ($defaults as $key => $value) { |
|
1079 | 1079 | |
1080 | - if ( empty( $args[ $key ] ) ) { |
|
1081 | - $args[ $key ] = $value; |
|
1080 | + if (empty($args[$key])) { |
|
1081 | + $args[$key] = $value; |
|
1082 | 1082 | } |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1095,12 +1095,12 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | $types = get_allowed_mime_types(); |
1097 | 1097 | |
1098 | - if ( isset( $types['htm|html'] ) ) { |
|
1099 | - unset( $types['htm|html'] ); |
|
1098 | + if (isset($types['htm|html'])) { |
|
1099 | + unset($types['htm|html']); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | - if ( isset( $types['js'] ) ) { |
|
1103 | - unset( $types['js'] ); |
|
1102 | + if (isset($types['js'])) { |
|
1103 | + unset($types['js']); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | return $types; |
@@ -1108,21 +1108,21 @@ discard block |
||
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | |
1111 | -function getpaid_user_delete_invoice( $data ) { |
|
1111 | +function getpaid_user_delete_invoice($data) { |
|
1112 | 1112 | |
1113 | 1113 | // Ensure there is an invoice to delete. |
1114 | - if ( empty( $data['invoice_id'] ) ) { |
|
1114 | + if (empty($data['invoice_id'])) { |
|
1115 | 1115 | return; |
1116 | 1116 | } |
1117 | 1117 | |
1118 | - $invoice = new WPInv_Invoice( (int) $data['invoice_id'] ); |
|
1118 | + $invoice = new WPInv_Invoice((int) $data['invoice_id']); |
|
1119 | 1119 | |
1120 | 1120 | // Ensure that it exists and that it belongs to the current user. |
1121 | - if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) { |
|
1121 | + if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) { |
|
1122 | 1122 | $notice = 'perm_delete_invoice'; |
1123 | 1123 | |
1124 | 1124 | // Can it be deleted? |
1125 | - } elseif ( ! $invoice->needs_payment() ) { |
|
1125 | + } elseif (!$invoice->needs_payment()) { |
|
1126 | 1126 | $notice = 'cannot_delete_invoice'; |
1127 | 1127 | |
1128 | 1128 | // Delete it. |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | ) |
1142 | 1142 | ); |
1143 | 1143 | |
1144 | - wp_safe_redirect( $redirect ); |
|
1144 | + wp_safe_redirect($redirect); |
|
1145 | 1145 | exit; |
1146 | 1146 | |
1147 | 1147 | } |
1148 | -add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' ); |
|
1148 | +add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice'); |
|
1149 | 1149 | |
1150 | 1150 | /** |
1151 | 1151 | * Converts string to lower case. |
@@ -1156,11 +1156,11 @@ discard block |
||
1156 | 1156 | * @param string $charset Character set to use for conversion. |
1157 | 1157 | * @return string Returns converted string. |
1158 | 1158 | */ |
1159 | -function getpaid_strtolower( $string, $charset = 'UTF-8' ) { |
|
1160 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
1161 | - return mb_convert_case( $string, MB_CASE_LOWER, $charset ); |
|
1159 | +function getpaid_strtolower($string, $charset = 'UTF-8') { |
|
1160 | + if (function_exists('mb_convert_case')) { |
|
1161 | + return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
1162 | 1162 | } else { |
1163 | - return strtolower( $string ); |
|
1163 | + return strtolower($string); |
|
1164 | 1164 | } |
1165 | 1165 | } |
1166 | 1166 | |
@@ -1173,10 +1173,10 @@ discard block |
||
1173 | 1173 | * @param string $charset Character set to use for conversion. |
1174 | 1174 | * @return string Returns converted string. |
1175 | 1175 | */ |
1176 | -function getpaid_strtoupper( $string, $charset = 'UTF-8' ) { |
|
1177 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
1178 | - return mb_convert_case( $string, MB_CASE_UPPER, $charset ); |
|
1176 | +function getpaid_strtoupper($string, $charset = 'UTF-8') { |
|
1177 | + if (function_exists('mb_convert_case')) { |
|
1178 | + return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
1179 | 1179 | } else { |
1180 | - return strtoupper( $string ); |
|
1180 | + return strtoupper($string); |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | \ No newline at end of file |
@@ -7,25 +7,25 @@ |
||
7 | 7 | * @version 2.8.32 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
14 | 14 | |
15 | -if ( ! empty( $required ) ) { |
|
15 | +if (!empty($required)) { |
|
16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
17 | 17 | } |
18 | 18 | |
19 | 19 | aui()->select( |
20 | 20 | array( |
21 | - 'name' => esc_attr( $id ), |
|
22 | - 'id' => esc_attr( $element_id ), |
|
23 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
24 | - 'required' => ! empty( $required ), |
|
21 | + 'name' => esc_attr($id), |
|
22 | + 'id' => esc_attr($element_id), |
|
23 | + 'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder), |
|
24 | + 'required' => !empty($required), |
|
25 | 25 | 'label' => $label, |
26 | 26 | 'label_type' => 'vertical', |
27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
28 | - 'options' => getpaid_parse_field_options( $options ), |
|
27 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
28 | + 'options' => getpaid_parse_field_options($options), |
|
29 | 29 | 'class' => $label_class, |
30 | 30 | 'value' => $query_value, |
31 | 31 | ), |
@@ -7,26 +7,26 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
14 | 14 | |
15 | -if ( ! empty( $required ) ) { |
|
15 | +if (!empty($required)) { |
|
16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
17 | 17 | } |
18 | 18 | |
19 | 19 | aui()->radio( |
20 | 20 | array( |
21 | - 'name' => esc_attr( $id ), |
|
22 | - 'id' => esc_attr( $element_id ), |
|
23 | - 'required' => ! empty( $required ), |
|
21 | + 'name' => esc_attr($id), |
|
22 | + 'id' => esc_attr($element_id), |
|
23 | + 'required' => !empty($required), |
|
24 | 24 | 'label' => $label, |
25 | 25 | 'label_type' => 'vertical', |
26 | 26 | 'class' => 'w-auto', |
27 | 27 | 'inline' => false, |
28 | - 'options' => getpaid_parse_field_options( $options ), |
|
29 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
28 | + 'options' => getpaid_parse_field_options($options), |
|
29 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
30 | 30 | 'class' => $label_class, |
31 | 31 | 'value' => $query_value, |
32 | 32 | ), |