@@ -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' ), 9 ); |
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', 'wp-hooks' ), $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', 'wp-hooks' ), $version ); |
|
286 | 286 | |
287 | - wp_localize_script( |
|
287 | + wp_localize_script( |
|
288 | 288 | 'wpinv-admin-payment-form-script', |
289 | 289 | 'wpinvPaymentFormAdmin', |
290 | 290 | array( |
291 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
292 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
293 | - 'currency' => wpinv_currency_symbol(), |
|
294 | - 'position' => wpinv_currency_position(), |
|
295 | - 'decimals' => (int) wpinv_decimals(), |
|
296 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
297 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
298 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
299 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
291 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
292 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
293 | + 'currency' => wpinv_currency_symbol(), |
|
294 | + 'position' => wpinv_currency_position(), |
|
295 | + 'decimals' => (int) wpinv_decimals(), |
|
296 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
297 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
298 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
299 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
300 | 300 | ) |
301 | 301 | ); |
302 | 302 | |
@@ -305,20 +305,20 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * Add our classes to admin pages. |
|
308 | + * Add our classes to admin pages. |
|
309 | 309 | * |
310 | 310 | * @param string $classes |
311 | 311 | * @return string |
312 | - * |
|
313 | - */ |
|
312 | + * |
|
313 | + */ |
|
314 | 314 | public function admin_body_class( $classes ) { |
315 | - global $pagenow, $post, $current_screen; |
|
315 | + global $pagenow, $post, $current_screen; |
|
316 | 316 | |
317 | 317 | |
318 | 318 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
319 | 319 | |
320 | 320 | if ( ! empty( $current_screen->post_type ) ) { |
321 | - $page = $current_screen->post_type; |
|
321 | + $page = $current_screen->post_type; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -327,68 +327,68 @@ discard block |
||
327 | 327 | |
328 | 328 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
329 | 329 | $classes .= ' wpinv-cpt wpinv'; |
330 | - } |
|
330 | + } |
|
331 | 331 | |
332 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
332 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
333 | 333 | $classes .= ' getpaid-is-invoice-cpt'; |
334 | 334 | } |
335 | 335 | |
336 | - return $classes; |
|
336 | + return $classes; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Maybe show the AyeCode Connect Notice. |
|
341 | - */ |
|
342 | - public function init_ayecode_connect_helper(){ |
|
340 | + * Maybe show the AyeCode Connect Notice. |
|
341 | + */ |
|
342 | + public function init_ayecode_connect_helper(){ |
|
343 | 343 | |
344 | - // Register with the deactivation survey class. |
|
345 | - AyeCode_Deactivation_Survey::instance(array( |
|
346 | - 'slug' => 'invoicing', |
|
347 | - 'version' => WPINV_VERSION, |
|
348 | - 'support_url' => 'https://wpgetpaid.com/support/', |
|
349 | - 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
350 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
351 | - )); |
|
344 | + // Register with the deactivation survey class. |
|
345 | + AyeCode_Deactivation_Survey::instance(array( |
|
346 | + 'slug' => 'invoicing', |
|
347 | + 'version' => WPINV_VERSION, |
|
348 | + 'support_url' => 'https://wpgetpaid.com/support/', |
|
349 | + 'documentation_url' => 'https://docs.wpgetpaid.com/', |
|
350 | + 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
351 | + )); |
|
352 | 352 | |
353 | 353 | new AyeCode_Connect_Helper( |
354 | 354 | array( |
355 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
356 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
357 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
358 | - 'connect_button' => __("Connect Site","invoicing"), |
|
359 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
360 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
361 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
355 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
356 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
357 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
358 | + 'connect_button' => __("Connect Site","invoicing"), |
|
359 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
360 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
361 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
362 | 362 | ), |
363 | 363 | array( 'wpi-addons' ) |
364 | 364 | ); |
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | - /** |
|
369 | - * Redirect users to settings on activation. |
|
370 | - * |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public function activation_redirect() { |
|
368 | + /** |
|
369 | + * Redirect users to settings on activation. |
|
370 | + * |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public function activation_redirect() { |
|
374 | 374 | |
375 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
375 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
376 | 376 | |
377 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
378 | - return; |
|
379 | - } |
|
377 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
378 | + return; |
|
379 | + } |
|
380 | 380 | |
381 | - // Bail if activating from network, or bulk |
|
382 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
383 | - return; |
|
384 | - } |
|
381 | + // Bail if activating from network, or bulk |
|
382 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
383 | + return; |
|
384 | + } |
|
385 | 385 | |
386 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
386 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
387 | 387 | |
388 | 388 | wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
389 | 389 | exit; |
390 | 390 | |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Fires an admin action after verifying that a user can fire them. |
@@ -402,498 +402,498 @@ discard block |
||
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | - /** |
|
405 | + /** |
|
406 | 406 | * Sends a payment reminder to a customer. |
407 | - * |
|
408 | - * @param array $args |
|
407 | + * |
|
408 | + * @param array $args |
|
409 | 409 | */ |
410 | 410 | public function duplicate_payment_form( $args ) { |
411 | 411 | |
412 | - if ( empty( $args['form_id'] ) ) { |
|
413 | - return; |
|
414 | - } |
|
415 | - |
|
416 | - $form = new GetPaid_Payment_Form( $args['form_id'] ); |
|
412 | + if ( empty( $args['form_id'] ) ) { |
|
413 | + return; |
|
414 | + } |
|
417 | 415 | |
418 | - if ( ! $form->exists() ) { |
|
419 | - return; |
|
420 | - } |
|
416 | + $form = new GetPaid_Payment_Form( $args['form_id'] ); |
|
421 | 417 | |
422 | - $new_form = new GetPaid_Payment_Form(); |
|
423 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
424 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
425 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
426 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
427 | - $new_form->save(); |
|
418 | + if ( ! $form->exists() ) { |
|
419 | + return; |
|
420 | + } |
|
428 | 421 | |
429 | - if ( $new_form->exists() ) { |
|
430 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
431 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
432 | - } else { |
|
433 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
434 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
435 | - } |
|
422 | + $new_form = new GetPaid_Payment_Form(); |
|
423 | + $new_form->set_author( $form->get_author( 'edit' ) ); |
|
424 | + $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
425 | + $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
426 | + $new_form->set_items( $form->get_items( 'edit' ) ); |
|
427 | + $new_form->save(); |
|
428 | + |
|
429 | + if ( $new_form->exists() ) { |
|
430 | + $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
431 | + $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
432 | + } else { |
|
433 | + $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
434 | + $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
435 | + } |
|
436 | 436 | |
437 | - wp_redirect( $url ); |
|
438 | - exit; |
|
439 | - } |
|
437 | + wp_redirect( $url ); |
|
438 | + exit; |
|
439 | + } |
|
440 | 440 | |
441 | - /** |
|
441 | + /** |
|
442 | 442 | * Sends a payment reminder to a customer. |
443 | - * |
|
444 | - * @param array $args |
|
443 | + * |
|
444 | + * @param array $args |
|
445 | 445 | */ |
446 | 446 | public function send_customer_invoice( $args ) { |
447 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
447 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
448 | 448 | |
449 | - if ( $sent ) { |
|
450 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
451 | - } else { |
|
452 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
453 | - } |
|
449 | + if ( $sent ) { |
|
450 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
451 | + } else { |
|
452 | + $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
453 | + } |
|
454 | 454 | |
455 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
456 | - exit; |
|
457 | - } |
|
455 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
456 | + exit; |
|
457 | + } |
|
458 | 458 | |
459 | - /** |
|
459 | + /** |
|
460 | 460 | * Sends a payment reminder to a customer. |
461 | - * |
|
462 | - * @param array $args |
|
461 | + * |
|
462 | + * @param array $args |
|
463 | 463 | */ |
464 | 464 | public function send_customer_payment_reminder( $args ) { |
465 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
465 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
466 | 466 | |
467 | - if ( $sent ) { |
|
468 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
469 | - } else { |
|
470 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
471 | - } |
|
467 | + if ( $sent ) { |
|
468 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
469 | + } else { |
|
470 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
471 | + } |
|
472 | 472 | |
473 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
474 | - exit; |
|
475 | - } |
|
473 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
474 | + exit; |
|
475 | + } |
|
476 | 476 | |
477 | - /** |
|
477 | + /** |
|
478 | 478 | * Resets tax rates. |
479 | - * |
|
479 | + * |
|
480 | 480 | */ |
481 | 481 | public function admin_reset_tax_rates() { |
482 | 482 | |
483 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
484 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
485 | - exit; |
|
483 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
484 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
485 | + exit; |
|
486 | 486 | |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | - /** |
|
489 | + /** |
|
490 | 490 | * Resets admin pages. |
491 | - * |
|
491 | + * |
|
492 | 492 | */ |
493 | 493 | public function admin_create_missing_pages() { |
494 | - $installer = new GetPaid_Installer(); |
|
495 | - $installer->create_pages(); |
|
496 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
498 | - exit; |
|
499 | - } |
|
500 | - |
|
501 | - /** |
|
494 | + $installer = new GetPaid_Installer(); |
|
495 | + $installer->create_pages(); |
|
496 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
497 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
498 | + exit; |
|
499 | + } |
|
500 | + |
|
501 | + /** |
|
502 | 502 | * Creates an missing admin tables. |
503 | - * |
|
503 | + * |
|
504 | 504 | */ |
505 | 505 | public function admin_create_missing_tables() { |
506 | - global $wpdb; |
|
507 | - $installer = new GetPaid_Installer(); |
|
506 | + global $wpdb; |
|
507 | + $installer = new GetPaid_Installer(); |
|
508 | 508 | |
509 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
510 | - $installer->create_subscriptions_table(); |
|
509 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
510 | + $installer->create_subscriptions_table(); |
|
511 | 511 | |
512 | - if ( $wpdb->last_error !== '' ) { |
|
513 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
514 | - } |
|
515 | - } |
|
512 | + if ( $wpdb->last_error !== '' ) { |
|
513 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
514 | + } |
|
515 | + } |
|
516 | 516 | |
517 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
518 | - $installer->create_invoices_table(); |
|
517 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
518 | + $installer->create_invoices_table(); |
|
519 | 519 | |
520 | - if ( $wpdb->last_error !== '' ) { |
|
521 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
522 | - } |
|
523 | - } |
|
520 | + if ( $wpdb->last_error !== '' ) { |
|
521 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
522 | + } |
|
523 | + } |
|
524 | 524 | |
525 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
526 | - $installer->create_invoice_items_table(); |
|
525 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
526 | + $installer->create_invoice_items_table(); |
|
527 | 527 | |
528 | - if ( $wpdb->last_error !== '' ) { |
|
529 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
530 | - } |
|
531 | - } |
|
528 | + if ( $wpdb->last_error !== '' ) { |
|
529 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
530 | + } |
|
531 | + } |
|
532 | 532 | |
533 | - if ( ! $this->has_notices() ) { |
|
534 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
535 | - } |
|
533 | + if ( ! $this->has_notices() ) { |
|
534 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
535 | + } |
|
536 | 536 | |
537 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
538 | - exit; |
|
539 | - } |
|
537 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
538 | + exit; |
|
539 | + } |
|
540 | 540 | |
541 | - /** |
|
541 | + /** |
|
542 | 542 | * Migrates old invoices to the new database tables. |
543 | - * |
|
543 | + * |
|
544 | 544 | */ |
545 | 545 | public function admin_migrate_old_invoices() { |
546 | 546 | |
547 | - // Migrate the invoices. |
|
548 | - $installer = new GetPaid_Installer(); |
|
549 | - $installer->migrate_old_invoices(); |
|
547 | + // Migrate the invoices. |
|
548 | + $installer = new GetPaid_Installer(); |
|
549 | + $installer->migrate_old_invoices(); |
|
550 | 550 | |
551 | - // Show an admin message. |
|
552 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
551 | + // Show an admin message. |
|
552 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
553 | 553 | |
554 | - // Redirect the admin. |
|
555 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
556 | - exit; |
|
554 | + // Redirect the admin. |
|
555 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
556 | + exit; |
|
557 | 557 | |
558 | - } |
|
558 | + } |
|
559 | 559 | |
560 | - /** |
|
560 | + /** |
|
561 | 561 | * Download customers. |
562 | - * |
|
562 | + * |
|
563 | 563 | */ |
564 | 564 | public function admin_download_customers() { |
565 | - global $wpdb; |
|
565 | + global $wpdb; |
|
566 | 566 | |
567 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
567 | + $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
568 | 568 | |
569 | - header( "Content-Type:text/csv" ); |
|
570 | - header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
569 | + header( "Content-Type:text/csv" ); |
|
570 | + header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
571 | 571 | |
572 | - $post_types = ''; |
|
572 | + $post_types = ''; |
|
573 | 573 | |
574 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
575 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
576 | - } |
|
574 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
575 | + $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
576 | + } |
|
577 | 577 | |
578 | - $post_types = rtrim( $post_types, ' OR' ); |
|
578 | + $post_types = rtrim( $post_types, ' OR' ); |
|
579 | 579 | |
580 | - $customers = $wpdb->get_col( |
|
581 | - $wpdb->prepare( |
|
582 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" |
|
583 | - ) |
|
584 | - ); |
|
580 | + $customers = $wpdb->get_col( |
|
581 | + $wpdb->prepare( |
|
582 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" |
|
583 | + ) |
|
584 | + ); |
|
585 | 585 | |
586 | - $columns = array( |
|
587 | - 'name' => __( 'Name', 'invoicing' ), |
|
588 | - 'email' => __( 'Email', 'invoicing' ), |
|
589 | - 'country' => __( 'Country', 'invoicing' ), |
|
590 | - 'state' => __( 'State', 'invoicing' ), |
|
591 | - 'city' => __( 'City', 'invoicing' ), |
|
592 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
593 | - 'address' => __( 'Address', 'invoicing' ), |
|
594 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
595 | - 'company' => __( 'Company', 'invoicing' ), |
|
596 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
597 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
598 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
599 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
600 | - ); |
|
586 | + $columns = array( |
|
587 | + 'name' => __( 'Name', 'invoicing' ), |
|
588 | + 'email' => __( 'Email', 'invoicing' ), |
|
589 | + 'country' => __( 'Country', 'invoicing' ), |
|
590 | + 'state' => __( 'State', 'invoicing' ), |
|
591 | + 'city' => __( 'City', 'invoicing' ), |
|
592 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
593 | + 'address' => __( 'Address', 'invoicing' ), |
|
594 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
595 | + 'company' => __( 'Company', 'invoicing' ), |
|
596 | + 'company_id' => __( 'Company ID', 'invoicing' ), |
|
597 | + 'invoices' => __( 'Invoices', 'invoicing' ), |
|
598 | + 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
599 | + 'signup' => __( 'Date created', 'invoicing' ), |
|
600 | + ); |
|
601 | 601 | |
602 | - // Output the csv column headers. |
|
603 | - fputcsv( $output, array_values( $columns ) ); |
|
602 | + // Output the csv column headers. |
|
603 | + fputcsv( $output, array_values( $columns ) ); |
|
604 | 604 | |
605 | - // Loop through |
|
606 | - $table = new WPInv_Customers_Table(); |
|
607 | - foreach ( $customers as $customer_id ) { |
|
605 | + // Loop through |
|
606 | + $table = new WPInv_Customers_Table(); |
|
607 | + foreach ( $customers as $customer_id ) { |
|
608 | 608 | |
609 | - $user = get_user_by( 'id', $customer_id ); |
|
610 | - $row = array(); |
|
611 | - if ( empty( $user ) ) { |
|
612 | - continue; |
|
613 | - } |
|
609 | + $user = get_user_by( 'id', $customer_id ); |
|
610 | + $row = array(); |
|
611 | + if ( empty( $user ) ) { |
|
612 | + continue; |
|
613 | + } |
|
614 | 614 | |
615 | - foreach ( array_keys( $columns ) as $column ) { |
|
615 | + foreach ( array_keys( $columns ) as $column ) { |
|
616 | 616 | |
617 | - $method = 'column_' . $column; |
|
617 | + $method = 'column_' . $column; |
|
618 | 618 | |
619 | - if ( 'name' == $column ) { |
|
620 | - $value = esc_html( $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 = esc_html( $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 = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
629 | - } |
|
627 | + if ( empty( $value ) ) { |
|
628 | + $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
629 | + } |
|
630 | 630 | |
631 | - $row[] = $value; |
|
631 | + $row[] = $value; |
|
632 | 632 | |
633 | - } |
|
633 | + } |
|
634 | 634 | |
635 | - fputcsv( $output, $row ); |
|
636 | - } |
|
635 | + fputcsv( $output, $row ); |
|
636 | + } |
|
637 | 637 | |
638 | - fclose( $output ); |
|
639 | - exit; |
|
638 | + fclose( $output ); |
|
639 | + exit; |
|
640 | 640 | |
641 | - } |
|
641 | + } |
|
642 | 642 | |
643 | - /** |
|
643 | + /** |
|
644 | 644 | * Installs a plugin. |
645 | - * |
|
646 | - * @param array $data |
|
645 | + * |
|
646 | + * @param array $data |
|
647 | 647 | */ |
648 | 648 | public function admin_install_plugin( $data ) { |
649 | 649 | |
650 | - if ( ! empty( $data['plugins'] ) ) { |
|
651 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
652 | - wp_cache_flush(); |
|
650 | + if ( ! empty( $data['plugins'] ) ) { |
|
651 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
652 | + wp_cache_flush(); |
|
653 | 653 | |
654 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
655 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
656 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
657 | - $installed = $upgrader->install( $plugin_zip ); |
|
654 | + foreach ( $data['plugins'] as $slug => $file ) { |
|
655 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
656 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
657 | + $installed = $upgrader->install( $plugin_zip ); |
|
658 | 658 | |
659 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
660 | - activate_plugin( $file, '', false, true ); |
|
661 | - } else { |
|
662 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
663 | - } |
|
659 | + if ( ! is_wp_error( $installed ) && $installed ) { |
|
660 | + activate_plugin( $file, '', false, true ); |
|
661 | + } else { |
|
662 | + wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
663 | + } |
|
664 | 664 | |
665 | - } |
|
665 | + } |
|
666 | 666 | |
667 | - } |
|
667 | + } |
|
668 | 668 | |
669 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
670 | - wp_safe_redirect( $redirect ); |
|
671 | - exit; |
|
669 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
670 | + wp_safe_redirect( $redirect ); |
|
671 | + exit; |
|
672 | 672 | |
673 | - } |
|
673 | + } |
|
674 | 674 | |
675 | - /** |
|
675 | + /** |
|
676 | 676 | * Connects a gateway. |
677 | - * |
|
678 | - * @param array $data |
|
677 | + * |
|
678 | + * @param array $data |
|
679 | 679 | */ |
680 | 680 | public function admin_connect_gateway( $data ) { |
681 | 681 | |
682 | - if ( ! empty( $data['plugin'] ) ) { |
|
682 | + if ( ! empty( $data['plugin'] ) ) { |
|
683 | 683 | |
684 | - $gateway = sanitize_key( $data['plugin'] ); |
|
685 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
684 | + $gateway = sanitize_key( $data['plugin'] ); |
|
685 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
686 | 686 | |
687 | - if ( ! empty( $connect_url ) ) { |
|
688 | - wp_redirect( $connect_url ); |
|
689 | - exit; |
|
690 | - } |
|
687 | + if ( ! empty( $connect_url ) ) { |
|
688 | + wp_redirect( $connect_url ); |
|
689 | + exit; |
|
690 | + } |
|
691 | 691 | |
692 | - if ( 'stripe' == $data['plugin'] ) { |
|
693 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
694 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
695 | - wp_cache_flush(); |
|
692 | + if ( 'stripe' == $data['plugin'] ) { |
|
693 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
694 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
695 | + wp_cache_flush(); |
|
696 | 696 | |
697 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
698 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
699 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
700 | - $upgrader->install( $plugin_zip ); |
|
701 | - } |
|
697 | + if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
698 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
699 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
700 | + $upgrader->install( $plugin_zip ); |
|
701 | + } |
|
702 | 702 | |
703 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
704 | - } |
|
703 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
704 | + } |
|
705 | 705 | |
706 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
707 | - if ( ! empty( $connect_url ) ) { |
|
708 | - wp_redirect( $connect_url ); |
|
709 | - exit; |
|
710 | - } |
|
706 | + $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
707 | + if ( ! empty( $connect_url ) ) { |
|
708 | + wp_redirect( $connect_url ); |
|
709 | + exit; |
|
710 | + } |
|
711 | 711 | |
712 | - } |
|
712 | + } |
|
713 | 713 | |
714 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
715 | - wp_safe_redirect( $redirect ); |
|
716 | - exit; |
|
714 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
715 | + wp_safe_redirect( $redirect ); |
|
716 | + exit; |
|
717 | 717 | |
718 | - } |
|
718 | + } |
|
719 | 719 | |
720 | - /** |
|
720 | + /** |
|
721 | 721 | * Recalculates discounts. |
722 | - * |
|
722 | + * |
|
723 | 723 | */ |
724 | 724 | public function admin_recalculate_discounts() { |
725 | - global $wpdb; |
|
725 | + global $wpdb; |
|
726 | 726 | |
727 | - // Fetch all invoices that have discount codes. |
|
728 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
729 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
727 | + // Fetch all invoices that have discount codes. |
|
728 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
729 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
730 | 730 | |
731 | - foreach ( $invoices as $invoice ) { |
|
731 | + foreach ( $invoices as $invoice ) { |
|
732 | 732 | |
733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
733 | + $invoice = new WPInv_Invoice( $invoice ); |
|
734 | 734 | |
735 | - if ( ! $invoice->exists() ) { |
|
736 | - continue; |
|
737 | - } |
|
735 | + if ( ! $invoice->exists() ) { |
|
736 | + continue; |
|
737 | + } |
|
738 | 738 | |
739 | - // Abort if the discount does not exist or does not apply here. |
|
740 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
741 | - if ( ! $discount->exists() ) { |
|
742 | - continue; |
|
743 | - } |
|
739 | + // Abort if the discount does not exist or does not apply here. |
|
740 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
741 | + if ( ! $discount->exists() ) { |
|
742 | + continue; |
|
743 | + } |
|
744 | 744 | |
745 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
746 | - $invoice->recalculate_total(); |
|
745 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
746 | + $invoice->recalculate_total(); |
|
747 | 747 | |
748 | - if ( $invoice->get_total_discount() > 0 ) { |
|
749 | - $invoice->save(); |
|
750 | - } |
|
748 | + if ( $invoice->get_total_discount() > 0 ) { |
|
749 | + $invoice->save(); |
|
750 | + } |
|
751 | 751 | |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | - // Show an admin message. |
|
755 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
754 | + // Show an admin message. |
|
755 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
756 | 756 | |
757 | - // Redirect the admin. |
|
758 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
759 | - exit; |
|
757 | + // Redirect the admin. |
|
758 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
759 | + exit; |
|
760 | 760 | |
761 | - } |
|
761 | + } |
|
762 | 762 | |
763 | 763 | /** |
764 | - * Returns an array of admin notices. |
|
765 | - * |
|
766 | - * @since 1.0.19 |
|
764 | + * Returns an array of admin notices. |
|
765 | + * |
|
766 | + * @since 1.0.19 |
|
767 | 767 | * @return array |
768 | - */ |
|
769 | - public function get_notices() { |
|
770 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
768 | + */ |
|
769 | + public function get_notices() { |
|
770 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
771 | 771 | return is_array( $notices ) ? $notices : array(); |
772 | - } |
|
772 | + } |
|
773 | 773 | |
774 | - /** |
|
775 | - * Checks if we have any admin notices. |
|
776 | - * |
|
777 | - * @since 2.0.4 |
|
774 | + /** |
|
775 | + * Checks if we have any admin notices. |
|
776 | + * |
|
777 | + * @since 2.0.4 |
|
778 | 778 | * @return array |
779 | - */ |
|
780 | - public function has_notices() { |
|
781 | - return count( $this->get_notices() ) > 0; |
|
782 | - } |
|
783 | - |
|
784 | - /** |
|
785 | - * Clears all admin notices |
|
786 | - * |
|
787 | - * @access public |
|
788 | - * @since 1.0.19 |
|
789 | - */ |
|
790 | - public function clear_notices() { |
|
791 | - delete_option( 'wpinv_admin_notices' ); |
|
792 | - } |
|
793 | - |
|
794 | - /** |
|
795 | - * Saves a new admin notice |
|
796 | - * |
|
797 | - * @access public |
|
798 | - * @since 1.0.19 |
|
799 | - */ |
|
800 | - public function save_notice( $type, $message ) { |
|
801 | - $notices = $this->get_notices(); |
|
802 | - |
|
803 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
804 | - $notices[ $type ] = array(); |
|
805 | - } |
|
806 | - |
|
807 | - $notices[ $type ][] = $message; |
|
808 | - |
|
809 | - update_option( 'wpinv_admin_notices', $notices ); |
|
810 | - } |
|
811 | - |
|
812 | - /** |
|
813 | - * Displays a success notice |
|
814 | - * |
|
815 | - * @param string $msg The message to qeue. |
|
816 | - * @access public |
|
817 | - * @since 1.0.19 |
|
818 | - */ |
|
819 | - public function show_success( $msg ) { |
|
820 | - $this->save_notice( 'success', $msg ); |
|
821 | - } |
|
822 | - |
|
823 | - /** |
|
824 | - * Displays a error notice |
|
825 | - * |
|
826 | - * @access public |
|
827 | - * @param string $msg The message to qeue. |
|
828 | - * @since 1.0.19 |
|
829 | - */ |
|
830 | - public function show_error( $msg ) { |
|
831 | - $this->save_notice( 'error', $msg ); |
|
832 | - } |
|
833 | - |
|
834 | - /** |
|
835 | - * Displays a warning notice |
|
836 | - * |
|
837 | - * @access public |
|
838 | - * @param string $msg The message to qeue. |
|
839 | - * @since 1.0.19 |
|
840 | - */ |
|
841 | - public function show_warning( $msg ) { |
|
842 | - $this->save_notice( 'warning', $msg ); |
|
843 | - } |
|
844 | - |
|
845 | - /** |
|
846 | - * Displays a info notice |
|
847 | - * |
|
848 | - * @access public |
|
849 | - * @param string $msg The message to qeue. |
|
850 | - * @since 1.0.19 |
|
851 | - */ |
|
852 | - public function show_info( $msg ) { |
|
853 | - $this->save_notice( 'info', $msg ); |
|
854 | - } |
|
855 | - |
|
856 | - /** |
|
857 | - * Show notices |
|
858 | - * |
|
859 | - * @access public |
|
860 | - * @since 1.0.19 |
|
861 | - */ |
|
862 | - public function show_notices() { |
|
779 | + */ |
|
780 | + public function has_notices() { |
|
781 | + return count( $this->get_notices() ) > 0; |
|
782 | + } |
|
783 | + |
|
784 | + /** |
|
785 | + * Clears all admin notices |
|
786 | + * |
|
787 | + * @access public |
|
788 | + * @since 1.0.19 |
|
789 | + */ |
|
790 | + public function clear_notices() { |
|
791 | + delete_option( 'wpinv_admin_notices' ); |
|
792 | + } |
|
793 | + |
|
794 | + /** |
|
795 | + * Saves a new admin notice |
|
796 | + * |
|
797 | + * @access public |
|
798 | + * @since 1.0.19 |
|
799 | + */ |
|
800 | + public function save_notice( $type, $message ) { |
|
801 | + $notices = $this->get_notices(); |
|
802 | + |
|
803 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
804 | + $notices[ $type ] = array(); |
|
805 | + } |
|
806 | + |
|
807 | + $notices[ $type ][] = $message; |
|
808 | + |
|
809 | + update_option( 'wpinv_admin_notices', $notices ); |
|
810 | + } |
|
811 | + |
|
812 | + /** |
|
813 | + * Displays a success notice |
|
814 | + * |
|
815 | + * @param string $msg The message to qeue. |
|
816 | + * @access public |
|
817 | + * @since 1.0.19 |
|
818 | + */ |
|
819 | + public function show_success( $msg ) { |
|
820 | + $this->save_notice( 'success', $msg ); |
|
821 | + } |
|
822 | + |
|
823 | + /** |
|
824 | + * Displays a error notice |
|
825 | + * |
|
826 | + * @access public |
|
827 | + * @param string $msg The message to qeue. |
|
828 | + * @since 1.0.19 |
|
829 | + */ |
|
830 | + public function show_error( $msg ) { |
|
831 | + $this->save_notice( 'error', $msg ); |
|
832 | + } |
|
833 | + |
|
834 | + /** |
|
835 | + * Displays a warning notice |
|
836 | + * |
|
837 | + * @access public |
|
838 | + * @param string $msg The message to qeue. |
|
839 | + * @since 1.0.19 |
|
840 | + */ |
|
841 | + public function show_warning( $msg ) { |
|
842 | + $this->save_notice( 'warning', $msg ); |
|
843 | + } |
|
844 | + |
|
845 | + /** |
|
846 | + * Displays a info notice |
|
847 | + * |
|
848 | + * @access public |
|
849 | + * @param string $msg The message to qeue. |
|
850 | + * @since 1.0.19 |
|
851 | + */ |
|
852 | + public function show_info( $msg ) { |
|
853 | + $this->save_notice( 'info', $msg ); |
|
854 | + } |
|
855 | + |
|
856 | + /** |
|
857 | + * Show notices |
|
858 | + * |
|
859 | + * @access public |
|
860 | + * @since 1.0.19 |
|
861 | + */ |
|
862 | + public function show_notices() { |
|
863 | 863 | |
864 | 864 | $notices = $this->get_notices(); |
865 | 865 | $this->clear_notices(); |
866 | 866 | |
867 | - foreach ( $notices as $type => $messages ) { |
|
867 | + foreach ( $notices as $type => $messages ) { |
|
868 | 868 | |
869 | - if ( ! is_array( $messages ) ) { |
|
870 | - continue; |
|
871 | - } |
|
869 | + if ( ! is_array( $messages ) ) { |
|
870 | + continue; |
|
871 | + } |
|
872 | 872 | |
873 | 873 | $type = sanitize_key( $type ); |
874 | - foreach ( $messages as $message ) { |
|
874 | + foreach ( $messages as $message ) { |
|
875 | 875 | $message = wp_kses_post( $message ); |
876 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
876 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | } |
880 | 880 | |
881 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
882 | - |
|
883 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
884 | - $url = wp_nonce_url( |
|
885 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
886 | - 'getpaid-nonce', |
|
887 | - 'getpaid-nonce' |
|
888 | - ); |
|
889 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
890 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
891 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
892 | - break; |
|
893 | - } |
|
881 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
882 | + |
|
883 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
884 | + $url = wp_nonce_url( |
|
885 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
886 | + 'getpaid-nonce', |
|
887 | + 'getpaid-nonce' |
|
888 | + ); |
|
889 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
890 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
891 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
892 | + break; |
|
893 | + } |
|
894 | 894 | |
895 | - } |
|
895 | + } |
|
896 | 896 | |
897 | - } |
|
897 | + } |
|
898 | 898 | |
899 | 899 | } |
@@ -1,103 +1,103 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) { |
8 | 8 | |
9 | - class AyeCode_Deactivation_Survey { |
|
9 | + class AyeCode_Deactivation_Survey { |
|
10 | 10 | |
11 | - /** |
|
12 | - * AyeCode_Deactivation_Survey instance. |
|
13 | - * |
|
14 | - * @access private |
|
15 | - * @since 1.0.0 |
|
16 | - * @var AyeCode_Deactivation_Survey There can be only one! |
|
17 | - */ |
|
18 | - private static $instance = null; |
|
11 | + /** |
|
12 | + * AyeCode_Deactivation_Survey instance. |
|
13 | + * |
|
14 | + * @access private |
|
15 | + * @since 1.0.0 |
|
16 | + * @var AyeCode_Deactivation_Survey There can be only one! |
|
17 | + */ |
|
18 | + private static $instance = null; |
|
19 | 19 | |
20 | - public static $plugins; |
|
20 | + public static $plugins; |
|
21 | 21 | |
22 | - public $version = "1.0.4"; |
|
22 | + public $version = "1.0.4"; |
|
23 | 23 | |
24 | - public static function instance( $plugin = array() ) { |
|
25 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) { |
|
26 | - self::$instance = new AyeCode_Deactivation_Survey; |
|
27 | - self::$plugins = array(); |
|
24 | + public static function instance( $plugin = array() ) { |
|
25 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) { |
|
26 | + self::$instance = new AyeCode_Deactivation_Survey; |
|
27 | + self::$plugins = array(); |
|
28 | 28 | |
29 | - add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) ); |
|
29 | + add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) ); |
|
30 | 30 | |
31 | - do_action( 'ayecode_deactivation_survey_loaded' ); |
|
32 | - } |
|
31 | + do_action( 'ayecode_deactivation_survey_loaded' ); |
|
32 | + } |
|
33 | 33 | |
34 | - if(!empty($plugin)){ |
|
35 | - self::$plugins[] = (object)$plugin; |
|
36 | - } |
|
34 | + if(!empty($plugin)){ |
|
35 | + self::$plugins[] = (object)$plugin; |
|
36 | + } |
|
37 | 37 | |
38 | - return self::$instance; |
|
39 | - } |
|
38 | + return self::$instance; |
|
39 | + } |
|
40 | 40 | |
41 | - public function scripts() { |
|
42 | - global $pagenow; |
|
41 | + public function scripts() { |
|
42 | + global $pagenow; |
|
43 | 43 | |
44 | - // Bail if we are not on the plugins page |
|
45 | - if ( $pagenow != "plugins.php" ) { |
|
46 | - return; |
|
47 | - } |
|
44 | + // Bail if we are not on the plugins page |
|
45 | + if ( $pagenow != "plugins.php" ) { |
|
46 | + return; |
|
47 | + } |
|
48 | 48 | |
49 | - // Enqueue scripts |
|
50 | - add_thickbox(); |
|
51 | - wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js'); |
|
49 | + // Enqueue scripts |
|
50 | + add_thickbox(); |
|
51 | + wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js'); |
|
52 | 52 | |
53 | - /* |
|
53 | + /* |
|
54 | 54 | * Localized strings. Strings can be localised by plugins using this class. |
55 | 55 | * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review. |
56 | 56 | */ |
57 | - wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array( |
|
58 | - 'quick_feedback' => 'Quick Feedback', |
|
59 | - 'foreword' => 'If you would be kind enough, please tell us why you\'re deactivating?', |
|
60 | - 'better_plugins_name' => 'Please tell us which plugin?', |
|
61 | - 'please_tell_us' => 'Please tell us the reason so we can improve the plugin', |
|
62 | - 'do_not_attach_email' => 'Do not send my e-mail address with this feedback', |
|
63 | - 'brief_description' => 'Please give us any feedback that could help us improve', |
|
64 | - 'cancel' => 'Cancel', |
|
65 | - 'skip_and_deactivate' => 'Skip & Deactivate', |
|
66 | - 'submit_and_deactivate' => 'Submit & Deactivate', |
|
67 | - 'please_wait' => 'Please wait', |
|
68 | - 'get_support' => 'Get Support', |
|
69 | - 'documentation' => 'Documentation', |
|
70 | - 'thank_you' => 'Thank you!', |
|
71 | - )); |
|
72 | - |
|
73 | - // Plugins |
|
74 | - $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins); |
|
75 | - |
|
76 | - // Reasons |
|
77 | - $defaultReasons = array( |
|
78 | - 'suddenly-stopped-working' => 'The plugin suddenly stopped working', |
|
79 | - 'plugin-broke-site' => 'The plugin broke my site', |
|
80 | - 'plugin-setup-difficult' => 'Too difficult to setup', |
|
81 | - 'plugin-design-difficult' => 'Too difficult to get the design i want', |
|
82 | - 'no-longer-needed' => 'I don\'t need this plugin any more', |
|
83 | - 'found-better-plugin' => 'I found a better plugin', |
|
84 | - 'temporary-deactivation' => 'It\'s a temporary deactivation, I\'m troubleshooting', |
|
85 | - 'other' => 'Other', |
|
86 | - ); |
|
87 | - |
|
88 | - foreach($plugins as $plugin) |
|
89 | - { |
|
90 | - $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin); |
|
91 | - $plugin->url = home_url(); |
|
92 | - $plugin->activated = 0; |
|
93 | - } |
|
94 | - |
|
95 | - // Send plugin data |
|
96 | - wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins); |
|
97 | - |
|
98 | - } |
|
57 | + wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array( |
|
58 | + 'quick_feedback' => 'Quick Feedback', |
|
59 | + 'foreword' => 'If you would be kind enough, please tell us why you\'re deactivating?', |
|
60 | + 'better_plugins_name' => 'Please tell us which plugin?', |
|
61 | + 'please_tell_us' => 'Please tell us the reason so we can improve the plugin', |
|
62 | + 'do_not_attach_email' => 'Do not send my e-mail address with this feedback', |
|
63 | + 'brief_description' => 'Please give us any feedback that could help us improve', |
|
64 | + 'cancel' => 'Cancel', |
|
65 | + 'skip_and_deactivate' => 'Skip & Deactivate', |
|
66 | + 'submit_and_deactivate' => 'Submit & Deactivate', |
|
67 | + 'please_wait' => 'Please wait', |
|
68 | + 'get_support' => 'Get Support', |
|
69 | + 'documentation' => 'Documentation', |
|
70 | + 'thank_you' => 'Thank you!', |
|
71 | + )); |
|
72 | + |
|
73 | + // Plugins |
|
74 | + $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins); |
|
75 | + |
|
76 | + // Reasons |
|
77 | + $defaultReasons = array( |
|
78 | + 'suddenly-stopped-working' => 'The plugin suddenly stopped working', |
|
79 | + 'plugin-broke-site' => 'The plugin broke my site', |
|
80 | + 'plugin-setup-difficult' => 'Too difficult to setup', |
|
81 | + 'plugin-design-difficult' => 'Too difficult to get the design i want', |
|
82 | + 'no-longer-needed' => 'I don\'t need this plugin any more', |
|
83 | + 'found-better-plugin' => 'I found a better plugin', |
|
84 | + 'temporary-deactivation' => 'It\'s a temporary deactivation, I\'m troubleshooting', |
|
85 | + 'other' => 'Other', |
|
86 | + ); |
|
87 | + |
|
88 | + foreach($plugins as $plugin) |
|
89 | + { |
|
90 | + $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin); |
|
91 | + $plugin->url = home_url(); |
|
92 | + $plugin->activated = 0; |
|
93 | + } |
|
94 | + |
|
95 | + // Send plugin data |
|
96 | + wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins); |
|
97 | + |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | 14 | private static $installed = array ( |
15 | - 'root' => |
|
16 | - array ( |
|
15 | + 'root' => |
|
16 | + array ( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
@@ -21,96 +21,96 @@ discard block |
||
21 | 21 | ), |
22 | 22 | 'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | - ), |
|
25 | - 'versions' => |
|
26 | - array ( |
|
24 | + ), |
|
25 | + 'versions' => |
|
26 | + array ( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | 28 | array ( |
29 | - 'pretty_version' => '1.0.3', |
|
30 | - 'version' => '1.0.3.0', |
|
31 | - 'aliases' => |
|
32 | - array ( |
|
33 | - ), |
|
34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
29 | + 'pretty_version' => '1.0.3', |
|
30 | + 'version' => '1.0.3.0', |
|
31 | + 'aliases' => |
|
32 | + array ( |
|
33 | + ), |
|
34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | 37 | array ( |
38 | - 'pretty_version' => 'dev-master', |
|
39 | - 'version' => 'dev-master', |
|
40 | - 'aliases' => |
|
41 | - array ( |
|
42 | - ), |
|
43 | - 'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a', |
|
38 | + 'pretty_version' => 'dev-master', |
|
39 | + 'version' => 'dev-master', |
|
40 | + 'aliases' => |
|
41 | + array ( |
|
42 | + ), |
|
43 | + 'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a', |
|
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | 46 | array ( |
47 | - 'pretty_version' => '0.1.61', |
|
48 | - 'version' => '0.1.61.0', |
|
49 | - 'aliases' => |
|
50 | - array ( |
|
51 | - ), |
|
52 | - 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
47 | + 'pretty_version' => '0.1.61', |
|
48 | + 'version' => '0.1.61.0', |
|
49 | + 'aliases' => |
|
50 | + array ( |
|
51 | + ), |
|
52 | + 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
53 | 53 | ), |
54 | 54 | 'ayecode/wp-deactivation-survey' => |
55 | 55 | array ( |
56 | - 'pretty_version' => '1.0.4', |
|
57 | - 'version' => '1.0.4.0', |
|
58 | - 'aliases' => |
|
59 | - array ( |
|
60 | - ), |
|
61 | - 'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398', |
|
56 | + 'pretty_version' => '1.0.4', |
|
57 | + 'version' => '1.0.4.0', |
|
58 | + 'aliases' => |
|
59 | + array ( |
|
60 | + ), |
|
61 | + 'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398', |
|
62 | 62 | ), |
63 | 63 | 'ayecode/wp-font-awesome-settings' => |
64 | 64 | array ( |
65 | - 'pretty_version' => '1.0.13', |
|
66 | - 'version' => '1.0.13.0', |
|
67 | - 'aliases' => |
|
68 | - array ( |
|
69 | - ), |
|
70 | - 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
65 | + 'pretty_version' => '1.0.13', |
|
66 | + 'version' => '1.0.13.0', |
|
67 | + 'aliases' => |
|
68 | + array ( |
|
69 | + ), |
|
70 | + 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
71 | 71 | ), |
72 | 72 | 'ayecode/wp-super-duper' => |
73 | 73 | array ( |
74 | - 'pretty_version' => '1.0.27', |
|
75 | - 'version' => '1.0.27.0', |
|
76 | - 'aliases' => |
|
77 | - array ( |
|
78 | - ), |
|
79 | - 'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d', |
|
74 | + 'pretty_version' => '1.0.27', |
|
75 | + 'version' => '1.0.27.0', |
|
76 | + 'aliases' => |
|
77 | + array ( |
|
78 | + ), |
|
79 | + 'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d', |
|
80 | 80 | ), |
81 | 81 | 'composer/installers' => |
82 | 82 | array ( |
83 | - 'pretty_version' => 'v1.12.0', |
|
84 | - 'version' => '1.12.0.0', |
|
85 | - 'aliases' => |
|
86 | - array ( |
|
87 | - ), |
|
88 | - 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
83 | + 'pretty_version' => 'v1.12.0', |
|
84 | + 'version' => '1.12.0.0', |
|
85 | + 'aliases' => |
|
86 | + array ( |
|
87 | + ), |
|
88 | + 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
89 | 89 | ), |
90 | 90 | 'maxmind-db/reader' => |
91 | 91 | array ( |
92 | - 'pretty_version' => 'v1.6.0', |
|
93 | - 'version' => '1.6.0.0', |
|
94 | - 'aliases' => |
|
95 | - array ( |
|
96 | - ), |
|
97 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
92 | + 'pretty_version' => 'v1.6.0', |
|
93 | + 'version' => '1.6.0.0', |
|
94 | + 'aliases' => |
|
95 | + array ( |
|
96 | + ), |
|
97 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
98 | 98 | ), |
99 | 99 | 'roundcube/plugin-installer' => |
100 | 100 | array ( |
101 | - 'replaced' => |
|
102 | - array ( |
|
101 | + 'replaced' => |
|
102 | + array ( |
|
103 | 103 | 0 => '*', |
104 | - ), |
|
104 | + ), |
|
105 | 105 | ), |
106 | 106 | 'shama/baton' => |
107 | 107 | array ( |
108 | - 'replaced' => |
|
109 | - array ( |
|
108 | + 'replaced' => |
|
109 | + array ( |
|
110 | 110 | 0 => '*', |
111 | - ), |
|
111 | + ), |
|
112 | + ), |
|
112 | 113 | ), |
113 | - ), |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'root' => |
|
3 | - array ( |
|
2 | + 'root' => |
|
3 | + array ( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
@@ -8,94 +8,94 @@ discard block |
||
8 | 8 | ), |
9 | 9 | 'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | - ), |
|
12 | - 'versions' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'versions' => |
|
13 | + array ( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | 15 | array ( |
16 | - 'pretty_version' => '1.0.3', |
|
17 | - 'version' => '1.0.3.0', |
|
18 | - 'aliases' => |
|
19 | - array ( |
|
20 | - ), |
|
21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
16 | + 'pretty_version' => '1.0.3', |
|
17 | + 'version' => '1.0.3.0', |
|
18 | + 'aliases' => |
|
19 | + array ( |
|
20 | + ), |
|
21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | 24 | array ( |
25 | - 'pretty_version' => 'dev-master', |
|
26 | - 'version' => 'dev-master', |
|
27 | - 'aliases' => |
|
28 | - array ( |
|
29 | - ), |
|
30 | - 'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a', |
|
25 | + 'pretty_version' => 'dev-master', |
|
26 | + 'version' => 'dev-master', |
|
27 | + 'aliases' => |
|
28 | + array ( |
|
29 | + ), |
|
30 | + 'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a', |
|
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | 33 | array ( |
34 | - 'pretty_version' => '0.1.61', |
|
35 | - 'version' => '0.1.61.0', |
|
36 | - 'aliases' => |
|
37 | - array ( |
|
38 | - ), |
|
39 | - 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
34 | + 'pretty_version' => '0.1.61', |
|
35 | + 'version' => '0.1.61.0', |
|
36 | + 'aliases' => |
|
37 | + array ( |
|
38 | + ), |
|
39 | + 'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5', |
|
40 | 40 | ), |
41 | 41 | 'ayecode/wp-deactivation-survey' => |
42 | 42 | array ( |
43 | - 'pretty_version' => '1.0.4', |
|
44 | - 'version' => '1.0.4.0', |
|
45 | - 'aliases' => |
|
46 | - array ( |
|
47 | - ), |
|
48 | - 'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398', |
|
43 | + 'pretty_version' => '1.0.4', |
|
44 | + 'version' => '1.0.4.0', |
|
45 | + 'aliases' => |
|
46 | + array ( |
|
47 | + ), |
|
48 | + 'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398', |
|
49 | 49 | ), |
50 | 50 | 'ayecode/wp-font-awesome-settings' => |
51 | 51 | array ( |
52 | - 'pretty_version' => '1.0.13', |
|
53 | - 'version' => '1.0.13.0', |
|
54 | - 'aliases' => |
|
55 | - array ( |
|
56 | - ), |
|
57 | - 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
52 | + 'pretty_version' => '1.0.13', |
|
53 | + 'version' => '1.0.13.0', |
|
54 | + 'aliases' => |
|
55 | + array ( |
|
56 | + ), |
|
57 | + 'reference' => 'a7a11ee4290674ec214d1fe694139af275350402', |
|
58 | 58 | ), |
59 | 59 | 'ayecode/wp-super-duper' => |
60 | 60 | array ( |
61 | - 'pretty_version' => '1.0.27', |
|
62 | - 'version' => '1.0.27.0', |
|
63 | - 'aliases' => |
|
64 | - array ( |
|
65 | - ), |
|
66 | - 'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d', |
|
61 | + 'pretty_version' => '1.0.27', |
|
62 | + 'version' => '1.0.27.0', |
|
63 | + 'aliases' => |
|
64 | + array ( |
|
65 | + ), |
|
66 | + 'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d', |
|
67 | 67 | ), |
68 | 68 | 'composer/installers' => |
69 | 69 | array ( |
70 | - 'pretty_version' => 'v1.12.0', |
|
71 | - 'version' => '1.12.0.0', |
|
72 | - 'aliases' => |
|
73 | - array ( |
|
74 | - ), |
|
75 | - 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
70 | + 'pretty_version' => 'v1.12.0', |
|
71 | + 'version' => '1.12.0.0', |
|
72 | + 'aliases' => |
|
73 | + array ( |
|
74 | + ), |
|
75 | + 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19', |
|
76 | 76 | ), |
77 | 77 | 'maxmind-db/reader' => |
78 | 78 | array ( |
79 | - 'pretty_version' => 'v1.6.0', |
|
80 | - 'version' => '1.6.0.0', |
|
81 | - 'aliases' => |
|
82 | - array ( |
|
83 | - ), |
|
84 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
79 | + 'pretty_version' => 'v1.6.0', |
|
80 | + 'version' => '1.6.0.0', |
|
81 | + 'aliases' => |
|
82 | + array ( |
|
83 | + ), |
|
84 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
85 | 85 | ), |
86 | 86 | 'roundcube/plugin-installer' => |
87 | 87 | array ( |
88 | - 'replaced' => |
|
89 | - array ( |
|
88 | + 'replaced' => |
|
89 | + array ( |
|
90 | 90 | 0 => '*', |
91 | - ), |
|
91 | + ), |
|
92 | 92 | ), |
93 | 93 | 'shama/baton' => |
94 | 94 | array ( |
95 | - 'replaced' => |
|
96 | - array ( |
|
95 | + 'replaced' => |
|
96 | + array ( |
|
97 | 97 | 0 => '*', |
98 | - ), |
|
98 | + ), |
|
99 | + ), |
|
99 | 100 | ), |
100 | - ), |
|
101 | 101 | ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,67 +10,67 @@ discard block |
||
10 | 10 | class GetPaid_Form_Item extends WPInv_Item { |
11 | 11 | |
12 | 12 | /** |
13 | - * Stores a custom description for the item. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $custom_description = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * Stores the item quantity. |
|
21 | - * |
|
22 | - * @var float |
|
23 | - */ |
|
24 | - protected $quantity = 1; |
|
25 | - |
|
26 | - /** |
|
27 | - * Stores the item meta. |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - protected $meta = array(); |
|
32 | - |
|
33 | - /** |
|
34 | - * Is this item required? |
|
35 | - * |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - protected $is_required = true; |
|
39 | - |
|
40 | - /** |
|
41 | - * Are quantities allowed? |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - protected $allow_quantities = false; |
|
46 | - |
|
47 | - /** |
|
48 | - * Associated invoice. |
|
49 | - * |
|
50 | - * @var int |
|
51 | - */ |
|
52 | - public $invoice_id = 0; |
|
53 | - |
|
54 | - /** |
|
55 | - * Item discount. |
|
56 | - * |
|
57 | - * @var float |
|
58 | - */ |
|
59 | - public $item_discount = 0; |
|
60 | - |
|
61 | - /** |
|
62 | - * Recurring item discount. |
|
63 | - * |
|
64 | - * @var float |
|
65 | - */ |
|
66 | - public $recurring_item_discount = 0; |
|
67 | - |
|
68 | - /** |
|
69 | - * Item tax. |
|
70 | - * |
|
71 | - * @var float |
|
72 | - */ |
|
73 | - public $item_tax = 0; |
|
13 | + * Stores a custom description for the item. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $custom_description = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * Stores the item quantity. |
|
21 | + * |
|
22 | + * @var float |
|
23 | + */ |
|
24 | + protected $quantity = 1; |
|
25 | + |
|
26 | + /** |
|
27 | + * Stores the item meta. |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + protected $meta = array(); |
|
32 | + |
|
33 | + /** |
|
34 | + * Is this item required? |
|
35 | + * |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + protected $is_required = true; |
|
39 | + |
|
40 | + /** |
|
41 | + * Are quantities allowed? |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + protected $allow_quantities = false; |
|
46 | + |
|
47 | + /** |
|
48 | + * Associated invoice. |
|
49 | + * |
|
50 | + * @var int |
|
51 | + */ |
|
52 | + public $invoice_id = 0; |
|
53 | + |
|
54 | + /** |
|
55 | + * Item discount. |
|
56 | + * |
|
57 | + * @var float |
|
58 | + */ |
|
59 | + public $item_discount = 0; |
|
60 | + |
|
61 | + /** |
|
62 | + * Recurring item discount. |
|
63 | + * |
|
64 | + * @var float |
|
65 | + */ |
|
66 | + public $recurring_item_discount = 0; |
|
67 | + |
|
68 | + /** |
|
69 | + * Item tax. |
|
70 | + * |
|
71 | + * @var float |
|
72 | + */ |
|
73 | + public $item_tax = 0; |
|
74 | 74 | |
75 | 75 | /* |
76 | 76 | |-------------------------------------------------------------------------- |
@@ -88,230 +88,230 @@ discard block |
||
88 | 88 | */ |
89 | 89 | |
90 | 90 | /** |
91 | - * Get the item name. |
|
92 | - * |
|
93 | - * @since 1.0.19 |
|
94 | - * @param string $context View or edit context. |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function get_name( $context = 'view' ) { |
|
98 | - $name = parent::get_name( $context ); |
|
99 | - return $name . wpinv_get_item_suffix( $this ); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Get the item name without a suffix. |
|
104 | - * |
|
105 | - * @since 1.0.19 |
|
106 | - * @param string $context View or edit context. |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function get_raw_name( $context = 'view' ) { |
|
110 | - return parent::get_name( $context ); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Get the item description. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - * @param string $context View or edit context. |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function get_description( $context = 'view' ) { |
|
121 | - |
|
122 | - if ( isset( $this->custom_description ) ) { |
|
123 | - return $this->custom_description; |
|
124 | - } |
|
125 | - |
|
126 | - return parent::get_description( $context ); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Returns the sub total. |
|
131 | - * |
|
132 | - * @since 1.0.19 |
|
133 | - * @param string $context View or edit context. |
|
134 | - * @return float |
|
135 | - */ |
|
136 | - public function get_sub_total( $context = 'view' ) { |
|
137 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Returns the recurring sub total. |
|
142 | - * |
|
143 | - * @since 1.0.19 |
|
144 | - * @param string $context View or edit context. |
|
145 | - * @return float |
|
146 | - */ |
|
147 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
148 | - |
|
149 | - if ( $this->is_recurring() ) { |
|
150 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
151 | - } |
|
152 | - |
|
153 | - return 0; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @deprecated |
|
158 | - */ |
|
159 | - public function get_qantity( $context = 'view' ) { |
|
160 | - return $this->get_quantity( $context ); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Get the item quantity. |
|
165 | - * |
|
166 | - * @since 1.0.19 |
|
167 | - * @param string $context View or edit context. |
|
168 | - * @return float |
|
169 | - */ |
|
170 | - public function get_quantity( $context = 'view' ) { |
|
171 | - $quantity = (float) $this->quantity; |
|
172 | - |
|
173 | - if ( 'view' == $context ) { |
|
174 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
175 | - } |
|
176 | - |
|
177 | - return $quantity; |
|
178 | - |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Get the item meta data. |
|
183 | - * |
|
184 | - * @since 1.0.19 |
|
185 | - * @param string $context View or edit context. |
|
186 | - * @return meta |
|
187 | - */ |
|
188 | - public function get_item_meta( $context = 'view' ) { |
|
189 | - $meta = $this->meta; |
|
190 | - |
|
191 | - if ( 'view' == $context ) { |
|
192 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
193 | - } |
|
194 | - |
|
195 | - return $meta; |
|
196 | - |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns whether or not customers can update the item quantity. |
|
201 | - * |
|
202 | - * @since 1.0.19 |
|
203 | - * @param string $context View or edit context. |
|
204 | - * @return bool |
|
205 | - */ |
|
206 | - public function get_allow_quantities( $context = 'view' ) { |
|
207 | - $allow_quantities = (bool) $this->allow_quantities; |
|
208 | - |
|
209 | - if ( 'view' == $context ) { |
|
210 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
211 | - } |
|
212 | - |
|
213 | - return $allow_quantities; |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Returns whether or not the item is required. |
|
219 | - * |
|
220 | - * @since 1.0.19 |
|
221 | - * @param string $context View or edit context. |
|
222 | - * @return bool |
|
223 | - */ |
|
224 | - public function get_is_required( $context = 'view' ) { |
|
225 | - $is_required = (bool) $this->is_required; |
|
226 | - |
|
227 | - if ( 'view' == $context ) { |
|
228 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
229 | - } |
|
230 | - |
|
231 | - return $is_required; |
|
232 | - |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Prepares form data for use. |
|
237 | - * |
|
238 | - * @since 1.0.19 |
|
239 | - * @return array |
|
240 | - */ |
|
241 | - public function prepare_data_for_use( $required = null ) { |
|
242 | - |
|
243 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
244 | - return array( |
|
245 | - 'title' => strip_tags( $this->get_name() ), |
|
246 | - 'id' => $this->get_id(), |
|
247 | - 'price' => $this->get_price(), |
|
248 | - 'recurring' => $this->is_recurring(), |
|
249 | - 'description' => $this->get_description(), |
|
250 | - 'allow_quantities' => $this->allows_quantities(), |
|
251 | - 'required' => $required, |
|
252 | - ); |
|
253 | - |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Prepares form data for ajax use. |
|
258 | - * |
|
259 | - * @since 1.0.19 |
|
260 | - * @return array |
|
261 | - */ |
|
262 | - public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) { |
|
263 | - |
|
264 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
265 | - |
|
266 | - if ( $description ) { |
|
267 | - $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
268 | - } |
|
269 | - |
|
270 | - $price = ! $is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
271 | - $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
272 | - return array( |
|
273 | - 'id' => $this->get_id(), |
|
274 | - 'texts' => array( |
|
275 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
276 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
277 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
278 | - 'item-price' => wpinv_price( $price, $currency ), |
|
279 | - 'item-total' => wpinv_price( $subtotal, $currency ), |
|
280 | - ), |
|
281 | - 'inputs' => array( |
|
282 | - 'item-id' => $this->get_id(), |
|
283 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
284 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
285 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
286 | - 'item-price' => $price, |
|
287 | - ) |
|
288 | - ); |
|
289 | - |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Prepares form data for saving (cart_details). |
|
294 | - * |
|
295 | - * @since 1.0.19 |
|
296 | - * @return array |
|
297 | - */ |
|
298 | - public function prepare_data_for_saving() { |
|
299 | - |
|
300 | - return array( |
|
301 | - 'post_id' => $this->invoice_id, |
|
302 | - 'item_id' => $this->get_id(), |
|
303 | - 'item_name' => sanitize_text_field( $this->get_raw_name( 'edit' ) ), |
|
304 | - 'item_description' => $this->get_description( 'edit' ), |
|
305 | - 'tax' => $this->item_tax, |
|
306 | - 'item_price' => $this->get_price( 'edit' ), |
|
307 | - 'quantity' => (float) $this->get_quantity( 'edit' ), |
|
308 | - 'discount' => $this->item_discount, |
|
309 | - 'subtotal' => $this->get_sub_total( 'edit' ), |
|
310 | - 'price' => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount, |
|
311 | - 'meta' => $this->get_item_meta( 'edit' ), |
|
312 | - ); |
|
313 | - |
|
314 | - } |
|
91 | + * Get the item name. |
|
92 | + * |
|
93 | + * @since 1.0.19 |
|
94 | + * @param string $context View or edit context. |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function get_name( $context = 'view' ) { |
|
98 | + $name = parent::get_name( $context ); |
|
99 | + return $name . wpinv_get_item_suffix( $this ); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Get the item name without a suffix. |
|
104 | + * |
|
105 | + * @since 1.0.19 |
|
106 | + * @param string $context View or edit context. |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function get_raw_name( $context = 'view' ) { |
|
110 | + return parent::get_name( $context ); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Get the item description. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + * @param string $context View or edit context. |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function get_description( $context = 'view' ) { |
|
121 | + |
|
122 | + if ( isset( $this->custom_description ) ) { |
|
123 | + return $this->custom_description; |
|
124 | + } |
|
125 | + |
|
126 | + return parent::get_description( $context ); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Returns the sub total. |
|
131 | + * |
|
132 | + * @since 1.0.19 |
|
133 | + * @param string $context View or edit context. |
|
134 | + * @return float |
|
135 | + */ |
|
136 | + public function get_sub_total( $context = 'view' ) { |
|
137 | + return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Returns the recurring sub total. |
|
142 | + * |
|
143 | + * @since 1.0.19 |
|
144 | + * @param string $context View or edit context. |
|
145 | + * @return float |
|
146 | + */ |
|
147 | + public function get_recurring_sub_total( $context = 'view' ) { |
|
148 | + |
|
149 | + if ( $this->is_recurring() ) { |
|
150 | + return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
151 | + } |
|
152 | + |
|
153 | + return 0; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * @deprecated |
|
158 | + */ |
|
159 | + public function get_qantity( $context = 'view' ) { |
|
160 | + return $this->get_quantity( $context ); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Get the item quantity. |
|
165 | + * |
|
166 | + * @since 1.0.19 |
|
167 | + * @param string $context View or edit context. |
|
168 | + * @return float |
|
169 | + */ |
|
170 | + public function get_quantity( $context = 'view' ) { |
|
171 | + $quantity = (float) $this->quantity; |
|
172 | + |
|
173 | + if ( 'view' == $context ) { |
|
174 | + return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
175 | + } |
|
176 | + |
|
177 | + return $quantity; |
|
178 | + |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Get the item meta data. |
|
183 | + * |
|
184 | + * @since 1.0.19 |
|
185 | + * @param string $context View or edit context. |
|
186 | + * @return meta |
|
187 | + */ |
|
188 | + public function get_item_meta( $context = 'view' ) { |
|
189 | + $meta = $this->meta; |
|
190 | + |
|
191 | + if ( 'view' == $context ) { |
|
192 | + return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
193 | + } |
|
194 | + |
|
195 | + return $meta; |
|
196 | + |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns whether or not customers can update the item quantity. |
|
201 | + * |
|
202 | + * @since 1.0.19 |
|
203 | + * @param string $context View or edit context. |
|
204 | + * @return bool |
|
205 | + */ |
|
206 | + public function get_allow_quantities( $context = 'view' ) { |
|
207 | + $allow_quantities = (bool) $this->allow_quantities; |
|
208 | + |
|
209 | + if ( 'view' == $context ) { |
|
210 | + return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
211 | + } |
|
212 | + |
|
213 | + return $allow_quantities; |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Returns whether or not the item is required. |
|
219 | + * |
|
220 | + * @since 1.0.19 |
|
221 | + * @param string $context View or edit context. |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | + public function get_is_required( $context = 'view' ) { |
|
225 | + $is_required = (bool) $this->is_required; |
|
226 | + |
|
227 | + if ( 'view' == $context ) { |
|
228 | + return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
229 | + } |
|
230 | + |
|
231 | + return $is_required; |
|
232 | + |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Prepares form data for use. |
|
237 | + * |
|
238 | + * @since 1.0.19 |
|
239 | + * @return array |
|
240 | + */ |
|
241 | + public function prepare_data_for_use( $required = null ) { |
|
242 | + |
|
243 | + $required = is_null( $required ) ? $this->is_required() : $required; |
|
244 | + return array( |
|
245 | + 'title' => strip_tags( $this->get_name() ), |
|
246 | + 'id' => $this->get_id(), |
|
247 | + 'price' => $this->get_price(), |
|
248 | + 'recurring' => $this->is_recurring(), |
|
249 | + 'description' => $this->get_description(), |
|
250 | + 'allow_quantities' => $this->allows_quantities(), |
|
251 | + 'required' => $required, |
|
252 | + ); |
|
253 | + |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Prepares form data for ajax use. |
|
258 | + * |
|
259 | + * @since 1.0.19 |
|
260 | + * @return array |
|
261 | + */ |
|
262 | + public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) { |
|
263 | + |
|
264 | + $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
265 | + |
|
266 | + if ( $description ) { |
|
267 | + $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
268 | + } |
|
269 | + |
|
270 | + $price = ! $is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
271 | + $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
272 | + return array( |
|
273 | + 'id' => $this->get_id(), |
|
274 | + 'texts' => array( |
|
275 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
276 | + 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
277 | + 'item-quantity' => floatval( $this->get_quantity() ), |
|
278 | + 'item-price' => wpinv_price( $price, $currency ), |
|
279 | + 'item-total' => wpinv_price( $subtotal, $currency ), |
|
280 | + ), |
|
281 | + 'inputs' => array( |
|
282 | + 'item-id' => $this->get_id(), |
|
283 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
284 | + 'item-description' => wp_kses_post( $this->get_description() ), |
|
285 | + 'item-quantity' => floatval( $this->get_quantity() ), |
|
286 | + 'item-price' => $price, |
|
287 | + ) |
|
288 | + ); |
|
289 | + |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Prepares form data for saving (cart_details). |
|
294 | + * |
|
295 | + * @since 1.0.19 |
|
296 | + * @return array |
|
297 | + */ |
|
298 | + public function prepare_data_for_saving() { |
|
299 | + |
|
300 | + return array( |
|
301 | + 'post_id' => $this->invoice_id, |
|
302 | + 'item_id' => $this->get_id(), |
|
303 | + 'item_name' => sanitize_text_field( $this->get_raw_name( 'edit' ) ), |
|
304 | + 'item_description' => $this->get_description( 'edit' ), |
|
305 | + 'tax' => $this->item_tax, |
|
306 | + 'item_price' => $this->get_price( 'edit' ), |
|
307 | + 'quantity' => (float) $this->get_quantity( 'edit' ), |
|
308 | + 'discount' => $this->item_discount, |
|
309 | + 'subtotal' => $this->get_sub_total( 'edit' ), |
|
310 | + 'price' => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount, |
|
311 | + 'meta' => $this->get_item_meta( 'edit' ), |
|
312 | + ); |
|
313 | + |
|
314 | + } |
|
315 | 315 | |
316 | 316 | /* |
317 | 317 | |-------------------------------------------------------------------------- |
@@ -323,70 +323,70 @@ discard block |
||
323 | 323 | | object. |
324 | 324 | */ |
325 | 325 | |
326 | - /** |
|
327 | - * Set the item qantity. |
|
328 | - * |
|
329 | - * @since 1.0.19 |
|
330 | - * @param float $quantity The item quantity. |
|
331 | - */ |
|
332 | - public function set_quantity( $quantity ) { |
|
333 | - |
|
334 | - if ( ! is_numeric( $quantity ) ) { |
|
335 | - $quantity = 1; |
|
336 | - } |
|
337 | - |
|
338 | - $this->quantity = (float) $quantity; |
|
339 | - |
|
340 | - } |
|
341 | - |
|
342 | - /** |
|
343 | - * Set the item meta data. |
|
344 | - * |
|
345 | - * @since 1.0.19 |
|
346 | - * @param array $meta The item meta data. |
|
347 | - */ |
|
348 | - public function set_item_meta( $meta ) { |
|
349 | - $this->meta = maybe_unserialize( $meta ); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Set whether or not the quantities are allowed. |
|
354 | - * |
|
355 | - * @since 1.0.19 |
|
356 | - * @param bool $allow_quantities |
|
357 | - */ |
|
358 | - public function set_allow_quantities( $allow_quantities ) { |
|
359 | - $this->allow_quantities = (bool) $allow_quantities; |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * Set whether or not the item is required. |
|
364 | - * |
|
365 | - * @since 1.0.19 |
|
366 | - * @param bool $is_required |
|
367 | - */ |
|
368 | - public function set_is_required( $is_required ) { |
|
369 | - $this->is_required = (bool) $is_required; |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * Sets the custom item description. |
|
374 | - * |
|
375 | - * @since 1.0.19 |
|
376 | - * @param string $description |
|
377 | - */ |
|
378 | - public function set_custom_description( $description ) { |
|
379 | - $this->custom_description = $description; |
|
380 | - } |
|
326 | + /** |
|
327 | + * Set the item qantity. |
|
328 | + * |
|
329 | + * @since 1.0.19 |
|
330 | + * @param float $quantity The item quantity. |
|
331 | + */ |
|
332 | + public function set_quantity( $quantity ) { |
|
333 | + |
|
334 | + if ( ! is_numeric( $quantity ) ) { |
|
335 | + $quantity = 1; |
|
336 | + } |
|
337 | + |
|
338 | + $this->quantity = (float) $quantity; |
|
339 | + |
|
340 | + } |
|
341 | + |
|
342 | + /** |
|
343 | + * Set the item meta data. |
|
344 | + * |
|
345 | + * @since 1.0.19 |
|
346 | + * @param array $meta The item meta data. |
|
347 | + */ |
|
348 | + public function set_item_meta( $meta ) { |
|
349 | + $this->meta = maybe_unserialize( $meta ); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Set whether or not the quantities are allowed. |
|
354 | + * |
|
355 | + * @since 1.0.19 |
|
356 | + * @param bool $allow_quantities |
|
357 | + */ |
|
358 | + public function set_allow_quantities( $allow_quantities ) { |
|
359 | + $this->allow_quantities = (bool) $allow_quantities; |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * Set whether or not the item is required. |
|
364 | + * |
|
365 | + * @since 1.0.19 |
|
366 | + * @param bool $is_required |
|
367 | + */ |
|
368 | + public function set_is_required( $is_required ) { |
|
369 | + $this->is_required = (bool) $is_required; |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * Sets the custom item description. |
|
374 | + * |
|
375 | + * @since 1.0.19 |
|
376 | + * @param string $description |
|
377 | + */ |
|
378 | + public function set_custom_description( $description ) { |
|
379 | + $this->custom_description = $description; |
|
380 | + } |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * We do not want to save items to the database. |
384 | 384 | * |
385 | - * @return int item id |
|
385 | + * @return int item id |
|
386 | 386 | */ |
387 | 387 | public function save( $data = array() ) { |
388 | 388 | return $this->get_id(); |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | 391 | /* |
392 | 392 | |-------------------------------------------------------------------------- |
@@ -398,23 +398,23 @@ discard block |
||
398 | 398 | */ |
399 | 399 | |
400 | 400 | /** |
401 | - * Checks whether the item has enabled dynamic pricing. |
|
402 | - * |
|
403 | - * @since 1.0.19 |
|
404 | - * @return bool |
|
405 | - */ |
|
406 | - public function is_required() { |
|
401 | + * Checks whether the item has enabled dynamic pricing. |
|
402 | + * |
|
403 | + * @since 1.0.19 |
|
404 | + * @return bool |
|
405 | + */ |
|
406 | + public function is_required() { |
|
407 | 407 | return (bool) $this->get_is_required(); |
408 | - } |
|
409 | - |
|
410 | - /** |
|
411 | - * Checks whether users can edit the quantities. |
|
412 | - * |
|
413 | - * @since 1.0.19 |
|
414 | - * @return bool |
|
415 | - */ |
|
416 | - public function allows_quantities() { |
|
408 | + } |
|
409 | + |
|
410 | + /** |
|
411 | + * Checks whether users can edit the quantities. |
|
412 | + * |
|
413 | + * @since 1.0.19 |
|
414 | + * @return bool |
|
415 | + */ |
|
416 | + public function allows_quantities() { |
|
417 | 417 | return (bool) $this->get_allow_quantities(); |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | 420 | } |
@@ -21,22 +21,22 @@ |
||
21 | 21 | |
22 | 22 | foreach ( $file_types as $file_type ) { |
23 | 23 | |
24 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
25 | - $types[] = $all_types[ $file_type ]; |
|
26 | - $file_type = explode( '|', $file_type ); |
|
24 | + if ( isset( $all_types[ $file_type ] ) ) { |
|
25 | + $types[] = $all_types[ $file_type ]; |
|
26 | + $file_type = explode( '|', $file_type ); |
|
27 | 27 | |
28 | - foreach ( $file_type as $type ) { |
|
29 | - $type = trim( $type ); |
|
30 | - $types[] = ".$type"; |
|
31 | - $_types[] = $type; |
|
32 | - } |
|
28 | + foreach ( $file_type as $type ) { |
|
29 | + $type = trim( $type ); |
|
30 | + $types[] = ".$type"; |
|
31 | + $_types[] = $type; |
|
32 | + } |
|
33 | 33 | |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | 38 | if ( ! empty( $required ) ) { |
39 | - $label .= "<span class='text-danger'> *</span>"; |
|
39 | + $label .= "<span class='text-danger'> *</span>"; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | ?> |
@@ -14,70 +14,70 @@ discard block |
||
14 | 14 | class WPInv_Ajax { |
15 | 15 | |
16 | 16 | /** |
17 | - * Hook in ajax handlers. |
|
18 | - */ |
|
19 | - public static function init() { |
|
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | - self::add_ajax_events(); |
|
17 | + * Hook in ajax handlers. |
|
18 | + */ |
|
19 | + public static function init() { |
|
20 | + add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | + add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | + self::add_ajax_events(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Set GetPaid AJAX constant and headers. |
|
27 | - */ |
|
28 | - public static function define_ajax() { |
|
29 | - |
|
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | - } |
|
36 | - $GLOBALS['wpdb']->hide_errors(); |
|
37 | - } |
|
26 | + * Set GetPaid AJAX constant and headers. |
|
27 | + */ |
|
28 | + public static function define_ajax() { |
|
29 | + |
|
30 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | + getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | + getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | + if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | + } |
|
36 | + $GLOBALS['wpdb']->hide_errors(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Send headers for GetPaid Ajax Requests. |
|
43 | - * |
|
44 | - * @since 1.0.18 |
|
45 | - */ |
|
46 | - private static function wpinv_ajax_headers() { |
|
47 | - if ( ! headers_sent() ) { |
|
48 | - send_origin_headers(); |
|
49 | - send_nosniff_header(); |
|
50 | - nocache_headers(); |
|
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
54 | - } |
|
42 | + * Send headers for GetPaid Ajax Requests. |
|
43 | + * |
|
44 | + * @since 1.0.18 |
|
45 | + */ |
|
46 | + private static function wpinv_ajax_headers() { |
|
47 | + if ( ! headers_sent() ) { |
|
48 | + send_origin_headers(); |
|
49 | + send_nosniff_header(); |
|
50 | + nocache_headers(); |
|
51 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | + header( 'X-Robots-Tag: noindex' ); |
|
53 | + status_header( 200 ); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Check for GetPaid Ajax request and fire action. |
|
59 | - */ |
|
60 | - public static function do_wpinv_ajax() { |
|
61 | - global $wp_query; |
|
58 | + * Check for GetPaid Ajax request and fire action. |
|
59 | + */ |
|
60 | + public static function do_wpinv_ajax() { |
|
61 | + global $wp_query; |
|
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | - } |
|
63 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | + $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get( 'wpinv-ajax' ); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
70 | - self::wpinv_ajax_headers(); |
|
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
73 | - wp_die(); |
|
74 | - } |
|
69 | + if ( $action ) { |
|
70 | + self::wpinv_ajax_headers(); |
|
71 | + $action = sanitize_text_field( $action ); |
|
72 | + do_action( 'wpinv_ajax_' . $action ); |
|
73 | + wp_die(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Hook in ajax methods. |
|
80 | - */ |
|
79 | + * Hook in ajax methods. |
|
80 | + */ |
|
81 | 81 | public static function add_ajax_events() { |
82 | 82 | |
83 | 83 | // array( 'event' => is_frontend ) |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | check_ajax_referer( 'getpaid_form_nonce' ); |
262 | 262 | |
263 | 263 | // Is the request set up correctly? |
264 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
265 | - echo aui()->alert( |
|
266 | - array( |
|
267 | - 'type' => 'warning', |
|
268 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
269 | - ) |
|
264 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
265 | + echo aui()->alert( |
|
266 | + array( |
|
267 | + 'type' => 'warning', |
|
268 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
269 | + ) |
|
270 | 270 | ); |
271 | 271 | exit; |
272 | 272 | } |
273 | 273 | |
274 | 274 | // Payment form or button? |
275 | - if ( ! empty( $_GET['form'] ) ) { |
|
275 | + if ( ! empty( $_GET['form'] ) ) { |
|
276 | 276 | $form = urldecode( $_GET['form'] ); |
277 | 277 | |
278 | 278 | if ( false !== strpos( $form, '|' ) ) { |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | getpaid_display_payment_form( $form ); |
327 | 327 | } |
328 | 328 | |
329 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
330 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
329 | + } else if( ! empty( $_GET['invoice'] ) ) { |
|
330 | + getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
331 | 331 | } else { |
332 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
333 | - getpaid_display_item_payment_form( $items ); |
|
332 | + $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
333 | + getpaid_display_item_payment_form( $items ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | exit; |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | if ( is_wp_error( $error ) ) { |
652 | 652 | $alert = $error->get_error_message(); |
653 | 653 | wp_send_json_success( compact( 'alert' ) ); |
654 | - } |
|
654 | + } |
|
655 | 655 | |
656 | 656 | // Update totals. |
657 | 657 | $invoice->recalculate_total(); |
@@ -1085,12 +1085,12 @@ discard block |
||
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | /** |
1088 | - * Handles file uploads. |
|
1089 | - * |
|
1090 | - * @since 1.0.0 |
|
1091 | - * @return void |
|
1092 | - */ |
|
1093 | - public static function file_upload() { |
|
1088 | + * Handles file uploads. |
|
1089 | + * |
|
1090 | + * @since 1.0.0 |
|
1091 | + * @return void |
|
1092 | + */ |
|
1093 | + public static function file_upload() { |
|
1094 | 1094 | |
1095 | 1095 | // Check nonce. |
1096 | 1096 | check_ajax_referer( 'getpaid_form_nonce' ); |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | wp_send_json_success( $response ); |
1153 | 1153 | |
1154 | - } |
|
1154 | + } |
|
1155 | 1155 | |
1156 | 1156 | } |
1157 | 1157 |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
138 | 138 | |
139 | - $invoice_statuses = array( |
|
140 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
139 | + $invoice_statuses = array( |
|
140 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
141 | 141 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
142 | 142 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
143 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
144 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
145 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
143 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
144 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
145 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
146 | 146 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
147 | 147 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
148 | 148 | ); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $invoice = $invoice->get_post_type(); |
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
162 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | * @return string |
278 | 278 | */ |
279 | 279 | function getpaid_get_price_format() { |
280 | - $currency_pos = wpinv_currency_position(); |
|
281 | - $format = '%1$s%2$s'; |
|
282 | - |
|
283 | - switch ( $currency_pos ) { |
|
284 | - case 'left': |
|
285 | - $format = '%1$s%2$s'; |
|
286 | - break; |
|
287 | - case 'right': |
|
288 | - $format = '%2$s%1$s'; |
|
289 | - break; |
|
290 | - case 'left_space': |
|
291 | - $format = '%1$s %2$s'; |
|
292 | - break; |
|
293 | - case 'right_space': |
|
294 | - $format = '%2$s %1$s'; |
|
295 | - break; |
|
296 | - } |
|
297 | - |
|
298 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
280 | + $currency_pos = wpinv_currency_position(); |
|
281 | + $format = '%1$s%2$s'; |
|
282 | + |
|
283 | + switch ( $currency_pos ) { |
|
284 | + case 'left': |
|
285 | + $format = '%1$s%2$s'; |
|
286 | + break; |
|
287 | + case 'right': |
|
288 | + $format = '%2$s%1$s'; |
|
289 | + break; |
|
290 | + case 'left_space': |
|
291 | + $format = '%1$s %2$s'; |
|
292 | + break; |
|
293 | + case 'right_space': |
|
294 | + $format = '%2$s %1$s'; |
|
295 | + break; |
|
296 | + } |
|
297 | + |
|
298 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | * @param mixed $value Value. |
391 | 391 | */ |
392 | 392 | function getpaid_maybe_define_constant( $name, $value ) { |
393 | - if ( ! defined( $name ) ) { |
|
394 | - define( $name, $value ); |
|
395 | - } |
|
393 | + if ( ! defined( $name ) ) { |
|
394 | + define( $name, $value ); |
|
395 | + } |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_get_php_arg_separator_output() { |
399 | - return ini_get( 'arg_separator.output' ); |
|
399 | + return ini_get( 'arg_separator.output' ); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | function wpinv_rgb_from_hex( $color ) { |
@@ -751,11 +751,11 @@ discard block |
||
751 | 751 | $list = array(); |
752 | 752 | } |
753 | 753 | |
754 | - if ( ! is_array( $list ) ) { |
|
755 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
756 | - } |
|
754 | + if ( ! is_array( $list ) ) { |
|
755 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
756 | + } |
|
757 | 757 | |
758 | - return $list; |
|
758 | + return $list; |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -775,9 +775,9 @@ discard block |
||
775 | 775 | } |
776 | 776 | |
777 | 777 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
778 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
778 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
779 | 779 | |
780 | - return $data; |
|
780 | + return $data; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -806,17 +806,17 @@ discard block |
||
806 | 806 | */ |
807 | 807 | function wpinv_clean( $var ) { |
808 | 808 | |
809 | - if ( is_array( $var ) ) { |
|
810 | - return array_map( 'wpinv_clean', $var ); |
|
809 | + if ( is_array( $var ) ) { |
|
810 | + return array_map( 'wpinv_clean', $var ); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | if ( is_object( $var ) ) { |
814 | - $object_vars = get_object_vars( $var ); |
|
815 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
816 | - $var->$property_name = wpinv_clean( $property_value ); |
|
814 | + $object_vars = get_object_vars( $var ); |
|
815 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
816 | + $var->$property_name = wpinv_clean( $property_value ); |
|
817 | 817 | } |
818 | 818 | return $var; |
819 | - } |
|
819 | + } |
|
820 | 820 | |
821 | 821 | return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
822 | 822 | } |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | */ |
830 | 830 | function getpaid_convert_price_string_to_options( $str ) { |
831 | 831 | |
832 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
832 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
833 | 833 | $options = array(); |
834 | 834 | |
835 | 835 | foreach ( $raw_options as $option ) { |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | * @return string |
913 | 913 | */ |
914 | 914 | function getpaid_date_format() { |
915 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
915 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * @return string |
922 | 922 | */ |
923 | 923 | function getpaid_time_format() { |
924 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
924 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -934,15 +934,15 @@ discard block |
||
934 | 934 | function getpaid_limit_length( $string, $limit ) { |
935 | 935 | $str_limit = $limit - 3; |
936 | 936 | |
937 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
938 | - if ( mb_strlen( $string ) > $limit ) { |
|
939 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
940 | - } |
|
941 | - } else { |
|
942 | - if ( strlen( $string ) > $limit ) { |
|
943 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
944 | - } |
|
945 | - } |
|
937 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
938 | + if ( mb_strlen( $string ) > $limit ) { |
|
939 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
940 | + } |
|
941 | + } else { |
|
942 | + if ( strlen( $string ) > $limit ) { |
|
943 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
944 | + } |
|
945 | + } |
|
946 | 946 | return $string; |
947 | 947 | |
948 | 948 | } |
@@ -1073,12 +1073,12 @@ discard block |
||
1073 | 1073 | $types = get_allowed_mime_types(); |
1074 | 1074 | |
1075 | 1075 | if ( isset( $types['htm|html'] ) ) { |
1076 | - unset( $types['htm|html'] ); |
|
1077 | - } |
|
1076 | + unset( $types['htm|html'] ); |
|
1077 | + } |
|
1078 | 1078 | |
1079 | 1079 | if ( isset( $types['js'] ) ) { |
1080 | - unset( $types['js'] ); |
|
1081 | - } |
|
1080 | + unset( $types['js'] ); |
|
1081 | + } |
|
1082 | 1082 | |
1083 | 1083 | return $types; |
1084 | 1084 |
@@ -1,32 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - // Is the request set up correctly? |
|
4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
5 | - return aui()->alert( |
|
6 | - array( |
|
7 | - 'type' => 'warning', |
|
8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
9 | - ) |
|
10 | - ); |
|
11 | - wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
12 | - } |
|
13 | - |
|
14 | - // Payment form or button? |
|
15 | - if ( ! empty( $_GET['form'] ) ) { |
|
16 | - |
|
17 | - $shortcode = sprintf( |
|
18 | - '[getpaid form=%s]', |
|
19 | - (int) urldecode( $_GET['form'] ) |
|
20 | - ); |
|
21 | - |
|
22 | - } else { |
|
23 | - |
|
24 | - $shortcode = sprintf( |
|
25 | - '[getpaid item=%s]', |
|
26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
27 | - ); |
|
28 | - |
|
29 | - } |
|
3 | + // Is the request set up correctly? |
|
4 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
5 | + return aui()->alert( |
|
6 | + array( |
|
7 | + 'type' => 'warning', |
|
8 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
9 | + ) |
|
10 | + ); |
|
11 | + wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
12 | + } |
|
13 | + |
|
14 | + // Payment form or button? |
|
15 | + if ( ! empty( $_GET['form'] ) ) { |
|
16 | + |
|
17 | + $shortcode = sprintf( |
|
18 | + '[getpaid form=%s]', |
|
19 | + (int) urldecode( $_GET['form'] ) |
|
20 | + ); |
|
21 | + |
|
22 | + } else { |
|
23 | + |
|
24 | + $shortcode = sprintf( |
|
25 | + '[getpaid item=%s]', |
|
26 | + esc_attr( urldecode( $_GET['item'] ) ) |
|
27 | + ); |
|
28 | + |
|
29 | + } |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | |
45 | 45 | <title>GetPaid</title> |
46 | 46 | <?php |
47 | - wp_enqueue_scripts(); |
|
48 | - wp_print_styles(); |
|
49 | - wp_print_head_scripts(); |
|
50 | - wp_custom_css_cb(); |
|
51 | - wpinv_get_template( 'frontend-head.php' ); |
|
52 | - ?> |
|
47 | + wp_enqueue_scripts(); |
|
48 | + wp_print_styles(); |
|
49 | + wp_print_head_scripts(); |
|
50 | + wp_custom_css_cb(); |
|
51 | + wpinv_get_template( 'frontend-head.php' ); |
|
52 | + ?> |
|
53 | 53 | |
54 | 54 | <style type="text/css"> |
55 | 55 | .body{ |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | <body class="body page-template-default page"> |
84 | 84 | <div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content"> |
85 | 85 | <?php |
86 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
87 | - echo do_shortcode( $shortcode ); |
|
88 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
89 | - wpinv_get_template( 'frontend-footer.php' ); |
|
90 | - ?> |
|
86 | + do_action( 'getpaid_payment_form_embed_top' ); |
|
87 | + echo do_shortcode( $shortcode ); |
|
88 | + do_action( 'getpaid_payment_form_embed_bottom' ); |
|
89 | + wpinv_get_template( 'frontend-footer.php' ); |
|
90 | + ?> |
|
91 | 91 | </div> |
92 | 92 | <?php wp_footer(); ?> |
93 | 93 | </body> |