@@ -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 | } |
@@ -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 | } |
@@ -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 |
@@ -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 | } |
@@ -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 |