@@ -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 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The main admin class. |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * Class constructor. |
39 | 39 | */ |
40 | - public function __construct(){ |
|
40 | + public function __construct() { |
|
41 | 41 | |
42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
44 | 44 | $this->reports = new GetPaid_Reports(); |
45 | 45 | |
46 | - if ( is_admin() ) { |
|
46 | + if (is_admin()) { |
|
47 | 47 | $this->init_admin_hooks(); |
48 | 48 | } |
49 | 49 | |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | private function init_admin_hooks() { |
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
|
58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
60 | - add_action( 'admin_init', array( $this, 'activation_redirect') ); |
|
61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
|
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
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 ); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts')); |
|
58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
64 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
65 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
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); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -76,39 +76,39 @@ discard block |
||
76 | 76 | public function enqeue_scripts() { |
77 | 77 | global $current_screen, $pagenow; |
78 | 78 | |
79 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
79 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
80 | 80 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
81 | 81 | |
82 | - if ( ! empty( $current_screen->post_type ) ) { |
|
82 | + if (!empty($current_screen->post_type)) { |
|
83 | 83 | $page = $current_screen->post_type; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // General styles. |
87 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
87 | + if (false !== stripos($page, 'wpi')) { |
|
88 | 88 | |
89 | 89 | // Styles. |
90 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
91 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
92 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
93 | - wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' ); |
|
90 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
91 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
92 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
93 | + wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16'); |
|
94 | 94 | |
95 | 95 | // Scripts. |
96 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true ); |
|
97 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
96 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true); |
|
97 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
98 | 98 | |
99 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
100 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ), $version ); |
|
101 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
99 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
100 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version); |
|
101 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
102 | 102 | |
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' ); |
|
110 | + if ($page == 'wpinv-subscriptions') { |
|
111 | + wp_enqueue_script('postbox'); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | } |
@@ -121,32 +121,32 @@ discard block |
||
121 | 121 | global $post; |
122 | 122 | |
123 | 123 | $date_range = array( |
124 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
124 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days' |
|
125 | 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 ); |
|
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 | 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 ); |
|
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 | 135 | } |
136 | 136 | |
137 | 137 | } |
138 | 138 | |
139 | 139 | $i18n = array( |
140 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
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() ), |
|
140 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
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 | 145 | 'date_range' => $date_range, |
146 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
147 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
148 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
149 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
146 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
147 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
148 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
149 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
150 | 150 | 'tax' => wpinv_tax_amount(), |
151 | 151 | 'discount' => 0, |
152 | 152 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -155,35 +155,35 @@ discard block |
||
155 | 155 | 'thousand_sep' => wpinv_thousands_separator(), |
156 | 156 | 'decimal_sep' => wpinv_decimal_separator(), |
157 | 157 | 'decimals' => wpinv_decimals(), |
158 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
159 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
160 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
161 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
162 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
163 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
164 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
165 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
166 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
167 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
168 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
169 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
170 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
171 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
172 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
173 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
158 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
159 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
160 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
161 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
162 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
163 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
164 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
165 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
166 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
167 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
168 | + 'action_edit' => __('Edit', 'invoicing'), |
|
169 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
170 | + 'item_description' => __('Item Description', 'invoicing'), |
|
171 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
172 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
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 ); |
|
178 | + $invoice = new WPInv_Invoice($post); |
|
179 | 179 | $i18n['save_invoice'] = sprintf( |
180 | - __( 'Save %s', 'invoicing' ), |
|
181 | - ucfirst( $invoice->get_type() ) |
|
180 | + __('Save %s', 'invoicing'), |
|
181 | + ucfirst($invoice->get_type()) |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | $i18n['invoice_description'] = sprintf( |
185 | - __( '%s Description', 'invoicing' ), |
|
186 | - ucfirst( $invoice->get_type() ) |
|
185 | + __('%s Description', 'invoicing'), |
|
186 | + ucfirst($invoice->get_type()) |
|
187 | 187 | ); |
188 | 188 | |
189 | 189 | } |
@@ -197,24 +197,24 @@ discard block |
||
197 | 197 | * @param string $footer_text |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function admin_footer_text( $footer_text ) { |
|
200 | + public function admin_footer_text($footer_text) { |
|
201 | 201 | global $current_screen; |
202 | 202 | |
203 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
203 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
204 | 204 | |
205 | - if ( ! empty( $current_screen->post_type ) ) { |
|
205 | + if (!empty($current_screen->post_type)) { |
|
206 | 206 | $page = $current_screen->post_type; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // General styles. |
210 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
210 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
211 | 211 | |
212 | 212 | // Change the footer text |
213 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
213 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
214 | 214 | |
215 | - $rating_url = esc_url( |
|
215 | + $rating_url = esc_url( |
|
216 | 216 | wp_nonce_url( |
217 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
217 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
218 | 218 | 'getpaid-nonce', |
219 | 219 | 'getpaid-nonce' |
220 | 220 | ) |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | $footer_text = sprintf( |
224 | 224 | /* translators: %s: five stars */ |
225 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
225 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
226 | 226 | "<a href='$rating_url'>★★★★★</a>" |
227 | 227 | ); |
228 | 228 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | $footer_text = sprintf( |
232 | 232 | /* translators: %s: GetPaid */ |
233 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
233 | + __('Thank you for using %s!', 'invoicing'), |
|
234 | 234 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
235 | 235 | ); |
236 | 236 | |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @since 2.0.0 |
248 | 248 | */ |
249 | 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' ); |
|
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 | 252 | exit; |
253 | 253 | } |
254 | 254 | |
@@ -259,30 +259,30 @@ discard block |
||
259 | 259 | protected function load_payment_form_scripts() { |
260 | 260 | global $post; |
261 | 261 | |
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 ); |
|
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); |
|
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 | 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 ), |
|
273 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
274 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
275 | 275 | 'currency' => wpinv_currency_symbol(), |
276 | 276 | 'position' => wpinv_currency_position(), |
277 | 277 | 'decimals' => (int) wpinv_decimals(), |
278 | 278 | 'thousands_sep' => wpinv_thousands_separator(), |
279 | 279 | 'decimals_sep' => wpinv_decimal_separator(), |
280 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
280 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
281 | 281 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
282 | 282 | ) |
283 | 283 | ); |
284 | 284 | |
285 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
285 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
286 | 286 | |
287 | 287 | } |
288 | 288 | |
@@ -293,25 +293,25 @@ discard block |
||
293 | 293 | * @return string |
294 | 294 | * |
295 | 295 | */ |
296 | - public function admin_body_class( $classes ) { |
|
296 | + public function admin_body_class($classes) { |
|
297 | 297 | global $pagenow, $post, $current_screen; |
298 | 298 | |
299 | 299 | |
300 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
300 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
301 | 301 | |
302 | - if ( ! empty( $current_screen->post_type ) ) { |
|
302 | + if (!empty($current_screen->post_type)) { |
|
303 | 303 | $page = $current_screen->post_type; |
304 | 304 | } |
305 | 305 | |
306 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
307 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
306 | + if (false !== stripos($page, 'wpi')) { |
|
307 | + $classes .= ' wpi-' . sanitize_key($page); |
|
308 | 308 | } |
309 | 309 | |
310 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
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 | |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * Maybe show the AyeCode Connect Notice. |
323 | 323 | */ |
324 | - public function init_ayecode_connect_helper(){ |
|
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 | - array( 'wpi-addons' ) |
|
336 | + array('wpi-addons') |
|
337 | 337 | ); |
338 | 338 | |
339 | 339 | } |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | public function activation_redirect() { |
345 | 345 | |
346 | 346 | // Bail if no activation redirect. |
347 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
347 | + if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | 351 | // Delete the redirect transient. |
352 | - delete_transient( '_wpinv_activation_redirect' ); |
|
352 | + delete_transient('_wpinv_activation_redirect'); |
|
353 | 353 | |
354 | 354 | // Bail if activating from network, or bulk |
355 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
355 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
359 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
360 | 360 | exit; |
361 | 361 | } |
362 | 362 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function maybe_do_admin_action() { |
367 | 367 | |
368 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
369 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
370 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
368 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
369 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
370 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | } |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @param array $args |
379 | 379 | */ |
380 | - public function send_customer_invoice( $args ) { |
|
381 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
380 | + public function send_customer_invoice($args) { |
|
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' ) ); |
|
383 | + if ($sent) { |
|
384 | + $this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
385 | 385 | } else { |
386 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
386 | + $this->show_error(__('Could not sent the invoice to the customer', 'invoicing')); |
|
387 | 387 | } |
388 | 388 | |
389 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
389 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
390 | 390 | exit; |
391 | 391 | } |
392 | 392 | |
@@ -395,16 +395,16 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @param array $args |
397 | 397 | */ |
398 | - public function send_customer_payment_reminder( $args ) { |
|
399 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
398 | + public function send_customer_payment_reminder($args) { |
|
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' ) ); |
|
401 | + if ($sent) { |
|
402 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
403 | 403 | } else { |
404 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
404 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
405 | 405 | } |
406 | 406 | |
407 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
407 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
408 | 408 | exit; |
409 | 409 | } |
410 | 410 | |
@@ -414,8 +414,8 @@ discard block |
||
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' ) ) ); |
|
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 | 419 | exit; |
420 | 420 | |
421 | 421 | } |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @return array |
428 | 428 | */ |
429 | 429 | public function get_notices() { |
430 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
431 | - return is_array( $notices ) ? $notices : array(); |
|
430 | + $notices = get_option('wpinv_admin_notices'); |
|
431 | + return is_array($notices) ? $notices : array(); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @since 1.0.19 |
439 | 439 | */ |
440 | 440 | public function clear_notices() { |
441 | - delete_option( 'wpinv_admin_notices' ); |
|
441 | + delete_option('wpinv_admin_notices'); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -447,16 +447,16 @@ discard block |
||
447 | 447 | * @access public |
448 | 448 | * @since 1.0.19 |
449 | 449 | */ |
450 | - public function save_notice( $type, $message ) { |
|
450 | + public function save_notice($type, $message) { |
|
451 | 451 | $notices = $this->get_notices(); |
452 | 452 | |
453 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
454 | - $notices[ $type ] = array(); |
|
453 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
454 | + $notices[$type] = array(); |
|
455 | 455 | } |
456 | 456 | |
457 | - $notices[ $type ][] = $message; |
|
457 | + $notices[$type][] = $message; |
|
458 | 458 | |
459 | - update_option( 'wpinv_admin_notices', $notices ); |
|
459 | + update_option('wpinv_admin_notices', $notices); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | * @access public |
467 | 467 | * @since 1.0.19 |
468 | 468 | */ |
469 | - public function show_success( $msg ) { |
|
470 | - $this->save_notice( 'success', $msg ); |
|
469 | + public function show_success($msg) { |
|
470 | + $this->save_notice('success', $msg); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | /** |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | * @param string $msg The message to qeue. |
478 | 478 | * @since 1.0.19 |
479 | 479 | */ |
480 | - public function show_error( $msg ) { |
|
481 | - $this->save_notice( 'error', $msg ); |
|
480 | + public function show_error($msg) { |
|
481 | + $this->save_notice('error', $msg); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | * @param string $msg The message to qeue. |
489 | 489 | * @since 1.0.19 |
490 | 490 | */ |
491 | - public function show_warning( $msg ) { |
|
492 | - $this->save_notice( 'warning', $msg ); |
|
491 | + public function show_warning($msg) { |
|
492 | + $this->save_notice('warning', $msg); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | * @param string $msg The message to qeue. |
500 | 500 | * @since 1.0.19 |
501 | 501 | */ |
502 | - public function show_info( $msg ) { |
|
503 | - $this->save_notice( 'info', $msg ); |
|
502 | + public function show_info($msg) { |
|
503 | + $this->save_notice('info', $msg); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -514,15 +514,15 @@ discard block |
||
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 ) ) { |
|
519 | + if (!is_array($messages)) { |
|
520 | 520 | continue; |
521 | 521 | } |
522 | 522 | |
523 | - $type = sanitize_key( $type ); |
|
524 | - foreach ( $messages as $message ) { |
|
525 | - $message = wp_kses_post( $message ); |
|
523 | + $type = sanitize_key($type); |
|
524 | + foreach ($messages as $message) { |
|
525 | + $message = wp_kses_post($message); |
|
526 | 526 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
527 | 527 | } |
528 | 528 |