@@ -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,495 +402,495 @@ 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'; |
|
692 | + if ( 'stripe' == $data['plugin'] ) { |
|
693 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
694 | 694 | |
695 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
696 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
697 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
698 | - $upgrader->install( $plugin_zip ); |
|
699 | - } |
|
695 | + if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
696 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
697 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
698 | + $upgrader->install( $plugin_zip ); |
|
699 | + } |
|
700 | 700 | |
701 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
702 | - } |
|
701 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
702 | + } |
|
703 | 703 | |
704 | - if ( ! empty( $connect_url ) ) { |
|
705 | - wp_redirect( $connect_url ); |
|
706 | - exit; |
|
707 | - } |
|
704 | + if ( ! empty( $connect_url ) ) { |
|
705 | + wp_redirect( $connect_url ); |
|
706 | + exit; |
|
707 | + } |
|
708 | 708 | |
709 | - } |
|
709 | + } |
|
710 | 710 | |
711 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
712 | - wp_safe_redirect( $redirect ); |
|
713 | - exit; |
|
711 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
712 | + wp_safe_redirect( $redirect ); |
|
713 | + exit; |
|
714 | 714 | |
715 | - } |
|
715 | + } |
|
716 | 716 | |
717 | - /** |
|
717 | + /** |
|
718 | 718 | * Recalculates discounts. |
719 | - * |
|
719 | + * |
|
720 | 720 | */ |
721 | 721 | public function admin_recalculate_discounts() { |
722 | - global $wpdb; |
|
722 | + global $wpdb; |
|
723 | 723 | |
724 | - // Fetch all invoices that have discount codes. |
|
725 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
726 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
724 | + // Fetch all invoices that have discount codes. |
|
725 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
726 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
727 | 727 | |
728 | - foreach ( $invoices as $invoice ) { |
|
728 | + foreach ( $invoices as $invoice ) { |
|
729 | 729 | |
730 | - $invoice = new WPInv_Invoice( $invoice ); |
|
730 | + $invoice = new WPInv_Invoice( $invoice ); |
|
731 | 731 | |
732 | - if ( ! $invoice->exists() ) { |
|
733 | - continue; |
|
734 | - } |
|
732 | + if ( ! $invoice->exists() ) { |
|
733 | + continue; |
|
734 | + } |
|
735 | 735 | |
736 | - // Abort if the discount does not exist or does not apply here. |
|
737 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
738 | - if ( ! $discount->exists() ) { |
|
739 | - continue; |
|
740 | - } |
|
736 | + // Abort if the discount does not exist or does not apply here. |
|
737 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
738 | + if ( ! $discount->exists() ) { |
|
739 | + continue; |
|
740 | + } |
|
741 | 741 | |
742 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
743 | - $invoice->recalculate_total(); |
|
742 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
743 | + $invoice->recalculate_total(); |
|
744 | 744 | |
745 | - if ( $invoice->get_total_discount() > 0 ) { |
|
746 | - $invoice->save(); |
|
747 | - } |
|
745 | + if ( $invoice->get_total_discount() > 0 ) { |
|
746 | + $invoice->save(); |
|
747 | + } |
|
748 | 748 | |
749 | - } |
|
749 | + } |
|
750 | 750 | |
751 | - // Show an admin message. |
|
752 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
751 | + // Show an admin message. |
|
752 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
753 | 753 | |
754 | - // Redirect the admin. |
|
755 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
756 | - exit; |
|
754 | + // Redirect the admin. |
|
755 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
756 | + exit; |
|
757 | 757 | |
758 | - } |
|
758 | + } |
|
759 | 759 | |
760 | 760 | /** |
761 | - * Returns an array of admin notices. |
|
762 | - * |
|
763 | - * @since 1.0.19 |
|
761 | + * Returns an array of admin notices. |
|
762 | + * |
|
763 | + * @since 1.0.19 |
|
764 | 764 | * @return array |
765 | - */ |
|
766 | - public function get_notices() { |
|
767 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
765 | + */ |
|
766 | + public function get_notices() { |
|
767 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
768 | 768 | return is_array( $notices ) ? $notices : array(); |
769 | - } |
|
769 | + } |
|
770 | 770 | |
771 | - /** |
|
772 | - * Checks if we have any admin notices. |
|
773 | - * |
|
774 | - * @since 2.0.4 |
|
771 | + /** |
|
772 | + * Checks if we have any admin notices. |
|
773 | + * |
|
774 | + * @since 2.0.4 |
|
775 | 775 | * @return array |
776 | - */ |
|
777 | - public function has_notices() { |
|
778 | - return count( $this->get_notices() ) > 0; |
|
779 | - } |
|
780 | - |
|
781 | - /** |
|
782 | - * Clears all admin notices |
|
783 | - * |
|
784 | - * @access public |
|
785 | - * @since 1.0.19 |
|
786 | - */ |
|
787 | - public function clear_notices() { |
|
788 | - delete_option( 'wpinv_admin_notices' ); |
|
789 | - } |
|
790 | - |
|
791 | - /** |
|
792 | - * Saves a new admin notice |
|
793 | - * |
|
794 | - * @access public |
|
795 | - * @since 1.0.19 |
|
796 | - */ |
|
797 | - public function save_notice( $type, $message ) { |
|
798 | - $notices = $this->get_notices(); |
|
799 | - |
|
800 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
801 | - $notices[ $type ] = array(); |
|
802 | - } |
|
803 | - |
|
804 | - $notices[ $type ][] = $message; |
|
805 | - |
|
806 | - update_option( 'wpinv_admin_notices', $notices ); |
|
807 | - } |
|
808 | - |
|
809 | - /** |
|
810 | - * Displays a success notice |
|
811 | - * |
|
812 | - * @param string $msg The message to qeue. |
|
813 | - * @access public |
|
814 | - * @since 1.0.19 |
|
815 | - */ |
|
816 | - public function show_success( $msg ) { |
|
817 | - $this->save_notice( 'success', $msg ); |
|
818 | - } |
|
819 | - |
|
820 | - /** |
|
821 | - * Displays a error notice |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @param string $msg The message to qeue. |
|
825 | - * @since 1.0.19 |
|
826 | - */ |
|
827 | - public function show_error( $msg ) { |
|
828 | - $this->save_notice( 'error', $msg ); |
|
829 | - } |
|
830 | - |
|
831 | - /** |
|
832 | - * Displays a warning notice |
|
833 | - * |
|
834 | - * @access public |
|
835 | - * @param string $msg The message to qeue. |
|
836 | - * @since 1.0.19 |
|
837 | - */ |
|
838 | - public function show_warning( $msg ) { |
|
839 | - $this->save_notice( 'warning', $msg ); |
|
840 | - } |
|
841 | - |
|
842 | - /** |
|
843 | - * Displays a info notice |
|
844 | - * |
|
845 | - * @access public |
|
846 | - * @param string $msg The message to qeue. |
|
847 | - * @since 1.0.19 |
|
848 | - */ |
|
849 | - public function show_info( $msg ) { |
|
850 | - $this->save_notice( 'info', $msg ); |
|
851 | - } |
|
852 | - |
|
853 | - /** |
|
854 | - * Show notices |
|
855 | - * |
|
856 | - * @access public |
|
857 | - * @since 1.0.19 |
|
858 | - */ |
|
859 | - public function show_notices() { |
|
776 | + */ |
|
777 | + public function has_notices() { |
|
778 | + return count( $this->get_notices() ) > 0; |
|
779 | + } |
|
780 | + |
|
781 | + /** |
|
782 | + * Clears all admin notices |
|
783 | + * |
|
784 | + * @access public |
|
785 | + * @since 1.0.19 |
|
786 | + */ |
|
787 | + public function clear_notices() { |
|
788 | + delete_option( 'wpinv_admin_notices' ); |
|
789 | + } |
|
790 | + |
|
791 | + /** |
|
792 | + * Saves a new admin notice |
|
793 | + * |
|
794 | + * @access public |
|
795 | + * @since 1.0.19 |
|
796 | + */ |
|
797 | + public function save_notice( $type, $message ) { |
|
798 | + $notices = $this->get_notices(); |
|
799 | + |
|
800 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
801 | + $notices[ $type ] = array(); |
|
802 | + } |
|
803 | + |
|
804 | + $notices[ $type ][] = $message; |
|
805 | + |
|
806 | + update_option( 'wpinv_admin_notices', $notices ); |
|
807 | + } |
|
808 | + |
|
809 | + /** |
|
810 | + * Displays a success notice |
|
811 | + * |
|
812 | + * @param string $msg The message to qeue. |
|
813 | + * @access public |
|
814 | + * @since 1.0.19 |
|
815 | + */ |
|
816 | + public function show_success( $msg ) { |
|
817 | + $this->save_notice( 'success', $msg ); |
|
818 | + } |
|
819 | + |
|
820 | + /** |
|
821 | + * Displays a error notice |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @param string $msg The message to qeue. |
|
825 | + * @since 1.0.19 |
|
826 | + */ |
|
827 | + public function show_error( $msg ) { |
|
828 | + $this->save_notice( 'error', $msg ); |
|
829 | + } |
|
830 | + |
|
831 | + /** |
|
832 | + * Displays a warning notice |
|
833 | + * |
|
834 | + * @access public |
|
835 | + * @param string $msg The message to qeue. |
|
836 | + * @since 1.0.19 |
|
837 | + */ |
|
838 | + public function show_warning( $msg ) { |
|
839 | + $this->save_notice( 'warning', $msg ); |
|
840 | + } |
|
841 | + |
|
842 | + /** |
|
843 | + * Displays a info notice |
|
844 | + * |
|
845 | + * @access public |
|
846 | + * @param string $msg The message to qeue. |
|
847 | + * @since 1.0.19 |
|
848 | + */ |
|
849 | + public function show_info( $msg ) { |
|
850 | + $this->save_notice( 'info', $msg ); |
|
851 | + } |
|
852 | + |
|
853 | + /** |
|
854 | + * Show notices |
|
855 | + * |
|
856 | + * @access public |
|
857 | + * @since 1.0.19 |
|
858 | + */ |
|
859 | + public function show_notices() { |
|
860 | 860 | |
861 | 861 | $notices = $this->get_notices(); |
862 | 862 | $this->clear_notices(); |
863 | 863 | |
864 | - foreach ( $notices as $type => $messages ) { |
|
864 | + foreach ( $notices as $type => $messages ) { |
|
865 | 865 | |
866 | - if ( ! is_array( $messages ) ) { |
|
867 | - continue; |
|
868 | - } |
|
866 | + if ( ! is_array( $messages ) ) { |
|
867 | + continue; |
|
868 | + } |
|
869 | 869 | |
870 | 870 | $type = sanitize_key( $type ); |
871 | - foreach ( $messages as $message ) { |
|
871 | + foreach ( $messages as $message ) { |
|
872 | 872 | $message = wp_kses_post( $message ); |
873 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
873 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | } |
877 | 877 | |
878 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
879 | - |
|
880 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
881 | - $url = wp_nonce_url( |
|
882 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
883 | - 'getpaid-nonce', |
|
884 | - 'getpaid-nonce' |
|
885 | - ); |
|
886 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
887 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
888 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
889 | - break; |
|
890 | - } |
|
878 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
879 | + |
|
880 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
881 | + $url = wp_nonce_url( |
|
882 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
883 | + 'getpaid-nonce', |
|
884 | + 'getpaid-nonce' |
|
885 | + ); |
|
886 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
887 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
888 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
889 | + break; |
|
890 | + } |
|
891 | 891 | |
892 | - } |
|
892 | + } |
|
893 | 893 | |
894 | - } |
|
894 | + } |
|
895 | 895 | |
896 | 896 | } |
@@ -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,39 +677,39 @@ 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 | |
695 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
696 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
697 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
698 | - $upgrader->install( $plugin_zip ); |
|
695 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
696 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
697 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
698 | + $upgrader->install($plugin_zip); |
|
699 | 699 | } |
700 | 700 | |
701 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
701 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
702 | 702 | } |
703 | 703 | |
704 | - if ( ! empty( $connect_url ) ) { |
|
705 | - wp_redirect( $connect_url ); |
|
704 | + if (!empty($connect_url)) { |
|
705 | + wp_redirect($connect_url); |
|
706 | 706 | exit; |
707 | 707 | } |
708 | 708 | |
709 | 709 | } |
710 | 710 | |
711 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
712 | - wp_safe_redirect( $redirect ); |
|
711 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
712 | + wp_safe_redirect($redirect); |
|
713 | 713 | exit; |
714 | 714 | |
715 | 715 | } |
@@ -723,36 +723,36 @@ discard block |
||
723 | 723 | |
724 | 724 | // Fetch all invoices that have discount codes. |
725 | 725 | $table = $wpdb->prefix . 'getpaid_invoices'; |
726 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
726 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
727 | 727 | |
728 | - foreach ( $invoices as $invoice ) { |
|
728 | + foreach ($invoices as $invoice) { |
|
729 | 729 | |
730 | - $invoice = new WPInv_Invoice( $invoice ); |
|
730 | + $invoice = new WPInv_Invoice($invoice); |
|
731 | 731 | |
732 | - if ( ! $invoice->exists() ) { |
|
732 | + if (!$invoice->exists()) { |
|
733 | 733 | continue; |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Abort if the discount does not exist or does not apply here. |
737 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
738 | - if ( ! $discount->exists() ) { |
|
737 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
738 | + if (!$discount->exists()) { |
|
739 | 739 | continue; |
740 | 740 | } |
741 | 741 | |
742 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
742 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
743 | 743 | $invoice->recalculate_total(); |
744 | 744 | |
745 | - if ( $invoice->get_total_discount() > 0 ) { |
|
745 | + if ($invoice->get_total_discount() > 0) { |
|
746 | 746 | $invoice->save(); |
747 | 747 | } |
748 | 748 | |
749 | 749 | } |
750 | 750 | |
751 | 751 | // Show an admin message. |
752 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
752 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
753 | 753 | |
754 | 754 | // Redirect the admin. |
755 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
755 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
756 | 756 | exit; |
757 | 757 | |
758 | 758 | } |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | * @return array |
765 | 765 | */ |
766 | 766 | public function get_notices() { |
767 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
768 | - return is_array( $notices ) ? $notices : array(); |
|
767 | + $notices = get_option('wpinv_admin_notices'); |
|
768 | + return is_array($notices) ? $notices : array(); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | * @return array |
776 | 776 | */ |
777 | 777 | public function has_notices() { |
778 | - return count( $this->get_notices() ) > 0; |
|
778 | + return count($this->get_notices()) > 0; |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * @since 1.0.19 |
786 | 786 | */ |
787 | 787 | public function clear_notices() { |
788 | - delete_option( 'wpinv_admin_notices' ); |
|
788 | + delete_option('wpinv_admin_notices'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | /** |
@@ -794,16 +794,16 @@ discard block |
||
794 | 794 | * @access public |
795 | 795 | * @since 1.0.19 |
796 | 796 | */ |
797 | - public function save_notice( $type, $message ) { |
|
797 | + public function save_notice($type, $message) { |
|
798 | 798 | $notices = $this->get_notices(); |
799 | 799 | |
800 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
801 | - $notices[ $type ] = array(); |
|
800 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
801 | + $notices[$type] = array(); |
|
802 | 802 | } |
803 | 803 | |
804 | - $notices[ $type ][] = $message; |
|
804 | + $notices[$type][] = $message; |
|
805 | 805 | |
806 | - update_option( 'wpinv_admin_notices', $notices ); |
|
806 | + update_option('wpinv_admin_notices', $notices); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | * @access public |
814 | 814 | * @since 1.0.19 |
815 | 815 | */ |
816 | - public function show_success( $msg ) { |
|
817 | - $this->save_notice( 'success', $msg ); |
|
816 | + public function show_success($msg) { |
|
817 | + $this->save_notice('success', $msg); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
@@ -824,8 +824,8 @@ discard block |
||
824 | 824 | * @param string $msg The message to qeue. |
825 | 825 | * @since 1.0.19 |
826 | 826 | */ |
827 | - public function show_error( $msg ) { |
|
828 | - $this->save_notice( 'error', $msg ); |
|
827 | + public function show_error($msg) { |
|
828 | + $this->save_notice('error', $msg); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | /** |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | * @param string $msg The message to qeue. |
836 | 836 | * @since 1.0.19 |
837 | 837 | */ |
838 | - public function show_warning( $msg ) { |
|
839 | - $this->save_notice( 'warning', $msg ); |
|
838 | + public function show_warning($msg) { |
|
839 | + $this->save_notice('warning', $msg); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -846,8 +846,8 @@ discard block |
||
846 | 846 | * @param string $msg The message to qeue. |
847 | 847 | * @since 1.0.19 |
848 | 848 | */ |
849 | - public function show_info( $msg ) { |
|
850 | - $this->save_notice( 'info', $msg ); |
|
849 | + public function show_info($msg) { |
|
850 | + $this->save_notice('info', $msg); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | /** |
@@ -861,30 +861,30 @@ discard block |
||
861 | 861 | $notices = $this->get_notices(); |
862 | 862 | $this->clear_notices(); |
863 | 863 | |
864 | - foreach ( $notices as $type => $messages ) { |
|
864 | + foreach ($notices as $type => $messages) { |
|
865 | 865 | |
866 | - if ( ! is_array( $messages ) ) { |
|
866 | + if (!is_array($messages)) { |
|
867 | 867 | continue; |
868 | 868 | } |
869 | 869 | |
870 | - $type = sanitize_key( $type ); |
|
871 | - foreach ( $messages as $message ) { |
|
872 | - $message = wp_kses_post( $message ); |
|
870 | + $type = sanitize_key($type); |
|
871 | + foreach ($messages as $message) { |
|
872 | + $message = wp_kses_post($message); |
|
873 | 873 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
874 | 874 | } |
875 | 875 | |
876 | 876 | } |
877 | 877 | |
878 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
878 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
879 | 879 | |
880 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
881 | - $url = wp_nonce_url( |
|
882 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
880 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
881 | + $url = wp_nonce_url( |
|
882 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
883 | 883 | 'getpaid-nonce', |
884 | 884 | 'getpaid-nonce' |
885 | 885 | ); |
886 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
887 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
886 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
887 | + $message2 = __('Generate Pages', 'invoicing'); |
|
888 | 888 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
889 | 889 | break; |
890 | 890 | } |
@@ -13,669 +13,669 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | - |
|
30 | - // Invoice table columns. |
|
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - |
|
34 | - // Items table columns. |
|
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | - |
|
42 | - // Payment forms columns. |
|
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | - |
|
47 | - // Discount table columns. |
|
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | - |
|
51 | - // Deleting posts. |
|
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | - |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Post updated messages. |
|
60 | - */ |
|
61 | - public static function post_updated_messages( $messages ) { |
|
62 | - global $post; |
|
63 | - |
|
64 | - $messages['wpi_discount'] = array( |
|
65 | - 0 => '', |
|
66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
76 | - ); |
|
77 | - |
|
78 | - $messages['wpi_payment_form'] = array( |
|
79 | - 0 => '', |
|
80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
90 | - ); |
|
91 | - |
|
92 | - return $messages; |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Post row actions. |
|
98 | - */ |
|
99 | - public static function post_row_actions( $actions, $post ) { |
|
100 | - |
|
101 | - $post = get_post( $post ); |
|
102 | - |
|
103 | - // We do not want to edit the default payment form. |
|
104 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
105 | - |
|
106 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
107 | - unset( $actions['trash'] ); |
|
108 | - unset( $actions['inline hide-if-no-js'] ); |
|
109 | - } |
|
110 | - |
|
111 | - $actions['duplicate'] = sprintf( |
|
112 | - '<a href="%1$s">%2$s</a>', |
|
113 | - esc_url( |
|
114 | - wp_nonce_url( |
|
115 | - add_query_arg( |
|
116 | - array( |
|
117 | - 'getpaid-admin-action' => 'duplicate_form', |
|
118 | - 'form_id' => $post->ID |
|
119 | - ) |
|
120 | - ), |
|
121 | - 'getpaid-nonce', |
|
122 | - 'getpaid-nonce' |
|
123 | - ) |
|
124 | - ), |
|
125 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
126 | - ); |
|
127 | - |
|
128 | - } |
|
129 | - |
|
130 | - return $actions; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
19 | + |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
22 | + |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | + |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | + |
|
30 | + // Invoice table columns. |
|
31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | + |
|
34 | + // Items table columns. |
|
35 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | + |
|
42 | + // Payment forms columns. |
|
43 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | + |
|
47 | + // Discount table columns. |
|
48 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + |
|
51 | + // Deleting posts. |
|
52 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + |
|
55 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Post updated messages. |
|
60 | + */ |
|
61 | + public static function post_updated_messages( $messages ) { |
|
62 | + global $post; |
|
63 | + |
|
64 | + $messages['wpi_discount'] = array( |
|
65 | + 0 => '', |
|
66 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
76 | + ); |
|
77 | + |
|
78 | + $messages['wpi_payment_form'] = array( |
|
79 | + 0 => '', |
|
80 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
90 | + ); |
|
91 | + |
|
92 | + return $messages; |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Post row actions. |
|
98 | + */ |
|
99 | + public static function post_row_actions( $actions, $post ) { |
|
100 | + |
|
101 | + $post = get_post( $post ); |
|
102 | + |
|
103 | + // We do not want to edit the default payment form. |
|
104 | + if ( 'wpi_payment_form' == $post->post_type ) { |
|
105 | + |
|
106 | + if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
107 | + unset( $actions['trash'] ); |
|
108 | + unset( $actions['inline hide-if-no-js'] ); |
|
109 | + } |
|
110 | + |
|
111 | + $actions['duplicate'] = sprintf( |
|
112 | + '<a href="%1$s">%2$s</a>', |
|
113 | + esc_url( |
|
114 | + wp_nonce_url( |
|
115 | + add_query_arg( |
|
116 | + array( |
|
117 | + 'getpaid-admin-action' => 'duplicate_form', |
|
118 | + 'form_id' => $post->ID |
|
119 | + ) |
|
120 | + ), |
|
121 | + 'getpaid-nonce', |
|
122 | + 'getpaid-nonce' |
|
123 | + ) |
|
124 | + ), |
|
125 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
126 | + ); |
|
127 | + |
|
128 | + } |
|
129 | + |
|
130 | + return $actions; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | 134 | * Remove bulk edit option from admin side quote listing |
135 | 135 | * |
136 | 136 | * @since 1.0.0 |
137 | 137 | * @param array $actions post actions |
138 | - * @param WP_Post $post |
|
138 | + * @param WP_Post $post |
|
139 | 139 | * @return array $actions actions without edit option |
140 | 140 | */ |
141 | 141 | public static function filter_invoice_row_actions( $actions, $post ) { |
142 | 142 | |
143 | 143 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
144 | 144 | |
145 | - $actions = array(); |
|
146 | - $invoice = new WPInv_Invoice( $post ); |
|
147 | - |
|
148 | - $actions['edit'] = sprintf( |
|
149 | - '<a href="%1$s">%2$s</a>', |
|
150 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
151 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
152 | - ); |
|
153 | - |
|
154 | - if ( ! $invoice->is_draft() ) { |
|
155 | - |
|
156 | - $actions['view'] = sprintf( |
|
157 | - '<a href="%1$s">%2$s</a>', |
|
158 | - esc_url( $invoice->get_view_url() ), |
|
159 | - sprintf( |
|
160 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
161 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
162 | - ) |
|
163 | - ); |
|
164 | - |
|
165 | - $actions['send'] = sprintf( |
|
166 | - '<a href="%1$s">%2$s</a>', |
|
167 | - esc_url( |
|
168 | - wp_nonce_url( |
|
169 | - add_query_arg( |
|
170 | - array( |
|
171 | - 'getpaid-admin-action' => 'send_invoice', |
|
172 | - 'invoice_id' => $invoice->get_id() |
|
173 | - ) |
|
174 | - ), |
|
175 | - 'getpaid-nonce', |
|
176 | - 'getpaid-nonce' |
|
177 | - ) |
|
178 | - ), |
|
179 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
180 | - ); |
|
181 | - |
|
182 | - } |
|
145 | + $actions = array(); |
|
146 | + $invoice = new WPInv_Invoice( $post ); |
|
147 | + |
|
148 | + $actions['edit'] = sprintf( |
|
149 | + '<a href="%1$s">%2$s</a>', |
|
150 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
151 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
152 | + ); |
|
153 | + |
|
154 | + if ( ! $invoice->is_draft() ) { |
|
155 | + |
|
156 | + $actions['view'] = sprintf( |
|
157 | + '<a href="%1$s">%2$s</a>', |
|
158 | + esc_url( $invoice->get_view_url() ), |
|
159 | + sprintf( |
|
160 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
161 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
162 | + ) |
|
163 | + ); |
|
164 | + |
|
165 | + $actions['send'] = sprintf( |
|
166 | + '<a href="%1$s">%2$s</a>', |
|
167 | + esc_url( |
|
168 | + wp_nonce_url( |
|
169 | + add_query_arg( |
|
170 | + array( |
|
171 | + 'getpaid-admin-action' => 'send_invoice', |
|
172 | + 'invoice_id' => $invoice->get_id() |
|
173 | + ) |
|
174 | + ), |
|
175 | + 'getpaid-nonce', |
|
176 | + 'getpaid-nonce' |
|
177 | + ) |
|
178 | + ), |
|
179 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
180 | + ); |
|
181 | + |
|
182 | + } |
|
183 | 183 | |
184 | 184 | } |
185 | 185 | |
186 | 186 | return $actions; |
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Returns an array of invoice table columns. |
|
191 | - */ |
|
192 | - public static function invoice_columns( $columns ) { |
|
193 | - |
|
194 | - $columns = array( |
|
195 | - 'cb' => $columns['cb'], |
|
196 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
197 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
198 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
199 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
200 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
201 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
202 | - 'status' => __( 'Status', 'invoicing' ), |
|
203 | - ); |
|
204 | - |
|
205 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Displays invoice table columns. |
|
210 | - */ |
|
211 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
212 | - |
|
213 | - $invoice = new WPInv_Invoice( $post_id ); |
|
214 | - |
|
215 | - switch ( $column_name ) { |
|
216 | - |
|
217 | - case 'invoice_date' : |
|
218 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
219 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
220 | - echo "<span title='$date_time'>$date</span>"; |
|
221 | - break; |
|
222 | - |
|
223 | - case 'payment_date' : |
|
224 | - |
|
225 | - if ( $invoice->is_paid() ) { |
|
226 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
227 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
228 | - echo "<span title='$date_time'>$date</span>"; |
|
229 | - } else { |
|
230 | - echo "—"; |
|
231 | - } |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Returns an array of invoice table columns. |
|
191 | + */ |
|
192 | + public static function invoice_columns( $columns ) { |
|
193 | + |
|
194 | + $columns = array( |
|
195 | + 'cb' => $columns['cb'], |
|
196 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
197 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
198 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
199 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
200 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
201 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
202 | + 'status' => __( 'Status', 'invoicing' ), |
|
203 | + ); |
|
204 | + |
|
205 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Displays invoice table columns. |
|
210 | + */ |
|
211 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
212 | + |
|
213 | + $invoice = new WPInv_Invoice( $post_id ); |
|
214 | + |
|
215 | + switch ( $column_name ) { |
|
216 | + |
|
217 | + case 'invoice_date' : |
|
218 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
219 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
220 | + echo "<span title='$date_time'>$date</span>"; |
|
221 | + break; |
|
222 | + |
|
223 | + case 'payment_date' : |
|
224 | + |
|
225 | + if ( $invoice->is_paid() ) { |
|
226 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
227 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
228 | + echo "<span title='$date_time'>$date</span>"; |
|
229 | + } else { |
|
230 | + echo "—"; |
|
231 | + } |
|
232 | 232 | |
233 | - break; |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'amount' : |
|
235 | + case 'amount' : |
|
236 | 236 | |
237 | - $amount = $invoice->get_total(); |
|
238 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
237 | + $amount = $invoice->get_total(); |
|
238 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
239 | 239 | |
240 | - if ( $invoice->is_refunded() ) { |
|
241 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
242 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
243 | - } else { |
|
240 | + if ( $invoice->is_refunded() ) { |
|
241 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
242 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
243 | + } else { |
|
244 | 244 | |
245 | - $discount = $invoice->get_total_discount(); |
|
245 | + $discount = $invoice->get_total_discount(); |
|
246 | 246 | |
247 | - if ( ! empty( $discount ) ) { |
|
248 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
249 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
250 | - } else { |
|
251 | - echo $formated_amount; |
|
252 | - } |
|
247 | + if ( ! empty( $discount ) ) { |
|
248 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
249 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
250 | + } else { |
|
251 | + echo $formated_amount; |
|
252 | + } |
|
253 | 253 | |
254 | - } |
|
254 | + } |
|
255 | 255 | |
256 | - break; |
|
256 | + break; |
|
257 | 257 | |
258 | - case 'status' : |
|
259 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
260 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
258 | + case 'status' : |
|
259 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
260 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
261 | 261 | |
262 | - // If it is paid, show the gateway title. |
|
263 | - if ( $invoice->is_paid() ) { |
|
264 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
265 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
262 | + // If it is paid, show the gateway title. |
|
263 | + if ( $invoice->is_paid() ) { |
|
264 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
265 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
266 | 266 | |
267 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
268 | - } else { |
|
269 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
270 | - } |
|
267 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
268 | + } else { |
|
269 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
270 | + } |
|
271 | 271 | |
272 | - // If it is not paid, display the overdue and view status. |
|
273 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
272 | + // If it is not paid, display the overdue and view status. |
|
273 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
274 | 274 | |
275 | - // Invoice view status. |
|
276 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
277 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
278 | - } else { |
|
279 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
280 | - } |
|
275 | + // Invoice view status. |
|
276 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
277 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
278 | + } else { |
|
279 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
280 | + } |
|
281 | 281 | |
282 | - // Display the overview status. |
|
283 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
284 | - $due_date = $invoice->get_due_date(); |
|
285 | - $fomatted = getpaid_format_date( $due_date ); |
|
282 | + // Display the overview status. |
|
283 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
284 | + $due_date = $invoice->get_due_date(); |
|
285 | + $fomatted = getpaid_format_date( $due_date ); |
|
286 | 286 | |
287 | - if ( ! empty( $fomatted ) ) { |
|
288 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
289 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
290 | - } |
|
291 | - } |
|
287 | + if ( ! empty( $fomatted ) ) { |
|
288 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
289 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
290 | + } |
|
291 | + } |
|
292 | 292 | |
293 | - } |
|
293 | + } |
|
294 | 294 | |
295 | - break; |
|
295 | + break; |
|
296 | 296 | |
297 | - case 'recurring': |
|
297 | + case 'recurring': |
|
298 | 298 | |
299 | - if ( $invoice->is_recurring() ) { |
|
300 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
301 | - } else { |
|
302 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
303 | - } |
|
304 | - break; |
|
299 | + if ( $invoice->is_recurring() ) { |
|
300 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
301 | + } else { |
|
302 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
303 | + } |
|
304 | + break; |
|
305 | 305 | |
306 | - case 'number' : |
|
306 | + case 'number' : |
|
307 | 307 | |
308 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
309 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
310 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
308 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
309 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
310 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
311 | 311 | |
312 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
312 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
313 | 313 | |
314 | - break; |
|
314 | + break; |
|
315 | 315 | |
316 | - case 'customer' : |
|
316 | + case 'customer' : |
|
317 | 317 | |
318 | - $customer_name = $invoice->get_user_full_name(); |
|
318 | + $customer_name = $invoice->get_user_full_name(); |
|
319 | 319 | |
320 | - if ( empty( $customer_name ) ) { |
|
321 | - $customer_name = $invoice->get_email(); |
|
322 | - } |
|
320 | + if ( empty( $customer_name ) ) { |
|
321 | + $customer_name = $invoice->get_email(); |
|
322 | + } |
|
323 | 323 | |
324 | - if ( ! empty( $customer_name ) ) { |
|
325 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
326 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
327 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
328 | - } else { |
|
329 | - echo '<div>—</div>'; |
|
330 | - } |
|
324 | + if ( ! empty( $customer_name ) ) { |
|
325 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
326 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
327 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
328 | + } else { |
|
329 | + echo '<div>—</div>'; |
|
330 | + } |
|
331 | 331 | |
332 | - break; |
|
332 | + break; |
|
333 | 333 | |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - } |
|
336 | + } |
|
337 | 337 | |
338 | - /** |
|
339 | - * Returns an array of payment forms table columns. |
|
340 | - */ |
|
341 | - public static function payment_form_columns( $columns ) { |
|
338 | + /** |
|
339 | + * Returns an array of payment forms table columns. |
|
340 | + */ |
|
341 | + public static function payment_form_columns( $columns ) { |
|
342 | 342 | |
343 | - $columns = array( |
|
344 | - 'cb' => $columns['cb'], |
|
345 | - 'title' => __( 'Name', 'invoicing' ), |
|
346 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
347 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
348 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
349 | - 'items' => __( 'Items', 'invoicing' ), |
|
350 | - 'date' => __( 'Date', 'invoicing' ), |
|
351 | - ); |
|
343 | + $columns = array( |
|
344 | + 'cb' => $columns['cb'], |
|
345 | + 'title' => __( 'Name', 'invoicing' ), |
|
346 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
347 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
348 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
349 | + 'items' => __( 'Items', 'invoicing' ), |
|
350 | + 'date' => __( 'Date', 'invoicing' ), |
|
351 | + ); |
|
352 | 352 | |
353 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
353 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
354 | 354 | |
355 | - } |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * Displays payment form table columns. |
|
359 | - */ |
|
360 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
357 | + /** |
|
358 | + * Displays payment form table columns. |
|
359 | + */ |
|
360 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
361 | 361 | |
362 | - // Retrieve the payment form. |
|
363 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
362 | + // Retrieve the payment form. |
|
363 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
364 | 364 | |
365 | - switch ( $column_name ) { |
|
365 | + switch ( $column_name ) { |
|
366 | 366 | |
367 | - case 'earnings' : |
|
368 | - echo wpinv_price( $form->get_earned() ); |
|
369 | - break; |
|
367 | + case 'earnings' : |
|
368 | + echo wpinv_price( $form->get_earned() ); |
|
369 | + break; |
|
370 | 370 | |
371 | - case 'refunds' : |
|
372 | - echo wpinv_price( $form->get_refunded() ); |
|
373 | - break; |
|
371 | + case 'refunds' : |
|
372 | + echo wpinv_price( $form->get_refunded() ); |
|
373 | + break; |
|
374 | 374 | |
375 | - case 'refunds' : |
|
376 | - echo wpinv_price( $form->get_refunded() ); |
|
377 | - break; |
|
375 | + case 'refunds' : |
|
376 | + echo wpinv_price( $form->get_refunded() ); |
|
377 | + break; |
|
378 | 378 | |
379 | - case 'shortcode' : |
|
379 | + case 'shortcode' : |
|
380 | 380 | |
381 | - if ( $form->is_default() ) { |
|
382 | - echo '—'; |
|
383 | - } else { |
|
384 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
385 | - } |
|
381 | + if ( $form->is_default() ) { |
|
382 | + echo '—'; |
|
383 | + } else { |
|
384 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
385 | + } |
|
386 | 386 | |
387 | - break; |
|
387 | + break; |
|
388 | 388 | |
389 | - case 'items' : |
|
389 | + case 'items' : |
|
390 | 390 | |
391 | - $items = $form->get_items(); |
|
391 | + $items = $form->get_items(); |
|
392 | 392 | |
393 | - if ( $form->is_default() || empty( $items ) ) { |
|
394 | - echo '—'; |
|
395 | - return; |
|
396 | - } |
|
393 | + if ( $form->is_default() || empty( $items ) ) { |
|
394 | + echo '—'; |
|
395 | + return; |
|
396 | + } |
|
397 | 397 | |
398 | - $_items = array(); |
|
398 | + $_items = array(); |
|
399 | 399 | |
400 | - foreach ( $items as $item ) { |
|
401 | - $url = $item->get_edit_url(); |
|
400 | + foreach ( $items as $item ) { |
|
401 | + $url = $item->get_edit_url(); |
|
402 | 402 | |
403 | - if ( empty( $url ) ) { |
|
404 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
405 | - } else { |
|
406 | - $_items[] = sprintf( |
|
407 | - '<a href="%s">%s</a>', |
|
408 | - esc_url( $url ), |
|
409 | - sanitize_text_field( $item->get_name() ) |
|
410 | - ); |
|
411 | - } |
|
403 | + if ( empty( $url ) ) { |
|
404 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
405 | + } else { |
|
406 | + $_items[] = sprintf( |
|
407 | + '<a href="%s">%s</a>', |
|
408 | + esc_url( $url ), |
|
409 | + sanitize_text_field( $item->get_name() ) |
|
410 | + ); |
|
411 | + } |
|
412 | 412 | |
413 | - } |
|
413 | + } |
|
414 | 414 | |
415 | - echo implode( '<br>', $_items ); |
|
415 | + echo implode( '<br>', $_items ); |
|
416 | 416 | |
417 | - break; |
|
417 | + break; |
|
418 | 418 | |
419 | - } |
|
419 | + } |
|
420 | 420 | |
421 | - } |
|
421 | + } |
|
422 | 422 | |
423 | - /** |
|
424 | - * Filters post states. |
|
425 | - */ |
|
426 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
423 | + /** |
|
424 | + * Filters post states. |
|
425 | + */ |
|
426 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
427 | 427 | |
428 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
429 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
430 | - } |
|
428 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
429 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
430 | + } |
|
431 | 431 | |
432 | - return $post_states; |
|
433 | - |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * Returns an array of coupon table columns. |
|
438 | - */ |
|
439 | - public static function discount_columns( $columns ) { |
|
440 | - |
|
441 | - $columns = array( |
|
442 | - 'cb' => $columns['cb'], |
|
443 | - 'title' => __( 'Name', 'invoicing' ), |
|
444 | - 'code' => __( 'Code', 'invoicing' ), |
|
445 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
446 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
447 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
448 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
449 | - ); |
|
450 | - |
|
451 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * Filters post states. |
|
456 | - */ |
|
457 | - public static function filter_discount_state( $post_states, $post ) { |
|
458 | - |
|
459 | - if ( 'wpi_discount' == $post->post_type ) { |
|
460 | - |
|
461 | - $discount = new WPInv_Discount( $post ); |
|
462 | - |
|
463 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
464 | - |
|
465 | - if ( $status != 'publish' ) { |
|
466 | - return array( |
|
467 | - 'discount_status' => wpinv_discount_status( $status ), |
|
468 | - ); |
|
469 | - } |
|
470 | - |
|
471 | - return array(); |
|
472 | - |
|
473 | - } |
|
474 | - |
|
475 | - return $post_states; |
|
476 | - |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * Returns an array of items table columns. |
|
481 | - */ |
|
482 | - public static function item_columns( $columns ) { |
|
483 | - |
|
484 | - $columns = array( |
|
485 | - 'cb' => $columns['cb'], |
|
486 | - 'title' => __( 'Name', 'invoicing' ), |
|
487 | - 'price' => __( 'Price', 'invoicing' ), |
|
488 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
489 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
490 | - 'type' => __( 'Type', 'invoicing' ), |
|
491 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
492 | - ); |
|
493 | - |
|
494 | - if ( ! wpinv_use_taxes() ) { |
|
495 | - unset( $columns['vat_rule'] ); |
|
496 | - unset( $columns['vat_class'] ); |
|
497 | - } |
|
498 | - |
|
499 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Returns an array of sortable items table columns. |
|
504 | - */ |
|
505 | - public static function sortable_item_columns( $columns ) { |
|
506 | - |
|
507 | - return array_merge( |
|
508 | - $columns, |
|
509 | - array( |
|
510 | - 'price' => 'price', |
|
511 | - 'vat_rule' => 'vat_rule', |
|
512 | - 'vat_class' => 'vat_class', |
|
513 | - 'type' => 'type', |
|
514 | - ) |
|
515 | - ); |
|
516 | - |
|
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * Displays items table columns. |
|
521 | - */ |
|
522 | - public static function display_item_columns( $column_name, $post_id ) { |
|
432 | + return $post_states; |
|
433 | + |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * Returns an array of coupon table columns. |
|
438 | + */ |
|
439 | + public static function discount_columns( $columns ) { |
|
440 | + |
|
441 | + $columns = array( |
|
442 | + 'cb' => $columns['cb'], |
|
443 | + 'title' => __( 'Name', 'invoicing' ), |
|
444 | + 'code' => __( 'Code', 'invoicing' ), |
|
445 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
446 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
447 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
448 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
449 | + ); |
|
450 | + |
|
451 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * Filters post states. |
|
456 | + */ |
|
457 | + public static function filter_discount_state( $post_states, $post ) { |
|
458 | + |
|
459 | + if ( 'wpi_discount' == $post->post_type ) { |
|
460 | + |
|
461 | + $discount = new WPInv_Discount( $post ); |
|
462 | + |
|
463 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
464 | + |
|
465 | + if ( $status != 'publish' ) { |
|
466 | + return array( |
|
467 | + 'discount_status' => wpinv_discount_status( $status ), |
|
468 | + ); |
|
469 | + } |
|
470 | + |
|
471 | + return array(); |
|
472 | + |
|
473 | + } |
|
474 | + |
|
475 | + return $post_states; |
|
476 | + |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * Returns an array of items table columns. |
|
481 | + */ |
|
482 | + public static function item_columns( $columns ) { |
|
483 | + |
|
484 | + $columns = array( |
|
485 | + 'cb' => $columns['cb'], |
|
486 | + 'title' => __( 'Name', 'invoicing' ), |
|
487 | + 'price' => __( 'Price', 'invoicing' ), |
|
488 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
489 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
490 | + 'type' => __( 'Type', 'invoicing' ), |
|
491 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
492 | + ); |
|
493 | + |
|
494 | + if ( ! wpinv_use_taxes() ) { |
|
495 | + unset( $columns['vat_rule'] ); |
|
496 | + unset( $columns['vat_class'] ); |
|
497 | + } |
|
498 | + |
|
499 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * Returns an array of sortable items table columns. |
|
504 | + */ |
|
505 | + public static function sortable_item_columns( $columns ) { |
|
506 | + |
|
507 | + return array_merge( |
|
508 | + $columns, |
|
509 | + array( |
|
510 | + 'price' => 'price', |
|
511 | + 'vat_rule' => 'vat_rule', |
|
512 | + 'vat_class' => 'vat_class', |
|
513 | + 'type' => 'type', |
|
514 | + ) |
|
515 | + ); |
|
516 | + |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * Displays items table columns. |
|
521 | + */ |
|
522 | + public static function display_item_columns( $column_name, $post_id ) { |
|
523 | 523 | |
524 | - $item = new WPInv_Item( $post_id ); |
|
524 | + $item = new WPInv_Item( $post_id ); |
|
525 | 525 | |
526 | - switch ( $column_name ) { |
|
526 | + switch ( $column_name ) { |
|
527 | 527 | |
528 | - case 'price' : |
|
528 | + case 'price' : |
|
529 | 529 | |
530 | - if ( ! $item->is_recurring() ) { |
|
531 | - echo $item->get_the_price(); |
|
532 | - break; |
|
533 | - } |
|
530 | + if ( ! $item->is_recurring() ) { |
|
531 | + echo $item->get_the_price(); |
|
532 | + break; |
|
533 | + } |
|
534 | 534 | |
535 | - $price = wp_sprintf( |
|
536 | - __( '%s / %s', 'invoicing' ), |
|
537 | - $item->get_the_price(), |
|
538 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
539 | - ); |
|
535 | + $price = wp_sprintf( |
|
536 | + __( '%s / %s', 'invoicing' ), |
|
537 | + $item->get_the_price(), |
|
538 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
539 | + ); |
|
540 | 540 | |
541 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
542 | - echo $price; |
|
543 | - break; |
|
544 | - } |
|
541 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
542 | + echo $price; |
|
543 | + break; |
|
544 | + } |
|
545 | 545 | |
546 | - echo $item->get_the_initial_price(); |
|
546 | + echo $item->get_the_initial_price(); |
|
547 | 547 | |
548 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
549 | - break; |
|
548 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
549 | + break; |
|
550 | 550 | |
551 | - case 'vat_rule' : |
|
552 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
553 | - break; |
|
551 | + case 'vat_rule' : |
|
552 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
553 | + break; |
|
554 | 554 | |
555 | - case 'vat_class' : |
|
556 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
557 | - break; |
|
555 | + case 'vat_class' : |
|
556 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
557 | + break; |
|
558 | 558 | |
559 | - case 'shortcode' : |
|
560 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
561 | - break; |
|
559 | + case 'shortcode' : |
|
560 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
561 | + break; |
|
562 | 562 | |
563 | - case 'type' : |
|
564 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
565 | - break; |
|
563 | + case 'type' : |
|
564 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
565 | + break; |
|
566 | 566 | |
567 | - } |
|
567 | + } |
|
568 | 568 | |
569 | - } |
|
569 | + } |
|
570 | 570 | |
571 | - /** |
|
572 | - * Lets users filter items using taxes. |
|
573 | - */ |
|
574 | - public static function add_item_filters( $post_type ) { |
|
571 | + /** |
|
572 | + * Lets users filter items using taxes. |
|
573 | + */ |
|
574 | + public static function add_item_filters( $post_type ) { |
|
575 | 575 | |
576 | - // Abort if we're not dealing with items. |
|
577 | - if ( $post_type != 'wpi_item' ) { |
|
578 | - return; |
|
579 | - } |
|
576 | + // Abort if we're not dealing with items. |
|
577 | + if ( $post_type != 'wpi_item' ) { |
|
578 | + return; |
|
579 | + } |
|
580 | 580 | |
581 | - // Filter by vat rules. |
|
582 | - if ( wpinv_use_taxes() ) { |
|
581 | + // Filter by vat rules. |
|
582 | + if ( wpinv_use_taxes() ) { |
|
583 | 583 | |
584 | - // Sanitize selected vat rule. |
|
585 | - $vat_rule = ''; |
|
586 | - $vat_rules = getpaid_get_tax_rules(); |
|
587 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
588 | - $vat_rule = $_GET['vat_rule']; |
|
589 | - } |
|
590 | - |
|
591 | - // Filter by VAT rule. |
|
592 | - echo wpinv_html_select( |
|
593 | - array( |
|
594 | - 'options' => array_merge( |
|
595 | - array( |
|
596 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
597 | - ), |
|
598 | - $vat_rules |
|
599 | - ), |
|
600 | - 'name' => 'vat_rule', |
|
601 | - 'id' => 'vat_rule', |
|
602 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
603 | - 'show_option_all' => false, |
|
604 | - 'show_option_none' => false, |
|
605 | - ) |
|
606 | - ); |
|
607 | - |
|
608 | - // Filter by VAT class. |
|
584 | + // Sanitize selected vat rule. |
|
585 | + $vat_rule = ''; |
|
586 | + $vat_rules = getpaid_get_tax_rules(); |
|
587 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
588 | + $vat_rule = $_GET['vat_rule']; |
|
589 | + } |
|
590 | + |
|
591 | + // Filter by VAT rule. |
|
592 | + echo wpinv_html_select( |
|
593 | + array( |
|
594 | + 'options' => array_merge( |
|
595 | + array( |
|
596 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
597 | + ), |
|
598 | + $vat_rules |
|
599 | + ), |
|
600 | + 'name' => 'vat_rule', |
|
601 | + 'id' => 'vat_rule', |
|
602 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
603 | + 'show_option_all' => false, |
|
604 | + 'show_option_none' => false, |
|
605 | + ) |
|
606 | + ); |
|
607 | + |
|
608 | + // Filter by VAT class. |
|
609 | 609 | |
610 | - // Sanitize selected vat rule. |
|
611 | - $vat_class = ''; |
|
612 | - $vat_classes = getpaid_get_tax_classes(); |
|
613 | - if ( isset( $_GET['vat_class'] ) ) { |
|
614 | - $vat_class = $_GET['vat_class']; |
|
615 | - } |
|
616 | - |
|
617 | - echo wpinv_html_select( |
|
618 | - array( |
|
619 | - 'options' => array_merge( |
|
620 | - array( |
|
621 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
622 | - ), |
|
623 | - $vat_classes |
|
624 | - ), |
|
625 | - 'name' => 'vat_class', |
|
626 | - 'id' => 'vat_class', |
|
627 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
628 | - 'show_option_all' => false, |
|
629 | - 'show_option_none' => false, |
|
630 | - ) |
|
631 | - ); |
|
632 | - |
|
633 | - } |
|
634 | - |
|
635 | - // Filter by item type. |
|
636 | - $type = ''; |
|
637 | - if ( isset( $_GET['type'] ) ) { |
|
638 | - $type = $_GET['type']; |
|
639 | - } |
|
640 | - |
|
641 | - echo wpinv_html_select( |
|
642 | - array( |
|
643 | - 'options' => array_merge( |
|
644 | - array( |
|
645 | - '' => __( 'All item types', 'invoicing' ) |
|
646 | - ), |
|
647 | - wpinv_get_item_types() |
|
648 | - ), |
|
649 | - 'name' => 'type', |
|
650 | - 'id' => 'type', |
|
651 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
652 | - 'show_option_all' => false, |
|
653 | - 'show_option_none' => false, |
|
654 | - ) |
|
655 | - ); |
|
656 | - |
|
657 | - } |
|
658 | - |
|
659 | - /** |
|
660 | - * Filters the item query. |
|
661 | - */ |
|
662 | - public static function filter_item_query( $query ) { |
|
663 | - |
|
664 | - // modify the query only if it admin and main query. |
|
665 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
666 | - return $query; |
|
667 | - } |
|
668 | - |
|
669 | - // we want to modify the query for our items. |
|
670 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
671 | - return $query; |
|
672 | - } |
|
673 | - |
|
674 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
675 | - $query->query_vars['meta_query'] = array(); |
|
676 | - } |
|
677 | - |
|
678 | - // Filter vat rule type |
|
610 | + // Sanitize selected vat rule. |
|
611 | + $vat_class = ''; |
|
612 | + $vat_classes = getpaid_get_tax_classes(); |
|
613 | + if ( isset( $_GET['vat_class'] ) ) { |
|
614 | + $vat_class = $_GET['vat_class']; |
|
615 | + } |
|
616 | + |
|
617 | + echo wpinv_html_select( |
|
618 | + array( |
|
619 | + 'options' => array_merge( |
|
620 | + array( |
|
621 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
622 | + ), |
|
623 | + $vat_classes |
|
624 | + ), |
|
625 | + 'name' => 'vat_class', |
|
626 | + 'id' => 'vat_class', |
|
627 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
628 | + 'show_option_all' => false, |
|
629 | + 'show_option_none' => false, |
|
630 | + ) |
|
631 | + ); |
|
632 | + |
|
633 | + } |
|
634 | + |
|
635 | + // Filter by item type. |
|
636 | + $type = ''; |
|
637 | + if ( isset( $_GET['type'] ) ) { |
|
638 | + $type = $_GET['type']; |
|
639 | + } |
|
640 | + |
|
641 | + echo wpinv_html_select( |
|
642 | + array( |
|
643 | + 'options' => array_merge( |
|
644 | + array( |
|
645 | + '' => __( 'All item types', 'invoicing' ) |
|
646 | + ), |
|
647 | + wpinv_get_item_types() |
|
648 | + ), |
|
649 | + 'name' => 'type', |
|
650 | + 'id' => 'type', |
|
651 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
652 | + 'show_option_all' => false, |
|
653 | + 'show_option_none' => false, |
|
654 | + ) |
|
655 | + ); |
|
656 | + |
|
657 | + } |
|
658 | + |
|
659 | + /** |
|
660 | + * Filters the item query. |
|
661 | + */ |
|
662 | + public static function filter_item_query( $query ) { |
|
663 | + |
|
664 | + // modify the query only if it admin and main query. |
|
665 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
666 | + return $query; |
|
667 | + } |
|
668 | + |
|
669 | + // we want to modify the query for our items. |
|
670 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
671 | + return $query; |
|
672 | + } |
|
673 | + |
|
674 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
675 | + $query->query_vars['meta_query'] = array(); |
|
676 | + } |
|
677 | + |
|
678 | + // Filter vat rule type |
|
679 | 679 | if ( ! empty( $_GET['vat_rule'] ) ) { |
680 | 680 | $query->query_vars['meta_query'][] = array( |
681 | 681 | 'key' => '_wpinv_vat_rule', |
@@ -700,97 +700,97 @@ discard block |
||
700 | 700 | 'value' => sanitize_text_field( $_GET['type'] ), |
701 | 701 | 'compare' => '=' |
702 | 702 | ); |
703 | - } |
|
704 | - |
|
705 | - } |
|
706 | - |
|
707 | - /** |
|
708 | - * Reorders items. |
|
709 | - */ |
|
710 | - public static function reorder_items( $vars ) { |
|
711 | - global $typenow; |
|
712 | - |
|
713 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
714 | - return $vars; |
|
715 | - } |
|
716 | - |
|
717 | - // By item type. |
|
718 | - if ( 'type' == $vars['orderby'] ) { |
|
719 | - return array_merge( |
|
720 | - $vars, |
|
721 | - array( |
|
722 | - 'meta_key' => '_wpinv_type', |
|
723 | - 'orderby' => 'meta_value' |
|
724 | - ) |
|
725 | - ); |
|
726 | - } |
|
727 | - |
|
728 | - // By vat class. |
|
729 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
730 | - return array_merge( |
|
731 | - $vars, |
|
732 | - array( |
|
733 | - 'meta_key' => '_wpinv_vat_class', |
|
734 | - 'orderby' => 'meta_value' |
|
735 | - ) |
|
736 | - ); |
|
737 | - } |
|
738 | - |
|
739 | - // By vat rule. |
|
740 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
741 | - return array_merge( |
|
742 | - $vars, |
|
743 | - array( |
|
744 | - 'meta_key' => '_wpinv_vat_rule', |
|
745 | - 'orderby' => 'meta_value' |
|
746 | - ) |
|
747 | - ); |
|
748 | - } |
|
749 | - |
|
750 | - // By price. |
|
751 | - if ( 'price' == $vars['orderby'] ) { |
|
752 | - return array_merge( |
|
753 | - $vars, |
|
754 | - array( |
|
755 | - 'meta_key' => '_wpinv_price', |
|
756 | - 'orderby' => 'meta_value_num' |
|
757 | - ) |
|
758 | - ); |
|
759 | - } |
|
760 | - |
|
761 | - return $vars; |
|
762 | - |
|
763 | - } |
|
764 | - |
|
765 | - /** |
|
766 | - * Fired when deleting a post. |
|
767 | - */ |
|
768 | - public static function delete_post( $post_id ) { |
|
769 | - |
|
770 | - switch ( get_post_type( $post_id ) ) { |
|
771 | - |
|
772 | - case 'wpi_item' : |
|
773 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
774 | - break; |
|
775 | - |
|
776 | - case 'wpi_payment_form' : |
|
777 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
778 | - break; |
|
779 | - |
|
780 | - case 'wpi_discount' : |
|
781 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
782 | - break; |
|
783 | - |
|
784 | - case 'wpi_invoice' : |
|
785 | - $invoice = new WPInv_Invoice( $post_id ); |
|
786 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
787 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
788 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
789 | - break; |
|
790 | - } |
|
791 | - } |
|
792 | - |
|
793 | - /** |
|
703 | + } |
|
704 | + |
|
705 | + } |
|
706 | + |
|
707 | + /** |
|
708 | + * Reorders items. |
|
709 | + */ |
|
710 | + public static function reorder_items( $vars ) { |
|
711 | + global $typenow; |
|
712 | + |
|
713 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
714 | + return $vars; |
|
715 | + } |
|
716 | + |
|
717 | + // By item type. |
|
718 | + if ( 'type' == $vars['orderby'] ) { |
|
719 | + return array_merge( |
|
720 | + $vars, |
|
721 | + array( |
|
722 | + 'meta_key' => '_wpinv_type', |
|
723 | + 'orderby' => 'meta_value' |
|
724 | + ) |
|
725 | + ); |
|
726 | + } |
|
727 | + |
|
728 | + // By vat class. |
|
729 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
730 | + return array_merge( |
|
731 | + $vars, |
|
732 | + array( |
|
733 | + 'meta_key' => '_wpinv_vat_class', |
|
734 | + 'orderby' => 'meta_value' |
|
735 | + ) |
|
736 | + ); |
|
737 | + } |
|
738 | + |
|
739 | + // By vat rule. |
|
740 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
741 | + return array_merge( |
|
742 | + $vars, |
|
743 | + array( |
|
744 | + 'meta_key' => '_wpinv_vat_rule', |
|
745 | + 'orderby' => 'meta_value' |
|
746 | + ) |
|
747 | + ); |
|
748 | + } |
|
749 | + |
|
750 | + // By price. |
|
751 | + if ( 'price' == $vars['orderby'] ) { |
|
752 | + return array_merge( |
|
753 | + $vars, |
|
754 | + array( |
|
755 | + 'meta_key' => '_wpinv_price', |
|
756 | + 'orderby' => 'meta_value_num' |
|
757 | + ) |
|
758 | + ); |
|
759 | + } |
|
760 | + |
|
761 | + return $vars; |
|
762 | + |
|
763 | + } |
|
764 | + |
|
765 | + /** |
|
766 | + * Fired when deleting a post. |
|
767 | + */ |
|
768 | + public static function delete_post( $post_id ) { |
|
769 | + |
|
770 | + switch ( get_post_type( $post_id ) ) { |
|
771 | + |
|
772 | + case 'wpi_item' : |
|
773 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
774 | + break; |
|
775 | + |
|
776 | + case 'wpi_payment_form' : |
|
777 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
778 | + break; |
|
779 | + |
|
780 | + case 'wpi_discount' : |
|
781 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
782 | + break; |
|
783 | + |
|
784 | + case 'wpi_invoice' : |
|
785 | + $invoice = new WPInv_Invoice( $post_id ); |
|
786 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
787 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
788 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
789 | + break; |
|
790 | + } |
|
791 | + } |
|
792 | + |
|
793 | + /** |
|
794 | 794 | * Add a post display state for special GetPaid pages in the page list table. |
795 | 795 | * |
796 | 796 | * @param array $post_states An array of post display states. |
@@ -804,22 +804,22 @@ discard block |
||
804 | 804 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
805 | 805 | } |
806 | 806 | |
807 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
807 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
808 | 808 | |
809 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
810 | - $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
811 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
812 | - $label |
|
813 | - ); |
|
814 | - } |
|
809 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
810 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
811 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
812 | + $label |
|
813 | + ); |
|
814 | + } |
|
815 | 815 | |
816 | - } |
|
816 | + } |
|
817 | 817 | |
818 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
818 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
819 | 819 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
820 | 820 | } |
821 | 821 | |
822 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
822 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
823 | 823 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
824 | 824 | } |
825 | 825 |
@@ -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 | * Post types Admin Class |
@@ -21,72 +21,72 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | |
55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Post updated messages. |
60 | 60 | */ |
61 | - public static function post_updated_messages( $messages ) { |
|
61 | + public static function post_updated_messages($messages) { |
|
62 | 62 | global $post; |
63 | 63 | |
64 | 64 | $messages['wpi_discount'] = array( |
65 | 65 | 0 => '', |
66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
66 | + 1 => __('Discount updated.', 'invoicing'), |
|
67 | + 2 => __('Custom field updated.', 'invoicing'), |
|
68 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
69 | + 4 => __('Discount updated.', 'invoicing'), |
|
70 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
71 | + 6 => __('Discount updated.', 'invoicing'), |
|
72 | + 7 => __('Discount saved.', 'invoicing'), |
|
73 | + 8 => __('Discount submitted.', 'invoicing'), |
|
74 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
75 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | $messages['wpi_payment_form'] = array( |
79 | 79 | 0 => '', |
80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
80 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
81 | + 2 => __('Custom field updated.', 'invoicing'), |
|
82 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
83 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
85 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
87 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
88 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
89 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | return $messages; |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Post row actions. |
98 | 98 | */ |
99 | - public static function post_row_actions( $actions, $post ) { |
|
99 | + public static function post_row_actions($actions, $post) { |
|
100 | 100 | |
101 | - $post = get_post( $post ); |
|
101 | + $post = get_post($post); |
|
102 | 102 | |
103 | 103 | // We do not want to edit the default payment form. |
104 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
104 | + if ('wpi_payment_form' == $post->post_type) { |
|
105 | 105 | |
106 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
107 | - unset( $actions['trash'] ); |
|
108 | - unset( $actions['inline hide-if-no-js'] ); |
|
106 | + if ($post->ID == wpinv_get_default_payment_form()) { |
|
107 | + unset($actions['trash']); |
|
108 | + unset($actions['inline hide-if-no-js']); |
|
109 | 109 | } |
110 | 110 | |
111 | - $actions['duplicate'] = sprintf( |
|
111 | + $actions['duplicate'] = sprintf( |
|
112 | 112 | '<a href="%1$s">%2$s</a>', |
113 | 113 | esc_url( |
114 | 114 | wp_nonce_url( |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'getpaid-nonce' |
123 | 123 | ) |
124 | 124 | ), |
125 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
125 | + esc_html(__('Duplicate', 'invoicing')) |
|
126 | 126 | ); |
127 | 127 | |
128 | 128 | } |
@@ -138,31 +138,31 @@ discard block |
||
138 | 138 | * @param WP_Post $post |
139 | 139 | * @return array $actions actions without edit option |
140 | 140 | */ |
141 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
141 | + public static function filter_invoice_row_actions($actions, $post) { |
|
142 | 142 | |
143 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
143 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
144 | 144 | |
145 | 145 | $actions = array(); |
146 | - $invoice = new WPInv_Invoice( $post ); |
|
146 | + $invoice = new WPInv_Invoice($post); |
|
147 | 147 | |
148 | - $actions['edit'] = sprintf( |
|
148 | + $actions['edit'] = sprintf( |
|
149 | 149 | '<a href="%1$s">%2$s</a>', |
150 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
151 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
150 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
151 | + esc_html(__('Edit', 'invoicing')) |
|
152 | 152 | ); |
153 | 153 | |
154 | - if ( ! $invoice->is_draft() ) { |
|
154 | + if (!$invoice->is_draft()) { |
|
155 | 155 | |
156 | - $actions['view'] = sprintf( |
|
156 | + $actions['view'] = sprintf( |
|
157 | 157 | '<a href="%1$s">%2$s</a>', |
158 | - esc_url( $invoice->get_view_url() ), |
|
158 | + esc_url($invoice->get_view_url()), |
|
159 | 159 | sprintf( |
160 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
161 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
160 | + esc_html(__('View %s', 'invoicing')), |
|
161 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
162 | 162 | ) |
163 | 163 | ); |
164 | 164 | |
165 | - $actions['send'] = sprintf( |
|
165 | + $actions['send'] = sprintf( |
|
166 | 166 | '<a href="%1$s">%2$s</a>', |
167 | 167 | esc_url( |
168 | 168 | wp_nonce_url( |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | 'getpaid-nonce' |
177 | 177 | ) |
178 | 178 | ), |
179 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
179 | + esc_html(__('Send to Customer', 'invoicing')) |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | } |
@@ -189,42 +189,42 @@ discard block |
||
189 | 189 | /** |
190 | 190 | * Returns an array of invoice table columns. |
191 | 191 | */ |
192 | - public static function invoice_columns( $columns ) { |
|
192 | + public static function invoice_columns($columns) { |
|
193 | 193 | |
194 | 194 | $columns = array( |
195 | 195 | 'cb' => $columns['cb'], |
196 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
197 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
198 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
199 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
200 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
201 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
202 | - 'status' => __( 'Status', 'invoicing' ), |
|
196 | + 'number' => __('Invoice', 'invoicing'), |
|
197 | + 'customer' => __('Customer', 'invoicing'), |
|
198 | + 'invoice_date' => __('Created', 'invoicing'), |
|
199 | + 'payment_date' => __('Completed', 'invoicing'), |
|
200 | + 'amount' => __('Amount', 'invoicing'), |
|
201 | + 'recurring' => __('Recurring', 'invoicing'), |
|
202 | + 'status' => __('Status', 'invoicing'), |
|
203 | 203 | ); |
204 | 204 | |
205 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
205 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | 209 | * Displays invoice table columns. |
210 | 210 | */ |
211 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
211 | + public static function display_invoice_columns($column_name, $post_id) { |
|
212 | 212 | |
213 | - $invoice = new WPInv_Invoice( $post_id ); |
|
213 | + $invoice = new WPInv_Invoice($post_id); |
|
214 | 214 | |
215 | - switch ( $column_name ) { |
|
215 | + switch ($column_name) { |
|
216 | 216 | |
217 | 217 | case 'invoice_date' : |
218 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
219 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
218 | + $date_time = esc_attr($invoice->get_created_date()); |
|
219 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
220 | 220 | echo "<span title='$date_time'>$date</span>"; |
221 | 221 | break; |
222 | 222 | |
223 | 223 | case 'payment_date' : |
224 | 224 | |
225 | - if ( $invoice->is_paid() ) { |
|
226 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
227 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
225 | + if ($invoice->is_paid()) { |
|
226 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
227 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
228 | 228 | echo "<span title='$date_time'>$date</span>"; |
229 | 229 | } else { |
230 | 230 | echo "—"; |
@@ -235,17 +235,17 @@ discard block |
||
235 | 235 | case 'amount' : |
236 | 236 | |
237 | 237 | $amount = $invoice->get_total(); |
238 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
238 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
239 | 239 | |
240 | - if ( $invoice->is_refunded() ) { |
|
241 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
240 | + if ($invoice->is_refunded()) { |
|
241 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
242 | 242 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
243 | 243 | } else { |
244 | 244 | |
245 | 245 | $discount = $invoice->get_total_discount(); |
246 | 246 | |
247 | - if ( ! empty( $discount ) ) { |
|
248 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
247 | + if (!empty($discount)) { |
|
248 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
249 | 249 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
250 | 250 | } else { |
251 | 251 | echo $formated_amount; |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | break; |
257 | 257 | |
258 | 258 | case 'status' : |
259 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
260 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
259 | + $status = sanitize_text_field($invoice->get_status()); |
|
260 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
261 | 261 | |
262 | 262 | // If it is paid, show the gateway title. |
263 | - if ( $invoice->is_paid() ) { |
|
264 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
265 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
263 | + if ($invoice->is_paid()) { |
|
264 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
265 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
266 | 266 | |
267 | 267 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
268 | 268 | } else { |
@@ -270,22 +270,22 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | // If it is not paid, display the overdue and view status. |
273 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
273 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
274 | 274 | |
275 | 275 | // Invoice view status. |
276 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
277 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
276 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
277 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
278 | 278 | } else { |
279 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
279 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Display the overview status. |
283 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
283 | + if (wpinv_get_option('overdue_active')) { |
|
284 | 284 | $due_date = $invoice->get_due_date(); |
285 | - $fomatted = getpaid_format_date( $due_date ); |
|
285 | + $fomatted = getpaid_format_date($due_date); |
|
286 | 286 | |
287 | - if ( ! empty( $fomatted ) ) { |
|
288 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
287 | + if (!empty($fomatted)) { |
|
288 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
289 | 289 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
290 | 290 | } |
291 | 291 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | case 'recurring': |
298 | 298 | |
299 | - if ( $invoice->is_recurring() ) { |
|
299 | + if ($invoice->is_recurring()) { |
|
300 | 300 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
301 | 301 | } else { |
302 | 302 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | |
306 | 306 | case 'number' : |
307 | 307 | |
308 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
309 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
310 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
308 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
309 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
310 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
311 | 311 | |
312 | 312 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
313 | 313 | |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | |
318 | 318 | $customer_name = $invoice->get_user_full_name(); |
319 | 319 | |
320 | - if ( empty( $customer_name ) ) { |
|
320 | + if (empty($customer_name)) { |
|
321 | 321 | $customer_name = $invoice->get_email(); |
322 | 322 | } |
323 | 323 | |
324 | - if ( ! empty( $customer_name ) ) { |
|
325 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
326 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
324 | + if (!empty($customer_name)) { |
|
325 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
326 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
327 | 327 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
328 | 328 | } else { |
329 | 329 | echo '<div>—</div>'; |
@@ -338,50 +338,50 @@ discard block |
||
338 | 338 | /** |
339 | 339 | * Returns an array of payment forms table columns. |
340 | 340 | */ |
341 | - public static function payment_form_columns( $columns ) { |
|
341 | + public static function payment_form_columns($columns) { |
|
342 | 342 | |
343 | 343 | $columns = array( |
344 | 344 | 'cb' => $columns['cb'], |
345 | - 'title' => __( 'Name', 'invoicing' ), |
|
346 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
347 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
348 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
349 | - 'items' => __( 'Items', 'invoicing' ), |
|
350 | - 'date' => __( 'Date', 'invoicing' ), |
|
345 | + 'title' => __('Name', 'invoicing'), |
|
346 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
347 | + 'earnings' => __('Revenue', 'invoicing'), |
|
348 | + 'refunds' => __('Refunded', 'invoicing'), |
|
349 | + 'items' => __('Items', 'invoicing'), |
|
350 | + 'date' => __('Date', 'invoicing'), |
|
351 | 351 | ); |
352 | 352 | |
353 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
353 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | 358 | * Displays payment form table columns. |
359 | 359 | */ |
360 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
360 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
361 | 361 | |
362 | 362 | // Retrieve the payment form. |
363 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
363 | + $form = new GetPaid_Payment_Form($post_id); |
|
364 | 364 | |
365 | - switch ( $column_name ) { |
|
365 | + switch ($column_name) { |
|
366 | 366 | |
367 | 367 | case 'earnings' : |
368 | - echo wpinv_price( $form->get_earned() ); |
|
368 | + echo wpinv_price($form->get_earned()); |
|
369 | 369 | break; |
370 | 370 | |
371 | 371 | case 'refunds' : |
372 | - echo wpinv_price( $form->get_refunded() ); |
|
372 | + echo wpinv_price($form->get_refunded()); |
|
373 | 373 | break; |
374 | 374 | |
375 | 375 | case 'refunds' : |
376 | - echo wpinv_price( $form->get_refunded() ); |
|
376 | + echo wpinv_price($form->get_refunded()); |
|
377 | 377 | break; |
378 | 378 | |
379 | 379 | case 'shortcode' : |
380 | 380 | |
381 | - if ( $form->is_default() ) { |
|
381 | + if ($form->is_default()) { |
|
382 | 382 | echo '—'; |
383 | 383 | } else { |
384 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
384 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | break; |
@@ -390,29 +390,29 @@ discard block |
||
390 | 390 | |
391 | 391 | $items = $form->get_items(); |
392 | 392 | |
393 | - if ( $form->is_default() || empty( $items ) ) { |
|
393 | + if ($form->is_default() || empty($items)) { |
|
394 | 394 | echo '—'; |
395 | 395 | return; |
396 | 396 | } |
397 | 397 | |
398 | 398 | $_items = array(); |
399 | 399 | |
400 | - foreach ( $items as $item ) { |
|
400 | + foreach ($items as $item) { |
|
401 | 401 | $url = $item->get_edit_url(); |
402 | 402 | |
403 | - if ( empty( $url ) ) { |
|
404 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
403 | + if (empty($url)) { |
|
404 | + $_items[] = sanitize_text_field($item->get_name()); |
|
405 | 405 | } else { |
406 | 406 | $_items[] = sprintf( |
407 | 407 | '<a href="%s">%s</a>', |
408 | - esc_url( $url ), |
|
409 | - sanitize_text_field( $item->get_name() ) |
|
408 | + esc_url($url), |
|
409 | + sanitize_text_field($item->get_name()) |
|
410 | 410 | ); |
411 | 411 | } |
412 | 412 | |
413 | 413 | } |
414 | 414 | |
415 | - echo implode( '<br>', $_items ); |
|
415 | + echo implode('<br>', $_items); |
|
416 | 416 | |
417 | 417 | break; |
418 | 418 | |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | /** |
424 | 424 | * Filters post states. |
425 | 425 | */ |
426 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
426 | + public static function filter_payment_form_state($post_states, $post) { |
|
427 | 427 | |
428 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
429 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
428 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
429 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | return $post_states; |
@@ -436,35 +436,35 @@ discard block |
||
436 | 436 | /** |
437 | 437 | * Returns an array of coupon table columns. |
438 | 438 | */ |
439 | - public static function discount_columns( $columns ) { |
|
439 | + public static function discount_columns($columns) { |
|
440 | 440 | |
441 | 441 | $columns = array( |
442 | 442 | 'cb' => $columns['cb'], |
443 | - 'title' => __( 'Name', 'invoicing' ), |
|
444 | - 'code' => __( 'Code', 'invoicing' ), |
|
445 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
446 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
447 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
448 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
443 | + 'title' => __('Name', 'invoicing'), |
|
444 | + 'code' => __('Code', 'invoicing'), |
|
445 | + 'amount' => __('Amount', 'invoicing'), |
|
446 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
447 | + 'start_date' => __('Start Date', 'invoicing'), |
|
448 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
449 | 449 | ); |
450 | 450 | |
451 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
451 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
455 | 455 | * Filters post states. |
456 | 456 | */ |
457 | - public static function filter_discount_state( $post_states, $post ) { |
|
457 | + public static function filter_discount_state($post_states, $post) { |
|
458 | 458 | |
459 | - if ( 'wpi_discount' == $post->post_type ) { |
|
459 | + if ('wpi_discount' == $post->post_type) { |
|
460 | 460 | |
461 | - $discount = new WPInv_Discount( $post ); |
|
461 | + $discount = new WPInv_Discount($post); |
|
462 | 462 | |
463 | 463 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
464 | 464 | |
465 | - if ( $status != 'publish' ) { |
|
465 | + if ($status != 'publish') { |
|
466 | 466 | return array( |
467 | - 'discount_status' => wpinv_discount_status( $status ), |
|
467 | + 'discount_status' => wpinv_discount_status($status), |
|
468 | 468 | ); |
469 | 469 | } |
470 | 470 | |
@@ -479,30 +479,30 @@ discard block |
||
479 | 479 | /** |
480 | 480 | * Returns an array of items table columns. |
481 | 481 | */ |
482 | - public static function item_columns( $columns ) { |
|
482 | + public static function item_columns($columns) { |
|
483 | 483 | |
484 | 484 | $columns = array( |
485 | 485 | 'cb' => $columns['cb'], |
486 | - 'title' => __( 'Name', 'invoicing' ), |
|
487 | - 'price' => __( 'Price', 'invoicing' ), |
|
488 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
489 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
490 | - 'type' => __( 'Type', 'invoicing' ), |
|
491 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
486 | + 'title' => __('Name', 'invoicing'), |
|
487 | + 'price' => __('Price', 'invoicing'), |
|
488 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
489 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
490 | + 'type' => __('Type', 'invoicing'), |
|
491 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
492 | 492 | ); |
493 | 493 | |
494 | - if ( ! wpinv_use_taxes() ) { |
|
495 | - unset( $columns['vat_rule'] ); |
|
496 | - unset( $columns['vat_class'] ); |
|
494 | + if (!wpinv_use_taxes()) { |
|
495 | + unset($columns['vat_rule']); |
|
496 | + unset($columns['vat_class']); |
|
497 | 497 | } |
498 | 498 | |
499 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
499 | + return apply_filters('wpi_item_table_columns', $columns); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
503 | 503 | * Returns an array of sortable items table columns. |
504 | 504 | */ |
505 | - public static function sortable_item_columns( $columns ) { |
|
505 | + public static function sortable_item_columns($columns) { |
|
506 | 506 | |
507 | 507 | return array_merge( |
508 | 508 | $columns, |
@@ -519,49 +519,49 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * Displays items table columns. |
521 | 521 | */ |
522 | - public static function display_item_columns( $column_name, $post_id ) { |
|
522 | + public static function display_item_columns($column_name, $post_id) { |
|
523 | 523 | |
524 | - $item = new WPInv_Item( $post_id ); |
|
524 | + $item = new WPInv_Item($post_id); |
|
525 | 525 | |
526 | - switch ( $column_name ) { |
|
526 | + switch ($column_name) { |
|
527 | 527 | |
528 | 528 | case 'price' : |
529 | 529 | |
530 | - if ( ! $item->is_recurring() ) { |
|
530 | + if (!$item->is_recurring()) { |
|
531 | 531 | echo $item->get_the_price(); |
532 | 532 | break; |
533 | 533 | } |
534 | 534 | |
535 | 535 | $price = wp_sprintf( |
536 | - __( '%s / %s', 'invoicing' ), |
|
536 | + __('%s / %s', 'invoicing'), |
|
537 | 537 | $item->get_the_price(), |
538 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
538 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
539 | 539 | ); |
540 | 540 | |
541 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
541 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
542 | 542 | echo $price; |
543 | 543 | break; |
544 | 544 | } |
545 | 545 | |
546 | 546 | echo $item->get_the_initial_price(); |
547 | 547 | |
548 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
548 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
549 | 549 | break; |
550 | 550 | |
551 | 551 | case 'vat_rule' : |
552 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
552 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
553 | 553 | break; |
554 | 554 | |
555 | 555 | case 'vat_class' : |
556 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
556 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
557 | 557 | break; |
558 | 558 | |
559 | 559 | case 'shortcode' : |
560 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
560 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
561 | 561 | break; |
562 | 562 | |
563 | 563 | case 'type' : |
564 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
564 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
565 | 565 | break; |
566 | 566 | |
567 | 567 | } |
@@ -571,21 +571,21 @@ discard block |
||
571 | 571 | /** |
572 | 572 | * Lets users filter items using taxes. |
573 | 573 | */ |
574 | - public static function add_item_filters( $post_type ) { |
|
574 | + public static function add_item_filters($post_type) { |
|
575 | 575 | |
576 | 576 | // Abort if we're not dealing with items. |
577 | - if ( $post_type != 'wpi_item' ) { |
|
577 | + if ($post_type != 'wpi_item') { |
|
578 | 578 | return; |
579 | 579 | } |
580 | 580 | |
581 | 581 | // Filter by vat rules. |
582 | - if ( wpinv_use_taxes() ) { |
|
582 | + if (wpinv_use_taxes()) { |
|
583 | 583 | |
584 | 584 | // Sanitize selected vat rule. |
585 | 585 | $vat_rule = ''; |
586 | 586 | $vat_rules = getpaid_get_tax_rules(); |
587 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
588 | - $vat_rule = $_GET['vat_rule']; |
|
587 | + if (isset($_GET['vat_rule'])) { |
|
588 | + $vat_rule = $_GET['vat_rule']; |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | // Filter by VAT rule. |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | array( |
594 | 594 | 'options' => array_merge( |
595 | 595 | array( |
596 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
596 | + '' => __('All VAT rules', 'invoicing') |
|
597 | 597 | ), |
598 | 598 | $vat_rules |
599 | 599 | ), |
600 | 600 | 'name' => 'vat_rule', |
601 | 601 | 'id' => 'vat_rule', |
602 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
602 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
603 | 603 | 'show_option_all' => false, |
604 | 604 | 'show_option_none' => false, |
605 | 605 | ) |
@@ -610,21 +610,21 @@ discard block |
||
610 | 610 | // Sanitize selected vat rule. |
611 | 611 | $vat_class = ''; |
612 | 612 | $vat_classes = getpaid_get_tax_classes(); |
613 | - if ( isset( $_GET['vat_class'] ) ) { |
|
614 | - $vat_class = $_GET['vat_class']; |
|
613 | + if (isset($_GET['vat_class'])) { |
|
614 | + $vat_class = $_GET['vat_class']; |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | echo wpinv_html_select( |
618 | 618 | array( |
619 | 619 | 'options' => array_merge( |
620 | 620 | array( |
621 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
621 | + '' => __('All VAT classes', 'invoicing') |
|
622 | 622 | ), |
623 | 623 | $vat_classes |
624 | 624 | ), |
625 | 625 | 'name' => 'vat_class', |
626 | 626 | 'id' => 'vat_class', |
627 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
627 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
628 | 628 | 'show_option_all' => false, |
629 | 629 | 'show_option_none' => false, |
630 | 630 | ) |
@@ -633,22 +633,22 @@ discard block |
||
633 | 633 | } |
634 | 634 | |
635 | 635 | // Filter by item type. |
636 | - $type = ''; |
|
637 | - if ( isset( $_GET['type'] ) ) { |
|
638 | - $type = $_GET['type']; |
|
636 | + $type = ''; |
|
637 | + if (isset($_GET['type'])) { |
|
638 | + $type = $_GET['type']; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | echo wpinv_html_select( |
642 | 642 | array( |
643 | 643 | 'options' => array_merge( |
644 | 644 | array( |
645 | - '' => __( 'All item types', 'invoicing' ) |
|
645 | + '' => __('All item types', 'invoicing') |
|
646 | 646 | ), |
647 | 647 | wpinv_get_item_types() |
648 | 648 | ), |
649 | 649 | 'name' => 'type', |
650 | 650 | 'id' => 'type', |
651 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
651 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
652 | 652 | 'show_option_all' => false, |
653 | 653 | 'show_option_none' => false, |
654 | 654 | ) |
@@ -659,45 +659,45 @@ discard block |
||
659 | 659 | /** |
660 | 660 | * Filters the item query. |
661 | 661 | */ |
662 | - public static function filter_item_query( $query ) { |
|
662 | + public static function filter_item_query($query) { |
|
663 | 663 | |
664 | 664 | // modify the query only if it admin and main query. |
665 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
665 | + if (!(is_admin() && $query->is_main_query())) { |
|
666 | 666 | return $query; |
667 | 667 | } |
668 | 668 | |
669 | 669 | // we want to modify the query for our items. |
670 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
670 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
671 | 671 | return $query; |
672 | 672 | } |
673 | 673 | |
674 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
674 | + if (empty($query->query_vars['meta_query'])) { |
|
675 | 675 | $query->query_vars['meta_query'] = array(); |
676 | 676 | } |
677 | 677 | |
678 | 678 | // Filter vat rule type |
679 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
679 | + if (!empty($_GET['vat_rule'])) { |
|
680 | 680 | $query->query_vars['meta_query'][] = array( |
681 | 681 | 'key' => '_wpinv_vat_rule', |
682 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
682 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
683 | 683 | 'compare' => '=' |
684 | 684 | ); |
685 | 685 | } |
686 | 686 | |
687 | 687 | // Filter vat class |
688 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
688 | + if (!empty($_GET['vat_class'])) { |
|
689 | 689 | $query->query_vars['meta_query'][] = array( |
690 | 690 | 'key' => '_wpinv_vat_class', |
691 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
691 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
692 | 692 | 'compare' => '=' |
693 | 693 | ); |
694 | 694 | } |
695 | 695 | |
696 | 696 | // Filter item type |
697 | - if ( ! empty( $_GET['type'] ) ) { |
|
697 | + if (!empty($_GET['type'])) { |
|
698 | 698 | $query->query_vars['meta_query'][] = array( |
699 | 699 | 'key' => '_wpinv_type', |
700 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
700 | + 'value' => sanitize_text_field($_GET['type']), |
|
701 | 701 | 'compare' => '=' |
702 | 702 | ); |
703 | 703 | } |
@@ -707,15 +707,15 @@ discard block |
||
707 | 707 | /** |
708 | 708 | * Reorders items. |
709 | 709 | */ |
710 | - public static function reorder_items( $vars ) { |
|
710 | + public static function reorder_items($vars) { |
|
711 | 711 | global $typenow; |
712 | 712 | |
713 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
713 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
714 | 714 | return $vars; |
715 | 715 | } |
716 | 716 | |
717 | 717 | // By item type. |
718 | - if ( 'type' == $vars['orderby'] ) { |
|
718 | + if ('type' == $vars['orderby']) { |
|
719 | 719 | return array_merge( |
720 | 720 | $vars, |
721 | 721 | array( |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | } |
727 | 727 | |
728 | 728 | // By vat class. |
729 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
729 | + if ('vat_class' == $vars['orderby']) { |
|
730 | 730 | return array_merge( |
731 | 731 | $vars, |
732 | 732 | array( |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | } |
738 | 738 | |
739 | 739 | // By vat rule. |
740 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
740 | + if ('vat_rule' == $vars['orderby']) { |
|
741 | 741 | return array_merge( |
742 | 742 | $vars, |
743 | 743 | array( |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | } |
749 | 749 | |
750 | 750 | // By price. |
751 | - if ( 'price' == $vars['orderby'] ) { |
|
751 | + if ('price' == $vars['orderby']) { |
|
752 | 752 | return array_merge( |
753 | 753 | $vars, |
754 | 754 | array( |
@@ -765,27 +765,27 @@ discard block |
||
765 | 765 | /** |
766 | 766 | * Fired when deleting a post. |
767 | 767 | */ |
768 | - public static function delete_post( $post_id ) { |
|
768 | + public static function delete_post($post_id) { |
|
769 | 769 | |
770 | - switch ( get_post_type( $post_id ) ) { |
|
770 | + switch (get_post_type($post_id)) { |
|
771 | 771 | |
772 | 772 | case 'wpi_item' : |
773 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
773 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
774 | 774 | break; |
775 | 775 | |
776 | 776 | case 'wpi_payment_form' : |
777 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
777 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
778 | 778 | break; |
779 | 779 | |
780 | 780 | case 'wpi_discount' : |
781 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
781 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
782 | 782 | break; |
783 | 783 | |
784 | 784 | case 'wpi_invoice' : |
785 | - $invoice = new WPInv_Invoice( $post_id ); |
|
786 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
787 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
788 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
785 | + $invoice = new WPInv_Invoice($post_id); |
|
786 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
787 | + $invoice->get_data_store()->delete_items($invoice); |
|
788 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
789 | 789 | break; |
790 | 790 | } |
791 | 791 | } |
@@ -798,29 +798,29 @@ discard block |
||
798 | 798 | * |
799 | 799 | * @return mixed |
800 | 800 | */ |
801 | - public static function add_display_post_states( $post_states, $post ) { |
|
801 | + public static function add_display_post_states($post_states, $post) { |
|
802 | 802 | |
803 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
804 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
803 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
804 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
805 | 805 | } |
806 | 806 | |
807 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
807 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
808 | 808 | |
809 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
809 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
810 | 810 | $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
811 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
811 | + __('GetPaid %s History Page', 'invoicing'), |
|
812 | 812 | $label |
813 | 813 | ); |
814 | 814 | } |
815 | 815 | |
816 | 816 | } |
817 | 817 | |
818 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
819 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
818 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
819 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
820 | 820 | } |
821 | 821 | |
822 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
823 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
822 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
823 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | return $post_states; |