@@ -14,77 +14,77 @@ 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_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
71 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
72 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
67 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
68 | + add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
69 | + add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
70 | + add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
71 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
72 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Register admin scripts |
|
78 | - * |
|
79 | - */ |
|
80 | - public function enqeue_scripts() { |
|
77 | + * Register admin scripts |
|
78 | + * |
|
79 | + */ |
|
80 | + public function enqeue_scripts() { |
|
81 | 81 | global $current_screen, $pagenow; |
82 | 82 | |
83 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
84 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
83 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
84 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
85 | 85 | |
86 | 86 | if ( ! empty( $current_screen->post_type ) ) { |
87 | - $page = $current_screen->post_type; |
|
87 | + $page = $current_screen->post_type; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // General styles. |
@@ -105,54 +105,54 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | // Payment form scripts. |
108 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
108 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
109 | 109 | $this->load_payment_form_scripts(); |
110 | 110 | } |
111 | 111 | |
112 | - if ( $page == 'wpinv-subscriptions' ) { |
|
113 | - wp_enqueue_script( 'postbox' ); |
|
114 | - } |
|
112 | + if ( $page == 'wpinv-subscriptions' ) { |
|
113 | + wp_enqueue_script( 'postbox' ); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | - * Returns admin js translations. |
|
120 | - * |
|
121 | - */ |
|
122 | - protected function get_admin_i18() { |
|
119 | + * Returns admin js translations. |
|
120 | + * |
|
121 | + */ |
|
122 | + protected function get_admin_i18() { |
|
123 | 123 | global $post; |
124 | 124 | |
125 | - $date_range = array( |
|
126 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
127 | - ); |
|
125 | + $date_range = array( |
|
126 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
127 | + ); |
|
128 | 128 | |
129 | - if ( $date_range['period'] == 'custom' ) { |
|
129 | + if ( $date_range['period'] == 'custom' ) { |
|
130 | 130 | |
131 | - if ( isset( $_GET['from'] ) ) { |
|
132 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
133 | - } |
|
131 | + if ( isset( $_GET['from'] ) ) { |
|
132 | + $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
133 | + } |
|
134 | 134 | |
135 | - if ( isset( $_GET['to'] ) ) { |
|
136 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
137 | - } |
|
135 | + if ( isset( $_GET['to'] ) ) { |
|
136 | + $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
137 | + } |
|
138 | 138 | |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | $i18n = array( |
142 | 142 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
143 | 143 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
144 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
145 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
146 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
147 | - 'date_range' => $date_range, |
|
144 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
145 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
146 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
147 | + 'date_range' => $date_range, |
|
148 | 148 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
149 | 149 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
150 | 150 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
151 | 151 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
152 | 152 | 'tax' => wpinv_tax_amount(), |
153 | 153 | 'discount' => 0, |
154 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
155 | - 'currency' => wpinv_get_currency(), |
|
154 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
155 | + 'currency' => wpinv_get_currency(), |
|
156 | 156 | 'currency_pos' => wpinv_currency_position(), |
157 | 157 | 'thousand_sep' => wpinv_thousands_separator(), |
158 | 158 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -172,118 +172,118 @@ discard block |
||
172 | 172 | 'item_description' => __( 'Item Description', 'invoicing' ), |
173 | 173 | 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
174 | 174 | 'discount_description' => __( 'Discount Description', 'invoicing' ), |
175 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
176 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
177 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
178 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
175 | + 'searching' => __( 'Searching', 'invoicing' ), |
|
176 | + 'loading' => __( 'Loading...', 'invoicing' ), |
|
177 | + 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
178 | + 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
181 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
182 | 182 | |
183 | - $invoice = new WPInv_Invoice( $post ); |
|
184 | - $i18n['save_invoice'] = sprintf( |
|
185 | - __( 'Save %s', 'invoicing' ), |
|
186 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
187 | - ); |
|
183 | + $invoice = new WPInv_Invoice( $post ); |
|
184 | + $i18n['save_invoice'] = sprintf( |
|
185 | + __( 'Save %s', 'invoicing' ), |
|
186 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
187 | + ); |
|
188 | 188 | |
189 | - $i18n['invoice_description'] = sprintf( |
|
190 | - __( '%s Description', 'invoicing' ), |
|
191 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
192 | - ); |
|
189 | + $i18n['invoice_description'] = sprintf( |
|
190 | + __( '%s Description', 'invoicing' ), |
|
191 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
192 | + ); |
|
193 | 193 | |
194 | - } |
|
195 | - return $i18n; |
|
196 | - } |
|
194 | + } |
|
195 | + return $i18n; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Change the admin footer text on GetPaid admin pages. |
|
200 | - * |
|
201 | - * @since 2.0.0 |
|
202 | - * @param string $footer_text |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function admin_footer_text( $footer_text ) { |
|
206 | - global $current_screen; |
|
198 | + /** |
|
199 | + * Change the admin footer text on GetPaid admin pages. |
|
200 | + * |
|
201 | + * @since 2.0.0 |
|
202 | + * @param string $footer_text |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function admin_footer_text( $footer_text ) { |
|
206 | + global $current_screen; |
|
207 | 207 | |
208 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
208 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
209 | 209 | |
210 | 210 | if ( ! empty( $current_screen->post_type ) ) { |
211 | - $page = $current_screen->post_type; |
|
211 | + $page = $current_screen->post_type; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // General styles. |
215 | 215 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
216 | 216 | |
217 | - // Change the footer text |
|
218 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
219 | - |
|
220 | - $rating_url = esc_url( |
|
221 | - wp_nonce_url( |
|
222 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
223 | - 'getpaid-nonce', |
|
224 | - 'getpaid-nonce' |
|
225 | - ) |
|
226 | - ); |
|
227 | - |
|
228 | - $footer_text = sprintf( |
|
229 | - /* translators: %s: five stars */ |
|
230 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
231 | - "<a href='$rating_url'>★★★★★</a>" |
|
232 | - ); |
|
233 | - |
|
234 | - } else { |
|
235 | - |
|
236 | - $footer_text = sprintf( |
|
237 | - /* translators: %s: GetPaid */ |
|
238 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
239 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
240 | - ); |
|
241 | - |
|
242 | - } |
|
243 | - |
|
244 | - } |
|
245 | - |
|
246 | - return $footer_text; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Redirects to wp.org to rate the plugin. |
|
251 | - * |
|
252 | - * @since 2.0.0 |
|
253 | - */ |
|
254 | - public function redirect_to_wordpress_rating_page() { |
|
255 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
256 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
257 | - exit; |
|
258 | - } |
|
217 | + // Change the footer text |
|
218 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
219 | + |
|
220 | + $rating_url = esc_url( |
|
221 | + wp_nonce_url( |
|
222 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
223 | + 'getpaid-nonce', |
|
224 | + 'getpaid-nonce' |
|
225 | + ) |
|
226 | + ); |
|
227 | + |
|
228 | + $footer_text = sprintf( |
|
229 | + /* translators: %s: five stars */ |
|
230 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
231 | + "<a href='$rating_url'>★★★★★</a>" |
|
232 | + ); |
|
233 | + |
|
234 | + } else { |
|
235 | + |
|
236 | + $footer_text = sprintf( |
|
237 | + /* translators: %s: GetPaid */ |
|
238 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
239 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
240 | + ); |
|
241 | + |
|
242 | + } |
|
243 | + |
|
244 | + } |
|
245 | + |
|
246 | + return $footer_text; |
|
247 | + } |
|
259 | 248 | |
260 | 249 | /** |
261 | - * Loads payment form js. |
|
262 | - * |
|
263 | - */ |
|
264 | - protected function load_payment_form_scripts() { |
|
250 | + * Redirects to wp.org to rate the plugin. |
|
251 | + * |
|
252 | + * @since 2.0.0 |
|
253 | + */ |
|
254 | + public function redirect_to_wordpress_rating_page() { |
|
255 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
256 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
257 | + exit; |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Loads payment form js. |
|
262 | + * |
|
263 | + */ |
|
264 | + protected function load_payment_form_scripts() { |
|
265 | 265 | global $post; |
266 | 266 | |
267 | 267 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
268 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
269 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
268 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
269 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
270 | 270 | |
271 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
272 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
271 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
272 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
273 | 273 | |
274 | - wp_localize_script( |
|
274 | + wp_localize_script( |
|
275 | 275 | 'wpinv-admin-payment-form-script', |
276 | 276 | 'wpinvPaymentFormAdmin', |
277 | 277 | array( |
278 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
279 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
280 | - 'currency' => wpinv_currency_symbol(), |
|
281 | - 'position' => wpinv_currency_position(), |
|
282 | - 'decimals' => (int) wpinv_decimals(), |
|
283 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
284 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
285 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
286 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
278 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
279 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
280 | + 'currency' => wpinv_currency_symbol(), |
|
281 | + 'position' => wpinv_currency_position(), |
|
282 | + 'decimals' => (int) wpinv_decimals(), |
|
283 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
284 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
285 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
286 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
287 | 287 | ) |
288 | 288 | ); |
289 | 289 | |
@@ -292,20 +292,20 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
295 | - * Add our classes to admin pages. |
|
295 | + * Add our classes to admin pages. |
|
296 | 296 | * |
297 | 297 | * @param string $classes |
298 | 298 | * @return string |
299 | - * |
|
300 | - */ |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function admin_body_class( $classes ) { |
302 | - global $pagenow, $post, $current_screen; |
|
302 | + global $pagenow, $post, $current_screen; |
|
303 | 303 | |
304 | 304 | |
305 | 305 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
306 | 306 | |
307 | 307 | if ( ! empty( $current_screen->post_type ) ) { |
308 | - $page = $current_screen->post_type; |
|
308 | + $page = $current_screen->post_type; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -314,59 +314,59 @@ discard block |
||
314 | 314 | |
315 | 315 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
316 | 316 | $classes .= ' wpinv-cpt wpinv'; |
317 | - } |
|
317 | + } |
|
318 | 318 | |
319 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
319 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
320 | 320 | $classes .= ' getpaid-is-invoice-cpt'; |
321 | 321 | } |
322 | 322 | |
323 | - return $classes; |
|
323 | + return $classes; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | - * Maybe show the AyeCode Connect Notice. |
|
328 | - */ |
|
329 | - public function init_ayecode_connect_helper(){ |
|
327 | + * Maybe show the AyeCode Connect Notice. |
|
328 | + */ |
|
329 | + public function init_ayecode_connect_helper(){ |
|
330 | 330 | |
331 | 331 | new AyeCode_Connect_Helper( |
332 | 332 | array( |
333 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
334 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
335 | - '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>" ), |
|
336 | - 'connect_button' => __("Connect Site","invoicing"), |
|
337 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
338 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
339 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
333 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
334 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
335 | + '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>" ), |
|
336 | + 'connect_button' => __("Connect Site","invoicing"), |
|
337 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
338 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
339 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
340 | 340 | ), |
341 | 341 | array( 'wpi-addons' ) |
342 | 342 | ); |
343 | 343 | |
344 | 344 | } |
345 | 345 | |
346 | - /** |
|
347 | - * Redirect users to settings on activation. |
|
348 | - * |
|
349 | - * @return void |
|
350 | - */ |
|
351 | - public function activation_redirect() { |
|
346 | + /** |
|
347 | + * Redirect users to settings on activation. |
|
348 | + * |
|
349 | + * @return void |
|
350 | + */ |
|
351 | + public function activation_redirect() { |
|
352 | 352 | |
353 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
353 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
354 | 354 | |
355 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
356 | - return; |
|
357 | - } |
|
355 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
356 | + return; |
|
357 | + } |
|
358 | 358 | |
359 | - // Bail if activating from network, or bulk |
|
360 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
361 | - return; |
|
362 | - } |
|
359 | + // Bail if activating from network, or bulk |
|
360 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
361 | + return; |
|
362 | + } |
|
363 | 363 | |
364 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
364 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
365 | 365 | |
366 | 366 | wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
367 | 367 | exit; |
368 | 368 | |
369 | - } |
|
369 | + } |
|
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Fires an admin action after verifying that a user can fire them. |
@@ -380,304 +380,304 @@ discard block |
||
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - /** |
|
383 | + /** |
|
384 | 384 | * Sends a payment reminder to a customer. |
385 | - * |
|
386 | - * @param array $args |
|
385 | + * |
|
386 | + * @param array $args |
|
387 | 387 | */ |
388 | 388 | public function send_customer_invoice( $args ) { |
389 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
389 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
390 | 390 | |
391 | - if ( $sent ) { |
|
392 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
393 | - } else { |
|
394 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
395 | - } |
|
391 | + if ( $sent ) { |
|
392 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
393 | + } else { |
|
394 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
395 | + } |
|
396 | 396 | |
397 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
398 | - exit; |
|
399 | - } |
|
397 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
398 | + exit; |
|
399 | + } |
|
400 | 400 | |
401 | - /** |
|
401 | + /** |
|
402 | 402 | * Sends a payment reminder to a customer. |
403 | - * |
|
404 | - * @param array $args |
|
403 | + * |
|
404 | + * @param array $args |
|
405 | 405 | */ |
406 | 406 | public function send_customer_payment_reminder( $args ) { |
407 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
407 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
408 | 408 | |
409 | - if ( $sent ) { |
|
410 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
411 | - } else { |
|
412 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
413 | - } |
|
409 | + if ( $sent ) { |
|
410 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
411 | + } else { |
|
412 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
413 | + } |
|
414 | 414 | |
415 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
416 | - exit; |
|
417 | - } |
|
415 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
416 | + exit; |
|
417 | + } |
|
418 | 418 | |
419 | - /** |
|
419 | + /** |
|
420 | 420 | * Resets tax rates. |
421 | - * |
|
421 | + * |
|
422 | 422 | */ |
423 | 423 | public function admin_reset_tax_rates() { |
424 | 424 | |
425 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
426 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
427 | - exit; |
|
425 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
426 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
427 | + exit; |
|
428 | 428 | |
429 | - } |
|
429 | + } |
|
430 | 430 | |
431 | - /** |
|
431 | + /** |
|
432 | 432 | * Resets admin pages. |
433 | - * |
|
433 | + * |
|
434 | 434 | */ |
435 | 435 | public function admin_create_missing_pages() { |
436 | - $installer = new GetPaid_Installer(); |
|
437 | - $installer->create_pages(); |
|
438 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
439 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
440 | - exit; |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
436 | + $installer = new GetPaid_Installer(); |
|
437 | + $installer->create_pages(); |
|
438 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
439 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
440 | + exit; |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | 444 | * Creates an missing admin tables. |
445 | - * |
|
445 | + * |
|
446 | 446 | */ |
447 | 447 | public function admin_create_missing_tables() { |
448 | - global $wpdb; |
|
449 | - $installer = new GetPaid_Installer(); |
|
448 | + global $wpdb; |
|
449 | + $installer = new GetPaid_Installer(); |
|
450 | 450 | |
451 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
452 | - $installer->create_subscriptions_table(); |
|
451 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
452 | + $installer->create_subscriptions_table(); |
|
453 | 453 | |
454 | - if ( $wpdb->last_error !== '' ) { |
|
455 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
456 | - } |
|
457 | - } |
|
454 | + if ( $wpdb->last_error !== '' ) { |
|
455 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
456 | + } |
|
457 | + } |
|
458 | 458 | |
459 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
460 | - $installer->create_invoices_table(); |
|
459 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
460 | + $installer->create_invoices_table(); |
|
461 | 461 | |
462 | - if ( $wpdb->last_error !== '' ) { |
|
463 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
464 | - } |
|
465 | - } |
|
462 | + if ( $wpdb->last_error !== '' ) { |
|
463 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
464 | + } |
|
465 | + } |
|
466 | 466 | |
467 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
468 | - $installer->create_invoice_items_table(); |
|
467 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
468 | + $installer->create_invoice_items_table(); |
|
469 | 469 | |
470 | - if ( $wpdb->last_error !== '' ) { |
|
471 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
472 | - } |
|
473 | - } |
|
470 | + if ( $wpdb->last_error !== '' ) { |
|
471 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
472 | + } |
|
473 | + } |
|
474 | 474 | |
475 | - if ( ! $this->has_notices() ) { |
|
476 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
477 | - } |
|
475 | + if ( ! $this->has_notices() ) { |
|
476 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
477 | + } |
|
478 | 478 | |
479 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
480 | - exit; |
|
481 | - } |
|
479 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
480 | + exit; |
|
481 | + } |
|
482 | 482 | |
483 | - /** |
|
483 | + /** |
|
484 | 484 | * Migrates old invoices to the new database tables. |
485 | - * |
|
485 | + * |
|
486 | 486 | */ |
487 | 487 | public function admin_migrate_old_invoices() { |
488 | 488 | |
489 | - // Migrate the invoices. |
|
490 | - $installer = new GetPaid_Installer(); |
|
491 | - $installer->migrate_old_invoices(); |
|
489 | + // Migrate the invoices. |
|
490 | + $installer = new GetPaid_Installer(); |
|
491 | + $installer->migrate_old_invoices(); |
|
492 | 492 | |
493 | - // Show an admin message. |
|
494 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
493 | + // Show an admin message. |
|
494 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
495 | 495 | |
496 | - // Redirect the admin. |
|
497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
498 | - exit; |
|
496 | + // Redirect the admin. |
|
497 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
498 | + exit; |
|
499 | 499 | |
500 | - } |
|
500 | + } |
|
501 | 501 | |
502 | - /** |
|
502 | + /** |
|
503 | 503 | * Recalculates discounts. |
504 | - * |
|
504 | + * |
|
505 | 505 | */ |
506 | 506 | public function admin_recalculate_discounts() { |
507 | - global $wpdb; |
|
507 | + global $wpdb; |
|
508 | 508 | |
509 | - // Fetch all invoices that have discount codes. |
|
510 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
511 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
509 | + // Fetch all invoices that have discount codes. |
|
510 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
511 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
512 | 512 | |
513 | - foreach ( $invoices as $invoice ) { |
|
513 | + foreach ( $invoices as $invoice ) { |
|
514 | 514 | |
515 | - $invoice = new WPInv_Invoice( $invoice ); |
|
515 | + $invoice = new WPInv_Invoice( $invoice ); |
|
516 | 516 | |
517 | - if ( ! $invoice->exists() ) { |
|
518 | - continue; |
|
519 | - } |
|
517 | + if ( ! $invoice->exists() ) { |
|
518 | + continue; |
|
519 | + } |
|
520 | 520 | |
521 | - // Abort if the discount does not exist or does not apply here. |
|
522 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
523 | - if ( ! $discount->exists() ) { |
|
524 | - continue; |
|
525 | - } |
|
521 | + // Abort if the discount does not exist or does not apply here. |
|
522 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
523 | + if ( ! $discount->exists() ) { |
|
524 | + continue; |
|
525 | + } |
|
526 | 526 | |
527 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
528 | - $invoice->recalculate_total(); |
|
527 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
528 | + $invoice->recalculate_total(); |
|
529 | 529 | |
530 | - if ( $invoice->get_total_discount() > 0 ) { |
|
531 | - $invoice->save(); |
|
532 | - } |
|
530 | + if ( $invoice->get_total_discount() > 0 ) { |
|
531 | + $invoice->save(); |
|
532 | + } |
|
533 | 533 | |
534 | - } |
|
534 | + } |
|
535 | 535 | |
536 | - // Show an admin message. |
|
537 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
536 | + // Show an admin message. |
|
537 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
538 | 538 | |
539 | - // Redirect the admin. |
|
540 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
541 | - exit; |
|
539 | + // Redirect the admin. |
|
540 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
541 | + exit; |
|
542 | 542 | |
543 | - } |
|
543 | + } |
|
544 | 544 | |
545 | 545 | /** |
546 | - * Returns an array of admin notices. |
|
547 | - * |
|
548 | - * @since 1.0.19 |
|
546 | + * Returns an array of admin notices. |
|
547 | + * |
|
548 | + * @since 1.0.19 |
|
549 | 549 | * @return array |
550 | - */ |
|
551 | - public function get_notices() { |
|
552 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
550 | + */ |
|
551 | + public function get_notices() { |
|
552 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
553 | 553 | return is_array( $notices ) ? $notices : array(); |
554 | - } |
|
554 | + } |
|
555 | 555 | |
556 | - /** |
|
557 | - * Checks if we have any admin notices. |
|
558 | - * |
|
559 | - * @since 2.0.4 |
|
556 | + /** |
|
557 | + * Checks if we have any admin notices. |
|
558 | + * |
|
559 | + * @since 2.0.4 |
|
560 | 560 | * @return array |
561 | - */ |
|
562 | - public function has_notices() { |
|
563 | - return count( $this->get_notices() ) > 0; |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Clears all admin notices |
|
568 | - * |
|
569 | - * @access public |
|
570 | - * @since 1.0.19 |
|
571 | - */ |
|
572 | - public function clear_notices() { |
|
573 | - delete_option( 'wpinv_admin_notices' ); |
|
574 | - } |
|
575 | - |
|
576 | - /** |
|
577 | - * Saves a new admin notice |
|
578 | - * |
|
579 | - * @access public |
|
580 | - * @since 1.0.19 |
|
581 | - */ |
|
582 | - public function save_notice( $type, $message ) { |
|
583 | - $notices = $this->get_notices(); |
|
584 | - |
|
585 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
586 | - $notices[ $type ] = array(); |
|
587 | - } |
|
588 | - |
|
589 | - $notices[ $type ][] = $message; |
|
590 | - |
|
591 | - update_option( 'wpinv_admin_notices', $notices ); |
|
592 | - } |
|
593 | - |
|
594 | - /** |
|
595 | - * Displays a success notice |
|
596 | - * |
|
597 | - * @param string $msg The message to qeue. |
|
598 | - * @access public |
|
599 | - * @since 1.0.19 |
|
600 | - */ |
|
601 | - public function show_success( $msg ) { |
|
602 | - $this->save_notice( 'success', $msg ); |
|
603 | - } |
|
604 | - |
|
605 | - /** |
|
606 | - * Displays a error notice |
|
607 | - * |
|
608 | - * @access public |
|
609 | - * @param string $msg The message to qeue. |
|
610 | - * @since 1.0.19 |
|
611 | - */ |
|
612 | - public function show_error( $msg ) { |
|
613 | - $this->save_notice( 'error', $msg ); |
|
614 | - } |
|
615 | - |
|
616 | - /** |
|
617 | - * Displays a warning notice |
|
618 | - * |
|
619 | - * @access public |
|
620 | - * @param string $msg The message to qeue. |
|
621 | - * @since 1.0.19 |
|
622 | - */ |
|
623 | - public function show_warning( $msg ) { |
|
624 | - $this->save_notice( 'warning', $msg ); |
|
625 | - } |
|
626 | - |
|
627 | - /** |
|
628 | - * Displays a info notice |
|
629 | - * |
|
630 | - * @access public |
|
631 | - * @param string $msg The message to qeue. |
|
632 | - * @since 1.0.19 |
|
633 | - */ |
|
634 | - public function show_info( $msg ) { |
|
635 | - $this->save_notice( 'info', $msg ); |
|
636 | - } |
|
637 | - |
|
638 | - /** |
|
639 | - * Show notices |
|
640 | - * |
|
641 | - * @access public |
|
642 | - * @since 1.0.19 |
|
643 | - */ |
|
644 | - public function show_notices() { |
|
561 | + */ |
|
562 | + public function has_notices() { |
|
563 | + return count( $this->get_notices() ) > 0; |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Clears all admin notices |
|
568 | + * |
|
569 | + * @access public |
|
570 | + * @since 1.0.19 |
|
571 | + */ |
|
572 | + public function clear_notices() { |
|
573 | + delete_option( 'wpinv_admin_notices' ); |
|
574 | + } |
|
575 | + |
|
576 | + /** |
|
577 | + * Saves a new admin notice |
|
578 | + * |
|
579 | + * @access public |
|
580 | + * @since 1.0.19 |
|
581 | + */ |
|
582 | + public function save_notice( $type, $message ) { |
|
583 | + $notices = $this->get_notices(); |
|
584 | + |
|
585 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
586 | + $notices[ $type ] = array(); |
|
587 | + } |
|
588 | + |
|
589 | + $notices[ $type ][] = $message; |
|
590 | + |
|
591 | + update_option( 'wpinv_admin_notices', $notices ); |
|
592 | + } |
|
593 | + |
|
594 | + /** |
|
595 | + * Displays a success notice |
|
596 | + * |
|
597 | + * @param string $msg The message to qeue. |
|
598 | + * @access public |
|
599 | + * @since 1.0.19 |
|
600 | + */ |
|
601 | + public function show_success( $msg ) { |
|
602 | + $this->save_notice( 'success', $msg ); |
|
603 | + } |
|
604 | + |
|
605 | + /** |
|
606 | + * Displays a error notice |
|
607 | + * |
|
608 | + * @access public |
|
609 | + * @param string $msg The message to qeue. |
|
610 | + * @since 1.0.19 |
|
611 | + */ |
|
612 | + public function show_error( $msg ) { |
|
613 | + $this->save_notice( 'error', $msg ); |
|
614 | + } |
|
615 | + |
|
616 | + /** |
|
617 | + * Displays a warning notice |
|
618 | + * |
|
619 | + * @access public |
|
620 | + * @param string $msg The message to qeue. |
|
621 | + * @since 1.0.19 |
|
622 | + */ |
|
623 | + public function show_warning( $msg ) { |
|
624 | + $this->save_notice( 'warning', $msg ); |
|
625 | + } |
|
626 | + |
|
627 | + /** |
|
628 | + * Displays a info notice |
|
629 | + * |
|
630 | + * @access public |
|
631 | + * @param string $msg The message to qeue. |
|
632 | + * @since 1.0.19 |
|
633 | + */ |
|
634 | + public function show_info( $msg ) { |
|
635 | + $this->save_notice( 'info', $msg ); |
|
636 | + } |
|
637 | + |
|
638 | + /** |
|
639 | + * Show notices |
|
640 | + * |
|
641 | + * @access public |
|
642 | + * @since 1.0.19 |
|
643 | + */ |
|
644 | + public function show_notices() { |
|
645 | 645 | |
646 | 646 | $notices = $this->get_notices(); |
647 | 647 | $this->clear_notices(); |
648 | 648 | |
649 | - foreach ( $notices as $type => $messages ) { |
|
649 | + foreach ( $notices as $type => $messages ) { |
|
650 | 650 | |
651 | - if ( ! is_array( $messages ) ) { |
|
652 | - continue; |
|
653 | - } |
|
651 | + if ( ! is_array( $messages ) ) { |
|
652 | + continue; |
|
653 | + } |
|
654 | 654 | |
655 | 655 | $type = sanitize_key( $type ); |
656 | - foreach ( $messages as $message ) { |
|
656 | + foreach ( $messages as $message ) { |
|
657 | 657 | $message = wp_kses_post( $message ); |
658 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
658 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
659 | + } |
|
660 | + |
|
661 | + } |
|
662 | + |
|
663 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
664 | + |
|
665 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
666 | + $url = esc_url( |
|
667 | + wp_nonce_url( |
|
668 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
669 | + 'getpaid-nonce', |
|
670 | + 'getpaid-nonce' |
|
671 | + ) |
|
672 | + ); |
|
673 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
674 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
675 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
676 | + break; |
|
659 | 677 | } |
660 | 678 | |
661 | 679 | } |
662 | 680 | |
663 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
664 | - |
|
665 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
666 | - $url = esc_url( |
|
667 | - wp_nonce_url( |
|
668 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
669 | - 'getpaid-nonce', |
|
670 | - 'getpaid-nonce' |
|
671 | - ) |
|
672 | - ); |
|
673 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
674 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
675 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
676 | - break; |
|
677 | - } |
|
678 | - |
|
679 | - } |
|
680 | - |
|
681 | - } |
|
681 | + } |
|
682 | 682 | |
683 | 683 | } |
@@ -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,22 +54,22 @@ 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_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
71 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
72 | - 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_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
68 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
69 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
70 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
71 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
72 | + do_action('getpaid_init_admin_hooks', $this); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -80,37 +80,37 @@ discard block |
||
80 | 80 | public function enqeue_scripts() { |
81 | 81 | global $current_screen, $pagenow; |
82 | 82 | |
83 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
83 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
84 | 84 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
85 | 85 | |
86 | - if ( ! empty( $current_screen->post_type ) ) { |
|
86 | + if (!empty($current_screen->post_type)) { |
|
87 | 87 | $page = $current_screen->post_type; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // General styles. |
91 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
91 | + if (false !== stripos($page, 'wpi')) { |
|
92 | 92 | |
93 | 93 | // Styles. |
94 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
95 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
96 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
94 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
95 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
96 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
97 | 97 | |
98 | 98 | // Scripts. |
99 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
99 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
100 | 100 | |
101 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
102 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker' ), $version ); |
|
103 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
101 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
102 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker'), $version); |
|
103 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Payment form scripts. |
108 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
108 | + if ('wpi_payment_form' == $page && $editing) { |
|
109 | 109 | $this->load_payment_form_scripts(); |
110 | 110 | } |
111 | 111 | |
112 | - if ( $page == 'wpinv-subscriptions' ) { |
|
113 | - wp_enqueue_script( 'postbox' ); |
|
112 | + if ($page == 'wpinv-subscriptions') { |
|
113 | + wp_enqueue_script('postbox'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | } |
@@ -123,32 +123,32 @@ discard block |
||
123 | 123 | global $post; |
124 | 124 | |
125 | 125 | $date_range = array( |
126 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
126 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days' |
|
127 | 127 | ); |
128 | 128 | |
129 | - if ( $date_range['period'] == 'custom' ) { |
|
129 | + if ($date_range['period'] == 'custom') { |
|
130 | 130 | |
131 | - if ( isset( $_GET['from'] ) ) { |
|
132 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
131 | + if (isset($_GET['from'])) { |
|
132 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
133 | 133 | } |
134 | 134 | |
135 | - if ( isset( $_GET['to'] ) ) { |
|
136 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
135 | + if (isset($_GET['to'])) { |
|
136 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | 141 | $i18n = array( |
142 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
143 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
144 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
145 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
146 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
142 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
143 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
144 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
145 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
146 | + 'rest_root' => esc_url_raw(rest_url()), |
|
147 | 147 | 'date_range' => $date_range, |
148 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
149 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
150 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
151 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
148 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
149 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
150 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
151 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
152 | 152 | 'tax' => wpinv_tax_amount(), |
153 | 153 | 'discount' => 0, |
154 | 154 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -157,38 +157,38 @@ discard block |
||
157 | 157 | 'thousand_sep' => wpinv_thousands_separator(), |
158 | 158 | 'decimal_sep' => wpinv_decimal_separator(), |
159 | 159 | 'decimals' => wpinv_decimals(), |
160 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
161 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
162 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
163 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
164 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
165 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
166 | - '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' ), |
|
167 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
168 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
169 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
170 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
171 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
172 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
173 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
174 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
175 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
176 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
177 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
178 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
160 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
161 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
162 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
163 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
164 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
165 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
166 | + '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'), |
|
167 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
168 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
169 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
170 | + 'action_edit' => __('Edit', 'invoicing'), |
|
171 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
172 | + 'item_description' => __('Item Description', 'invoicing'), |
|
173 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
174 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
175 | + 'searching' => __('Searching', 'invoicing'), |
|
176 | + 'loading' => __('Loading...', 'invoicing'), |
|
177 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
178 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
181 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
182 | 182 | |
183 | - $invoice = new WPInv_Invoice( $post ); |
|
183 | + $invoice = new WPInv_Invoice($post); |
|
184 | 184 | $i18n['save_invoice'] = sprintf( |
185 | - __( 'Save %s', 'invoicing' ), |
|
186 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
185 | + __('Save %s', 'invoicing'), |
|
186 | + ucfirst($invoice->get_invoice_quote_type()) |
|
187 | 187 | ); |
188 | 188 | |
189 | 189 | $i18n['invoice_description'] = sprintf( |
190 | - __( '%s Description', 'invoicing' ), |
|
191 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
190 | + __('%s Description', 'invoicing'), |
|
191 | + ucfirst($invoice->get_invoice_quote_type()) |
|
192 | 192 | ); |
193 | 193 | |
194 | 194 | } |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @param string $footer_text |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function admin_footer_text( $footer_text ) { |
|
205 | + public function admin_footer_text($footer_text) { |
|
206 | 206 | global $current_screen; |
207 | 207 | |
208 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
208 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
209 | 209 | |
210 | - if ( ! empty( $current_screen->post_type ) ) { |
|
210 | + if (!empty($current_screen->post_type)) { |
|
211 | 211 | $page = $current_screen->post_type; |
212 | 212 | } |
213 | 213 | |
214 | 214 | // General styles. |
215 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
215 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
216 | 216 | |
217 | 217 | // Change the footer text |
218 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
218 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
219 | 219 | |
220 | - $rating_url = esc_url( |
|
220 | + $rating_url = esc_url( |
|
221 | 221 | wp_nonce_url( |
222 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
222 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
223 | 223 | 'getpaid-nonce', |
224 | 224 | 'getpaid-nonce' |
225 | 225 | ) |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | $footer_text = sprintf( |
229 | 229 | /* translators: %s: five stars */ |
230 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
230 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
231 | 231 | "<a href='$rating_url'>★★★★★</a>" |
232 | 232 | ); |
233 | 233 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $footer_text = sprintf( |
237 | 237 | /* translators: %s: GetPaid */ |
238 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
238 | + __('Thank you for using %s!', 'invoicing'), |
|
239 | 239 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
240 | 240 | ); |
241 | 241 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @since 2.0.0 |
253 | 253 | */ |
254 | 254 | public function redirect_to_wordpress_rating_page() { |
255 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
256 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
255 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
256 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
257 | 257 | exit; |
258 | 258 | } |
259 | 259 | |
@@ -264,30 +264,30 @@ discard block |
||
264 | 264 | protected function load_payment_form_scripts() { |
265 | 265 | global $post; |
266 | 266 | |
267 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
268 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
269 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
267 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
268 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
269 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
270 | 270 | |
271 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
272 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
271 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
272 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
273 | 273 | |
274 | 274 | wp_localize_script( |
275 | 275 | 'wpinv-admin-payment-form-script', |
276 | 276 | 'wpinvPaymentFormAdmin', |
277 | 277 | array( |
278 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
279 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
278 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
279 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
280 | 280 | 'currency' => wpinv_currency_symbol(), |
281 | 281 | 'position' => wpinv_currency_position(), |
282 | 282 | 'decimals' => (int) wpinv_decimals(), |
283 | 283 | 'thousands_sep' => wpinv_thousands_separator(), |
284 | 284 | 'decimals_sep' => wpinv_decimal_separator(), |
285 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
285 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
286 | 286 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
287 | 287 | ) |
288 | 288 | ); |
289 | 289 | |
290 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
290 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
291 | 291 | |
292 | 292 | } |
293 | 293 | |
@@ -298,25 +298,25 @@ discard block |
||
298 | 298 | * @return string |
299 | 299 | * |
300 | 300 | */ |
301 | - public function admin_body_class( $classes ) { |
|
301 | + public function admin_body_class($classes) { |
|
302 | 302 | global $pagenow, $post, $current_screen; |
303 | 303 | |
304 | 304 | |
305 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
305 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
306 | 306 | |
307 | - if ( ! empty( $current_screen->post_type ) ) { |
|
307 | + if (!empty($current_screen->post_type)) { |
|
308 | 308 | $page = $current_screen->post_type; |
309 | 309 | } |
310 | 310 | |
311 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
312 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
311 | + if (false !== stripos($page, 'wpi')) { |
|
312 | + $classes .= ' wpi-' . sanitize_key($page); |
|
313 | 313 | } |
314 | 314 | |
315 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
315 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
316 | 316 | $classes .= ' wpinv-cpt wpinv'; |
317 | 317 | } |
318 | 318 | |
319 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
319 | + if (getpaid_is_invoice_post_type($page)) { |
|
320 | 320 | $classes .= ' getpaid-is-invoice-cpt'; |
321 | 321 | } |
322 | 322 | |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | /** |
327 | 327 | * Maybe show the AyeCode Connect Notice. |
328 | 328 | */ |
329 | - public function init_ayecode_connect_helper(){ |
|
329 | + public function init_ayecode_connect_helper() { |
|
330 | 330 | |
331 | 331 | new AyeCode_Connect_Helper( |
332 | 332 | array( |
333 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
334 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
335 | - '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>" ), |
|
336 | - 'connect_button' => __("Connect Site","invoicing"), |
|
337 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
338 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
339 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
333 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
334 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
335 | + '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>"), |
|
336 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
337 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
338 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
339 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
340 | 340 | ), |
341 | - array( 'wpi-addons' ) |
|
341 | + array('wpi-addons') |
|
342 | 342 | ); |
343 | 343 | |
344 | 344 | } |
@@ -350,20 +350,20 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function activation_redirect() { |
352 | 352 | |
353 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
353 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
354 | 354 | |
355 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
355 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | 359 | // Bail if activating from network, or bulk |
360 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
360 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
361 | 361 | return; |
362 | 362 | } |
363 | 363 | |
364 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
364 | + update_option('wpinv_redirected_to_settings', 1); |
|
365 | 365 | |
366 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
366 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
367 | 367 | exit; |
368 | 368 | |
369 | 369 | } |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function maybe_do_admin_action() { |
375 | 375 | |
376 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
377 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
378 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
376 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
377 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
378 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @param array $args |
387 | 387 | */ |
388 | - public function send_customer_invoice( $args ) { |
|
389 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
388 | + public function send_customer_invoice($args) { |
|
389 | + $sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id'])); |
|
390 | 390 | |
391 | - if ( $sent ) { |
|
392 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
391 | + if ($sent) { |
|
392 | + $this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
393 | 393 | } else { |
394 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
394 | + $this->show_error(__('Could not sent the invoice to the customer', 'invoicing')); |
|
395 | 395 | } |
396 | 396 | |
397 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
397 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
398 | 398 | exit; |
399 | 399 | } |
400 | 400 | |
@@ -403,16 +403,16 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @param array $args |
405 | 405 | */ |
406 | - public function send_customer_payment_reminder( $args ) { |
|
407 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
406 | + public function send_customer_payment_reminder($args) { |
|
407 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
408 | 408 | |
409 | - if ( $sent ) { |
|
410 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
409 | + if ($sent) { |
|
410 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
411 | 411 | } else { |
412 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
412 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
413 | 413 | } |
414 | 414 | |
415 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
415 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
416 | 416 | exit; |
417 | 417 | } |
418 | 418 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | */ |
423 | 423 | public function admin_reset_tax_rates() { |
424 | 424 | |
425 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
426 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
425 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
426 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
427 | 427 | exit; |
428 | 428 | |
429 | 429 | } |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | public function admin_create_missing_pages() { |
436 | 436 | $installer = new GetPaid_Installer(); |
437 | 437 | $installer->create_pages(); |
438 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
439 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
438 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
439 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
440 | 440 | exit; |
441 | 441 | } |
442 | 442 | |
@@ -448,35 +448,35 @@ discard block |
||
448 | 448 | global $wpdb; |
449 | 449 | $installer = new GetPaid_Installer(); |
450 | 450 | |
451 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
451 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { |
|
452 | 452 | $installer->create_subscriptions_table(); |
453 | 453 | |
454 | - if ( $wpdb->last_error !== '' ) { |
|
455 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
454 | + if ($wpdb->last_error !== '') { |
|
455 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
459 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { |
|
460 | 460 | $installer->create_invoices_table(); |
461 | 461 | |
462 | - if ( $wpdb->last_error !== '' ) { |
|
463 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
462 | + if ($wpdb->last_error !== '') { |
|
463 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
467 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { |
|
468 | 468 | $installer->create_invoice_items_table(); |
469 | 469 | |
470 | - if ( $wpdb->last_error !== '' ) { |
|
471 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
470 | + if ($wpdb->last_error !== '') { |
|
471 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | - if ( ! $this->has_notices() ) { |
|
476 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
475 | + if (!$this->has_notices()) { |
|
476 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
477 | 477 | } |
478 | 478 | |
479 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
479 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
480 | 480 | exit; |
481 | 481 | } |
482 | 482 | |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | $installer->migrate_old_invoices(); |
492 | 492 | |
493 | 493 | // Show an admin message. |
494 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
494 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
495 | 495 | |
496 | 496 | // Redirect the admin. |
497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
497 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
498 | 498 | exit; |
499 | 499 | |
500 | 500 | } |
@@ -508,36 +508,36 @@ discard block |
||
508 | 508 | |
509 | 509 | // Fetch all invoices that have discount codes. |
510 | 510 | $table = $wpdb->prefix . 'getpaid_invoices'; |
511 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
511 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
512 | 512 | |
513 | - foreach ( $invoices as $invoice ) { |
|
513 | + foreach ($invoices as $invoice) { |
|
514 | 514 | |
515 | - $invoice = new WPInv_Invoice( $invoice ); |
|
515 | + $invoice = new WPInv_Invoice($invoice); |
|
516 | 516 | |
517 | - if ( ! $invoice->exists() ) { |
|
517 | + if (!$invoice->exists()) { |
|
518 | 518 | continue; |
519 | 519 | } |
520 | 520 | |
521 | 521 | // Abort if the discount does not exist or does not apply here. |
522 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
523 | - if ( ! $discount->exists() ) { |
|
522 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
523 | + if (!$discount->exists()) { |
|
524 | 524 | continue; |
525 | 525 | } |
526 | 526 | |
527 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
527 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
528 | 528 | $invoice->recalculate_total(); |
529 | 529 | |
530 | - if ( $invoice->get_total_discount() > 0 ) { |
|
530 | + if ($invoice->get_total_discount() > 0) { |
|
531 | 531 | $invoice->save(); |
532 | 532 | } |
533 | 533 | |
534 | 534 | } |
535 | 535 | |
536 | 536 | // Show an admin message. |
537 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
537 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
538 | 538 | |
539 | 539 | // Redirect the admin. |
540 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
540 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
541 | 541 | exit; |
542 | 542 | |
543 | 543 | } |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @return array |
550 | 550 | */ |
551 | 551 | public function get_notices() { |
552 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
553 | - return is_array( $notices ) ? $notices : array(); |
|
552 | + $notices = get_option('wpinv_admin_notices'); |
|
553 | + return is_array($notices) ? $notices : array(); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @return array |
561 | 561 | */ |
562 | 562 | public function has_notices() { |
563 | - return count( $this->get_notices() ) > 0; |
|
563 | + return count($this->get_notices()) > 0; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @since 1.0.19 |
571 | 571 | */ |
572 | 572 | public function clear_notices() { |
573 | - delete_option( 'wpinv_admin_notices' ); |
|
573 | + delete_option('wpinv_admin_notices'); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -579,16 +579,16 @@ discard block |
||
579 | 579 | * @access public |
580 | 580 | * @since 1.0.19 |
581 | 581 | */ |
582 | - public function save_notice( $type, $message ) { |
|
582 | + public function save_notice($type, $message) { |
|
583 | 583 | $notices = $this->get_notices(); |
584 | 584 | |
585 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
586 | - $notices[ $type ] = array(); |
|
585 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
586 | + $notices[$type] = array(); |
|
587 | 587 | } |
588 | 588 | |
589 | - $notices[ $type ][] = $message; |
|
589 | + $notices[$type][] = $message; |
|
590 | 590 | |
591 | - update_option( 'wpinv_admin_notices', $notices ); |
|
591 | + update_option('wpinv_admin_notices', $notices); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -598,8 +598,8 @@ discard block |
||
598 | 598 | * @access public |
599 | 599 | * @since 1.0.19 |
600 | 600 | */ |
601 | - public function show_success( $msg ) { |
|
602 | - $this->save_notice( 'success', $msg ); |
|
601 | + public function show_success($msg) { |
|
602 | + $this->save_notice('success', $msg); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @param string $msg The message to qeue. |
610 | 610 | * @since 1.0.19 |
611 | 611 | */ |
612 | - public function show_error( $msg ) { |
|
613 | - $this->save_notice( 'error', $msg ); |
|
612 | + public function show_error($msg) { |
|
613 | + $this->save_notice('error', $msg); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -620,8 +620,8 @@ discard block |
||
620 | 620 | * @param string $msg The message to qeue. |
621 | 621 | * @since 1.0.19 |
622 | 622 | */ |
623 | - public function show_warning( $msg ) { |
|
624 | - $this->save_notice( 'warning', $msg ); |
|
623 | + public function show_warning($msg) { |
|
624 | + $this->save_notice('warning', $msg); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | * @param string $msg The message to qeue. |
632 | 632 | * @since 1.0.19 |
633 | 633 | */ |
634 | - public function show_info( $msg ) { |
|
635 | - $this->save_notice( 'info', $msg ); |
|
634 | + public function show_info($msg) { |
|
635 | + $this->save_notice('info', $msg); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -646,32 +646,32 @@ discard block |
||
646 | 646 | $notices = $this->get_notices(); |
647 | 647 | $this->clear_notices(); |
648 | 648 | |
649 | - foreach ( $notices as $type => $messages ) { |
|
649 | + foreach ($notices as $type => $messages) { |
|
650 | 650 | |
651 | - if ( ! is_array( $messages ) ) { |
|
651 | + if (!is_array($messages)) { |
|
652 | 652 | continue; |
653 | 653 | } |
654 | 654 | |
655 | - $type = sanitize_key( $type ); |
|
656 | - foreach ( $messages as $message ) { |
|
657 | - $message = wp_kses_post( $message ); |
|
655 | + $type = sanitize_key($type); |
|
656 | + foreach ($messages as $message) { |
|
657 | + $message = wp_kses_post($message); |
|
658 | 658 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
659 | 659 | } |
660 | 660 | |
661 | 661 | } |
662 | 662 | |
663 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
663 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
664 | 664 | |
665 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
666 | - $url = esc_url( |
|
665 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
666 | + $url = esc_url( |
|
667 | 667 | wp_nonce_url( |
668 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
668 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
669 | 669 | 'getpaid-nonce', |
670 | 670 | 'getpaid-nonce' |
671 | 671 | ) |
672 | 672 | ); |
673 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
674 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
673 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
674 | + $message2 = __('Generate Pages', 'invoicing'); |
|
675 | 675 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
676 | 676 | break; |
677 | 677 | } |