@@ -14,90 +14,90 @@ 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_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | + add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | + add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
66 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
67 | 67 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
68 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
75 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
76 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
77 | - |
|
78 | - // Setup/welcome |
|
79 | - if ( ! empty( $_GET['page'] ) ) { |
|
80 | - switch ( $_GET['page'] ) { |
|
81 | - case 'gp-setup' : |
|
82 | - include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' ); |
|
83 | - break; |
|
84 | - } |
|
85 | - } |
|
68 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
69 | + add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
70 | + add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
71 | + add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
72 | + add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
73 | + add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
74 | + add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
75 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
76 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
77 | + |
|
78 | + // Setup/welcome |
|
79 | + if ( ! empty( $_GET['page'] ) ) { |
|
80 | + switch ( $_GET['page'] ) { |
|
81 | + case 'gp-setup' : |
|
82 | + include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' ); |
|
83 | + break; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Register admin scripts |
|
91 | - * |
|
92 | - */ |
|
93 | - public function enqeue_scripts() { |
|
90 | + * Register admin scripts |
|
91 | + * |
|
92 | + */ |
|
93 | + public function enqeue_scripts() { |
|
94 | 94 | global $current_screen, $pagenow; |
95 | 95 | |
96 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
97 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
96 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
97 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
98 | 98 | |
99 | 99 | if ( ! empty( $current_screen->post_type ) ) { |
100 | - $page = $current_screen->post_type; |
|
100 | + $page = $current_screen->post_type; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // General styles. |
@@ -118,54 +118,54 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // Payment form scripts. |
121 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
121 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
122 | 122 | $this->load_payment_form_scripts(); |
123 | 123 | } |
124 | 124 | |
125 | - if ( $page == 'wpinv-subscriptions' ) { |
|
126 | - wp_enqueue_script( 'postbox' ); |
|
127 | - } |
|
125 | + if ( $page == 'wpinv-subscriptions' ) { |
|
126 | + wp_enqueue_script( 'postbox' ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * Returns admin js translations. |
|
133 | - * |
|
134 | - */ |
|
135 | - protected function get_admin_i18() { |
|
132 | + * Returns admin js translations. |
|
133 | + * |
|
134 | + */ |
|
135 | + protected function get_admin_i18() { |
|
136 | 136 | global $post; |
137 | 137 | |
138 | - $date_range = array( |
|
139 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
140 | - ); |
|
138 | + $date_range = array( |
|
139 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
140 | + ); |
|
141 | 141 | |
142 | - if ( $date_range['period'] == 'custom' ) { |
|
142 | + if ( $date_range['period'] == 'custom' ) { |
|
143 | 143 | |
144 | - if ( isset( $_GET['from'] ) ) { |
|
145 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
146 | - } |
|
144 | + if ( isset( $_GET['from'] ) ) { |
|
145 | + $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
146 | + } |
|
147 | 147 | |
148 | - if ( isset( $_GET['to'] ) ) { |
|
149 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
150 | - } |
|
148 | + if ( isset( $_GET['to'] ) ) { |
|
149 | + $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
150 | + } |
|
151 | 151 | |
152 | - } |
|
152 | + } |
|
153 | 153 | |
154 | 154 | $i18n = array( |
155 | 155 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
156 | 156 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
157 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
158 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
159 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
160 | - 'date_range' => $date_range, |
|
157 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
158 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
159 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
160 | + 'date_range' => $date_range, |
|
161 | 161 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
162 | 162 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
163 | 163 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
164 | 164 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
165 | 165 | 'tax' => wpinv_tax_amount(), |
166 | 166 | 'discount' => 0, |
167 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
168 | - 'currency' => wpinv_get_currency(), |
|
167 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
168 | + 'currency' => wpinv_get_currency(), |
|
169 | 169 | 'currency_pos' => wpinv_currency_position(), |
170 | 170 | 'thousand_sep' => wpinv_thousands_separator(), |
171 | 171 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -185,118 +185,118 @@ discard block |
||
185 | 185 | 'item_description' => __( 'Item Description', 'invoicing' ), |
186 | 186 | 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
187 | 187 | 'discount_description' => __( 'Discount Description', 'invoicing' ), |
188 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
189 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
190 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
191 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
188 | + 'searching' => __( 'Searching', 'invoicing' ), |
|
189 | + 'loading' => __( 'Loading...', 'invoicing' ), |
|
190 | + 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
191 | + 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
192 | 192 | ); |
193 | 193 | |
194 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
194 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
195 | 195 | |
196 | - $invoice = new WPInv_Invoice( $post ); |
|
197 | - $i18n['save_invoice'] = sprintf( |
|
198 | - __( 'Save %s', 'invoicing' ), |
|
199 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
200 | - ); |
|
196 | + $invoice = new WPInv_Invoice( $post ); |
|
197 | + $i18n['save_invoice'] = sprintf( |
|
198 | + __( 'Save %s', 'invoicing' ), |
|
199 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
200 | + ); |
|
201 | 201 | |
202 | - $i18n['invoice_description'] = sprintf( |
|
203 | - __( '%s Description', 'invoicing' ), |
|
204 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
205 | - ); |
|
202 | + $i18n['invoice_description'] = sprintf( |
|
203 | + __( '%s Description', 'invoicing' ), |
|
204 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
205 | + ); |
|
206 | 206 | |
207 | - } |
|
208 | - return $i18n; |
|
209 | - } |
|
207 | + } |
|
208 | + return $i18n; |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * Change the admin footer text on GetPaid admin pages. |
|
213 | - * |
|
214 | - * @since 2.0.0 |
|
215 | - * @param string $footer_text |
|
216 | - * @return string |
|
217 | - */ |
|
218 | - public function admin_footer_text( $footer_text ) { |
|
219 | - global $current_screen; |
|
211 | + /** |
|
212 | + * Change the admin footer text on GetPaid admin pages. |
|
213 | + * |
|
214 | + * @since 2.0.0 |
|
215 | + * @param string $footer_text |
|
216 | + * @return string |
|
217 | + */ |
|
218 | + public function admin_footer_text( $footer_text ) { |
|
219 | + global $current_screen; |
|
220 | 220 | |
221 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
221 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
222 | 222 | |
223 | 223 | if ( ! empty( $current_screen->post_type ) ) { |
224 | - $page = $current_screen->post_type; |
|
224 | + $page = $current_screen->post_type; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // General styles. |
228 | 228 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
229 | 229 | |
230 | - // Change the footer text |
|
231 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
232 | - |
|
233 | - $rating_url = esc_url( |
|
234 | - wp_nonce_url( |
|
235 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
236 | - 'getpaid-nonce', |
|
237 | - 'getpaid-nonce' |
|
238 | - ) |
|
239 | - ); |
|
240 | - |
|
241 | - $footer_text = sprintf( |
|
242 | - /* translators: %s: five stars */ |
|
243 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
244 | - "<a href='$rating_url'>★★★★★</a>" |
|
245 | - ); |
|
246 | - |
|
247 | - } else { |
|
248 | - |
|
249 | - $footer_text = sprintf( |
|
250 | - /* translators: %s: GetPaid */ |
|
251 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
252 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
253 | - ); |
|
254 | - |
|
255 | - } |
|
256 | - |
|
257 | - } |
|
258 | - |
|
259 | - return $footer_text; |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Redirects to wp.org to rate the plugin. |
|
264 | - * |
|
265 | - * @since 2.0.0 |
|
266 | - */ |
|
267 | - public function redirect_to_wordpress_rating_page() { |
|
268 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
269 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
270 | - exit; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Loads payment form js. |
|
275 | - * |
|
276 | - */ |
|
277 | - protected function load_payment_form_scripts() { |
|
230 | + // Change the footer text |
|
231 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
232 | + |
|
233 | + $rating_url = esc_url( |
|
234 | + wp_nonce_url( |
|
235 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
236 | + 'getpaid-nonce', |
|
237 | + 'getpaid-nonce' |
|
238 | + ) |
|
239 | + ); |
|
240 | + |
|
241 | + $footer_text = sprintf( |
|
242 | + /* translators: %s: five stars */ |
|
243 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
244 | + "<a href='$rating_url'>★★★★★</a>" |
|
245 | + ); |
|
246 | + |
|
247 | + } else { |
|
248 | + |
|
249 | + $footer_text = sprintf( |
|
250 | + /* translators: %s: GetPaid */ |
|
251 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
252 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
253 | + ); |
|
254 | + |
|
255 | + } |
|
256 | + |
|
257 | + } |
|
258 | + |
|
259 | + return $footer_text; |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Redirects to wp.org to rate the plugin. |
|
264 | + * |
|
265 | + * @since 2.0.0 |
|
266 | + */ |
|
267 | + public function redirect_to_wordpress_rating_page() { |
|
268 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
269 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
270 | + exit; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Loads payment form js. |
|
275 | + * |
|
276 | + */ |
|
277 | + protected function load_payment_form_scripts() { |
|
278 | 278 | global $post; |
279 | 279 | |
280 | 280 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
281 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
282 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
281 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
282 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
283 | 283 | |
284 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
285 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
284 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
285 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
286 | 286 | |
287 | - wp_localize_script( |
|
287 | + wp_localize_script( |
|
288 | 288 | 'wpinv-admin-payment-form-script', |
289 | 289 | 'wpinvPaymentFormAdmin', |
290 | 290 | array( |
291 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
292 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
293 | - 'currency' => wpinv_currency_symbol(), |
|
294 | - 'position' => wpinv_currency_position(), |
|
295 | - 'decimals' => (int) wpinv_decimals(), |
|
296 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
297 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
298 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
299 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
291 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
292 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
293 | + 'currency' => wpinv_currency_symbol(), |
|
294 | + 'position' => wpinv_currency_position(), |
|
295 | + 'decimals' => (int) wpinv_decimals(), |
|
296 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
297 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
298 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
299 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
300 | 300 | ) |
301 | 301 | ); |
302 | 302 | |
@@ -305,20 +305,20 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * Add our classes to admin pages. |
|
308 | + * Add our classes to admin pages. |
|
309 | 309 | * |
310 | 310 | * @param string $classes |
311 | 311 | * @return string |
312 | - * |
|
313 | - */ |
|
312 | + * |
|
313 | + */ |
|
314 | 314 | public function admin_body_class( $classes ) { |
315 | - global $pagenow, $post, $current_screen; |
|
315 | + global $pagenow, $post, $current_screen; |
|
316 | 316 | |
317 | 317 | |
318 | 318 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
319 | 319 | |
320 | 320 | if ( ! empty( $current_screen->post_type ) ) { |
321 | - $page = $current_screen->post_type; |
|
321 | + $page = $current_screen->post_type; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -327,68 +327,68 @@ discard block |
||
327 | 327 | |
328 | 328 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
329 | 329 | $classes .= ' wpinv-cpt wpinv'; |
330 | - } |
|
330 | + } |
|
331 | 331 | |
332 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
332 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
333 | 333 | $classes .= ' getpaid-is-invoice-cpt'; |
334 | 334 | } |
335 | 335 | |
336 | - return $classes; |
|
336 | + return $classes; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Maybe show the AyeCode Connect Notice. |
|
341 | - */ |
|
342 | - public function init_ayecode_connect_helper(){ |
|
340 | + * Maybe show the AyeCode Connect Notice. |
|
341 | + */ |
|
342 | + public function init_ayecode_connect_helper(){ |
|
343 | 343 | |
344 | - // Register with the deactivation survey class. |
|
345 | - AyeCode_Deactivation_Survey::instance(array( |
|
346 | - 'slug' => 'invoicing', |
|
347 | - 'version' => WPINV_VERSION, |
|
348 | - 'support_url' => 'https://wpgetpaid.com/support/', |
|
349 | - 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
350 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
351 | - )); |
|
344 | + // Register with the deactivation survey class. |
|
345 | + AyeCode_Deactivation_Survey::instance(array( |
|
346 | + 'slug' => 'invoicing', |
|
347 | + 'version' => WPINV_VERSION, |
|
348 | + 'support_url' => 'https://wpgetpaid.com/support/', |
|
349 | + 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
350 | + 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
351 | + )); |
|
352 | 352 | |
353 | 353 | new AyeCode_Connect_Helper( |
354 | 354 | array( |
355 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
356 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
357 | - '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>" ), |
|
358 | - 'connect_button' => __("Connect Site","invoicing"), |
|
359 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
360 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
361 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
355 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
356 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
357 | + '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>" ), |
|
358 | + 'connect_button' => __("Connect Site","invoicing"), |
|
359 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
360 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
361 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
362 | 362 | ), |
363 | 363 | array( 'wpi-addons' ) |
364 | 364 | ); |
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | - /** |
|
369 | - * Redirect users to settings on activation. |
|
370 | - * |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public function activation_redirect() { |
|
368 | + /** |
|
369 | + * Redirect users to settings on activation. |
|
370 | + * |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public function activation_redirect() { |
|
374 | 374 | |
375 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
375 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
376 | 376 | |
377 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
378 | - return; |
|
379 | - } |
|
377 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
378 | + return; |
|
379 | + } |
|
380 | 380 | |
381 | - // Bail if activating from network, or bulk |
|
382 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
383 | - return; |
|
384 | - } |
|
381 | + // Bail if activating from network, or bulk |
|
382 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
383 | + return; |
|
384 | + } |
|
385 | 385 | |
386 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
386 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
387 | 387 | |
388 | 388 | wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
389 | 389 | exit; |
390 | 390 | |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Fires an admin action after verifying that a user can fire them. |
@@ -402,498 +402,498 @@ discard block |
||
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | - /** |
|
405 | + /** |
|
406 | 406 | * Sends a payment reminder to a customer. |
407 | - * |
|
408 | - * @param array $args |
|
407 | + * |
|
408 | + * @param array $args |
|
409 | 409 | */ |
410 | 410 | public function duplicate_payment_form( $args ) { |
411 | 411 | |
412 | - if ( empty( $args['form_id'] ) ) { |
|
413 | - return; |
|
414 | - } |
|
415 | - |
|
416 | - $form = new GetPaid_Payment_Form( $args['form_id'] ); |
|
412 | + if ( empty( $args['form_id'] ) ) { |
|
413 | + return; |
|
414 | + } |
|
417 | 415 | |
418 | - if ( ! $form->exists() ) { |
|
419 | - return; |
|
420 | - } |
|
416 | + $form = new GetPaid_Payment_Form( $args['form_id'] ); |
|
421 | 417 | |
422 | - $new_form = new GetPaid_Payment_Form(); |
|
423 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
424 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
425 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
426 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
427 | - $new_form->save(); |
|
418 | + if ( ! $form->exists() ) { |
|
419 | + return; |
|
420 | + } |
|
428 | 421 | |
429 | - if ( $new_form->exists() ) { |
|
430 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
431 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
432 | - } else { |
|
433 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
434 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
435 | - } |
|
422 | + $new_form = new GetPaid_Payment_Form(); |
|
423 | + $new_form->set_author( $form->get_author( 'edit' ) ); |
|
424 | + $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
425 | + $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
426 | + $new_form->set_items( $form->get_items( 'edit' ) ); |
|
427 | + $new_form->save(); |
|
428 | + |
|
429 | + if ( $new_form->exists() ) { |
|
430 | + $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
431 | + $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
432 | + } else { |
|
433 | + $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
434 | + $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
435 | + } |
|
436 | 436 | |
437 | - wp_redirect( $url ); |
|
438 | - exit; |
|
439 | - } |
|
437 | + wp_redirect( $url ); |
|
438 | + exit; |
|
439 | + } |
|
440 | 440 | |
441 | - /** |
|
441 | + /** |
|
442 | 442 | * Sends a payment reminder to a customer. |
443 | - * |
|
444 | - * @param array $args |
|
443 | + * |
|
444 | + * @param array $args |
|
445 | 445 | */ |
446 | 446 | public function send_customer_invoice( $args ) { |
447 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
447 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
448 | 448 | |
449 | - if ( $sent ) { |
|
450 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
451 | - } else { |
|
452 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
453 | - } |
|
449 | + if ( $sent ) { |
|
450 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
451 | + } else { |
|
452 | + $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
453 | + } |
|
454 | 454 | |
455 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
456 | - exit; |
|
457 | - } |
|
455 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
456 | + exit; |
|
457 | + } |
|
458 | 458 | |
459 | - /** |
|
459 | + /** |
|
460 | 460 | * Sends a payment reminder to a customer. |
461 | - * |
|
462 | - * @param array $args |
|
461 | + * |
|
462 | + * @param array $args |
|
463 | 463 | */ |
464 | 464 | public function send_customer_payment_reminder( $args ) { |
465 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
465 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
466 | 466 | |
467 | - if ( $sent ) { |
|
468 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
469 | - } else { |
|
470 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
471 | - } |
|
467 | + if ( $sent ) { |
|
468 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
469 | + } else { |
|
470 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
471 | + } |
|
472 | 472 | |
473 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
474 | - exit; |
|
475 | - } |
|
473 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
474 | + exit; |
|
475 | + } |
|
476 | 476 | |
477 | - /** |
|
477 | + /** |
|
478 | 478 | * Resets tax rates. |
479 | - * |
|
479 | + * |
|
480 | 480 | */ |
481 | 481 | public function admin_reset_tax_rates() { |
482 | 482 | |
483 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
484 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
485 | - exit; |
|
483 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
484 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
485 | + exit; |
|
486 | 486 | |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | - /** |
|
489 | + /** |
|
490 | 490 | * Resets admin pages. |
491 | - * |
|
491 | + * |
|
492 | 492 | */ |
493 | 493 | public function admin_create_missing_pages() { |
494 | - $installer = new GetPaid_Installer(); |
|
495 | - $installer->create_pages(); |
|
496 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
498 | - exit; |
|
499 | - } |
|
500 | - |
|
501 | - /** |
|
494 | + $installer = new GetPaid_Installer(); |
|
495 | + $installer->create_pages(); |
|
496 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
497 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
498 | + exit; |
|
499 | + } |
|
500 | + |
|
501 | + /** |
|
502 | 502 | * Creates an missing admin tables. |
503 | - * |
|
503 | + * |
|
504 | 504 | */ |
505 | 505 | public function admin_create_missing_tables() { |
506 | - global $wpdb; |
|
507 | - $installer = new GetPaid_Installer(); |
|
506 | + global $wpdb; |
|
507 | + $installer = new GetPaid_Installer(); |
|
508 | 508 | |
509 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
510 | - $installer->create_subscriptions_table(); |
|
509 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
510 | + $installer->create_subscriptions_table(); |
|
511 | 511 | |
512 | - if ( $wpdb->last_error !== '' ) { |
|
513 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
514 | - } |
|
515 | - } |
|
512 | + if ( $wpdb->last_error !== '' ) { |
|
513 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
514 | + } |
|
515 | + } |
|
516 | 516 | |
517 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
518 | - $installer->create_invoices_table(); |
|
517 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
518 | + $installer->create_invoices_table(); |
|
519 | 519 | |
520 | - if ( $wpdb->last_error !== '' ) { |
|
521 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
522 | - } |
|
523 | - } |
|
520 | + if ( $wpdb->last_error !== '' ) { |
|
521 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
522 | + } |
|
523 | + } |
|
524 | 524 | |
525 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
526 | - $installer->create_invoice_items_table(); |
|
525 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
526 | + $installer->create_invoice_items_table(); |
|
527 | 527 | |
528 | - if ( $wpdb->last_error !== '' ) { |
|
529 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
530 | - } |
|
531 | - } |
|
528 | + if ( $wpdb->last_error !== '' ) { |
|
529 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
530 | + } |
|
531 | + } |
|
532 | 532 | |
533 | - if ( ! $this->has_notices() ) { |
|
534 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
535 | - } |
|
533 | + if ( ! $this->has_notices() ) { |
|
534 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
535 | + } |
|
536 | 536 | |
537 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
538 | - exit; |
|
539 | - } |
|
537 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
538 | + exit; |
|
539 | + } |
|
540 | 540 | |
541 | - /** |
|
541 | + /** |
|
542 | 542 | * Migrates old invoices to the new database tables. |
543 | - * |
|
543 | + * |
|
544 | 544 | */ |
545 | 545 | public function admin_migrate_old_invoices() { |
546 | 546 | |
547 | - // Migrate the invoices. |
|
548 | - $installer = new GetPaid_Installer(); |
|
549 | - $installer->migrate_old_invoices(); |
|
547 | + // Migrate the invoices. |
|
548 | + $installer = new GetPaid_Installer(); |
|
549 | + $installer->migrate_old_invoices(); |
|
550 | 550 | |
551 | - // Show an admin message. |
|
552 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
551 | + // Show an admin message. |
|
552 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
553 | 553 | |
554 | - // Redirect the admin. |
|
555 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
556 | - exit; |
|
554 | + // Redirect the admin. |
|
555 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
556 | + exit; |
|
557 | 557 | |
558 | - } |
|
558 | + } |
|
559 | 559 | |
560 | - /** |
|
560 | + /** |
|
561 | 561 | * Download customers. |
562 | - * |
|
562 | + * |
|
563 | 563 | */ |
564 | 564 | public function admin_download_customers() { |
565 | - global $wpdb; |
|
565 | + global $wpdb; |
|
566 | 566 | |
567 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
567 | + $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
568 | 568 | |
569 | - header( "Content-Type:text/csv" ); |
|
570 | - header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
569 | + header( "Content-Type:text/csv" ); |
|
570 | + header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
571 | 571 | |
572 | - $post_types = ''; |
|
572 | + $post_types = ''; |
|
573 | 573 | |
574 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
575 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
576 | - } |
|
574 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
575 | + $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
576 | + } |
|
577 | 577 | |
578 | - $post_types = rtrim( $post_types, ' OR' ); |
|
578 | + $post_types = rtrim( $post_types, ' OR' ); |
|
579 | 579 | |
580 | - $customers = $wpdb->get_col( |
|
581 | - $wpdb->prepare( |
|
582 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" |
|
583 | - ) |
|
584 | - ); |
|
580 | + $customers = $wpdb->get_col( |
|
581 | + $wpdb->prepare( |
|
582 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" |
|
583 | + ) |
|
584 | + ); |
|
585 | 585 | |
586 | - $columns = array( |
|
587 | - 'name' => __( 'Name', 'invoicing' ), |
|
588 | - 'email' => __( 'Email', 'invoicing' ), |
|
589 | - 'country' => __( 'Country', 'invoicing' ), |
|
590 | - 'state' => __( 'State', 'invoicing' ), |
|
591 | - 'city' => __( 'City', 'invoicing' ), |
|
592 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
593 | - 'address' => __( 'Address', 'invoicing' ), |
|
594 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
595 | - 'company' => __( 'Company', 'invoicing' ), |
|
596 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
597 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
598 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
599 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
600 | - ); |
|
586 | + $columns = array( |
|
587 | + 'name' => __( 'Name', 'invoicing' ), |
|
588 | + 'email' => __( 'Email', 'invoicing' ), |
|
589 | + 'country' => __( 'Country', 'invoicing' ), |
|
590 | + 'state' => __( 'State', 'invoicing' ), |
|
591 | + 'city' => __( 'City', 'invoicing' ), |
|
592 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
593 | + 'address' => __( 'Address', 'invoicing' ), |
|
594 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
595 | + 'company' => __( 'Company', 'invoicing' ), |
|
596 | + 'company_id' => __( 'Company ID', 'invoicing' ), |
|
597 | + 'invoices' => __( 'Invoices', 'invoicing' ), |
|
598 | + 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
599 | + 'signup' => __( 'Date created', 'invoicing' ), |
|
600 | + ); |
|
601 | 601 | |
602 | - // Output the csv column headers. |
|
603 | - fputcsv( $output, array_values( $columns ) ); |
|
602 | + // Output the csv column headers. |
|
603 | + fputcsv( $output, array_values( $columns ) ); |
|
604 | 604 | |
605 | - // Loop through |
|
606 | - $table = new WPInv_Customers_Table(); |
|
607 | - foreach ( $customers as $customer_id ) { |
|
605 | + // Loop through |
|
606 | + $table = new WPInv_Customers_Table(); |
|
607 | + foreach ( $customers as $customer_id ) { |
|
608 | 608 | |
609 | - $user = get_user_by( 'id', $customer_id ); |
|
610 | - $row = array(); |
|
611 | - if ( empty( $user ) ) { |
|
612 | - continue; |
|
613 | - } |
|
609 | + $user = get_user_by( 'id', $customer_id ); |
|
610 | + $row = array(); |
|
611 | + if ( empty( $user ) ) { |
|
612 | + continue; |
|
613 | + } |
|
614 | 614 | |
615 | - foreach ( array_keys( $columns ) as $column ) { |
|
615 | + foreach ( array_keys( $columns ) as $column ) { |
|
616 | 616 | |
617 | - $method = 'column_' . $column; |
|
617 | + $method = 'column_' . $column; |
|
618 | 618 | |
619 | - if ( 'name' == $column ) { |
|
620 | - $value = sanitize_text_field( $user->display_name ); |
|
621 | - } else if( 'email' == $column ) { |
|
622 | - $value = sanitize_email( $user->user_email ); |
|
623 | - } else if ( is_callable( array( $table, $method ) ) ) { |
|
624 | - $value = strip_tags( $table->$method( $user ) ); |
|
625 | - } |
|
619 | + if ( 'name' == $column ) { |
|
620 | + $value = sanitize_text_field( $user->display_name ); |
|
621 | + } else if( 'email' == $column ) { |
|
622 | + $value = sanitize_email( $user->user_email ); |
|
623 | + } else if ( is_callable( array( $table, $method ) ) ) { |
|
624 | + $value = strip_tags( $table->$method( $user ) ); |
|
625 | + } |
|
626 | 626 | |
627 | - if ( empty( $value ) ) { |
|
628 | - $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
629 | - } |
|
627 | + if ( empty( $value ) ) { |
|
628 | + $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
629 | + } |
|
630 | 630 | |
631 | - $row[] = $value; |
|
631 | + $row[] = $value; |
|
632 | 632 | |
633 | - } |
|
633 | + } |
|
634 | 634 | |
635 | - fputcsv( $output, $row ); |
|
636 | - } |
|
635 | + fputcsv( $output, $row ); |
|
636 | + } |
|
637 | 637 | |
638 | - fclose( $output ); |
|
639 | - exit; |
|
638 | + fclose( $output ); |
|
639 | + exit; |
|
640 | 640 | |
641 | - } |
|
641 | + } |
|
642 | 642 | |
643 | - /** |
|
643 | + /** |
|
644 | 644 | * Installs a plugin. |
645 | - * |
|
646 | - * @param array $data |
|
645 | + * |
|
646 | + * @param array $data |
|
647 | 647 | */ |
648 | 648 | public function admin_install_plugin( $data ) { |
649 | 649 | |
650 | - if ( ! empty( $data['plugins'] ) ) { |
|
651 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
652 | - wp_cache_flush(); |
|
650 | + if ( ! empty( $data['plugins'] ) ) { |
|
651 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
652 | + wp_cache_flush(); |
|
653 | 653 | |
654 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
655 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
656 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
657 | - $installed = $upgrader->install( $plugin_zip ); |
|
654 | + foreach ( $data['plugins'] as $slug => $file ) { |
|
655 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
656 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
657 | + $installed = $upgrader->install( $plugin_zip ); |
|
658 | 658 | |
659 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
660 | - activate_plugin( $file, '', false, true ); |
|
661 | - } else { |
|
662 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
663 | - } |
|
659 | + if ( ! is_wp_error( $installed ) && $installed ) { |
|
660 | + activate_plugin( $file, '', false, true ); |
|
661 | + } else { |
|
662 | + wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
663 | + } |
|
664 | 664 | |
665 | - } |
|
665 | + } |
|
666 | 666 | |
667 | - } |
|
667 | + } |
|
668 | 668 | |
669 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
670 | - wp_safe_redirect( $redirect ); |
|
671 | - exit; |
|
669 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
670 | + wp_safe_redirect( $redirect ); |
|
671 | + exit; |
|
672 | 672 | |
673 | - } |
|
673 | + } |
|
674 | 674 | |
675 | - /** |
|
675 | + /** |
|
676 | 676 | * Connects a gateway. |
677 | - * |
|
678 | - * @param array $data |
|
677 | + * |
|
678 | + * @param array $data |
|
679 | 679 | */ |
680 | 680 | public function admin_connect_gateway( $data ) { |
681 | 681 | |
682 | - if ( ! empty( $data['plugin'] ) ) { |
|
682 | + if ( ! empty( $data['plugin'] ) ) { |
|
683 | 683 | |
684 | - $gateway = sanitize_key( $data['plugin'] ); |
|
685 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
684 | + $gateway = sanitize_key( $data['plugin'] ); |
|
685 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
686 | 686 | |
687 | - if ( ! empty( $connect_url ) ) { |
|
688 | - wp_redirect( $connect_url ); |
|
689 | - exit; |
|
690 | - } |
|
687 | + if ( ! empty( $connect_url ) ) { |
|
688 | + wp_redirect( $connect_url ); |
|
689 | + exit; |
|
690 | + } |
|
691 | 691 | |
692 | - if ( 'stripe' == $data['plugin'] ) { |
|
693 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
694 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
695 | - wp_cache_flush(); |
|
692 | + if ( 'stripe' == $data['plugin'] ) { |
|
693 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
694 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
695 | + wp_cache_flush(); |
|
696 | 696 | |
697 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
698 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
699 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
700 | - $upgrader->install( $plugin_zip ); |
|
701 | - } |
|
697 | + if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
698 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
699 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
700 | + $upgrader->install( $plugin_zip ); |
|
701 | + } |
|
702 | 702 | |
703 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
704 | - } |
|
703 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
704 | + } |
|
705 | 705 | |
706 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
707 | - if ( ! empty( $connect_url ) ) { |
|
708 | - wp_redirect( $connect_url ); |
|
709 | - exit; |
|
710 | - } |
|
706 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
707 | + if ( ! empty( $connect_url ) ) { |
|
708 | + wp_redirect( $connect_url ); |
|
709 | + exit; |
|
710 | + } |
|
711 | 711 | |
712 | - } |
|
712 | + } |
|
713 | 713 | |
714 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
715 | - wp_safe_redirect( $redirect ); |
|
716 | - exit; |
|
714 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
715 | + wp_safe_redirect( $redirect ); |
|
716 | + exit; |
|
717 | 717 | |
718 | - } |
|
718 | + } |
|
719 | 719 | |
720 | - /** |
|
720 | + /** |
|
721 | 721 | * Recalculates discounts. |
722 | - * |
|
722 | + * |
|
723 | 723 | */ |
724 | 724 | public function admin_recalculate_discounts() { |
725 | - global $wpdb; |
|
725 | + global $wpdb; |
|
726 | 726 | |
727 | - // Fetch all invoices that have discount codes. |
|
728 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
729 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
727 | + // Fetch all invoices that have discount codes. |
|
728 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
729 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
730 | 730 | |
731 | - foreach ( $invoices as $invoice ) { |
|
731 | + foreach ( $invoices as $invoice ) { |
|
732 | 732 | |
733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
733 | + $invoice = new WPInv_Invoice( $invoice ); |
|
734 | 734 | |
735 | - if ( ! $invoice->exists() ) { |
|
736 | - continue; |
|
737 | - } |
|
735 | + if ( ! $invoice->exists() ) { |
|
736 | + continue; |
|
737 | + } |
|
738 | 738 | |
739 | - // Abort if the discount does not exist or does not apply here. |
|
740 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
741 | - if ( ! $discount->exists() ) { |
|
742 | - continue; |
|
743 | - } |
|
739 | + // Abort if the discount does not exist or does not apply here. |
|
740 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
741 | + if ( ! $discount->exists() ) { |
|
742 | + continue; |
|
743 | + } |
|
744 | 744 | |
745 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
746 | - $invoice->recalculate_total(); |
|
745 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
746 | + $invoice->recalculate_total(); |
|
747 | 747 | |
748 | - if ( $invoice->get_total_discount() > 0 ) { |
|
749 | - $invoice->save(); |
|
750 | - } |
|
748 | + if ( $invoice->get_total_discount() > 0 ) { |
|
749 | + $invoice->save(); |
|
750 | + } |
|
751 | 751 | |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | - // Show an admin message. |
|
755 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
754 | + // Show an admin message. |
|
755 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
756 | 756 | |
757 | - // Redirect the admin. |
|
758 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
759 | - exit; |
|
757 | + // Redirect the admin. |
|
758 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
759 | + exit; |
|
760 | 760 | |
761 | - } |
|
761 | + } |
|
762 | 762 | |
763 | 763 | /** |
764 | - * Returns an array of admin notices. |
|
765 | - * |
|
766 | - * @since 1.0.19 |
|
764 | + * Returns an array of admin notices. |
|
765 | + * |
|
766 | + * @since 1.0.19 |
|
767 | 767 | * @return array |
768 | - */ |
|
769 | - public function get_notices() { |
|
770 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
768 | + */ |
|
769 | + public function get_notices() { |
|
770 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
771 | 771 | return is_array( $notices ) ? $notices : array(); |
772 | - } |
|
772 | + } |
|
773 | 773 | |
774 | - /** |
|
775 | - * Checks if we have any admin notices. |
|
776 | - * |
|
777 | - * @since 2.0.4 |
|
774 | + /** |
|
775 | + * Checks if we have any admin notices. |
|
776 | + * |
|
777 | + * @since 2.0.4 |
|
778 | 778 | * @return array |
779 | - */ |
|
780 | - public function has_notices() { |
|
781 | - return count( $this->get_notices() ) > 0; |
|
782 | - } |
|
783 | - |
|
784 | - /** |
|
785 | - * Clears all admin notices |
|
786 | - * |
|
787 | - * @access public |
|
788 | - * @since 1.0.19 |
|
789 | - */ |
|
790 | - public function clear_notices() { |
|
791 | - delete_option( 'wpinv_admin_notices' ); |
|
792 | - } |
|
793 | - |
|
794 | - /** |
|
795 | - * Saves a new admin notice |
|
796 | - * |
|
797 | - * @access public |
|
798 | - * @since 1.0.19 |
|
799 | - */ |
|
800 | - public function save_notice( $type, $message ) { |
|
801 | - $notices = $this->get_notices(); |
|
802 | - |
|
803 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
804 | - $notices[ $type ] = array(); |
|
805 | - } |
|
806 | - |
|
807 | - $notices[ $type ][] = $message; |
|
808 | - |
|
809 | - update_option( 'wpinv_admin_notices', $notices ); |
|
810 | - } |
|
811 | - |
|
812 | - /** |
|
813 | - * Displays a success notice |
|
814 | - * |
|
815 | - * @param string $msg The message to qeue. |
|
816 | - * @access public |
|
817 | - * @since 1.0.19 |
|
818 | - */ |
|
819 | - public function show_success( $msg ) { |
|
820 | - $this->save_notice( 'success', $msg ); |
|
821 | - } |
|
822 | - |
|
823 | - /** |
|
824 | - * Displays a error notice |
|
825 | - * |
|
826 | - * @access public |
|
827 | - * @param string $msg The message to qeue. |
|
828 | - * @since 1.0.19 |
|
829 | - */ |
|
830 | - public function show_error( $msg ) { |
|
831 | - $this->save_notice( 'error', $msg ); |
|
832 | - } |
|
833 | - |
|
834 | - /** |
|
835 | - * Displays a warning notice |
|
836 | - * |
|
837 | - * @access public |
|
838 | - * @param string $msg The message to qeue. |
|
839 | - * @since 1.0.19 |
|
840 | - */ |
|
841 | - public function show_warning( $msg ) { |
|
842 | - $this->save_notice( 'warning', $msg ); |
|
843 | - } |
|
844 | - |
|
845 | - /** |
|
846 | - * Displays a info notice |
|
847 | - * |
|
848 | - * @access public |
|
849 | - * @param string $msg The message to qeue. |
|
850 | - * @since 1.0.19 |
|
851 | - */ |
|
852 | - public function show_info( $msg ) { |
|
853 | - $this->save_notice( 'info', $msg ); |
|
854 | - } |
|
855 | - |
|
856 | - /** |
|
857 | - * Show notices |
|
858 | - * |
|
859 | - * @access public |
|
860 | - * @since 1.0.19 |
|
861 | - */ |
|
862 | - public function show_notices() { |
|
779 | + */ |
|
780 | + public function has_notices() { |
|
781 | + return count( $this->get_notices() ) > 0; |
|
782 | + } |
|
783 | + |
|
784 | + /** |
|
785 | + * Clears all admin notices |
|
786 | + * |
|
787 | + * @access public |
|
788 | + * @since 1.0.19 |
|
789 | + */ |
|
790 | + public function clear_notices() { |
|
791 | + delete_option( 'wpinv_admin_notices' ); |
|
792 | + } |
|
793 | + |
|
794 | + /** |
|
795 | + * Saves a new admin notice |
|
796 | + * |
|
797 | + * @access public |
|
798 | + * @since 1.0.19 |
|
799 | + */ |
|
800 | + public function save_notice( $type, $message ) { |
|
801 | + $notices = $this->get_notices(); |
|
802 | + |
|
803 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
804 | + $notices[ $type ] = array(); |
|
805 | + } |
|
806 | + |
|
807 | + $notices[ $type ][] = $message; |
|
808 | + |
|
809 | + update_option( 'wpinv_admin_notices', $notices ); |
|
810 | + } |
|
811 | + |
|
812 | + /** |
|
813 | + * Displays a success notice |
|
814 | + * |
|
815 | + * @param string $msg The message to qeue. |
|
816 | + * @access public |
|
817 | + * @since 1.0.19 |
|
818 | + */ |
|
819 | + public function show_success( $msg ) { |
|
820 | + $this->save_notice( 'success', $msg ); |
|
821 | + } |
|
822 | + |
|
823 | + /** |
|
824 | + * Displays a error notice |
|
825 | + * |
|
826 | + * @access public |
|
827 | + * @param string $msg The message to qeue. |
|
828 | + * @since 1.0.19 |
|
829 | + */ |
|
830 | + public function show_error( $msg ) { |
|
831 | + $this->save_notice( 'error', $msg ); |
|
832 | + } |
|
833 | + |
|
834 | + /** |
|
835 | + * Displays a warning notice |
|
836 | + * |
|
837 | + * @access public |
|
838 | + * @param string $msg The message to qeue. |
|
839 | + * @since 1.0.19 |
|
840 | + */ |
|
841 | + public function show_warning( $msg ) { |
|
842 | + $this->save_notice( 'warning', $msg ); |
|
843 | + } |
|
844 | + |
|
845 | + /** |
|
846 | + * Displays a info notice |
|
847 | + * |
|
848 | + * @access public |
|
849 | + * @param string $msg The message to qeue. |
|
850 | + * @since 1.0.19 |
|
851 | + */ |
|
852 | + public function show_info( $msg ) { |
|
853 | + $this->save_notice( 'info', $msg ); |
|
854 | + } |
|
855 | + |
|
856 | + /** |
|
857 | + * Show notices |
|
858 | + * |
|
859 | + * @access public |
|
860 | + * @since 1.0.19 |
|
861 | + */ |
|
862 | + public function show_notices() { |
|
863 | 863 | |
864 | 864 | $notices = $this->get_notices(); |
865 | 865 | $this->clear_notices(); |
866 | 866 | |
867 | - foreach ( $notices as $type => $messages ) { |
|
867 | + foreach ( $notices as $type => $messages ) { |
|
868 | 868 | |
869 | - if ( ! is_array( $messages ) ) { |
|
870 | - continue; |
|
871 | - } |
|
869 | + if ( ! is_array( $messages ) ) { |
|
870 | + continue; |
|
871 | + } |
|
872 | 872 | |
873 | 873 | $type = sanitize_key( $type ); |
874 | - foreach ( $messages as $message ) { |
|
874 | + foreach ( $messages as $message ) { |
|
875 | 875 | $message = wp_kses_post( $message ); |
876 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
876 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | } |
880 | 880 | |
881 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
882 | - |
|
883 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
884 | - $url = wp_nonce_url( |
|
885 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
886 | - 'getpaid-nonce', |
|
887 | - 'getpaid-nonce' |
|
888 | - ); |
|
889 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
890 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
891 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
892 | - break; |
|
893 | - } |
|
881 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
882 | + |
|
883 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
884 | + $url = wp_nonce_url( |
|
885 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
886 | + 'getpaid-nonce', |
|
887 | + 'getpaid-nonce' |
|
888 | + ); |
|
889 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
890 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
891 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
892 | + break; |
|
893 | + } |
|
894 | 894 | |
895 | - } |
|
895 | + } |
|
896 | 896 | |
897 | - } |
|
897 | + } |
|
898 | 898 | |
899 | 899 | } |
@@ -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,32 +54,32 @@ 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_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
75 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
76 | - 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_duplicate_form', array($this, 'duplicate_payment_form')); |
|
65 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
66 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
67 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
68 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
69 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
70 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
71 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
72 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
73 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
74 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
75 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
76 | + do_action('getpaid_init_admin_hooks', $this); |
|
77 | 77 | |
78 | 78 | // Setup/welcome |
79 | - if ( ! empty( $_GET['page'] ) ) { |
|
80 | - switch ( $_GET['page'] ) { |
|
79 | + if (!empty($_GET['page'])) { |
|
80 | + switch ($_GET['page']) { |
|
81 | 81 | case 'gp-setup' : |
82 | - include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' ); |
|
82 | + include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'); |
|
83 | 83 | break; |
84 | 84 | } |
85 | 85 | } |
@@ -93,37 +93,37 @@ discard block |
||
93 | 93 | public function enqeue_scripts() { |
94 | 94 | global $current_screen, $pagenow; |
95 | 95 | |
96 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
96 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
97 | 97 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
98 | 98 | |
99 | - if ( ! empty( $current_screen->post_type ) ) { |
|
99 | + if (!empty($current_screen->post_type)) { |
|
100 | 100 | $page = $current_screen->post_type; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // General styles. |
104 | - if ( false !== stripos( $page, 'wpi' ) || 'gp-setup' == $page ) { |
|
104 | + if (false !== stripos($page, 'wpi') || 'gp-setup' == $page) { |
|
105 | 105 | |
106 | 106 | // Styles. |
107 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
108 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
109 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
107 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
108 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
109 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
110 | 110 | |
111 | 111 | // Scripts. |
112 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
112 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
113 | 113 | |
114 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
115 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
116 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
114 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
115 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
116 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Payment form scripts. |
121 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
121 | + if ('wpi_payment_form' == $page && $editing) { |
|
122 | 122 | $this->load_payment_form_scripts(); |
123 | 123 | } |
124 | 124 | |
125 | - if ( $page == 'wpinv-subscriptions' ) { |
|
126 | - wp_enqueue_script( 'postbox' ); |
|
125 | + if ($page == 'wpinv-subscriptions') { |
|
126 | + wp_enqueue_script('postbox'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | } |
@@ -136,32 +136,32 @@ discard block |
||
136 | 136 | global $post; |
137 | 137 | |
138 | 138 | $date_range = array( |
139 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
139 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days' |
|
140 | 140 | ); |
141 | 141 | |
142 | - if ( $date_range['period'] == 'custom' ) { |
|
142 | + if ($date_range['period'] == 'custom') { |
|
143 | 143 | |
144 | - if ( isset( $_GET['from'] ) ) { |
|
145 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
144 | + if (isset($_GET['from'])) { |
|
145 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
146 | 146 | } |
147 | 147 | |
148 | - if ( isset( $_GET['to'] ) ) { |
|
149 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
148 | + if (isset($_GET['to'])) { |
|
149 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
153 | 153 | |
154 | 154 | $i18n = array( |
155 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
156 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
157 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
158 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
159 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
155 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
156 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
157 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
158 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
159 | + 'rest_root' => esc_url_raw(rest_url()), |
|
160 | 160 | 'date_range' => $date_range, |
161 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
162 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
163 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
164 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
161 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
162 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
163 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
164 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
165 | 165 | 'tax' => wpinv_tax_amount(), |
166 | 166 | 'discount' => 0, |
167 | 167 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -170,38 +170,38 @@ discard block |
||
170 | 170 | 'thousand_sep' => wpinv_thousands_separator(), |
171 | 171 | 'decimal_sep' => wpinv_decimal_separator(), |
172 | 172 | 'decimals' => wpinv_decimals(), |
173 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
174 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
175 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
176 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
177 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
178 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
179 | - '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' ), |
|
180 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
181 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
182 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
183 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
184 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
185 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
186 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
187 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
188 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
189 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
190 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
191 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
173 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
174 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
175 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
176 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
177 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
178 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
179 | + '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'), |
|
180 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
181 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
182 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
183 | + 'action_edit' => __('Edit', 'invoicing'), |
|
184 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
185 | + 'item_description' => __('Item Description', 'invoicing'), |
|
186 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
187 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
188 | + 'searching' => __('Searching', 'invoicing'), |
|
189 | + 'loading' => __('Loading...', 'invoicing'), |
|
190 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
191 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
192 | 192 | ); |
193 | 193 | |
194 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
194 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
195 | 195 | |
196 | - $invoice = new WPInv_Invoice( $post ); |
|
196 | + $invoice = new WPInv_Invoice($post); |
|
197 | 197 | $i18n['save_invoice'] = sprintf( |
198 | - __( 'Save %s', 'invoicing' ), |
|
199 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
198 | + __('Save %s', 'invoicing'), |
|
199 | + ucfirst($invoice->get_invoice_quote_type()) |
|
200 | 200 | ); |
201 | 201 | |
202 | 202 | $i18n['invoice_description'] = sprintf( |
203 | - __( '%s Description', 'invoicing' ), |
|
204 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
203 | + __('%s Description', 'invoicing'), |
|
204 | + ucfirst($invoice->get_invoice_quote_type()) |
|
205 | 205 | ); |
206 | 206 | |
207 | 207 | } |
@@ -215,24 +215,24 @@ discard block |
||
215 | 215 | * @param string $footer_text |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function admin_footer_text( $footer_text ) { |
|
218 | + public function admin_footer_text($footer_text) { |
|
219 | 219 | global $current_screen; |
220 | 220 | |
221 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
221 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
222 | 222 | |
223 | - if ( ! empty( $current_screen->post_type ) ) { |
|
223 | + if (!empty($current_screen->post_type)) { |
|
224 | 224 | $page = $current_screen->post_type; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // General styles. |
228 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
228 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
229 | 229 | |
230 | 230 | // Change the footer text |
231 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
231 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
232 | 232 | |
233 | - $rating_url = esc_url( |
|
233 | + $rating_url = esc_url( |
|
234 | 234 | wp_nonce_url( |
235 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
235 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
236 | 236 | 'getpaid-nonce', |
237 | 237 | 'getpaid-nonce' |
238 | 238 | ) |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | $footer_text = sprintf( |
242 | 242 | /* translators: %s: five stars */ |
243 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
243 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
244 | 244 | "<a href='$rating_url'>★★★★★</a>" |
245 | 245 | ); |
246 | 246 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | $footer_text = sprintf( |
250 | 250 | /* translators: %s: GetPaid */ |
251 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
251 | + __('Thank you for using %s!', 'invoicing'), |
|
252 | 252 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
253 | 253 | ); |
254 | 254 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * @since 2.0.0 |
266 | 266 | */ |
267 | 267 | public function redirect_to_wordpress_rating_page() { |
268 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
269 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
268 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
269 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
@@ -277,30 +277,30 @@ discard block |
||
277 | 277 | protected function load_payment_form_scripts() { |
278 | 278 | global $post; |
279 | 279 | |
280 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
281 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
282 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
280 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
281 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
282 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
283 | 283 | |
284 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
285 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
284 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
285 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
286 | 286 | |
287 | 287 | wp_localize_script( |
288 | 288 | 'wpinv-admin-payment-form-script', |
289 | 289 | 'wpinvPaymentFormAdmin', |
290 | 290 | array( |
291 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
292 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
291 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
292 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
293 | 293 | 'currency' => wpinv_currency_symbol(), |
294 | 294 | 'position' => wpinv_currency_position(), |
295 | 295 | 'decimals' => (int) wpinv_decimals(), |
296 | 296 | 'thousands_sep' => wpinv_thousands_separator(), |
297 | 297 | 'decimals_sep' => wpinv_decimal_separator(), |
298 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
298 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
299 | 299 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
300 | 300 | ) |
301 | 301 | ); |
302 | 302 | |
303 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
303 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
@@ -311,25 +311,25 @@ discard block |
||
311 | 311 | * @return string |
312 | 312 | * |
313 | 313 | */ |
314 | - public function admin_body_class( $classes ) { |
|
314 | + public function admin_body_class($classes) { |
|
315 | 315 | global $pagenow, $post, $current_screen; |
316 | 316 | |
317 | 317 | |
318 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
318 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
319 | 319 | |
320 | - if ( ! empty( $current_screen->post_type ) ) { |
|
320 | + if (!empty($current_screen->post_type)) { |
|
321 | 321 | $page = $current_screen->post_type; |
322 | 322 | } |
323 | 323 | |
324 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
325 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
324 | + if (false !== stripos($page, 'wpi')) { |
|
325 | + $classes .= ' wpi-' . sanitize_key($page); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
328 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
329 | 329 | $classes .= ' wpinv-cpt wpinv'; |
330 | 330 | } |
331 | 331 | |
332 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
332 | + if (getpaid_is_invoice_post_type($page)) { |
|
333 | 333 | $classes .= ' getpaid-is-invoice-cpt'; |
334 | 334 | } |
335 | 335 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | /** |
340 | 340 | * Maybe show the AyeCode Connect Notice. |
341 | 341 | */ |
342 | - public function init_ayecode_connect_helper(){ |
|
342 | + public function init_ayecode_connect_helper() { |
|
343 | 343 | |
344 | 344 | // Register with the deactivation survey class. |
345 | 345 | AyeCode_Deactivation_Survey::instance(array( |
@@ -347,20 +347,20 @@ discard block |
||
347 | 347 | 'version' => WPINV_VERSION, |
348 | 348 | 'support_url' => 'https://wpgetpaid.com/support/', |
349 | 349 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
350 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
350 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
351 | 351 | )); |
352 | 352 | |
353 | 353 | new AyeCode_Connect_Helper( |
354 | 354 | array( |
355 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
356 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
357 | - '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>" ), |
|
358 | - 'connect_button' => __("Connect Site","invoicing"), |
|
359 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
360 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
361 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
355 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
356 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
357 | + '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>"), |
|
358 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
359 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
360 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
361 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
362 | 362 | ), |
363 | - array( 'wpi-addons' ) |
|
363 | + array('wpi-addons') |
|
364 | 364 | ); |
365 | 365 | |
366 | 366 | } |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function activation_redirect() { |
374 | 374 | |
375 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
375 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
376 | 376 | |
377 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
377 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
378 | 378 | return; |
379 | 379 | } |
380 | 380 | |
381 | 381 | // Bail if activating from network, or bulk |
382 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
382 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
386 | + update_option('wpinv_redirected_to_settings', 1); |
|
387 | 387 | |
388 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
388 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
389 | 389 | exit; |
390 | 390 | |
391 | 391 | } |
@@ -395,9 +395,9 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function maybe_do_admin_action() { |
397 | 397 | |
398 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
399 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
400 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
398 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
399 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
400 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | } |
@@ -407,34 +407,34 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @param array $args |
409 | 409 | */ |
410 | - public function duplicate_payment_form( $args ) { |
|
410 | + public function duplicate_payment_form($args) { |
|
411 | 411 | |
412 | - if ( empty( $args['form_id'] ) ) { |
|
412 | + if (empty($args['form_id'])) { |
|
413 | 413 | return; |
414 | 414 | } |
415 | 415 | |
416 | - $form = new GetPaid_Payment_Form( $args['form_id'] ); |
|
416 | + $form = new GetPaid_Payment_Form($args['form_id']); |
|
417 | 417 | |
418 | - if ( ! $form->exists() ) { |
|
418 | + if (!$form->exists()) { |
|
419 | 419 | return; |
420 | 420 | } |
421 | 421 | |
422 | 422 | $new_form = new GetPaid_Payment_Form(); |
423 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
424 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
425 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
426 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
423 | + $new_form->set_author($form->get_author('edit')); |
|
424 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
425 | + $new_form->set_elements($form->get_elements('edit')); |
|
426 | + $new_form->set_items($form->get_items('edit')); |
|
427 | 427 | $new_form->save(); |
428 | 428 | |
429 | - if ( $new_form->exists() ) { |
|
430 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
431 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
429 | + if ($new_form->exists()) { |
|
430 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
431 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
432 | 432 | } else { |
433 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
434 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
433 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
434 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
435 | 435 | } |
436 | 436 | |
437 | - wp_redirect( $url ); |
|
437 | + wp_redirect($url); |
|
438 | 438 | exit; |
439 | 439 | } |
440 | 440 | |
@@ -443,16 +443,16 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param array $args |
445 | 445 | */ |
446 | - public function send_customer_invoice( $args ) { |
|
447 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
446 | + public function send_customer_invoice($args) { |
|
447 | + $sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
448 | 448 | |
449 | - if ( $sent ) { |
|
450 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
449 | + if ($sent) { |
|
450 | + $this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
451 | 451 | } else { |
452 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
452 | + $this->show_error(__('Could not send the invoice to the customer', 'invoicing')); |
|
453 | 453 | } |
454 | 454 | |
455 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
455 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
456 | 456 | exit; |
457 | 457 | } |
458 | 458 | |
@@ -461,16 +461,16 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @param array $args |
463 | 463 | */ |
464 | - public function send_customer_payment_reminder( $args ) { |
|
465 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
464 | + public function send_customer_payment_reminder($args) { |
|
465 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
466 | 466 | |
467 | - if ( $sent ) { |
|
468 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
467 | + if ($sent) { |
|
468 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
469 | 469 | } else { |
470 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
470 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
471 | 471 | } |
472 | 472 | |
473 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
473 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
474 | 474 | exit; |
475 | 475 | } |
476 | 476 | |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | */ |
481 | 481 | public function admin_reset_tax_rates() { |
482 | 482 | |
483 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
484 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
483 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
484 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
485 | 485 | exit; |
486 | 486 | |
487 | 487 | } |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | public function admin_create_missing_pages() { |
494 | 494 | $installer = new GetPaid_Installer(); |
495 | 495 | $installer->create_pages(); |
496 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
496 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
497 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
498 | 498 | exit; |
499 | 499 | } |
500 | 500 | |
@@ -506,35 +506,35 @@ discard block |
||
506 | 506 | global $wpdb; |
507 | 507 | $installer = new GetPaid_Installer(); |
508 | 508 | |
509 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
509 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { |
|
510 | 510 | $installer->create_subscriptions_table(); |
511 | 511 | |
512 | - if ( $wpdb->last_error !== '' ) { |
|
513 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
512 | + if ($wpdb->last_error !== '') { |
|
513 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
517 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
517 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { |
|
518 | 518 | $installer->create_invoices_table(); |
519 | 519 | |
520 | - if ( $wpdb->last_error !== '' ) { |
|
521 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
520 | + if ($wpdb->last_error !== '') { |
|
521 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
525 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { |
|
526 | 526 | $installer->create_invoice_items_table(); |
527 | 527 | |
528 | - if ( $wpdb->last_error !== '' ) { |
|
529 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
528 | + if ($wpdb->last_error !== '') { |
|
529 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
533 | - if ( ! $this->has_notices() ) { |
|
534 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
533 | + if (!$this->has_notices()) { |
|
534 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
535 | 535 | } |
536 | 536 | |
537 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
537 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
538 | 538 | exit; |
539 | 539 | } |
540 | 540 | |
@@ -549,10 +549,10 @@ discard block |
||
549 | 549 | $installer->migrate_old_invoices(); |
550 | 550 | |
551 | 551 | // Show an admin message. |
552 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
552 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
553 | 553 | |
554 | 554 | // Redirect the admin. |
555 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
555 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
556 | 556 | exit; |
557 | 557 | |
558 | 558 | } |
@@ -564,18 +564,18 @@ discard block |
||
564 | 564 | public function admin_download_customers() { |
565 | 565 | global $wpdb; |
566 | 566 | |
567 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
567 | + $output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing')); |
|
568 | 568 | |
569 | - header( "Content-Type:text/csv" ); |
|
570 | - header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
569 | + header("Content-Type:text/csv"); |
|
570 | + header("Content-Disposition:attachment;filename=customers.csv"); |
|
571 | 571 | |
572 | 572 | $post_types = ''; |
573 | 573 | |
574 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
575 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
574 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
575 | + $post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); |
|
576 | 576 | } |
577 | 577 | |
578 | - $post_types = rtrim( $post_types, ' OR' ); |
|
578 | + $post_types = rtrim($post_types, ' OR'); |
|
579 | 579 | |
580 | 580 | $customers = $wpdb->get_col( |
581 | 581 | $wpdb->prepare( |
@@ -584,58 +584,58 @@ discard block |
||
584 | 584 | ); |
585 | 585 | |
586 | 586 | $columns = array( |
587 | - 'name' => __( 'Name', 'invoicing' ), |
|
588 | - 'email' => __( 'Email', 'invoicing' ), |
|
589 | - 'country' => __( 'Country', 'invoicing' ), |
|
590 | - 'state' => __( 'State', 'invoicing' ), |
|
591 | - 'city' => __( 'City', 'invoicing' ), |
|
592 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
593 | - 'address' => __( 'Address', 'invoicing' ), |
|
594 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
595 | - 'company' => __( 'Company', 'invoicing' ), |
|
596 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
597 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
598 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
599 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
587 | + 'name' => __('Name', 'invoicing'), |
|
588 | + 'email' => __('Email', 'invoicing'), |
|
589 | + 'country' => __('Country', 'invoicing'), |
|
590 | + 'state' => __('State', 'invoicing'), |
|
591 | + 'city' => __('City', 'invoicing'), |
|
592 | + 'zip' => __('ZIP', 'invoicing'), |
|
593 | + 'address' => __('Address', 'invoicing'), |
|
594 | + 'phone' => __('Phone', 'invoicing'), |
|
595 | + 'company' => __('Company', 'invoicing'), |
|
596 | + 'company_id' => __('Company ID', 'invoicing'), |
|
597 | + 'invoices' => __('Invoices', 'invoicing'), |
|
598 | + 'total_raw' => __('Total Spend', 'invoicing'), |
|
599 | + 'signup' => __('Date created', 'invoicing'), |
|
600 | 600 | ); |
601 | 601 | |
602 | 602 | // Output the csv column headers. |
603 | - fputcsv( $output, array_values( $columns ) ); |
|
603 | + fputcsv($output, array_values($columns)); |
|
604 | 604 | |
605 | 605 | // Loop through |
606 | 606 | $table = new WPInv_Customers_Table(); |
607 | - foreach ( $customers as $customer_id ) { |
|
607 | + foreach ($customers as $customer_id) { |
|
608 | 608 | |
609 | - $user = get_user_by( 'id', $customer_id ); |
|
609 | + $user = get_user_by('id', $customer_id); |
|
610 | 610 | $row = array(); |
611 | - if ( empty( $user ) ) { |
|
611 | + if (empty($user)) { |
|
612 | 612 | continue; |
613 | 613 | } |
614 | 614 | |
615 | - foreach ( array_keys( $columns ) as $column ) { |
|
615 | + foreach (array_keys($columns) as $column) { |
|
616 | 616 | |
617 | 617 | $method = 'column_' . $column; |
618 | 618 | |
619 | - if ( 'name' == $column ) { |
|
620 | - $value = sanitize_text_field( $user->display_name ); |
|
621 | - } else if( 'email' == $column ) { |
|
622 | - $value = sanitize_email( $user->user_email ); |
|
623 | - } else if ( is_callable( array( $table, $method ) ) ) { |
|
624 | - $value = strip_tags( $table->$method( $user ) ); |
|
619 | + if ('name' == $column) { |
|
620 | + $value = sanitize_text_field($user->display_name); |
|
621 | + } else if ('email' == $column) { |
|
622 | + $value = sanitize_email($user->user_email); |
|
623 | + } else if (is_callable(array($table, $method))) { |
|
624 | + $value = strip_tags($table->$method($user)); |
|
625 | 625 | } |
626 | 626 | |
627 | - if ( empty( $value ) ) { |
|
628 | - $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
627 | + if (empty($value)) { |
|
628 | + $value = sanitize_text_field(get_user_meta($user->ID, '_wpinv_' . $column, true)); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | $row[] = $value; |
632 | 632 | |
633 | 633 | } |
634 | 634 | |
635 | - fputcsv( $output, $row ); |
|
635 | + fputcsv($output, $row); |
|
636 | 636 | } |
637 | 637 | |
638 | - fclose( $output ); |
|
638 | + fclose($output); |
|
639 | 639 | exit; |
640 | 640 | |
641 | 641 | } |
@@ -645,29 +645,29 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @param array $data |
647 | 647 | */ |
648 | - public function admin_install_plugin( $data ) { |
|
648 | + public function admin_install_plugin($data) { |
|
649 | 649 | |
650 | - if ( ! empty( $data['plugins'] ) ) { |
|
650 | + if (!empty($data['plugins'])) { |
|
651 | 651 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
652 | 652 | wp_cache_flush(); |
653 | 653 | |
654 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
655 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
656 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
657 | - $installed = $upgrader->install( $plugin_zip ); |
|
654 | + foreach ($data['plugins'] as $slug => $file) { |
|
655 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
656 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
657 | + $installed = $upgrader->install($plugin_zip); |
|
658 | 658 | |
659 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
660 | - activate_plugin( $file, '', false, true ); |
|
659 | + if (!is_wp_error($installed) && $installed) { |
|
660 | + activate_plugin($file, '', false, true); |
|
661 | 661 | } else { |
662 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
662 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | } |
666 | 666 | |
667 | 667 | } |
668 | 668 | |
669 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
670 | - wp_safe_redirect( $redirect ); |
|
669 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
670 | + wp_safe_redirect($redirect); |
|
671 | 671 | exit; |
672 | 672 | |
673 | 673 | } |
@@ -677,42 +677,42 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @param array $data |
679 | 679 | */ |
680 | - public function admin_connect_gateway( $data ) { |
|
680 | + public function admin_connect_gateway($data) { |
|
681 | 681 | |
682 | - if ( ! empty( $data['plugin'] ) ) { |
|
682 | + if (!empty($data['plugin'])) { |
|
683 | 683 | |
684 | - $gateway = sanitize_key( $data['plugin'] ); |
|
685 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
684 | + $gateway = sanitize_key($data['plugin']); |
|
685 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
686 | 686 | |
687 | - if ( ! empty( $connect_url ) ) { |
|
688 | - wp_redirect( $connect_url ); |
|
687 | + if (!empty($connect_url)) { |
|
688 | + wp_redirect($connect_url); |
|
689 | 689 | exit; |
690 | 690 | } |
691 | 691 | |
692 | - if ( 'stripe' == $data['plugin'] ) { |
|
692 | + if ('stripe' == $data['plugin']) { |
|
693 | 693 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
694 | 694 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
695 | 695 | wp_cache_flush(); |
696 | 696 | |
697 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
698 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
699 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
700 | - $upgrader->install( $plugin_zip ); |
|
697 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
698 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
699 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
700 | + $upgrader->install($plugin_zip); |
|
701 | 701 | } |
702 | 702 | |
703 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
703 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
704 | 704 | } |
705 | 705 | |
706 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
707 | - if ( ! empty( $connect_url ) ) { |
|
708 | - wp_redirect( $connect_url ); |
|
706 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
707 | + if (!empty($connect_url)) { |
|
708 | + wp_redirect($connect_url); |
|
709 | 709 | exit; |
710 | 710 | } |
711 | 711 | |
712 | 712 | } |
713 | 713 | |
714 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
715 | - wp_safe_redirect( $redirect ); |
|
714 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
715 | + wp_safe_redirect($redirect); |
|
716 | 716 | exit; |
717 | 717 | |
718 | 718 | } |
@@ -726,36 +726,36 @@ discard block |
||
726 | 726 | |
727 | 727 | // Fetch all invoices that have discount codes. |
728 | 728 | $table = $wpdb->prefix . 'getpaid_invoices'; |
729 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
729 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
730 | 730 | |
731 | - foreach ( $invoices as $invoice ) { |
|
731 | + foreach ($invoices as $invoice) { |
|
732 | 732 | |
733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
733 | + $invoice = new WPInv_Invoice($invoice); |
|
734 | 734 | |
735 | - if ( ! $invoice->exists() ) { |
|
735 | + if (!$invoice->exists()) { |
|
736 | 736 | continue; |
737 | 737 | } |
738 | 738 | |
739 | 739 | // Abort if the discount does not exist or does not apply here. |
740 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
741 | - if ( ! $discount->exists() ) { |
|
740 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
741 | + if (!$discount->exists()) { |
|
742 | 742 | continue; |
743 | 743 | } |
744 | 744 | |
745 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
745 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
746 | 746 | $invoice->recalculate_total(); |
747 | 747 | |
748 | - if ( $invoice->get_total_discount() > 0 ) { |
|
748 | + if ($invoice->get_total_discount() > 0) { |
|
749 | 749 | $invoice->save(); |
750 | 750 | } |
751 | 751 | |
752 | 752 | } |
753 | 753 | |
754 | 754 | // Show an admin message. |
755 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
755 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
756 | 756 | |
757 | 757 | // Redirect the admin. |
758 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
758 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
759 | 759 | exit; |
760 | 760 | |
761 | 761 | } |
@@ -767,8 +767,8 @@ discard block |
||
767 | 767 | * @return array |
768 | 768 | */ |
769 | 769 | public function get_notices() { |
770 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
771 | - return is_array( $notices ) ? $notices : array(); |
|
770 | + $notices = get_option('wpinv_admin_notices'); |
|
771 | + return is_array($notices) ? $notices : array(); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @return array |
779 | 779 | */ |
780 | 780 | public function has_notices() { |
781 | - return count( $this->get_notices() ) > 0; |
|
781 | + return count($this->get_notices()) > 0; |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * @since 1.0.19 |
789 | 789 | */ |
790 | 790 | public function clear_notices() { |
791 | - delete_option( 'wpinv_admin_notices' ); |
|
791 | + delete_option('wpinv_admin_notices'); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -797,16 +797,16 @@ discard block |
||
797 | 797 | * @access public |
798 | 798 | * @since 1.0.19 |
799 | 799 | */ |
800 | - public function save_notice( $type, $message ) { |
|
800 | + public function save_notice($type, $message) { |
|
801 | 801 | $notices = $this->get_notices(); |
802 | 802 | |
803 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
804 | - $notices[ $type ] = array(); |
|
803 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
804 | + $notices[$type] = array(); |
|
805 | 805 | } |
806 | 806 | |
807 | - $notices[ $type ][] = $message; |
|
807 | + $notices[$type][] = $message; |
|
808 | 808 | |
809 | - update_option( 'wpinv_admin_notices', $notices ); |
|
809 | + update_option('wpinv_admin_notices', $notices); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -816,8 +816,8 @@ discard block |
||
816 | 816 | * @access public |
817 | 817 | * @since 1.0.19 |
818 | 818 | */ |
819 | - public function show_success( $msg ) { |
|
820 | - $this->save_notice( 'success', $msg ); |
|
819 | + public function show_success($msg) { |
|
820 | + $this->save_notice('success', $msg); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | /** |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | * @param string $msg The message to qeue. |
828 | 828 | * @since 1.0.19 |
829 | 829 | */ |
830 | - public function show_error( $msg ) { |
|
831 | - $this->save_notice( 'error', $msg ); |
|
830 | + public function show_error($msg) { |
|
831 | + $this->save_notice('error', $msg); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | /** |
@@ -838,8 +838,8 @@ discard block |
||
838 | 838 | * @param string $msg The message to qeue. |
839 | 839 | * @since 1.0.19 |
840 | 840 | */ |
841 | - public function show_warning( $msg ) { |
|
842 | - $this->save_notice( 'warning', $msg ); |
|
841 | + public function show_warning($msg) { |
|
842 | + $this->save_notice('warning', $msg); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * @param string $msg The message to qeue. |
850 | 850 | * @since 1.0.19 |
851 | 851 | */ |
852 | - public function show_info( $msg ) { |
|
853 | - $this->save_notice( 'info', $msg ); |
|
852 | + public function show_info($msg) { |
|
853 | + $this->save_notice('info', $msg); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -864,30 +864,30 @@ discard block |
||
864 | 864 | $notices = $this->get_notices(); |
865 | 865 | $this->clear_notices(); |
866 | 866 | |
867 | - foreach ( $notices as $type => $messages ) { |
|
867 | + foreach ($notices as $type => $messages) { |
|
868 | 868 | |
869 | - if ( ! is_array( $messages ) ) { |
|
869 | + if (!is_array($messages)) { |
|
870 | 870 | continue; |
871 | 871 | } |
872 | 872 | |
873 | - $type = sanitize_key( $type ); |
|
874 | - foreach ( $messages as $message ) { |
|
875 | - $message = wp_kses_post( $message ); |
|
873 | + $type = sanitize_key($type); |
|
874 | + foreach ($messages as $message) { |
|
875 | + $message = wp_kses_post($message); |
|
876 | 876 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
877 | 877 | } |
878 | 878 | |
879 | 879 | } |
880 | 880 | |
881 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
881 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
882 | 882 | |
883 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
884 | - $url = wp_nonce_url( |
|
885 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
883 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
884 | + $url = wp_nonce_url( |
|
885 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
886 | 886 | 'getpaid-nonce', |
887 | 887 | 'getpaid-nonce' |
888 | 888 | ); |
889 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
890 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
889 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
890 | + $message2 = __('Generate Pages', 'invoicing'); |
|
891 | 891 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
892 | 892 | break; |
893 | 893 | } |