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