@@ -14,73 +14,73 @@ 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; |
|
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 | 29 | |
30 | - /** |
|
31 | - * Reports components. |
|
32 | - * |
|
33 | - * @var GetPaid_Reports |
|
34 | - */ |
|
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' ) ); |
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_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
65 | - 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_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
65 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
66 | 66 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
67 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
68 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
67 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
68 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | - * Register admin scripts |
|
74 | - * |
|
75 | - */ |
|
76 | - public function enqeue_scripts() { |
|
73 | + * Register admin scripts |
|
74 | + * |
|
75 | + */ |
|
76 | + public function enqeue_scripts() { |
|
77 | 77 | global $current_screen, $pagenow; |
78 | 78 | |
79 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
80 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
79 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
80 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
81 | 81 | |
82 | 82 | if ( ! empty( $current_screen->post_type ) ) { |
83 | - $page = $current_screen->post_type; |
|
83 | + $page = $current_screen->post_type; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // General styles. |
@@ -103,54 +103,54 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | // Payment form scripts. |
106 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
106 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
107 | 107 | $this->load_payment_form_scripts(); |
108 | 108 | } |
109 | 109 | |
110 | - if ( $page == 'wpinv-subscriptions' ) { |
|
111 | - wp_enqueue_script( 'postbox' ); |
|
112 | - } |
|
110 | + if ( $page == 'wpinv-subscriptions' ) { |
|
111 | + wp_enqueue_script( 'postbox' ); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * Returns admin js translations. |
|
118 | - * |
|
119 | - */ |
|
120 | - protected function get_admin_i18() { |
|
117 | + * Returns admin js translations. |
|
118 | + * |
|
119 | + */ |
|
120 | + protected function get_admin_i18() { |
|
121 | 121 | global $post; |
122 | 122 | |
123 | - $date_range = array( |
|
124 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
125 | - ); |
|
123 | + $date_range = array( |
|
124 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
125 | + ); |
|
126 | 126 | |
127 | - if ( $date_range['period'] == 'custom' ) { |
|
127 | + if ( $date_range['period'] == 'custom' ) { |
|
128 | 128 | |
129 | - if ( isset( $_GET['from'] ) ) { |
|
130 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
131 | - } |
|
129 | + if ( isset( $_GET['from'] ) ) { |
|
130 | + $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
131 | + } |
|
132 | 132 | |
133 | - if ( isset( $_GET['to'] ) ) { |
|
134 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
135 | - } |
|
133 | + if ( isset( $_GET['to'] ) ) { |
|
134 | + $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
135 | + } |
|
136 | 136 | |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | 139 | $i18n = array( |
140 | 140 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
141 | 141 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
142 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
143 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
144 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
145 | - 'date_range' => $date_range, |
|
142 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
143 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
144 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
145 | + 'date_range' => $date_range, |
|
146 | 146 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
147 | 147 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
148 | 148 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
149 | 149 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
150 | 150 | 'tax' => wpinv_tax_amount(), |
151 | 151 | 'discount' => 0, |
152 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
153 | - 'currency' => wpinv_get_currency(), |
|
152 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
153 | + 'currency' => wpinv_get_currency(), |
|
154 | 154 | 'currency_pos' => wpinv_currency_position(), |
155 | 155 | 'thousand_sep' => wpinv_thousands_separator(), |
156 | 156 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -173,112 +173,112 @@ discard block |
||
173 | 173 | 'searching' => __( 'Searching', 'invoicing' ), |
174 | 174 | ); |
175 | 175 | |
176 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
176 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
177 | 177 | |
178 | - $invoice = new WPInv_Invoice( $post ); |
|
179 | - $i18n['save_invoice'] = sprintf( |
|
180 | - __( 'Save %s', 'invoicing' ), |
|
181 | - ucfirst( $invoice->get_type() ) |
|
182 | - ); |
|
178 | + $invoice = new WPInv_Invoice( $post ); |
|
179 | + $i18n['save_invoice'] = sprintf( |
|
180 | + __( 'Save %s', 'invoicing' ), |
|
181 | + ucfirst( $invoice->get_type() ) |
|
182 | + ); |
|
183 | 183 | |
184 | - $i18n['invoice_description'] = sprintf( |
|
185 | - __( '%s Description', 'invoicing' ), |
|
186 | - ucfirst( $invoice->get_type() ) |
|
187 | - ); |
|
184 | + $i18n['invoice_description'] = sprintf( |
|
185 | + __( '%s Description', 'invoicing' ), |
|
186 | + ucfirst( $invoice->get_type() ) |
|
187 | + ); |
|
188 | 188 | |
189 | - } |
|
190 | - return $i18n; |
|
191 | - } |
|
189 | + } |
|
190 | + return $i18n; |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Change the admin footer text on GetPaid admin pages. |
|
195 | - * |
|
196 | - * @since 2.0.0 |
|
197 | - * @param string $footer_text |
|
198 | - * @return string |
|
199 | - */ |
|
200 | - public function admin_footer_text( $footer_text ) { |
|
201 | - global $current_screen; |
|
193 | + /** |
|
194 | + * Change the admin footer text on GetPaid admin pages. |
|
195 | + * |
|
196 | + * @since 2.0.0 |
|
197 | + * @param string $footer_text |
|
198 | + * @return string |
|
199 | + */ |
|
200 | + public function admin_footer_text( $footer_text ) { |
|
201 | + global $current_screen; |
|
202 | 202 | |
203 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
203 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
204 | 204 | |
205 | 205 | if ( ! empty( $current_screen->post_type ) ) { |
206 | - $page = $current_screen->post_type; |
|
206 | + $page = $current_screen->post_type; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | // General styles. |
210 | 210 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
211 | 211 | |
212 | - // Change the footer text |
|
213 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
214 | - |
|
215 | - $rating_url = esc_url( |
|
216 | - wp_nonce_url( |
|
217 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
218 | - 'getpaid-nonce', |
|
219 | - 'getpaid-nonce' |
|
220 | - ) |
|
221 | - ); |
|
222 | - |
|
223 | - $footer_text = sprintf( |
|
224 | - /* translators: %s: five stars */ |
|
225 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
226 | - "<a href='$rating_url'>★★★★★</a>" |
|
227 | - ); |
|
228 | - |
|
229 | - } else { |
|
230 | - |
|
231 | - $footer_text = sprintf( |
|
232 | - /* translators: %s: GetPaid */ |
|
233 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
234 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
235 | - ); |
|
236 | - |
|
237 | - } |
|
238 | - |
|
239 | - } |
|
240 | - |
|
241 | - return $footer_text; |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * Redirects to wp.org to rate the plugin. |
|
246 | - * |
|
247 | - * @since 2.0.0 |
|
248 | - */ |
|
249 | - public function redirect_to_wordpress_rating_page() { |
|
250 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
251 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
252 | - exit; |
|
253 | - } |
|
212 | + // Change the footer text |
|
213 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
214 | + |
|
215 | + $rating_url = esc_url( |
|
216 | + wp_nonce_url( |
|
217 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
218 | + 'getpaid-nonce', |
|
219 | + 'getpaid-nonce' |
|
220 | + ) |
|
221 | + ); |
|
222 | + |
|
223 | + $footer_text = sprintf( |
|
224 | + /* translators: %s: five stars */ |
|
225 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
226 | + "<a href='$rating_url'>★★★★★</a>" |
|
227 | + ); |
|
228 | + |
|
229 | + } else { |
|
230 | + |
|
231 | + $footer_text = sprintf( |
|
232 | + /* translators: %s: GetPaid */ |
|
233 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
234 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
235 | + ); |
|
236 | + |
|
237 | + } |
|
238 | + |
|
239 | + } |
|
240 | + |
|
241 | + return $footer_text; |
|
242 | + } |
|
254 | 243 | |
255 | 244 | /** |
256 | - * Loads payment form js. |
|
257 | - * |
|
258 | - */ |
|
259 | - protected function load_payment_form_scripts() { |
|
245 | + * Redirects to wp.org to rate the plugin. |
|
246 | + * |
|
247 | + * @since 2.0.0 |
|
248 | + */ |
|
249 | + public function redirect_to_wordpress_rating_page() { |
|
250 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
251 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
252 | + exit; |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Loads payment form js. |
|
257 | + * |
|
258 | + */ |
|
259 | + protected function load_payment_form_scripts() { |
|
260 | 260 | global $post; |
261 | 261 | |
262 | 262 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
263 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
264 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
263 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
264 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
265 | 265 | |
266 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
267 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
266 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
267 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
268 | 268 | |
269 | - wp_localize_script( |
|
269 | + wp_localize_script( |
|
270 | 270 | 'wpinv-admin-payment-form-script', |
271 | 271 | 'wpinvPaymentFormAdmin', |
272 | 272 | array( |
273 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
274 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
275 | - 'currency' => wpinv_currency_symbol(), |
|
276 | - 'position' => wpinv_currency_position(), |
|
277 | - 'decimals' => (int) wpinv_decimals(), |
|
278 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
279 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
280 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
281 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
273 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
274 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
275 | + 'currency' => wpinv_currency_symbol(), |
|
276 | + 'position' => wpinv_currency_position(), |
|
277 | + 'decimals' => (int) wpinv_decimals(), |
|
278 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
279 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
280 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
281 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
282 | 282 | ) |
283 | 283 | ); |
284 | 284 | |
@@ -287,20 +287,20 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
290 | - * Add our classes to admin pages. |
|
290 | + * Add our classes to admin pages. |
|
291 | 291 | * |
292 | 292 | * @param string $classes |
293 | 293 | * @return string |
294 | - * |
|
295 | - */ |
|
294 | + * |
|
295 | + */ |
|
296 | 296 | public function admin_body_class( $classes ) { |
297 | - global $pagenow, $post, $current_screen; |
|
297 | + global $pagenow, $post, $current_screen; |
|
298 | 298 | |
299 | 299 | |
300 | 300 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
301 | 301 | |
302 | 302 | if ( ! empty( $current_screen->post_type ) ) { |
303 | - $page = $current_screen->post_type; |
|
303 | + $page = $current_screen->post_type; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -309,29 +309,29 @@ discard block |
||
309 | 309 | |
310 | 310 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
311 | 311 | $classes .= ' wpinv-cpt wpinv'; |
312 | - } |
|
312 | + } |
|
313 | 313 | |
314 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
314 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
315 | 315 | $classes .= ' getpaid-is-invoice-cpt'; |
316 | 316 | } |
317 | 317 | |
318 | - return $classes; |
|
318 | + return $classes; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
322 | - * Maybe show the AyeCode Connect Notice. |
|
323 | - */ |
|
324 | - public function init_ayecode_connect_helper(){ |
|
322 | + * Maybe show the AyeCode Connect Notice. |
|
323 | + */ |
|
324 | + public function init_ayecode_connect_helper(){ |
|
325 | 325 | |
326 | 326 | new AyeCode_Connect_Helper( |
327 | 327 | array( |
328 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
329 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
330 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
331 | - 'connect_button' => __("Connect Site","invoicing"), |
|
332 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
333 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
334 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
328 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
329 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
330 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
331 | + 'connect_button' => __("Connect Site","invoicing"), |
|
332 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
333 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
334 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
335 | 335 | ), |
336 | 336 | array( 'wpi-addons' ) |
337 | 337 | ); |
@@ -343,21 +343,21 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function activation_redirect() { |
345 | 345 | |
346 | - // Bail if no activation redirect. |
|
347 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
348 | - return; |
|
349 | - } |
|
346 | + // Bail if no activation redirect. |
|
347 | + if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
348 | + return; |
|
349 | + } |
|
350 | 350 | |
351 | - // Delete the redirect transient. |
|
352 | - delete_transient( '_wpinv_activation_redirect' ); |
|
351 | + // Delete the redirect transient. |
|
352 | + delete_transient( '_wpinv_activation_redirect' ); |
|
353 | 353 | |
354 | - // Bail if activating from network, or bulk |
|
355 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
356 | - return; |
|
357 | - } |
|
354 | + // Bail if activating from network, or bulk |
|
355 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
356 | + return; |
|
357 | + } |
|
358 | 358 | |
359 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
360 | - exit; |
|
359 | + wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
360 | + exit; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -372,162 +372,162 @@ discard block |
||
372 | 372 | |
373 | 373 | } |
374 | 374 | |
375 | - /** |
|
375 | + /** |
|
376 | 376 | * Sends a payment reminder to a customer. |
377 | - * |
|
378 | - * @param array $args |
|
377 | + * |
|
378 | + * @param array $args |
|
379 | 379 | */ |
380 | 380 | public function send_customer_invoice( $args ) { |
381 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
381 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
382 | 382 | |
383 | - if ( $sent ) { |
|
384 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
385 | - } else { |
|
386 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
387 | - } |
|
383 | + if ( $sent ) { |
|
384 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
385 | + } else { |
|
386 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
387 | + } |
|
388 | 388 | |
389 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
390 | - exit; |
|
391 | - } |
|
389 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
390 | + exit; |
|
391 | + } |
|
392 | 392 | |
393 | - /** |
|
393 | + /** |
|
394 | 394 | * Sends a payment reminder to a customer. |
395 | - * |
|
396 | - * @param array $args |
|
395 | + * |
|
396 | + * @param array $args |
|
397 | 397 | */ |
398 | 398 | public function send_customer_payment_reminder( $args ) { |
399 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
399 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
400 | 400 | |
401 | - if ( $sent ) { |
|
402 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
403 | - } else { |
|
404 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
405 | - } |
|
401 | + if ( $sent ) { |
|
402 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
403 | + } else { |
|
404 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
405 | + } |
|
406 | 406 | |
407 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
408 | - exit; |
|
409 | - } |
|
407 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
408 | + exit; |
|
409 | + } |
|
410 | 410 | |
411 | - /** |
|
411 | + /** |
|
412 | 412 | * Resets tax rates. |
413 | - * |
|
413 | + * |
|
414 | 414 | */ |
415 | 415 | public function admin_reset_tax_rates() { |
416 | 416 | |
417 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
418 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
419 | - exit; |
|
417 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
418 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
419 | + exit; |
|
420 | 420 | |
421 | - } |
|
421 | + } |
|
422 | 422 | |
423 | 423 | /** |
424 | - * Returns an array of admin notices. |
|
425 | - * |
|
426 | - * @since 1.0.19 |
|
424 | + * Returns an array of admin notices. |
|
425 | + * |
|
426 | + * @since 1.0.19 |
|
427 | 427 | * @return array |
428 | - */ |
|
429 | - public function get_notices() { |
|
430 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
428 | + */ |
|
429 | + public function get_notices() { |
|
430 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
431 | 431 | return is_array( $notices ) ? $notices : array(); |
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Clears all admin notices |
|
436 | - * |
|
437 | - * @access public |
|
438 | - * @since 1.0.19 |
|
439 | - */ |
|
440 | - public function clear_notices() { |
|
441 | - delete_option( 'wpinv_admin_notices' ); |
|
442 | - } |
|
443 | - |
|
444 | - /** |
|
445 | - * Saves a new admin notice |
|
446 | - * |
|
447 | - * @access public |
|
448 | - * @since 1.0.19 |
|
449 | - */ |
|
450 | - public function save_notice( $type, $message ) { |
|
451 | - $notices = $this->get_notices(); |
|
452 | - |
|
453 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
454 | - $notices[ $type ] = array(); |
|
455 | - } |
|
456 | - |
|
457 | - $notices[ $type ][] = $message; |
|
458 | - |
|
459 | - update_option( 'wpinv_admin_notices', $notices ); |
|
460 | - } |
|
461 | - |
|
462 | - /** |
|
463 | - * Displays a success notice |
|
464 | - * |
|
465 | - * @param string $msg The message to qeue. |
|
466 | - * @access public |
|
467 | - * @since 1.0.19 |
|
468 | - */ |
|
469 | - public function show_success( $msg ) { |
|
470 | - $this->save_notice( 'success', $msg ); |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Displays a error notice |
|
475 | - * |
|
476 | - * @access public |
|
477 | - * @param string $msg The message to qeue. |
|
478 | - * @since 1.0.19 |
|
479 | - */ |
|
480 | - public function show_error( $msg ) { |
|
481 | - $this->save_notice( 'error', $msg ); |
|
482 | - } |
|
483 | - |
|
484 | - /** |
|
485 | - * Displays a warning notice |
|
486 | - * |
|
487 | - * @access public |
|
488 | - * @param string $msg The message to qeue. |
|
489 | - * @since 1.0.19 |
|
490 | - */ |
|
491 | - public function show_warning( $msg ) { |
|
492 | - $this->save_notice( 'warning', $msg ); |
|
493 | - } |
|
494 | - |
|
495 | - /** |
|
496 | - * Displays a info notice |
|
497 | - * |
|
498 | - * @access public |
|
499 | - * @param string $msg The message to qeue. |
|
500 | - * @since 1.0.19 |
|
501 | - */ |
|
502 | - public function show_info( $msg ) { |
|
503 | - $this->save_notice( 'info', $msg ); |
|
504 | - } |
|
505 | - |
|
506 | - /** |
|
507 | - * Show notices |
|
508 | - * |
|
509 | - * @access public |
|
510 | - * @since 1.0.19 |
|
511 | - */ |
|
512 | - public function show_notices() { |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Clears all admin notices |
|
436 | + * |
|
437 | + * @access public |
|
438 | + * @since 1.0.19 |
|
439 | + */ |
|
440 | + public function clear_notices() { |
|
441 | + delete_option( 'wpinv_admin_notices' ); |
|
442 | + } |
|
443 | + |
|
444 | + /** |
|
445 | + * Saves a new admin notice |
|
446 | + * |
|
447 | + * @access public |
|
448 | + * @since 1.0.19 |
|
449 | + */ |
|
450 | + public function save_notice( $type, $message ) { |
|
451 | + $notices = $this->get_notices(); |
|
452 | + |
|
453 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
454 | + $notices[ $type ] = array(); |
|
455 | + } |
|
456 | + |
|
457 | + $notices[ $type ][] = $message; |
|
458 | + |
|
459 | + update_option( 'wpinv_admin_notices', $notices ); |
|
460 | + } |
|
461 | + |
|
462 | + /** |
|
463 | + * Displays a success notice |
|
464 | + * |
|
465 | + * @param string $msg The message to qeue. |
|
466 | + * @access public |
|
467 | + * @since 1.0.19 |
|
468 | + */ |
|
469 | + public function show_success( $msg ) { |
|
470 | + $this->save_notice( 'success', $msg ); |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * Displays a error notice |
|
475 | + * |
|
476 | + * @access public |
|
477 | + * @param string $msg The message to qeue. |
|
478 | + * @since 1.0.19 |
|
479 | + */ |
|
480 | + public function show_error( $msg ) { |
|
481 | + $this->save_notice( 'error', $msg ); |
|
482 | + } |
|
483 | + |
|
484 | + /** |
|
485 | + * Displays a warning notice |
|
486 | + * |
|
487 | + * @access public |
|
488 | + * @param string $msg The message to qeue. |
|
489 | + * @since 1.0.19 |
|
490 | + */ |
|
491 | + public function show_warning( $msg ) { |
|
492 | + $this->save_notice( 'warning', $msg ); |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * Displays a info notice |
|
497 | + * |
|
498 | + * @access public |
|
499 | + * @param string $msg The message to qeue. |
|
500 | + * @since 1.0.19 |
|
501 | + */ |
|
502 | + public function show_info( $msg ) { |
|
503 | + $this->save_notice( 'info', $msg ); |
|
504 | + } |
|
505 | + |
|
506 | + /** |
|
507 | + * Show notices |
|
508 | + * |
|
509 | + * @access public |
|
510 | + * @since 1.0.19 |
|
511 | + */ |
|
512 | + public function show_notices() { |
|
513 | 513 | |
514 | 514 | $notices = $this->get_notices(); |
515 | 515 | $this->clear_notices(); |
516 | 516 | |
517 | - foreach ( $notices as $type => $messages ) { |
|
517 | + foreach ( $notices as $type => $messages ) { |
|
518 | 518 | |
519 | - if ( ! is_array( $messages ) ) { |
|
520 | - continue; |
|
521 | - } |
|
519 | + if ( ! is_array( $messages ) ) { |
|
520 | + continue; |
|
521 | + } |
|
522 | 522 | |
523 | 523 | $type = sanitize_key( $type ); |
524 | - foreach ( $messages as $message ) { |
|
524 | + foreach ( $messages as $message ) { |
|
525 | 525 | $message = wp_kses_post( $message ); |
526 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
526 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | } |
530 | 530 | |
531 | - } |
|
531 | + } |
|
532 | 532 | |
533 | 533 | } |