@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | $args = wp_parse_args( |
58 | 58 | $args, |
59 | 59 | array( |
60 | - 'status' => array( 'publish' ), |
|
61 | - 'limit' => get_option( 'posts_per_page' ), |
|
62 | - 'page' => 1, |
|
63 | - 'exclude' => array(), |
|
64 | - 'orderby' => 'date', |
|
65 | - 'order' => 'DESC', |
|
66 | - 'type' => wpinv_item_types(), |
|
67 | - 'meta_query' => array( |
|
60 | + 'status' => array( 'publish' ), |
|
61 | + 'limit' => get_option( 'posts_per_page' ), |
|
62 | + 'page' => 1, |
|
63 | + 'exclude' => array(), |
|
64 | + 'orderby' => 'date', |
|
65 | + 'order' => 'DESC', |
|
66 | + 'type' => wpinv_item_types(), |
|
67 | + 'meta_query' => array( |
|
68 | 68 | array( |
69 | 69 | 'key' => '_wpinv_one_time', |
70 | 70 | 'compare' => 'NOT EXISTS', |
71 | 71 | ), |
72 | 72 | ), |
73 | - 'return' => 'objects', |
|
74 | - 'paginate' => false, |
|
73 | + 'return' => 'objects', |
|
74 | + 'paginate' => false, |
|
75 | 75 | ) |
76 | 76 | ); |
77 | 77 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | function wpinv_get_item_types() { |
213 | 213 | $item_types = array( |
214 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
216 | - ); |
|
214 | + 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | + 'fee' => __( 'Fee', 'invoicing' ), |
|
216 | + ); |
|
217 | 217 | return apply_filters( 'wpinv_get_item_types', $item_types ); |
218 | 218 | } |
219 | 219 | |
@@ -255,16 +255,16 @@ discard block |
||
255 | 255 | $args = array(); |
256 | 256 | if ( $post_ids ) { |
257 | 257 | $args = array( |
258 | - 'fields' => 'ids', |
|
259 | - ); |
|
258 | + 'fields' => 'ids', |
|
259 | + ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $args = array_merge( |
263 | 263 | $args, |
264 | 264 | array( |
265 | 265 | 'post_type' => 'wpi_item', |
266 | - 'orderby' => 'rand', |
|
267 | - 'post_count' => $num, |
|
266 | + 'orderby' => 'rand', |
|
267 | + 'post_count' => $num, |
|
268 | 268 | 'meta_query' => array( |
269 | 269 | array( |
270 | 270 | 'key' => '_wpinv_one_time', |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $bill_times_less = $bill_times - 1; |
440 | 440 | |
441 | 441 | if ( ! empty( $bill_times ) ) { |
442 | - $bill_times = $item->get_recurring_interval() * $bill_times; |
|
442 | + $bill_times = $item->get_recurring_interval() * $bill_times; |
|
443 | 443 | $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
444 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
445 | - } |
|
444 | + $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
445 | + } |
|
446 | 446 | |
447 | 447 | if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
448 | 448 | $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | * @return bool Whether the item type supports the given feature. |
588 | 588 | */ |
589 | 589 | function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) { |
590 | - $supports = false; |
|
590 | + $supports = false; |
|
591 | 591 | |
592 | - if ( ! is_scalar( $item_type ) ) { |
|
593 | - return $supports; |
|
594 | - } |
|
592 | + if ( ! is_scalar( $item_type ) ) { |
|
593 | + return $supports; |
|
594 | + } |
|
595 | 595 | |
596 | - switch ( $feature ) { |
|
597 | - case 'buy_now': |
|
598 | - if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
599 | - $supports = true; |
|
600 | - } |
|
601 | - break; |
|
602 | - } |
|
596 | + switch ( $feature ) { |
|
597 | + case 'buy_now': |
|
598 | + if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
599 | + $supports = true; |
|
600 | + } |
|
601 | + break; |
|
602 | + } |
|
603 | 603 | |
604 | - return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
604 | + return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
605 | 605 | } |
606 | 606 | \ No newline at end of file |
@@ -5,129 +5,129 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
8 | - exit; // Exit if accessed directly |
|
8 | + exit; // Exit if accessed directly |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
12 | 12 | |
13 | - /** |
|
14 | - * GetPaid_Admin_Profile Class. |
|
15 | - */ |
|
16 | - class GetPaid_Admin_Profile { |
|
17 | - |
|
18 | - /** |
|
19 | - * Hook in tabs. |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | - |
|
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Get Address Fields for the edit user pages. |
|
31 | - * |
|
32 | - * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | - */ |
|
34 | - public function get_customer_meta_fields() { |
|
35 | - |
|
36 | - $show_fields = apply_filters( |
|
37 | - 'getpaid_customer_meta_fields', |
|
38 | - array( |
|
39 | - 'billing' => array( |
|
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | - 'fields' => array( |
|
42 | - '_wpinv_first_name' => array( |
|
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
44 | - 'description' => '', |
|
45 | - ), |
|
46 | - '_wpinv_last_name' => array( |
|
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
48 | - 'description' => '', |
|
49 | - ), |
|
50 | - '_wpinv_company' => array( |
|
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
52 | - 'description' => '', |
|
53 | - ), |
|
54 | - '_wpinv_company_id' => array( |
|
55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
56 | - 'description' => '', |
|
57 | - ), |
|
58 | - '_wpinv_address' => array( |
|
59 | - 'label' => __( 'Address', 'invoicing' ), |
|
60 | - 'description' => '', |
|
61 | - ), |
|
62 | - '_wpinv_city' => array( |
|
63 | - 'label' => __( 'City', 'invoicing' ), |
|
64 | - 'description' => '', |
|
65 | - ), |
|
66 | - '_wpinv_zip' => array( |
|
67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
68 | - 'description' => '', |
|
69 | - ), |
|
70 | - '_wpinv_country' => array( |
|
71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
72 | - 'description' => '', |
|
73 | - 'class' => 'getpaid_js_field-country', |
|
74 | - 'type' => 'select', |
|
75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
76 | - ), |
|
77 | - '_wpinv_state' => array( |
|
78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
80 | - 'class' => 'getpaid_js_field-state regular-text', |
|
81 | - ), |
|
82 | - '_wpinv_phone' => array( |
|
83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
84 | - 'description' => '', |
|
85 | - ), |
|
86 | - '_wpinv_vat_number' => array( |
|
87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
88 | - 'description' => '', |
|
89 | - ), |
|
90 | - ), |
|
91 | - ), |
|
92 | - ) |
|
93 | - ); |
|
94 | - return $show_fields; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Show Address Fields on edit user pages. |
|
99 | - * |
|
100 | - * @param WP_User $user |
|
101 | - */ |
|
102 | - public function add_customer_meta_fields( $user ) { |
|
103 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
104 | - return; |
|
105 | - } |
|
106 | - |
|
107 | - $show_fields = $this->get_customer_meta_fields(); |
|
108 | - |
|
109 | - $customer = getpaid_get_customer_by_user_id( (int) $user->ID ); |
|
110 | - |
|
111 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
112 | - if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) { |
|
113 | - unset( $fieldset['fields']['_wpinv_vat_number'] ); |
|
114 | - } |
|
115 | - ?> |
|
13 | + /** |
|
14 | + * GetPaid_Admin_Profile Class. |
|
15 | + */ |
|
16 | + class GetPaid_Admin_Profile { |
|
17 | + |
|
18 | + /** |
|
19 | + * Hook in tabs. |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | + add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | + |
|
25 | + add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | + add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Get Address Fields for the edit user pages. |
|
31 | + * |
|
32 | + * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | + */ |
|
34 | + public function get_customer_meta_fields() { |
|
35 | + |
|
36 | + $show_fields = apply_filters( |
|
37 | + 'getpaid_customer_meta_fields', |
|
38 | + array( |
|
39 | + 'billing' => array( |
|
40 | + 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | + 'fields' => array( |
|
42 | + '_wpinv_first_name' => array( |
|
43 | + 'label' => __( 'First name', 'invoicing' ), |
|
44 | + 'description' => '', |
|
45 | + ), |
|
46 | + '_wpinv_last_name' => array( |
|
47 | + 'label' => __( 'Last name', 'invoicing' ), |
|
48 | + 'description' => '', |
|
49 | + ), |
|
50 | + '_wpinv_company' => array( |
|
51 | + 'label' => __( 'Company', 'invoicing' ), |
|
52 | + 'description' => '', |
|
53 | + ), |
|
54 | + '_wpinv_company_id' => array( |
|
55 | + 'label' => __( 'Company ID', 'invoicing' ), |
|
56 | + 'description' => '', |
|
57 | + ), |
|
58 | + '_wpinv_address' => array( |
|
59 | + 'label' => __( 'Address', 'invoicing' ), |
|
60 | + 'description' => '', |
|
61 | + ), |
|
62 | + '_wpinv_city' => array( |
|
63 | + 'label' => __( 'City', 'invoicing' ), |
|
64 | + 'description' => '', |
|
65 | + ), |
|
66 | + '_wpinv_zip' => array( |
|
67 | + 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
68 | + 'description' => '', |
|
69 | + ), |
|
70 | + '_wpinv_country' => array( |
|
71 | + 'label' => __( 'Country / Region', 'invoicing' ), |
|
72 | + 'description' => '', |
|
73 | + 'class' => 'getpaid_js_field-country', |
|
74 | + 'type' => 'select', |
|
75 | + 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
76 | + ), |
|
77 | + '_wpinv_state' => array( |
|
78 | + 'label' => __( 'State / County', 'invoicing' ), |
|
79 | + 'description' => __( 'State / County or state code', 'invoicing' ), |
|
80 | + 'class' => 'getpaid_js_field-state regular-text', |
|
81 | + ), |
|
82 | + '_wpinv_phone' => array( |
|
83 | + 'label' => __( 'Phone', 'invoicing' ), |
|
84 | + 'description' => '', |
|
85 | + ), |
|
86 | + '_wpinv_vat_number' => array( |
|
87 | + 'label' => __( 'VAT Number', 'invoicing' ), |
|
88 | + 'description' => '', |
|
89 | + ), |
|
90 | + ), |
|
91 | + ), |
|
92 | + ) |
|
93 | + ); |
|
94 | + return $show_fields; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Show Address Fields on edit user pages. |
|
99 | + * |
|
100 | + * @param WP_User $user |
|
101 | + */ |
|
102 | + public function add_customer_meta_fields( $user ) { |
|
103 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
104 | + return; |
|
105 | + } |
|
106 | + |
|
107 | + $show_fields = $this->get_customer_meta_fields(); |
|
108 | + |
|
109 | + $customer = getpaid_get_customer_by_user_id( (int) $user->ID ); |
|
110 | + |
|
111 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
112 | + if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) { |
|
113 | + unset( $fieldset['fields']['_wpinv_vat_number'] ); |
|
114 | + } |
|
115 | + ?> |
|
116 | 116 | <h2><?php echo esc_html( $fieldset['title'] ); ?></h2> |
117 | 117 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
118 | 118 | <?php foreach ( $fieldset['fields'] as $key => $field ) : |
119 | - if ( ! empty( $customer ) ) { |
|
120 | - if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
121 | - $save_key = substr( $key , 7 ); |
|
122 | - } else { |
|
123 | - $save_key = $key; |
|
124 | - } |
|
125 | - |
|
126 | - $value = $customer->get( $save_key ); |
|
127 | - } else { |
|
128 | - $value = $this->get_user_meta( $user->ID, $key ); |
|
129 | - } |
|
130 | - ?> |
|
119 | + if ( ! empty( $customer ) ) { |
|
120 | + if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
121 | + $save_key = substr( $key , 7 ); |
|
122 | + } else { |
|
123 | + $save_key = $key; |
|
124 | + } |
|
125 | + |
|
126 | + $value = $customer->get( $save_key ); |
|
127 | + } else { |
|
128 | + $value = $this->get_user_meta( $user->ID, $key ); |
|
129 | + } |
|
130 | + ?> |
|
131 | 131 | <tr> |
132 | 132 | <th> |
133 | 133 | <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
@@ -150,75 +150,75 @@ discard block |
||
150 | 150 | <?php endforeach; ?> |
151 | 151 | </table> |
152 | 152 | <?php |
153 | - endforeach; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Save Address Fields on edit user pages. |
|
158 | - * |
|
159 | - * @param int $user_id User ID of the user being saved |
|
160 | - */ |
|
161 | - public function save_customer_meta_fields( $user_id ) { |
|
162 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
163 | - return; |
|
164 | - } |
|
165 | - |
|
166 | - $save_fields = $this->get_customer_meta_fields(); |
|
167 | - $save_data = array(); |
|
168 | - |
|
169 | - foreach ( $save_fields as $fieldset ) { |
|
170 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
171 | - if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
172 | - $save_key = substr( $key , 7 ); |
|
173 | - } else { |
|
174 | - $save_key = $key; |
|
175 | - } |
|
176 | - |
|
177 | - if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
178 | - $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false; |
|
179 | - } else if ( $save_key && isset( $_POST[ $key ] ) ) { |
|
180 | - $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] ); |
|
181 | - } |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - if ( empty( $save_data ) ) { |
|
186 | - return; |
|
187 | - } |
|
188 | - |
|
189 | - $customer = getpaid_get_customer_by_user_id( (int) $user_id ); |
|
190 | - |
|
191 | - if ( empty( $customer ) ) { |
|
192 | - $customer = new GetPaid_Customer( 0 ); |
|
193 | - $customer->clone_user( (int) $user_id ); |
|
194 | - } |
|
195 | - |
|
196 | - foreach ( $save_data as $key => $value ) { |
|
197 | - $customer->set( $key, $value ); |
|
198 | - } |
|
199 | - |
|
200 | - $customer->save(); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
205 | - * |
|
206 | - * @since 3.1.0 |
|
207 | - * @param int $user_id User ID of the user being edited |
|
208 | - * @param string $key Key for user meta field |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - protected function get_user_meta( $user_id, $key ) { |
|
212 | - $value = get_user_meta( $user_id, $key, true ); |
|
213 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
214 | - |
|
215 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
216 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
217 | - } |
|
218 | - |
|
219 | - return $value; |
|
220 | - } |
|
221 | - } |
|
153 | + endforeach; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Save Address Fields on edit user pages. |
|
158 | + * |
|
159 | + * @param int $user_id User ID of the user being saved |
|
160 | + */ |
|
161 | + public function save_customer_meta_fields( $user_id ) { |
|
162 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
163 | + return; |
|
164 | + } |
|
165 | + |
|
166 | + $save_fields = $this->get_customer_meta_fields(); |
|
167 | + $save_data = array(); |
|
168 | + |
|
169 | + foreach ( $save_fields as $fieldset ) { |
|
170 | + foreach ( $fieldset['fields'] as $key => $field ) { |
|
171 | + if ( strpos( $key, '_wpinv_' ) === 0 ) { |
|
172 | + $save_key = substr( $key , 7 ); |
|
173 | + } else { |
|
174 | + $save_key = $key; |
|
175 | + } |
|
176 | + |
|
177 | + if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
178 | + $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false; |
|
179 | + } else if ( $save_key && isset( $_POST[ $key ] ) ) { |
|
180 | + $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] ); |
|
181 | + } |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + if ( empty( $save_data ) ) { |
|
186 | + return; |
|
187 | + } |
|
188 | + |
|
189 | + $customer = getpaid_get_customer_by_user_id( (int) $user_id ); |
|
190 | + |
|
191 | + if ( empty( $customer ) ) { |
|
192 | + $customer = new GetPaid_Customer( 0 ); |
|
193 | + $customer->clone_user( (int) $user_id ); |
|
194 | + } |
|
195 | + |
|
196 | + foreach ( $save_data as $key => $value ) { |
|
197 | + $customer->set( $key, $value ); |
|
198 | + } |
|
199 | + |
|
200 | + $customer->save(); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
205 | + * |
|
206 | + * @since 3.1.0 |
|
207 | + * @param int $user_id User ID of the user being edited |
|
208 | + * @param string $key Key for user meta field |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + protected function get_user_meta( $user_id, $key ) { |
|
212 | + $value = get_user_meta( $user_id, $key, true ); |
|
213 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
214 | + |
|
215 | + if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
216 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
217 | + } |
|
218 | + |
|
219 | + return $value; |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | 223 | endif; |
224 | 224 |
@@ -14,76 +14,76 @@ |
||
14 | 14 | * @return array|mixed|string|string[] |
15 | 15 | */ |
16 | 16 | function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
17 | - global $aui_bs5; |
|
17 | + global $aui_bs5; |
|
18 | 18 | |
19 | - if ( $aui_bs5 ) { |
|
20 | - $convert = array( |
|
21 | - '"ml-' => '"ms-', |
|
22 | - '"mr-' => '"me-', |
|
23 | - '"pl-' => '"ps-', |
|
24 | - '"pr-' => '"pe-', |
|
25 | - "'ml-" => "'ms-", |
|
26 | - "'mr-" => "'me-", |
|
27 | - "'pl-" => "'ps-", |
|
28 | - "'pr-" => "'pe-", |
|
29 | - ' ml-' => ' ms-', |
|
30 | - ' mr-' => ' me-', |
|
31 | - ' pl-' => ' ps-', |
|
32 | - ' pr-' => ' pe-', |
|
33 | - '.ml-' => '.ms-', |
|
34 | - '.mr-' => '.me-', |
|
35 | - '.pl-' => '.ps-', |
|
36 | - '.pr-' => '.pe-', |
|
37 | - ' form-row' => ' row', |
|
38 | - ' embed-responsive-item' => '', |
|
39 | - ' embed-responsive' => ' ratio', |
|
40 | - '-1by1' => '-1x1', |
|
41 | - '-4by3' => '-4x3', |
|
42 | - '-16by9' => '-16x9', |
|
43 | - '-21by9' => '-21x9', |
|
44 | - 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
45 | - 'geodir-lightbox-iframe' => 'aui-lightbox-iframe', |
|
46 | - ' badge-' => ' text-bg-', |
|
47 | - 'form-group' => 'mb-3', |
|
48 | - 'custom-select' => 'form-select', |
|
49 | - 'float-left' => 'float-start', |
|
50 | - 'float-right' => 'float-end', |
|
51 | - 'text-left' => 'text-start', |
|
52 | - 'text-sm-left' => 'text-sm-start', |
|
53 | - 'text-md-left' => 'text-md-start', |
|
54 | - 'text-lg-left' => 'text-lg-start', |
|
55 | - 'text-right' => 'text-end', |
|
56 | - 'text-sm-right' => 'text-sm-end', |
|
57 | - 'text-md-right' => 'text-md-end', |
|
58 | - 'text-lg-right' => 'text-lg-end', |
|
59 | - 'border-right' => 'border-end', |
|
60 | - 'border-left' => 'border-start', |
|
61 | - 'font-weight-' => 'fw-', |
|
62 | - 'btn-block' => 'w-100', |
|
63 | - 'rounded-left' => 'rounded-start', |
|
64 | - 'rounded-right' => 'rounded-end', |
|
65 | - 'font-italic' => 'fst-italic', |
|
19 | + if ( $aui_bs5 ) { |
|
20 | + $convert = array( |
|
21 | + '"ml-' => '"ms-', |
|
22 | + '"mr-' => '"me-', |
|
23 | + '"pl-' => '"ps-', |
|
24 | + '"pr-' => '"pe-', |
|
25 | + "'ml-" => "'ms-", |
|
26 | + "'mr-" => "'me-", |
|
27 | + "'pl-" => "'ps-", |
|
28 | + "'pr-" => "'pe-", |
|
29 | + ' ml-' => ' ms-', |
|
30 | + ' mr-' => ' me-', |
|
31 | + ' pl-' => ' ps-', |
|
32 | + ' pr-' => ' pe-', |
|
33 | + '.ml-' => '.ms-', |
|
34 | + '.mr-' => '.me-', |
|
35 | + '.pl-' => '.ps-', |
|
36 | + '.pr-' => '.pe-', |
|
37 | + ' form-row' => ' row', |
|
38 | + ' embed-responsive-item' => '', |
|
39 | + ' embed-responsive' => ' ratio', |
|
40 | + '-1by1' => '-1x1', |
|
41 | + '-4by3' => '-4x3', |
|
42 | + '-16by9' => '-16x9', |
|
43 | + '-21by9' => '-21x9', |
|
44 | + 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
45 | + 'geodir-lightbox-iframe' => 'aui-lightbox-iframe', |
|
46 | + ' badge-' => ' text-bg-', |
|
47 | + 'form-group' => 'mb-3', |
|
48 | + 'custom-select' => 'form-select', |
|
49 | + 'float-left' => 'float-start', |
|
50 | + 'float-right' => 'float-end', |
|
51 | + 'text-left' => 'text-start', |
|
52 | + 'text-sm-left' => 'text-sm-start', |
|
53 | + 'text-md-left' => 'text-md-start', |
|
54 | + 'text-lg-left' => 'text-lg-start', |
|
55 | + 'text-right' => 'text-end', |
|
56 | + 'text-sm-right' => 'text-sm-end', |
|
57 | + 'text-md-right' => 'text-md-end', |
|
58 | + 'text-lg-right' => 'text-lg-end', |
|
59 | + 'border-right' => 'border-end', |
|
60 | + 'border-left' => 'border-start', |
|
61 | + 'font-weight-' => 'fw-', |
|
62 | + 'btn-block' => 'w-100', |
|
63 | + 'rounded-left' => 'rounded-start', |
|
64 | + 'rounded-right' => 'rounded-end', |
|
65 | + 'font-italic' => 'fst-italic', |
|
66 | 66 | |
67 | 67 | // 'custom-control custom-checkbox' => 'form-check', |
68 | - // data |
|
69 | - ' data-toggle=' => ' data-bs-toggle=', |
|
70 | - 'data-ride=' => 'data-bs-ride=', |
|
71 | - 'data-controlnav=' => 'data-bs-controlnav=', |
|
72 | - 'data-slide=' => 'data-bs-slide=', |
|
73 | - 'data-slide-to=' => 'data-bs-slide-to=', |
|
74 | - 'data-target=' => 'data-bs-target=', |
|
75 | - 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
76 | - 'class="close"' => 'class="btn-close"', |
|
77 | - '<span aria-hidden="true">×</span>' => '', |
|
78 | - ); |
|
79 | - $output = str_replace( |
|
80 | - array_keys( $convert ), |
|
81 | - array_values( $convert ), |
|
82 | - $output |
|
83 | - ); |
|
84 | - } |
|
68 | + // data |
|
69 | + ' data-toggle=' => ' data-bs-toggle=', |
|
70 | + 'data-ride=' => 'data-bs-ride=', |
|
71 | + 'data-controlnav=' => 'data-bs-controlnav=', |
|
72 | + 'data-slide=' => 'data-bs-slide=', |
|
73 | + 'data-slide-to=' => 'data-bs-slide-to=', |
|
74 | + 'data-target=' => 'data-bs-target=', |
|
75 | + 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
76 | + 'class="close"' => 'class="btn-close"', |
|
77 | + '<span aria-hidden="true">×</span>' => '', |
|
78 | + ); |
|
79 | + $output = str_replace( |
|
80 | + array_keys( $convert ), |
|
81 | + array_values( $convert ), |
|
82 | + $output |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - return $output; |
|
86 | + return $output; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | */ |
16 | 16 | |
17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
18 | - exit; |
|
18 | + exit; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
22 | - // include the class if needed |
|
23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
22 | + // include the class if needed |
|
23 | + include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /* |
@@ -35,5 +35,5 @@ discard block |
||
35 | 35 | |
36 | 36 | |
37 | 37 | if ( ! function_exists( 'sd_get_class_build_keys' ) ) { |
38 | - include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
38 | + include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -3,114 +3,114 @@ discard block |
||
3 | 3 | class SD_Hello_World extends WP_Super_Duper { |
4 | 4 | |
5 | 5 | |
6 | - public $arguments; |
|
7 | - |
|
8 | - /** |
|
9 | - * Sets up the widgets name etc |
|
10 | - */ |
|
11 | - public function __construct() { |
|
12 | - |
|
13 | - $options = array( |
|
14 | - 'textdomain' => 'super-duper', |
|
15 | - // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
16 | - 'block-icon' => 'fas fa-globe-americas', |
|
17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | - // OR font-awesome 5 class name: fas fa-globe-americas |
|
19 | - 'block-category' => 'widgets', |
|
20 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
21 | - 'block-keywords' => "['hello','world']", |
|
22 | - // used in the block search, MAX 3 |
|
23 | - 'block-output' => array( // the block visual output elements as an array |
|
6 | + public $arguments; |
|
7 | + |
|
8 | + /** |
|
9 | + * Sets up the widgets name etc |
|
10 | + */ |
|
11 | + public function __construct() { |
|
12 | + |
|
13 | + $options = array( |
|
14 | + 'textdomain' => 'super-duper', |
|
15 | + // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
16 | + 'block-icon' => 'fas fa-globe-americas', |
|
17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | + // OR font-awesome 5 class name: fas fa-globe-americas |
|
19 | + 'block-category' => 'widgets', |
|
20 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
21 | + 'block-keywords' => "['hello','world']", |
|
22 | + // used in the block search, MAX 3 |
|
23 | + 'block-output' => array( // the block visual output elements as an array |
|
24 | 24 | // array( |
25 | 25 | // 'element' => 'p', |
26 | 26 | // 'title' => __( 'Placeholder', 'ayecode-connect' ), |
27 | 27 | // 'class' => '[%className%]', |
28 | 28 | // 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
29 | 29 | // ) |
30 | - array( |
|
31 | - 'element' => 'BlocksProps', |
|
32 | - 'inner_element' => 'p', |
|
33 | - 'blockProps' => array( |
|
34 | - 'className' => '[%WrapClass%]', |
|
30 | + array( |
|
31 | + 'element' => 'BlocksProps', |
|
32 | + 'inner_element' => 'p', |
|
33 | + 'blockProps' => array( |
|
34 | + 'className' => '[%WrapClass%]', |
|
35 | 35 | // 'content' => 'Hello: [%after_text%]' |
36 | 36 | // 'if_dangerouslySetInnerHTML' => '{__html: blockstrap_build_shape(props.attributes) }', |
37 | - ), |
|
38 | - 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
39 | - |
|
40 | - |
|
41 | - ), |
|
42 | - ), |
|
43 | - 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
44 | - 'class_name' => __CLASS__, |
|
45 | - // The calling class name |
|
46 | - 'base_id' => 'hello_world', |
|
47 | - // this is used as the widget id and the shortcode id. |
|
48 | - 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
49 | - // the name of the widget/block |
|
50 | - 'widget_ops' => array( |
|
51 | - 'classname' => 'hello-world-class', |
|
52 | - // widget class |
|
53 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
54 | - // widget description |
|
55 | - ), |
|
56 | - 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
57 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
58 | - 'after_text' => array( // this is the input name='' |
|
59 | - 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
60 | - // input title |
|
61 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
62 | - // input description |
|
63 | - 'type' => 'text', |
|
64 | - // the type of input, test, select, checkbox etc. |
|
65 | - 'placeholder' => 'World', |
|
66 | - // the input placeholder text. |
|
67 | - 'desc_tip' => true, |
|
68 | - // if the input should show the widget description text as a tooltip. |
|
69 | - 'default' => 'World', |
|
70 | - // the input default value. |
|
71 | - 'advanced' => false |
|
72 | - // not yet implemented |
|
73 | - ), |
|
74 | - ) |
|
75 | - ); |
|
76 | - |
|
77 | - parent::__construct( $options ); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * This is the output function for the widget, shortcode and block (front end). |
|
83 | - * |
|
84 | - * @param array $args The arguments values. |
|
85 | - * @param array $widget_args The widget arguments when used. |
|
86 | - * @param string $content The shortcode content argument |
|
87 | - * |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
91 | - |
|
92 | - /** |
|
93 | - * @var string $after_text |
|
94 | - * @var string $another_input This is added by filter below. |
|
95 | - */ |
|
96 | - extract( $args, EXTR_SKIP ); |
|
97 | - |
|
98 | - /* |
|
37 | + ), |
|
38 | + 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
39 | + |
|
40 | + |
|
41 | + ), |
|
42 | + ), |
|
43 | + 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
44 | + 'class_name' => __CLASS__, |
|
45 | + // The calling class name |
|
46 | + 'base_id' => 'hello_world', |
|
47 | + // this is used as the widget id and the shortcode id. |
|
48 | + 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
49 | + // the name of the widget/block |
|
50 | + 'widget_ops' => array( |
|
51 | + 'classname' => 'hello-world-class', |
|
52 | + // widget class |
|
53 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
54 | + // widget description |
|
55 | + ), |
|
56 | + 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
57 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
58 | + 'after_text' => array( // this is the input name='' |
|
59 | + 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
60 | + // input title |
|
61 | + 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
62 | + // input description |
|
63 | + 'type' => 'text', |
|
64 | + // the type of input, test, select, checkbox etc. |
|
65 | + 'placeholder' => 'World', |
|
66 | + // the input placeholder text. |
|
67 | + 'desc_tip' => true, |
|
68 | + // if the input should show the widget description text as a tooltip. |
|
69 | + 'default' => 'World', |
|
70 | + // the input default value. |
|
71 | + 'advanced' => false |
|
72 | + // not yet implemented |
|
73 | + ), |
|
74 | + ) |
|
75 | + ); |
|
76 | + |
|
77 | + parent::__construct( $options ); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * This is the output function for the widget, shortcode and block (front end). |
|
83 | + * |
|
84 | + * @param array $args The arguments values. |
|
85 | + * @param array $widget_args The widget arguments when used. |
|
86 | + * @param string $content The shortcode content argument |
|
87 | + * |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
91 | + |
|
92 | + /** |
|
93 | + * @var string $after_text |
|
94 | + * @var string $another_input This is added by filter below. |
|
95 | + */ |
|
96 | + extract( $args, EXTR_SKIP ); |
|
97 | + |
|
98 | + /* |
|
99 | 99 | * This value is added by filter so might not exist if filter is removed so we check. |
100 | 100 | */ |
101 | - if ( ! isset( $another_input ) ) { |
|
102 | - $another_input = ''; |
|
103 | - } |
|
101 | + if ( ! isset( $another_input ) ) { |
|
102 | + $another_input = ''; |
|
103 | + } |
|
104 | 104 | |
105 | - return "Helllo: " . $after_text . "" . $another_input; |
|
105 | + return "Helllo: " . $after_text . "" . $another_input; |
|
106 | 106 | |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | 111 | // register it. |
112 | 112 | add_action( 'widgets_init', function () { |
113 | - register_widget( 'SD_Hello_World' ); |
|
113 | + register_widget( 'SD_Hello_World' ); |
|
114 | 114 | } ); |
115 | 115 | |
116 | 116 | |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function _my_extra_arguments( $options ) { |
125 | 125 | |
126 | - /* |
|
126 | + /* |
|
127 | 127 | * Add a new input option. |
128 | 128 | */ |
129 | - $options['arguments']['another_input'] = array( |
|
130 | - 'name' => 'another_input', // this is the input name='' |
|
131 | - 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
132 | - 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
133 | - 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
134 | - 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
135 | - 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
136 | - 'default' => '', // the input default value. |
|
137 | - 'advanced' => false // not yet implemented |
|
138 | - ); |
|
139 | - |
|
140 | - /* |
|
129 | + $options['arguments']['another_input'] = array( |
|
130 | + 'name' => 'another_input', // this is the input name='' |
|
131 | + 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
132 | + 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
133 | + 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
134 | + 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
135 | + 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
136 | + 'default' => '', // the input default value. |
|
137 | + 'advanced' => false // not yet implemented |
|
138 | + ); |
|
139 | + |
|
140 | + /* |
|
141 | 141 | * Output the new option in the block output also. |
142 | 142 | */ |
143 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
143 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
144 | 144 | |
145 | - return $options; |
|
145 | + return $options; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' ); |
149 | 149 | \ No newline at end of file |
@@ -14,143 +14,143 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class WPInv_Subscriptions_Widget extends WP_Super_Duper { |
16 | 16 | |
17 | - /** |
|
18 | - * Register the widget with WordPress. |
|
19 | - * |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - |
|
23 | - $options = array( |
|
24 | - 'textdomain' => 'invoicing', |
|
25 | - 'block-icon' => 'controls-repeat', |
|
26 | - 'block-category' => 'widgets', |
|
27 | - 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
28 | - 'class_name' => __CLASS__, |
|
29 | - 'base_id' => 'wpinv_subscriptions', |
|
30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
31 | - 'widget_ops' => array( |
|
32 | - 'classname' => 'getpaid-subscriptions bsui', |
|
33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
34 | - ), |
|
35 | - 'arguments' => array( |
|
36 | - 'title' => array( |
|
37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
39 | - 'type' => 'text', |
|
40 | - 'desc_tip' => true, |
|
41 | - 'default' => '', |
|
42 | - 'advanced' => false, |
|
43 | - ), |
|
44 | - ), |
|
45 | - |
|
46 | - ); |
|
47 | - |
|
48 | - parent::__construct( $options ); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Retrieves current user's subscriptions. |
|
53 | - * |
|
54 | - * @return GetPaid_Subscriptions_Query |
|
55 | - */ |
|
56 | - public function get_subscriptions() { |
|
57 | - |
|
58 | - // Prepare license args. |
|
59 | - $args = array( |
|
60 | - 'customer_in' => get_current_user_id(), |
|
61 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | - ); |
|
63 | - |
|
64 | - return new GetPaid_Subscriptions_Query( $args ); |
|
65 | - |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * The Super block output function. |
|
70 | - * |
|
71 | - * @param array $args |
|
72 | - * @param array $widget_args |
|
73 | - * @param string $content |
|
74 | - * |
|
75 | - * @return mixed|string|bool |
|
76 | - */ |
|
77 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | - |
|
79 | - // Ensure that the user is logged in. |
|
80 | - if ( ! is_user_logged_in() ) { |
|
81 | - |
|
82 | - return aui()->alert( |
|
83 | - array( |
|
84 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | - 'type' => 'error', |
|
86 | - ) |
|
87 | - ); |
|
88 | - |
|
89 | - } |
|
90 | - |
|
91 | - // Are we displaying a single subscription? |
|
92 | - if ( isset( $_GET['subscription'] ) ) { |
|
93 | - return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
94 | - } |
|
95 | - |
|
96 | - // Retrieve the user's subscriptions. |
|
97 | - $subscriptions = $this->get_subscriptions(); |
|
98 | - |
|
99 | - // Start the output buffer. |
|
100 | - ob_start(); |
|
101 | - |
|
102 | - // Backwards compatibility. |
|
103 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | - |
|
105 | - // Display errors and notices. |
|
106 | - wpinv_print_errors(); |
|
107 | - |
|
108 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | - |
|
110 | - // Print the table header. |
|
111 | - $this->print_table_header(); |
|
112 | - |
|
113 | - // Print table body. |
|
114 | - $this->print_table_body( $subscriptions->get_results() ); |
|
115 | - |
|
116 | - // Print table footer. |
|
117 | - $this->print_table_footer(); |
|
118 | - |
|
119 | - // Print the navigation. |
|
120 | - $this->print_navigation( $subscriptions->get_total() ); |
|
121 | - |
|
122 | - // Backwards compatibility. |
|
123 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | - |
|
125 | - // Return the output. |
|
126 | - return ob_get_clean(); |
|
127 | - |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Retrieves the subscription columns. |
|
132 | - * |
|
133 | - * @return array |
|
134 | - */ |
|
135 | - public function get_subscriptions_table_columns() { |
|
17 | + /** |
|
18 | + * Register the widget with WordPress. |
|
19 | + * |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + |
|
23 | + $options = array( |
|
24 | + 'textdomain' => 'invoicing', |
|
25 | + 'block-icon' => 'controls-repeat', |
|
26 | + 'block-category' => 'widgets', |
|
27 | + 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
28 | + 'class_name' => __CLASS__, |
|
29 | + 'base_id' => 'wpinv_subscriptions', |
|
30 | + 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
31 | + 'widget_ops' => array( |
|
32 | + 'classname' => 'getpaid-subscriptions bsui', |
|
33 | + 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
34 | + ), |
|
35 | + 'arguments' => array( |
|
36 | + 'title' => array( |
|
37 | + 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | + 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
39 | + 'type' => 'text', |
|
40 | + 'desc_tip' => true, |
|
41 | + 'default' => '', |
|
42 | + 'advanced' => false, |
|
43 | + ), |
|
44 | + ), |
|
45 | + |
|
46 | + ); |
|
47 | + |
|
48 | + parent::__construct( $options ); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Retrieves current user's subscriptions. |
|
53 | + * |
|
54 | + * @return GetPaid_Subscriptions_Query |
|
55 | + */ |
|
56 | + public function get_subscriptions() { |
|
57 | + |
|
58 | + // Prepare license args. |
|
59 | + $args = array( |
|
60 | + 'customer_in' => get_current_user_id(), |
|
61 | + 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | + ); |
|
63 | + |
|
64 | + return new GetPaid_Subscriptions_Query( $args ); |
|
65 | + |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * The Super block output function. |
|
70 | + * |
|
71 | + * @param array $args |
|
72 | + * @param array $widget_args |
|
73 | + * @param string $content |
|
74 | + * |
|
75 | + * @return mixed|string|bool |
|
76 | + */ |
|
77 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | + |
|
79 | + // Ensure that the user is logged in. |
|
80 | + if ( ! is_user_logged_in() ) { |
|
81 | + |
|
82 | + return aui()->alert( |
|
83 | + array( |
|
84 | + 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | + 'type' => 'error', |
|
86 | + ) |
|
87 | + ); |
|
88 | + |
|
89 | + } |
|
90 | + |
|
91 | + // Are we displaying a single subscription? |
|
92 | + if ( isset( $_GET['subscription'] ) ) { |
|
93 | + return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
94 | + } |
|
95 | + |
|
96 | + // Retrieve the user's subscriptions. |
|
97 | + $subscriptions = $this->get_subscriptions(); |
|
98 | + |
|
99 | + // Start the output buffer. |
|
100 | + ob_start(); |
|
101 | + |
|
102 | + // Backwards compatibility. |
|
103 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | + |
|
105 | + // Display errors and notices. |
|
106 | + wpinv_print_errors(); |
|
107 | + |
|
108 | + do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | + |
|
110 | + // Print the table header. |
|
111 | + $this->print_table_header(); |
|
112 | + |
|
113 | + // Print table body. |
|
114 | + $this->print_table_body( $subscriptions->get_results() ); |
|
115 | + |
|
116 | + // Print table footer. |
|
117 | + $this->print_table_footer(); |
|
118 | + |
|
119 | + // Print the navigation. |
|
120 | + $this->print_navigation( $subscriptions->get_total() ); |
|
121 | + |
|
122 | + // Backwards compatibility. |
|
123 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | + |
|
125 | + // Return the output. |
|
126 | + return ob_get_clean(); |
|
127 | + |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Retrieves the subscription columns. |
|
132 | + * |
|
133 | + * @return array |
|
134 | + */ |
|
135 | + public function get_subscriptions_table_columns() { |
|
136 | 136 | |
137 | - $columns = array( |
|
138 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | - 'status' => __( 'Status', 'invoicing' ), |
|
142 | - ); |
|
137 | + $columns = array( |
|
138 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | + 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | + 'status' => __( 'Status', 'invoicing' ), |
|
142 | + ); |
|
143 | 143 | |
144 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | - } |
|
144 | + return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Displays the table header. |
|
149 | - * |
|
150 | - */ |
|
151 | - public function print_table_header() { |
|
147 | + /** |
|
148 | + * Displays the table header. |
|
149 | + * |
|
150 | + */ |
|
151 | + public function print_table_header() { |
|
152 | 152 | |
153 | - ?> |
|
153 | + ?> |
|
154 | 154 | |
155 | 155 | <table class="table table-bordered table-striped"> |
156 | 156 | |
@@ -166,122 +166,122 @@ discard block |
||
166 | 166 | |
167 | 167 | <?php |
168 | 168 | |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Displays the table body. |
|
173 | - * |
|
174 | - * @param WPInv_Subscription[] $subscriptions |
|
175 | - */ |
|
176 | - public function print_table_body( $subscriptions ) { |
|
171 | + /** |
|
172 | + * Displays the table body. |
|
173 | + * |
|
174 | + * @param WPInv_Subscription[] $subscriptions |
|
175 | + */ |
|
176 | + public function print_table_body( $subscriptions ) { |
|
177 | 177 | |
178 | - if ( empty( $subscriptions ) ) { |
|
179 | - $this->print_table_body_no_subscriptions(); |
|
180 | - } else { |
|
181 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | - } |
|
178 | + if ( empty( $subscriptions ) ) { |
|
179 | + $this->print_table_body_no_subscriptions(); |
|
180 | + } else { |
|
181 | + $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | + } |
|
183 | 183 | |
184 | - } |
|
184 | + } |
|
185 | 185 | |
186 | - /** |
|
187 | - * Displays the table body if no subscriptions were found. |
|
188 | - * |
|
189 | - */ |
|
190 | - public function print_table_body_no_subscriptions() { |
|
186 | + /** |
|
187 | + * Displays the table body if no subscriptions were found. |
|
188 | + * |
|
189 | + */ |
|
190 | + public function print_table_body_no_subscriptions() { |
|
191 | 191 | |
192 | - ?> |
|
192 | + ?> |
|
193 | 193 | <tbody> |
194 | 194 | |
195 | 195 | <tr> |
196 | 196 | <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
197 | 197 | |
198 | 198 | <?php |
199 | - aui()->alert( |
|
200 | - array( |
|
201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | - 'type' => 'warning', |
|
203 | - ), |
|
199 | + aui()->alert( |
|
200 | + array( |
|
201 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | + 'type' => 'warning', |
|
203 | + ), |
|
204 | 204 | true |
205 | - ); |
|
206 | - ?> |
|
205 | + ); |
|
206 | + ?> |
|
207 | 207 | |
208 | 208 | </td> |
209 | 209 | </tr> |
210 | 210 | |
211 | 211 | </tbody> |
212 | 212 | <?php |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * Displays the table body if subscriptions were found. |
|
217 | - * |
|
218 | - * @param WPInv_Subscription[] $subscriptions |
|
219 | - */ |
|
220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
215 | + /** |
|
216 | + * Displays the table body if subscriptions were found. |
|
217 | + * |
|
218 | + * @param WPInv_Subscription[] $subscriptions |
|
219 | + */ |
|
220 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
221 | 221 | |
222 | - ?> |
|
222 | + ?> |
|
223 | 223 | <tbody> |
224 | 224 | |
225 | 225 | <?php foreach ( $subscriptions as $subscription ) : ?> |
226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
227 | 227 | <?php |
228 | - wpinv_get_template( |
|
229 | - 'subscriptions/subscriptions-table-row.php', |
|
230 | - array( |
|
231 | - 'subscription' => $subscription, |
|
232 | - 'widget' => $this, |
|
233 | - ) |
|
234 | - ); |
|
235 | - ?> |
|
228 | + wpinv_get_template( |
|
229 | + 'subscriptions/subscriptions-table-row.php', |
|
230 | + array( |
|
231 | + 'subscription' => $subscription, |
|
232 | + 'widget' => $this, |
|
233 | + ) |
|
234 | + ); |
|
235 | + ?> |
|
236 | 236 | </tr> |
237 | 237 | <?php endforeach; ?> |
238 | 238 | |
239 | 239 | </tbody> |
240 | 240 | <?php |
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Adds row actions to a column |
|
245 | - * |
|
246 | - * @param string $content column content |
|
247 | - * @param WPInv_Subscription $subscription |
|
248 | - * @since 1.0.0 |
|
249 | - * @return string |
|
250 | - */ |
|
251 | - public function add_row_actions( $content, $subscription ) { |
|
252 | - |
|
253 | - // Prepare row actions. |
|
254 | - $actions = array(); |
|
255 | - |
|
256 | - // View subscription action. |
|
257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
260 | - |
|
261 | - // Filter the actions. |
|
262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
263 | - |
|
264 | - $sanitized = array(); |
|
265 | - foreach ( $actions as $key => $action ) { |
|
266 | - $key = sanitize_html_class( $key ); |
|
267 | - $action = wp_kses_post( $action ); |
|
268 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
269 | - } |
|
270 | - |
|
271 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
273 | - $row_actions .= '</small>'; |
|
274 | - |
|
275 | - return $content . $row_actions; |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Displays the table footer. |
|
280 | - * |
|
281 | - */ |
|
282 | - public function print_table_footer() { |
|
283 | - |
|
284 | - ?> |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Adds row actions to a column |
|
245 | + * |
|
246 | + * @param string $content column content |
|
247 | + * @param WPInv_Subscription $subscription |
|
248 | + * @since 1.0.0 |
|
249 | + * @return string |
|
250 | + */ |
|
251 | + public function add_row_actions( $content, $subscription ) { |
|
252 | + |
|
253 | + // Prepare row actions. |
|
254 | + $actions = array(); |
|
255 | + |
|
256 | + // View subscription action. |
|
257 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
260 | + |
|
261 | + // Filter the actions. |
|
262 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
263 | + |
|
264 | + $sanitized = array(); |
|
265 | + foreach ( $actions as $key => $action ) { |
|
266 | + $key = sanitize_html_class( $key ); |
|
267 | + $action = wp_kses_post( $action ); |
|
268 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
269 | + } |
|
270 | + |
|
271 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
272 | + $row_actions .= implode( ' | ', $sanitized ); |
|
273 | + $row_actions .= '</small>'; |
|
274 | + |
|
275 | + return $content . $row_actions; |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Displays the table footer. |
|
280 | + * |
|
281 | + */ |
|
282 | + public function print_table_footer() { |
|
283 | + |
|
284 | + ?> |
|
285 | 285 | |
286 | 286 | <tfoot> |
287 | 287 | <tr> |
@@ -296,145 +296,145 @@ discard block |
||
296 | 296 | </table> |
297 | 297 | <?php |
298 | 298 | |
299 | - } |
|
299 | + } |
|
300 | 300 | |
301 | - /** |
|
302 | - * Displays the navigation. |
|
303 | - * |
|
304 | - * @param int $total |
|
305 | - */ |
|
306 | - public function print_navigation( $total ) { |
|
301 | + /** |
|
302 | + * Displays the navigation. |
|
303 | + * |
|
304 | + * @param int $total |
|
305 | + */ |
|
306 | + public function print_navigation( $total ) { |
|
307 | 307 | |
308 | - if ( $total < 1 ) { |
|
308 | + if ( $total < 1 ) { |
|
309 | 309 | |
310 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
311 | - $args = array( |
|
312 | - 'customer_in' => get_current_user_id(), |
|
313 | - 'fields' => 'id', |
|
314 | - ); |
|
310 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
311 | + $args = array( |
|
312 | + 'customer_in' => get_current_user_id(), |
|
313 | + 'fields' => 'id', |
|
314 | + ); |
|
315 | 315 | |
316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
317 | - $total = $count_query->get_total(); |
|
318 | - } |
|
316 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
317 | + $total = $count_query->get_total(); |
|
318 | + } |
|
319 | 319 | |
320 | - // Abort if we do not have pages. |
|
321 | - if ( 2 > $total ) { |
|
322 | - return; |
|
323 | - } |
|
320 | + // Abort if we do not have pages. |
|
321 | + if ( 2 > $total ) { |
|
322 | + return; |
|
323 | + } |
|
324 | 324 | |
325 | - ?> |
|
325 | + ?> |
|
326 | 326 | |
327 | 327 | <div class="getpaid-subscriptions-pagination"> |
328 | 328 | <?php |
329 | - $big = 999999; |
|
330 | - |
|
331 | - echo wp_kses_post( |
|
332 | - getpaid_paginate_links( |
|
333 | - array( |
|
334 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
335 | - 'format' => '?paged=%#%', |
|
336 | - 'total' => (int) ceil( $total / 10 ), |
|
337 | - ) |
|
338 | - ) |
|
339 | - ); |
|
340 | - ?> |
|
329 | + $big = 999999; |
|
330 | + |
|
331 | + echo wp_kses_post( |
|
332 | + getpaid_paginate_links( |
|
333 | + array( |
|
334 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
335 | + 'format' => '?paged=%#%', |
|
336 | + 'total' => (int) ceil( $total / 10 ), |
|
337 | + ) |
|
338 | + ) |
|
339 | + ); |
|
340 | + ?> |
|
341 | 341 | </div> |
342 | 342 | |
343 | 343 | <?php |
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Returns a single subscription's columns. |
|
348 | - * |
|
349 | - * @param WPInv_Subscription $subscription |
|
350 | - * |
|
351 | - * @return array |
|
352 | - */ |
|
353 | - public function get_single_subscription_columns( $subscription ) { |
|
354 | - |
|
355 | - // Prepare subscription detail columns. |
|
356 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
358 | - $fields = apply_filters( |
|
359 | - 'getpaid_single_subscription_details_fields', |
|
360 | - array( |
|
361 | - 'status' => __( 'Status', 'invoicing' ), |
|
362 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | - 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
368 | - ), |
|
369 | - $subscription, |
|
370 | - $items_count |
|
371 | - ); |
|
372 | - |
|
373 | - if ( isset( $fields['expiry_date'] ) ) { |
|
374 | - |
|
375 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
376 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
377 | - } |
|
378 | - |
|
379 | - if ( 'pending' === $subscription->get_status() ) { |
|
380 | - unset( $fields['expiry_date'] ); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
385 | - unset( $fields['start_date'] ); |
|
386 | - } |
|
387 | - |
|
388 | - if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
389 | - unset( $fields['initial_amount'] ); |
|
390 | - } |
|
391 | - |
|
392 | - return $fields; |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Displays a single subscription. |
|
397 | - * |
|
398 | - * @param string $subscription |
|
399 | - * |
|
400 | - * @return string |
|
401 | - */ |
|
402 | - public function display_single_subscription( $subscription ) { |
|
403 | - |
|
404 | - // Fetch the subscription. |
|
405 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
406 | - |
|
407 | - if ( ! $subscription->exists() ) { |
|
408 | - |
|
409 | - return aui()->alert( |
|
410 | - array( |
|
411 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
412 | - 'type' => 'error', |
|
413 | - ) |
|
414 | - ); |
|
415 | - |
|
416 | - } |
|
417 | - |
|
418 | - // Ensure that the user owns this subscription key. |
|
419 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
420 | - |
|
421 | - return aui()->alert( |
|
422 | - array( |
|
423 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
424 | - 'type' => 'error', |
|
425 | - ) |
|
426 | - ); |
|
427 | - |
|
428 | - } |
|
429 | - |
|
430 | - return wpinv_get_template_html( |
|
431 | - 'subscriptions/subscription-details.php', |
|
432 | - array( |
|
433 | - 'subscription' => $subscription, |
|
434 | - 'widget' => $this, |
|
435 | - ) |
|
436 | - ); |
|
437 | - |
|
438 | - } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Returns a single subscription's columns. |
|
348 | + * |
|
349 | + * @param WPInv_Subscription $subscription |
|
350 | + * |
|
351 | + * @return array |
|
352 | + */ |
|
353 | + public function get_single_subscription_columns( $subscription ) { |
|
354 | + |
|
355 | + // Prepare subscription detail columns. |
|
356 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
358 | + $fields = apply_filters( |
|
359 | + 'getpaid_single_subscription_details_fields', |
|
360 | + array( |
|
361 | + 'status' => __( 'Status', 'invoicing' ), |
|
362 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | + 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
368 | + ), |
|
369 | + $subscription, |
|
370 | + $items_count |
|
371 | + ); |
|
372 | + |
|
373 | + if ( isset( $fields['expiry_date'] ) ) { |
|
374 | + |
|
375 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
376 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
377 | + } |
|
378 | + |
|
379 | + if ( 'pending' === $subscription->get_status() ) { |
|
380 | + unset( $fields['expiry_date'] ); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
385 | + unset( $fields['start_date'] ); |
|
386 | + } |
|
387 | + |
|
388 | + if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
389 | + unset( $fields['initial_amount'] ); |
|
390 | + } |
|
391 | + |
|
392 | + return $fields; |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Displays a single subscription. |
|
397 | + * |
|
398 | + * @param string $subscription |
|
399 | + * |
|
400 | + * @return string |
|
401 | + */ |
|
402 | + public function display_single_subscription( $subscription ) { |
|
403 | + |
|
404 | + // Fetch the subscription. |
|
405 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
406 | + |
|
407 | + if ( ! $subscription->exists() ) { |
|
408 | + |
|
409 | + return aui()->alert( |
|
410 | + array( |
|
411 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
412 | + 'type' => 'error', |
|
413 | + ) |
|
414 | + ); |
|
415 | + |
|
416 | + } |
|
417 | + |
|
418 | + // Ensure that the user owns this subscription key. |
|
419 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
420 | + |
|
421 | + return aui()->alert( |
|
422 | + array( |
|
423 | + 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
424 | + 'type' => 'error', |
|
425 | + ) |
|
426 | + ); |
|
427 | + |
|
428 | + } |
|
429 | + |
|
430 | + return wpinv_get_template_html( |
|
431 | + 'subscriptions/subscription-details.php', |
|
432 | + array( |
|
433 | + 'subscription' => $subscription, |
|
434 | + 'widget' => $this, |
|
435 | + ) |
|
436 | + ); |
|
437 | + |
|
438 | + } |
|
439 | 439 | |
440 | 440 | } |
@@ -21,20 +21,20 @@ |
||
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 | if ( ! empty( $required ) ) { |
37 | - $label .= "<span class='text-danger'> *</span>"; |
|
37 | + $label .= "<span class='text-danger'> *</span>"; |
|
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | <label><span v-html="form_element.label"></span></label> |
@@ -15,321 +15,321 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | - } |
|
18 | + * Hook in methods. |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register core post types. |
|
29 | - */ |
|
30 | - public static function register_post_types() { |
|
27 | + /** |
|
28 | + * Register core post types. |
|
29 | + */ |
|
30 | + public static function register_post_types() { |
|
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | - return; |
|
34 | - } |
|
32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
36 | + $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
37 | 37 | |
38 | - // Fires before registering post types. |
|
39 | - do_action( 'getpaid_register_post_types' ); |
|
38 | + // Fires before registering post types. |
|
39 | + do_action( 'getpaid_register_post_types' ); |
|
40 | 40 | |
41 | - // Register item post type. |
|
42 | - register_post_type( |
|
43 | - 'wpi_item', |
|
44 | - apply_filters( |
|
45 | - 'wpinv_register_post_type_invoice_item', |
|
46 | - array( |
|
47 | - 'labels' => array( |
|
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ), |
|
62 | - ), |
|
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | - 'public' => false, |
|
65 | - 'has_archive' => false, |
|
66 | - '_builtin' => false, |
|
67 | - 'show_ui' => $capabilities ? true : false, |
|
68 | - 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
69 | - 'show_in_nav_menus' => false, |
|
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | - 'rewrite' => false, |
|
72 | - 'query_var' => false, |
|
73 | - 'map_meta_cap' => true, |
|
74 | - 'show_in_admin_bar' => $capabilities ? true : false, |
|
75 | - 'can_export' => $capabilities ? true : false |
|
76 | - ) |
|
77 | - ) |
|
78 | - ); |
|
41 | + // Register item post type. |
|
42 | + register_post_type( |
|
43 | + 'wpi_item', |
|
44 | + apply_filters( |
|
45 | + 'wpinv_register_post_type_invoice_item', |
|
46 | + array( |
|
47 | + 'labels' => array( |
|
48 | + 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | + 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | + 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | + 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | + 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | + 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | + 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | + 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | + 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | + 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | + 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | + 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ), |
|
62 | + ), |
|
63 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | + 'public' => false, |
|
65 | + 'has_archive' => false, |
|
66 | + '_builtin' => false, |
|
67 | + 'show_ui' => $capabilities ? true : false, |
|
68 | + 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
69 | + 'show_in_nav_menus' => false, |
|
70 | + 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | + 'rewrite' => false, |
|
72 | + 'query_var' => false, |
|
73 | + 'map_meta_cap' => true, |
|
74 | + 'show_in_admin_bar' => $capabilities ? true : false, |
|
75 | + 'can_export' => $capabilities ? true : false |
|
76 | + ) |
|
77 | + ) |
|
78 | + ); |
|
79 | 79 | |
80 | - // Register payment form post type. |
|
81 | - register_post_type( |
|
82 | - 'wpi_payment_form', |
|
83 | - apply_filters( |
|
84 | - 'wpinv_register_post_type_payment_form', |
|
85 | - array( |
|
86 | - 'labels' => array( |
|
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ), |
|
101 | - ), |
|
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | - 'public' => false, |
|
104 | - 'show_ui' => $capabilities ? true : false, |
|
105 | - 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
106 | - 'show_in_nav_menus' => false, |
|
107 | - 'query_var' => false, |
|
108 | - 'rewrite' => true, |
|
109 | - 'map_meta_cap' => true, |
|
110 | - 'has_archive' => false, |
|
111 | - 'hierarchical' => false, |
|
112 | - 'menu_position' => null, |
|
113 | - 'supports' => array( 'title' ), |
|
114 | - 'menu_icon' => 'dashicons-media-form', |
|
115 | - ) |
|
116 | - ) |
|
117 | - ); |
|
80 | + // Register payment form post type. |
|
81 | + register_post_type( |
|
82 | + 'wpi_payment_form', |
|
83 | + apply_filters( |
|
84 | + 'wpinv_register_post_type_payment_form', |
|
85 | + array( |
|
86 | + 'labels' => array( |
|
87 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ), |
|
101 | + ), |
|
102 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | + 'public' => false, |
|
104 | + 'show_ui' => $capabilities ? true : false, |
|
105 | + 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
106 | + 'show_in_nav_menus' => false, |
|
107 | + 'query_var' => false, |
|
108 | + 'rewrite' => true, |
|
109 | + 'map_meta_cap' => true, |
|
110 | + 'has_archive' => false, |
|
111 | + 'hierarchical' => false, |
|
112 | + 'menu_position' => null, |
|
113 | + 'supports' => array( 'title' ), |
|
114 | + 'menu_icon' => 'dashicons-media-form', |
|
115 | + ) |
|
116 | + ) |
|
117 | + ); |
|
118 | 118 | |
119 | - // Register invoice post type. |
|
120 | - register_post_type( |
|
121 | - 'wpi_invoice', |
|
122 | - apply_filters( |
|
123 | - 'wpinv_register_post_type_invoice', |
|
124 | - array( |
|
125 | - 'labels' => array( |
|
126 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
127 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
128 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
129 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
130 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
131 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
132 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
133 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
134 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
135 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
136 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
137 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
138 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
139 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
140 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
141 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
142 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
143 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
144 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
145 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
146 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
147 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
148 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
149 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
150 | - ), |
|
151 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
152 | - 'public' => true, |
|
153 | - 'has_archive' => false, |
|
154 | - 'publicly_queryable' => true, |
|
155 | - 'exclude_from_search' => true, |
|
156 | - 'show_ui' => $capabilities ? true : false, |
|
157 | - 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
158 | - 'show_in_nav_menus' => false, |
|
159 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
160 | - 'rewrite' => array( |
|
161 | - 'slug' => 'invoice', |
|
162 | - 'with_front' => false, |
|
163 | - ), |
|
164 | - 'query_var' => false, |
|
165 | - 'map_meta_cap' => true, |
|
166 | - 'show_in_admin_bar' => $capabilities ? true : false, |
|
167 | - 'can_export' => $capabilities ? true : false, |
|
168 | - 'hierarchical' => false, |
|
169 | - 'menu_position' => null, |
|
170 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
171 | - ) |
|
172 | - ) |
|
173 | - ); |
|
119 | + // Register invoice post type. |
|
120 | + register_post_type( |
|
121 | + 'wpi_invoice', |
|
122 | + apply_filters( |
|
123 | + 'wpinv_register_post_type_invoice', |
|
124 | + array( |
|
125 | + 'labels' => array( |
|
126 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
127 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
128 | + 'all_items' => __( 'Invoices', 'invoicing' ), |
|
129 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
130 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
131 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
132 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
133 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
134 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
135 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
136 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
137 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
138 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
139 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
140 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
141 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
142 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
143 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
144 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
145 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
146 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
147 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
148 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
149 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
150 | + ), |
|
151 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
152 | + 'public' => true, |
|
153 | + 'has_archive' => false, |
|
154 | + 'publicly_queryable' => true, |
|
155 | + 'exclude_from_search' => true, |
|
156 | + 'show_ui' => $capabilities ? true : false, |
|
157 | + 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
158 | + 'show_in_nav_menus' => false, |
|
159 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
160 | + 'rewrite' => array( |
|
161 | + 'slug' => 'invoice', |
|
162 | + 'with_front' => false, |
|
163 | + ), |
|
164 | + 'query_var' => false, |
|
165 | + 'map_meta_cap' => true, |
|
166 | + 'show_in_admin_bar' => $capabilities ? true : false, |
|
167 | + 'can_export' => $capabilities ? true : false, |
|
168 | + 'hierarchical' => false, |
|
169 | + 'menu_position' => null, |
|
170 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
171 | + ) |
|
172 | + ) |
|
173 | + ); |
|
174 | 174 | |
175 | - // Register discount post type. |
|
176 | - register_post_type( |
|
177 | - 'wpi_discount', |
|
178 | - apply_filters( |
|
179 | - 'wpinv_register_post_type_discount', |
|
180 | - array( |
|
181 | - 'labels' => array( |
|
182 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
183 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
184 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
185 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
186 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
187 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
188 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
189 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
190 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
191 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
192 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
193 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
194 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
195 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
196 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
197 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
198 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
199 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
200 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
201 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
202 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
203 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
204 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
205 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
206 | - ), |
|
207 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
208 | - 'public' => false, |
|
209 | - 'can_export' => $capabilities ? true : false, |
|
210 | - '_builtin' => false, |
|
211 | - 'publicly_queryable' => false, |
|
212 | - 'exclude_from_search' => true, |
|
213 | - 'show_ui' => $capabilities ? true : false, |
|
214 | - 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
215 | - 'query_var' => false, |
|
216 | - 'rewrite' => false, |
|
217 | - 'map_meta_cap' => true, |
|
218 | - 'has_archive' => false, |
|
219 | - 'hierarchical' => false, |
|
220 | - 'supports' => array( 'title', 'excerpt' ), |
|
221 | - 'show_in_nav_menus' => false, |
|
222 | - 'show_in_admin_bar' => $capabilities ? true : false, |
|
223 | - 'menu_position' => null, |
|
224 | - ) |
|
225 | - ) |
|
226 | - ); |
|
175 | + // Register discount post type. |
|
176 | + register_post_type( |
|
177 | + 'wpi_discount', |
|
178 | + apply_filters( |
|
179 | + 'wpinv_register_post_type_discount', |
|
180 | + array( |
|
181 | + 'labels' => array( |
|
182 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
183 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
184 | + 'all_items' => __( 'Discounts', 'invoicing' ), |
|
185 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
186 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
187 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
188 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
189 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
190 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
191 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
192 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
193 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
194 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
195 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
196 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
197 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
198 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
199 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
200 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
201 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
202 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
203 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
204 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
205 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
206 | + ), |
|
207 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
208 | + 'public' => false, |
|
209 | + 'can_export' => $capabilities ? true : false, |
|
210 | + '_builtin' => false, |
|
211 | + 'publicly_queryable' => false, |
|
212 | + 'exclude_from_search' => true, |
|
213 | + 'show_ui' => $capabilities ? true : false, |
|
214 | + 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
215 | + 'query_var' => false, |
|
216 | + 'rewrite' => false, |
|
217 | + 'map_meta_cap' => true, |
|
218 | + 'has_archive' => false, |
|
219 | + 'hierarchical' => false, |
|
220 | + 'supports' => array( 'title', 'excerpt' ), |
|
221 | + 'show_in_nav_menus' => false, |
|
222 | + 'show_in_admin_bar' => $capabilities ? true : false, |
|
223 | + 'menu_position' => null, |
|
224 | + ) |
|
225 | + ) |
|
226 | + ); |
|
227 | 227 | |
228 | - do_action( 'getpaid_after_register_post_types' ); |
|
229 | - } |
|
228 | + do_action( 'getpaid_after_register_post_types' ); |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * Register our custom post statuses. |
|
233 | - */ |
|
234 | - public static function register_post_status() { |
|
231 | + /** |
|
232 | + * Register our custom post statuses. |
|
233 | + */ |
|
234 | + public static function register_post_status() { |
|
235 | 235 | |
236 | - $invoice_statuses = apply_filters( |
|
237 | - 'getpaid_register_invoice_post_statuses', |
|
238 | - array( |
|
236 | + $invoice_statuses = apply_filters( |
|
237 | + 'getpaid_register_invoice_post_statuses', |
|
238 | + array( |
|
239 | 239 | |
240 | - 'wpi-pending' => array( |
|
241 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
242 | - 'public' => true, |
|
243 | - 'exclude_from_search' => true, |
|
244 | - 'show_in_admin_all_list' => true, |
|
245 | - 'show_in_admin_status_list' => true, |
|
246 | - /* translators: %s: number of invoices */ |
|
247 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ), |
|
248 | - ), |
|
240 | + 'wpi-pending' => array( |
|
241 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
242 | + 'public' => true, |
|
243 | + 'exclude_from_search' => true, |
|
244 | + 'show_in_admin_all_list' => true, |
|
245 | + 'show_in_admin_status_list' => true, |
|
246 | + /* translators: %s: number of invoices */ |
|
247 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ), |
|
248 | + ), |
|
249 | 249 | |
250 | - 'wpi-processing' => array( |
|
251 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
252 | - 'public' => true, |
|
253 | - 'exclude_from_search' => true, |
|
254 | - 'show_in_admin_all_list' => true, |
|
255 | - 'show_in_admin_status_list' => true, |
|
256 | - /* translators: %s: number of invoices */ |
|
257 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ), |
|
258 | - ), |
|
250 | + 'wpi-processing' => array( |
|
251 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
252 | + 'public' => true, |
|
253 | + 'exclude_from_search' => true, |
|
254 | + 'show_in_admin_all_list' => true, |
|
255 | + 'show_in_admin_status_list' => true, |
|
256 | + /* translators: %s: number of invoices */ |
|
257 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ), |
|
258 | + ), |
|
259 | 259 | |
260 | - 'wpi-onhold' => array( |
|
261 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
262 | - 'public' => true, |
|
263 | - 'exclude_from_search' => true, |
|
264 | - 'show_in_admin_all_list' => true, |
|
265 | - 'show_in_admin_status_list' => true, |
|
266 | - /* translators: %s: number of invoices */ |
|
267 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ), |
|
268 | - ), |
|
260 | + 'wpi-onhold' => array( |
|
261 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
262 | + 'public' => true, |
|
263 | + 'exclude_from_search' => true, |
|
264 | + 'show_in_admin_all_list' => true, |
|
265 | + 'show_in_admin_status_list' => true, |
|
266 | + /* translators: %s: number of invoices */ |
|
267 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ), |
|
268 | + ), |
|
269 | 269 | |
270 | - 'wpi-cancelled' => array( |
|
271 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
272 | - 'public' => true, |
|
273 | - 'exclude_from_search' => true, |
|
274 | - 'show_in_admin_all_list' => true, |
|
275 | - 'show_in_admin_status_list' => true, |
|
276 | - /* translators: %s: number of invoices */ |
|
277 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ), |
|
278 | - ), |
|
270 | + 'wpi-cancelled' => array( |
|
271 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
272 | + 'public' => true, |
|
273 | + 'exclude_from_search' => true, |
|
274 | + 'show_in_admin_all_list' => true, |
|
275 | + 'show_in_admin_status_list' => true, |
|
276 | + /* translators: %s: number of invoices */ |
|
277 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ), |
|
278 | + ), |
|
279 | 279 | |
280 | - 'wpi-refunded' => array( |
|
281 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
282 | - 'public' => true, |
|
283 | - 'exclude_from_search' => true, |
|
284 | - 'show_in_admin_all_list' => true, |
|
285 | - 'show_in_admin_status_list' => true, |
|
286 | - /* translators: %s: number of invoices */ |
|
287 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ), |
|
288 | - ), |
|
280 | + 'wpi-refunded' => array( |
|
281 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
282 | + 'public' => true, |
|
283 | + 'exclude_from_search' => true, |
|
284 | + 'show_in_admin_all_list' => true, |
|
285 | + 'show_in_admin_status_list' => true, |
|
286 | + /* translators: %s: number of invoices */ |
|
287 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ), |
|
288 | + ), |
|
289 | 289 | |
290 | - 'wpi-failed' => array( |
|
291 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
292 | - 'public' => true, |
|
293 | - 'exclude_from_search' => true, |
|
294 | - 'show_in_admin_all_list' => true, |
|
295 | - 'show_in_admin_status_list' => true, |
|
296 | - /* translators: %s: number of invoices */ |
|
297 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ), |
|
298 | - ), |
|
290 | + 'wpi-failed' => array( |
|
291 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
292 | + 'public' => true, |
|
293 | + 'exclude_from_search' => true, |
|
294 | + 'show_in_admin_all_list' => true, |
|
295 | + 'show_in_admin_status_list' => true, |
|
296 | + /* translators: %s: number of invoices */ |
|
297 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ), |
|
298 | + ), |
|
299 | 299 | |
300 | - 'wpi-renewal' => array( |
|
301 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
302 | - 'public' => true, |
|
303 | - 'exclude_from_search' => true, |
|
304 | - 'show_in_admin_all_list' => true, |
|
305 | - 'show_in_admin_status_list' => true, |
|
306 | - /* translators: %s: number of invoices */ |
|
307 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ), |
|
308 | - ), |
|
309 | - ) |
|
310 | - ); |
|
300 | + 'wpi-renewal' => array( |
|
301 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
302 | + 'public' => true, |
|
303 | + 'exclude_from_search' => true, |
|
304 | + 'show_in_admin_all_list' => true, |
|
305 | + 'show_in_admin_status_list' => true, |
|
306 | + /* translators: %s: number of invoices */ |
|
307 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ), |
|
308 | + ), |
|
309 | + ) |
|
310 | + ); |
|
311 | 311 | |
312 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
313 | - register_post_status( $invoice_statuse, $args ); |
|
314 | - } |
|
315 | - } |
|
312 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
313 | + register_post_status( $invoice_statuse, $args ); |
|
314 | + } |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Flush rewrite rules. |
|
319 | - */ |
|
320 | - public static function flush_rewrite_rules() { |
|
321 | - flush_rewrite_rules(); |
|
322 | - } |
|
317 | + /** |
|
318 | + * Flush rewrite rules. |
|
319 | + */ |
|
320 | + public static function flush_rewrite_rules() { |
|
321 | + flush_rewrite_rules(); |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * Flush rules to prevent 404. |
|
326 | - * |
|
327 | - */ |
|
328 | - public static function maybe_flush_rewrite_rules() { |
|
329 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
330 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
331 | - self::flush_rewrite_rules(); |
|
332 | - } |
|
333 | - } |
|
324 | + /** |
|
325 | + * Flush rules to prevent 404. |
|
326 | + * |
|
327 | + */ |
|
328 | + public static function maybe_flush_rewrite_rules() { |
|
329 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
330 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
331 | + self::flush_rewrite_rules(); |
|
332 | + } |
|
333 | + } |
|
334 | 334 | |
335 | 335 | } |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | $defaults[ $key ] = $setting['std']; |
26 | 26 | } |
27 | 27 | } |
28 | - } |
|
29 | - } |
|
28 | + } |
|
29 | + } |
|
30 | 30 | |
31 | 31 | return $defaults; |
32 | 32 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | */ |
146 | 146 | function wpinv_register_settings() { |
147 | - do_action( 'getpaid_before_register_settings' ); |
|
147 | + do_action( 'getpaid_before_register_settings' ); |
|
148 | 148 | |
149 | 149 | // Loop through all tabs. |
150 | 150 | foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $settings = $sections; |
160 | 160 | } |
161 | 161 | |
162 | - do_action( "getpaid_register_{$tab}_{$section}" ); |
|
162 | + do_action( "getpaid_register_{$tab}_{$section}" ); |
|
163 | 163 | |
164 | 164 | // Register the setting section. |
165 | 165 | add_settings_section( |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // Creates our settings in the options table. |
181 | 181 | register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
182 | 182 | |
183 | - do_action( 'getpaid_after_register_settings' ); |
|
183 | + do_action( 'getpaid_after_register_settings' ); |
|
184 | 184 | } |
185 | 185 | add_action( 'admin_init', 'wpinv_register_settings' ); |
186 | 186 | |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | $name = isset( $option['name'] ) ? $option['name'] : ''; |
198 | 198 | $cb = "wpinv_{$option['type']}_callback"; |
199 | 199 | $section = "wpinv_settings_{$tab}_$section"; |
200 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
200 | + $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
201 | 201 | |
202 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
203 | - $tip = wpinv_clean( $option['desc'] ); |
|
204 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
205 | - unset( $option['desc'] ); |
|
206 | - } |
|
202 | + if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
203 | + $tip = wpinv_clean( $option['desc'] ); |
|
204 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
205 | + unset( $option['desc'] ); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | // Loop through all tabs. |
209 | 209 | add_settings_field( |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
231 | 231 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
232 | 232 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
233 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
234 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
235 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
233 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
234 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
235 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
236 | 236 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
237 | 237 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
238 | 238 | ) |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return array |
247 | 247 | */ |
248 | 248 | function wpinv_get_registered_settings() { |
249 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
249 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -265,18 +265,18 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function wpinv_settings_sanitize( $input = array() ) { |
267 | 267 | |
268 | - $wpinv_options = wpinv_get_options(); |
|
269 | - $raw_referrer = wp_get_raw_referer(); |
|
268 | + $wpinv_options = wpinv_get_options(); |
|
269 | + $raw_referrer = wp_get_raw_referer(); |
|
270 | 270 | |
271 | 271 | if ( empty( $raw_referrer ) ) { |
272 | - return array_merge( $wpinv_options, $input ); |
|
272 | + return array_merge( $wpinv_options, $input ); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | wp_parse_str( $raw_referrer, $referrer ); |
276 | 276 | |
277 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
278 | - return array_merge( $wpinv_options, $input ); |
|
279 | - } |
|
277 | + if ( in_array( 'gp-setup', $referrer ) ) { |
|
278 | + return array_merge( $wpinv_options, $input ); |
|
279 | + } |
|
280 | 280 | |
281 | 281 | $settings = wpinv_get_registered_settings(); |
282 | 282 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | // General filter |
301 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
301 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
302 | 302 | |
303 | - // Key specific filter. |
|
304 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
303 | + // Key specific filter. |
|
304 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | |
345 | 345 | foreach ( $new_rates as $rate ) { |
346 | 346 | |
347 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
348 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
349 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
350 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
351 | - $rate['global'] = empty( $rate['state'] ); |
|
352 | - $tax_rates[] = $rate; |
|
347 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
348 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
349 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
350 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
351 | + $rate['global'] = empty( $rate['state'] ); |
|
352 | + $tax_rates[] = $rate; |
|
353 | 353 | |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | 356 | update_option( 'wpinv_tax_rates', $tax_rates ); |
357 | 357 | |
@@ -364,21 +364,21 @@ discard block |
||
364 | 364 | return $input; |
365 | 365 | } |
366 | 366 | |
367 | - if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) { |
|
368 | - return $input; |
|
369 | - } |
|
367 | + if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) { |
|
368 | + return $input; |
|
369 | + } |
|
370 | 370 | |
371 | 371 | $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array(); |
372 | 372 | $tax_rules = array(); |
373 | 373 | |
374 | 374 | foreach ( $new_rules as $rule ) { |
375 | 375 | |
376 | - $rule['key'] = sanitize_title_with_dashes( $rule['key'] ); |
|
377 | - $rule['label'] = sanitize_text_field( $rule['label'] ); |
|
378 | - $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] ); |
|
379 | - $tax_rules[] = $rule; |
|
376 | + $rule['key'] = sanitize_title_with_dashes( $rule['key'] ); |
|
377 | + $rule['label'] = sanitize_text_field( $rule['label'] ); |
|
378 | + $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] ); |
|
379 | + $tax_rules[] = $rule; |
|
380 | 380 | |
381 | - } |
|
381 | + } |
|
382 | 382 | |
383 | 383 | update_option( 'wpinv_tax_rules', $tax_rules ); |
384 | 384 | |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | $tabs['general'] = __( 'General', 'invoicing' ); |
392 | 392 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
393 | 393 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
394 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
394 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
395 | 395 | |
396 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
397 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
398 | - } |
|
396 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
397 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
398 | + } |
|
399 | 399 | |
400 | 400 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
401 | 401 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -426,53 +426,53 @@ discard block |
||
426 | 426 | 'general' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_general', |
428 | 428 | array( |
429 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
430 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
431 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
432 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
429 | + 'main' => __( 'General Settings', 'invoicing' ), |
|
430 | + 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
431 | + 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
432 | + 'labels' => __( 'Label Texts', 'invoicing' ), |
|
433 | 433 | ) |
434 | 434 | ), |
435 | 435 | 'gateways' => apply_filters( |
436 | 436 | 'wpinv_settings_sections_gateways', |
437 | 437 | array( |
438 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
438 | + 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | 'taxes' => apply_filters( |
442 | 442 | 'wpinv_settings_sections_taxes', |
443 | 443 | array( |
444 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
445 | - 'rules' => __( 'Tax Rules', 'invoicing' ), |
|
446 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
447 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
444 | + 'main' => __( 'Tax Settings', 'invoicing' ), |
|
445 | + 'rules' => __( 'Tax Rules', 'invoicing' ), |
|
446 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
447 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | 'emails' => apply_filters( |
451 | 451 | 'wpinv_settings_sections_emails', |
452 | 452 | array( |
453 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
453 | + 'main' => __( 'Email Settings', 'invoicing' ), |
|
454 | 454 | ) |
455 | 455 | ), |
456 | 456 | |
457 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
457 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
458 | 458 | |
459 | 459 | 'privacy' => apply_filters( |
460 | 460 | 'wpinv_settings_sections_privacy', |
461 | 461 | array( |
462 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
462 | + 'main' => __( 'Privacy policy', 'invoicing' ), |
|
463 | 463 | ) |
464 | 464 | ), |
465 | 465 | 'misc' => apply_filters( |
466 | 466 | 'wpinv_settings_sections_misc', |
467 | 467 | array( |
468 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
469 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
468 | + 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
469 | + 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
470 | 470 | ) |
471 | 471 | ), |
472 | 472 | 'tools' => apply_filters( |
473 | 473 | 'wpinv_settings_sections_tools', |
474 | 474 | array( |
475 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
475 | + 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | ); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | // Prepare the SQL query to include the excluded pages only if we have placeholders |
526 | 526 | $pages = $exclude_pages_placeholders ? $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) ) : $wpdb->get_results( $sql ); |
527 | 527 | |
528 | - $pages_options = array(); |
|
528 | + $pages_options = array(); |
|
529 | 529 | |
530 | 530 | if ( $pages ) { |
531 | 531 | foreach ( $pages as $page ) { |
@@ -542,32 +542,32 @@ discard block |
||
542 | 542 | $pages_options = array( '' => $default_label ) + $pages_options; // Blank option |
543 | 543 | } |
544 | 544 | |
545 | - return $pages_options; |
|
545 | + return $pages_options; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | function wpinv_header_callback( $args ) { |
549 | - if ( ! empty( $args['desc'] ) ) { |
|
549 | + if ( ! empty( $args['desc'] ) ) { |
|
550 | 550 | echo wp_kses_post( $args['desc'] ); |
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
554 | 554 | function wpinv_hidden_callback( $args ) { |
555 | 555 | |
556 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
557 | - $value = wpinv_get_option( $args['id'], $std ); |
|
556 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
557 | + $value = wpinv_get_option( $args['id'], $std ); |
|
558 | 558 | |
559 | - if ( isset( $args['set_value'] ) ) { |
|
560 | - $value = $args['set_value']; |
|
561 | - } |
|
559 | + if ( isset( $args['set_value'] ) ) { |
|
560 | + $value = $args['set_value']; |
|
561 | + } |
|
562 | 562 | |
563 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
564 | - $args['readonly'] = true; |
|
565 | - $name = ''; |
|
566 | - } else { |
|
567 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
568 | - } |
|
563 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
564 | + $args['readonly'] = true; |
|
565 | + $name = ''; |
|
566 | + } else { |
|
567 | + $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
568 | + } |
|
569 | 569 | |
570 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
570 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
571 | 571 | |
572 | 572 | } |
573 | 573 | |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | */ |
577 | 577 | function wpinv_checkbox_callback( $args ) { |
578 | 578 | |
579 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
580 | - $std = wpinv_get_option( $args['id'], $std ); |
|
581 | - $id = esc_attr( $args['id'] ); |
|
579 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
580 | + $std = wpinv_get_option( $args['id'], $std ); |
|
581 | + $id = esc_attr( $args['id'] ); |
|
582 | 582 | |
583 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
584 | - ?> |
|
583 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
584 | + ?> |
|
585 | 585 | <label> |
586 | 586 | <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" /> |
587 | 587 | <?php echo wp_kses_post( $args['desc'] ); ?> |
@@ -591,75 +591,75 @@ discard block |
||
591 | 591 | |
592 | 592 | function wpinv_multicheck_callback( $args ) { |
593 | 593 | |
594 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
595 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
594 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
595 | + $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
596 | 596 | |
597 | - if ( ! empty( $args['options'] ) ) { |
|
597 | + if ( ! empty( $args['options'] ) ) { |
|
598 | 598 | |
599 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
600 | - $value = wpinv_get_option( $args['id'], $std ); |
|
599 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
600 | + $value = wpinv_get_option( $args['id'], $std ); |
|
601 | 601 | |
602 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
602 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
603 | 603 | foreach ( $args['options'] as $key => $option ) : |
604 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
605 | - if ( in_array( $sanitize_key, $value ) ) { |
|
606 | - $enabled = $sanitize_key; |
|
607 | - } else { |
|
608 | - $enabled = null; |
|
609 | - } |
|
610 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
611 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
612 | - endforeach; |
|
613 | - echo '</div>'; |
|
614 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
615 | - } |
|
604 | + $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
605 | + if ( in_array( $sanitize_key, $value ) ) { |
|
606 | + $enabled = $sanitize_key; |
|
607 | + } else { |
|
608 | + $enabled = null; |
|
609 | + } |
|
610 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
611 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
612 | + endforeach; |
|
613 | + echo '</div>'; |
|
614 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
615 | + } |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | function wpinv_payment_icons_callback( $args ) { |
619 | 619 | |
620 | 620 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
621 | - $value = wpinv_get_option( $args['id'], false ); |
|
621 | + $value = wpinv_get_option( $args['id'], false ); |
|
622 | 622 | |
623 | - if ( ! empty( $args['options'] ) ) { |
|
624 | - foreach ( $args['options'] as $key => $option ) { |
|
623 | + if ( ! empty( $args['options'] ) ) { |
|
624 | + foreach ( $args['options'] as $key => $option ) { |
|
625 | 625 | $sanitize_key = wpinv_sanitize_key( $key ); |
626 | 626 | |
627 | - if ( empty( $value ) ) { |
|
628 | - $enabled = $option; |
|
629 | - } else { |
|
630 | - $enabled = null; |
|
631 | - } |
|
632 | - |
|
633 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
634 | - |
|
635 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
636 | - |
|
637 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
638 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
639 | - } else { |
|
640 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
641 | - |
|
642 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
643 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
644 | - } else { |
|
645 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
646 | - $content_dir = WP_CONTENT_DIR; |
|
647 | - |
|
648 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
649 | - // Replaces backslashes with forward slashes for Windows systems |
|
650 | - $image = wp_normalize_path( $image ); |
|
651 | - $content_dir = wp_normalize_path( $content_dir ); |
|
652 | - } |
|
653 | - |
|
654 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
655 | - } |
|
656 | - |
|
657 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
658 | - } |
|
659 | - echo wp_kses_post( $option ) . '</label>'; |
|
660 | - } |
|
661 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
662 | - } |
|
627 | + if ( empty( $value ) ) { |
|
628 | + $enabled = $option; |
|
629 | + } else { |
|
630 | + $enabled = null; |
|
631 | + } |
|
632 | + |
|
633 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
634 | + |
|
635 | + echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
636 | + |
|
637 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
638 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
639 | + } else { |
|
640 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
641 | + |
|
642 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
643 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
644 | + } else { |
|
645 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
646 | + $content_dir = WP_CONTENT_DIR; |
|
647 | + |
|
648 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
649 | + // Replaces backslashes with forward slashes for Windows systems |
|
650 | + $image = wp_normalize_path( $image ); |
|
651 | + $content_dir = wp_normalize_path( $content_dir ); |
|
652 | + } |
|
653 | + |
|
654 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
655 | + } |
|
656 | + |
|
657 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
658 | + } |
|
659 | + echo wp_kses_post( $option ) . '</label>'; |
|
660 | + } |
|
661 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
662 | + } |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | */ |
668 | 668 | function wpinv_radio_callback( $args ) { |
669 | 669 | |
670 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
671 | - $std = wpinv_get_option( $args['id'], $std ); |
|
672 | - ?> |
|
670 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
671 | + $std = wpinv_get_option( $args['id'], $std ); |
|
672 | + ?> |
|
673 | 673 | <fieldset> |
674 | 674 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
675 | 675 | <?php foreach ( $args['options'] as $key => $option ) : ?> |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | </ul> |
684 | 684 | </fieldset> |
685 | 685 | <?php |
686 | - getpaid_settings_description_callback( $args ); |
|
686 | + getpaid_settings_description_callback( $args ); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -691,10 +691,10 @@ discard block |
||
691 | 691 | */ |
692 | 692 | function getpaid_settings_description_callback( $args ) { |
693 | 693 | |
694 | - if ( ! empty( $args['desc'] ) ) { |
|
695 | - $description = $args['desc']; |
|
696 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
697 | - } |
|
694 | + if ( ! empty( $args['desc'] ) ) { |
|
695 | + $description = $args['desc']; |
|
696 | + echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
697 | + } |
|
698 | 698 | |
699 | 699 | } |
700 | 700 | |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | function wpinv_gateways_callback() { |
705 | 705 | |
706 | - ?> |
|
706 | + ?> |
|
707 | 707 | </td> |
708 | 708 | </tr> |
709 | 709 | <tr class="bsui"> |
@@ -717,26 +717,26 @@ discard block |
||
717 | 717 | |
718 | 718 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
719 | 719 | $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
720 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
721 | - $value = wpinv_get_option( $args['id'], $std ); |
|
720 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
721 | + $value = wpinv_get_option( $args['id'], $std ); |
|
722 | 722 | |
723 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
723 | + echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
724 | 724 | |
725 | - foreach ( $args['options'] as $key => $option ) : |
|
725 | + foreach ( $args['options'] as $key => $option ) : |
|
726 | 726 | |
727 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
727 | + echo '<option value="' . esc_attr( $key ) . '" '; |
|
728 | 728 | |
729 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
729 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
730 | 730 | selected( $key, $args['selected'] ); |
731 | 731 | } else { |
732 | 732 | selected( $key, $value ); |
733 | 733 | } |
734 | 734 | |
735 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
736 | - endforeach; |
|
735 | + echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
736 | + endforeach; |
|
737 | 737 | |
738 | - echo '</select>'; |
|
739 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
738 | + echo '</select>'; |
|
739 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -747,38 +747,38 @@ discard block |
||
747 | 747 | */ |
748 | 748 | function wpinv_settings_attrs_helper( $args ) { |
749 | 749 | |
750 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
751 | - $id = esc_attr( $args['id'] ); |
|
752 | - $value = is_scalar( $value ) ? $value : ''; |
|
753 | - |
|
754 | - $attrs = array( |
|
755 | - 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
756 | - 'readonly' => ! empty( $args['faux'] ), |
|
757 | - 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
758 | - 'id' => 'wpinv-settings-' . $args['id'], |
|
759 | - 'style' => $args['style'], |
|
760 | - 'class' => $args['class'], |
|
761 | - 'placeholder' => $args['placeholder'], |
|
762 | - 'data-placeholder' => $args['placeholder'], |
|
763 | - ); |
|
750 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
751 | + $id = esc_attr( $args['id'] ); |
|
752 | + $value = is_scalar( $value ) ? $value : ''; |
|
753 | + |
|
754 | + $attrs = array( |
|
755 | + 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
756 | + 'readonly' => ! empty( $args['faux'] ), |
|
757 | + 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
758 | + 'id' => 'wpinv-settings-' . $args['id'], |
|
759 | + 'style' => $args['style'], |
|
760 | + 'class' => $args['class'], |
|
761 | + 'placeholder' => $args['placeholder'], |
|
762 | + 'data-placeholder' => $args['placeholder'], |
|
763 | + ); |
|
764 | 764 | |
765 | - if ( ! empty( $args['onchange'] ) ) { |
|
766 | - $attrs['onchange'] = $args['onchange']; |
|
767 | - } |
|
765 | + if ( ! empty( $args['onchange'] ) ) { |
|
766 | + $attrs['onchange'] = $args['onchange']; |
|
767 | + } |
|
768 | 768 | |
769 | - foreach ( $attrs as $key => $value ) { |
|
769 | + foreach ( $attrs as $key => $value ) { |
|
770 | 770 | |
771 | - if ( false === $value ) { |
|
772 | - continue; |
|
773 | - } |
|
771 | + if ( false === $value ) { |
|
772 | + continue; |
|
773 | + } |
|
774 | 774 | |
775 | - if ( true === $value ) { |
|
776 | - echo ' ' . esc_attr( $key ); |
|
777 | - } else { |
|
778 | - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
779 | - } |
|
775 | + if ( true === $value ) { |
|
776 | + echo ' ' . esc_attr( $key ); |
|
777 | + } else { |
|
778 | + echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
779 | + } |
|
780 | 780 | |
781 | - } |
|
781 | + } |
|
782 | 782 | |
783 | 783 | } |
784 | 784 | |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | */ |
788 | 788 | function wpinv_text_callback( $args ) { |
789 | 789 | |
790 | - ?> |
|
790 | + ?> |
|
791 | 791 | <label style="width: 100%;"> |
792 | 792 | <input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>> |
793 | 793 | <?php getpaid_settings_description_callback( $args ); ?> |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | */ |
802 | 802 | function wpinv_number_callback( $args ) { |
803 | 803 | |
804 | - ?> |
|
804 | + ?> |
|
805 | 805 | <label style="width: 100%;"> |
806 | 806 | <input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>> |
807 | 807 | <?php getpaid_settings_description_callback( $args ); ?> |
@@ -813,34 +813,34 @@ discard block |
||
813 | 813 | function wpinv_textarea_callback( $args ) { |
814 | 814 | |
815 | 815 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
816 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
817 | - $value = wpinv_get_option( $args['id'], $std ); |
|
816 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
817 | + $value = wpinv_get_option( $args['id'], $std ); |
|
818 | 818 | |
819 | 819 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
820 | 820 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
821 | 821 | |
822 | - echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
823 | - echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
822 | + echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
823 | + echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
824 | 824 | |
825 | 825 | } |
826 | 826 | |
827 | 827 | function wpinv_password_callback( $args ) { |
828 | 828 | |
829 | 829 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
830 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
831 | - $value = wpinv_get_option( $args['id'], $std ); |
|
830 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
831 | + $value = wpinv_get_option( $args['id'], $std ); |
|
832 | 832 | |
833 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
834 | - echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
835 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
833 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
834 | + echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
835 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | 839 | function wpinv_missing_callback( $args ) { |
840 | - printf( |
|
841 | - esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
842 | - '<strong>' . esc_html( $args['id'] ) . '</strong>' |
|
843 | - ); |
|
840 | + printf( |
|
841 | + esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
842 | + '<strong>' . esc_html( $args['id'] ) . '</strong>' |
|
843 | + ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -848,13 +848,13 @@ discard block |
||
848 | 848 | */ |
849 | 849 | function wpinv_select_callback( $args ) { |
850 | 850 | |
851 | - $desc = wp_kses_post( $args['desc'] ); |
|
852 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
853 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
854 | - $value = wpinv_get_option( $args['id'], $value ); |
|
855 | - $rand = uniqid( 'random_id' ); |
|
851 | + $desc = wp_kses_post( $args['desc'] ); |
|
852 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
853 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
854 | + $value = wpinv_get_option( $args['id'], $value ); |
|
855 | + $rand = uniqid( 'random_id' ); |
|
856 | 856 | |
857 | - ?> |
|
857 | + ?> |
|
858 | 858 | <label style="width: 100%;"> |
859 | 859 | <select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true"> |
860 | 860 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -887,50 +887,50 @@ discard block |
||
887 | 887 | function wpinv_color_select_callback( $args ) { |
888 | 888 | |
889 | 889 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
890 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
891 | - $value = wpinv_get_option( $args['id'], $std ); |
|
890 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
891 | + $value = wpinv_get_option( $args['id'], $std ); |
|
892 | 892 | |
893 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
893 | + echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
894 | 894 | |
895 | - foreach ( $args['options'] as $option => $color ) { |
|
896 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
897 | - } |
|
895 | + foreach ( $args['options'] as $option => $color ) { |
|
896 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
897 | + } |
|
898 | 898 | |
899 | - echo '</select>'; |
|
900 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
899 | + echo '</select>'; |
|
900 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
901 | 901 | |
902 | 902 | } |
903 | 903 | |
904 | 904 | function wpinv_rich_editor_callback( $args ) { |
905 | - global $wp_version; |
|
905 | + global $wp_version; |
|
906 | 906 | |
907 | 907 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
908 | 908 | |
909 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
910 | - $value = wpinv_get_option( $args['id'], $std ); |
|
909 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
910 | + $value = wpinv_get_option( $args['id'], $std ); |
|
911 | 911 | |
912 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
913 | - $value = $std; |
|
914 | - } |
|
912 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
913 | + $value = $std; |
|
914 | + } |
|
915 | 915 | |
916 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
916 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
917 | 917 | |
918 | - echo '<div class="getpaid-settings-editor-input">'; |
|
919 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
920 | - wp_editor( |
|
918 | + echo '<div class="getpaid-settings-editor-input">'; |
|
919 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
920 | + wp_editor( |
|
921 | 921 | stripslashes( $value ), |
922 | 922 | 'wpinv_settings_' . esc_attr( $args['id'] ), |
923 | 923 | array( |
924 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
925 | - 'textarea_rows' => absint( $rows ), |
|
926 | - 'media_buttons' => false, |
|
924 | + 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
925 | + 'textarea_rows' => absint( $rows ), |
|
926 | + 'media_buttons' => false, |
|
927 | 927 | ) |
928 | 928 | ); |
929 | - } else { |
|
930 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
931 | - } |
|
929 | + } else { |
|
930 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
931 | + } |
|
932 | 932 | |
933 | - echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
933 | + echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
934 | 934 | |
935 | 935 | } |
936 | 936 | |
@@ -938,51 +938,51 @@ discard block |
||
938 | 938 | |
939 | 939 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
940 | 940 | |
941 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
942 | - $value = wpinv_get_option( $args['id'], $std ); |
|
941 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
942 | + $value = wpinv_get_option( $args['id'], $std ); |
|
943 | 943 | |
944 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
945 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
946 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
947 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
944 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
945 | + echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
946 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
947 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
948 | 948 | |
949 | 949 | } |
950 | 950 | |
951 | 951 | function wpinv_color_callback( $args ) { |
952 | 952 | |
953 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
954 | - $value = wpinv_get_option( $args['id'], $std ); |
|
953 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
954 | + $value = wpinv_get_option( $args['id'], $std ); |
|
955 | 955 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
956 | 956 | |
957 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
958 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
957 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
958 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
959 | 959 | |
960 | 960 | } |
961 | 961 | |
962 | 962 | function wpinv_country_states_callback( $args ) { |
963 | 963 | |
964 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
965 | - $value = wpinv_get_option( $args['id'], $std ); |
|
964 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
965 | + $value = wpinv_get_option( $args['id'], $std ); |
|
966 | 966 | |
967 | 967 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
968 | 968 | |
969 | - if ( isset( $args['placeholder'] ) ) { |
|
970 | - $placeholder = $args['placeholder']; |
|
971 | - } else { |
|
972 | - $placeholder = ''; |
|
973 | - } |
|
969 | + if ( isset( $args['placeholder'] ) ) { |
|
970 | + $placeholder = $args['placeholder']; |
|
971 | + } else { |
|
972 | + $placeholder = ''; |
|
973 | + } |
|
974 | 974 | |
975 | - $states = wpinv_get_country_states(); |
|
975 | + $states = wpinv_get_country_states(); |
|
976 | 976 | |
977 | - $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2'; |
|
978 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
977 | + $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2'; |
|
978 | + echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
979 | 979 | |
980 | - foreach ( $states as $option => $name ) { |
|
981 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
982 | - } |
|
980 | + foreach ( $states as $option => $name ) { |
|
981 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
982 | + } |
|
983 | 983 | |
984 | - echo '</select>'; |
|
985 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
984 | + echo '</select>'; |
|
985 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
986 | 986 | |
987 | 987 | } |
988 | 988 | |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | */ |
992 | 992 | function wpinv_tax_rates_callback() { |
993 | 993 | |
994 | - ?> |
|
994 | + ?> |
|
995 | 995 | </td> |
996 | 996 | </tr> |
997 | 997 | <tr class="bsui"> |
@@ -1007,9 +1007,9 @@ discard block |
||
1007 | 1007 | */ |
1008 | 1008 | function wpinv_tax_rate_callback( $tax_rate, $key ) { |
1009 | 1009 | |
1010 | - $key = sanitize_key( $key ); |
|
1011 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
1012 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
1010 | + $key = sanitize_key( $key ); |
|
1011 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
1012 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
1013 | 1013 | |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | */ |
1019 | 1019 | function wpinv_tax_rules_callback() { |
1020 | 1020 | |
1021 | - ?> |
|
1021 | + ?> |
|
1022 | 1022 | </td> |
1023 | 1023 | </tr> |
1024 | 1024 | <tr class="bsui"> |
@@ -1056,14 +1056,14 @@ discard block |
||
1056 | 1056 | <td> |
1057 | 1057 | <a href=" |
1058 | 1058 | <?php |
1059 | - echo esc_url( |
|
1060 | - wp_nonce_url( |
|
1061 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
1062 | - 'getpaid-nonce', |
|
1063 | - 'getpaid-nonce' |
|
1064 | - ) |
|
1065 | - ); |
|
1066 | - ?> |
|
1059 | + echo esc_url( |
|
1060 | + wp_nonce_url( |
|
1061 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
1062 | + 'getpaid-nonce', |
|
1063 | + 'getpaid-nonce' |
|
1064 | + ) |
|
1065 | + ); |
|
1066 | + ?> |
|
1067 | 1067 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1068 | 1068 | </td> |
1069 | 1069 | </tr> |
@@ -1075,14 +1075,14 @@ discard block |
||
1075 | 1075 | <td> |
1076 | 1076 | <a href=" |
1077 | 1077 | <?php |
1078 | - echo esc_url( |
|
1079 | - wp_nonce_url( |
|
1080 | - add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ), |
|
1081 | - 'getpaid-nonce', |
|
1082 | - 'getpaid-nonce' |
|
1083 | - ) |
|
1084 | - ); |
|
1085 | - ?> |
|
1078 | + echo esc_url( |
|
1079 | + wp_nonce_url( |
|
1080 | + add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ), |
|
1081 | + 'getpaid-nonce', |
|
1082 | + 'getpaid-nonce' |
|
1083 | + ) |
|
1084 | + ); |
|
1085 | + ?> |
|
1086 | 1086 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1087 | 1087 | </td> |
1088 | 1088 | </tr> |
@@ -1094,14 +1094,14 @@ discard block |
||
1094 | 1094 | <td> |
1095 | 1095 | <a href=" |
1096 | 1096 | <?php |
1097 | - echo esc_url( |
|
1098 | - wp_nonce_url( |
|
1099 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1100 | - 'getpaid-nonce', |
|
1101 | - 'getpaid-nonce' |
|
1102 | - ) |
|
1103 | - ); |
|
1104 | - ?> |
|
1097 | + echo esc_url( |
|
1098 | + wp_nonce_url( |
|
1099 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1100 | + 'getpaid-nonce', |
|
1101 | + 'getpaid-nonce' |
|
1102 | + ) |
|
1103 | + ); |
|
1104 | + ?> |
|
1105 | 1105 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1106 | 1106 | </td> |
1107 | 1107 | </tr> |
@@ -1113,14 +1113,14 @@ discard block |
||
1113 | 1113 | <td> |
1114 | 1114 | <a href=" |
1115 | 1115 | <?php |
1116 | - echo esc_url( |
|
1117 | - wp_nonce_url( |
|
1118 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1119 | - 'getpaid-nonce', |
|
1120 | - 'getpaid-nonce' |
|
1121 | - ) |
|
1122 | - ); |
|
1123 | - ?> |
|
1116 | + echo esc_url( |
|
1117 | + wp_nonce_url( |
|
1118 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1119 | + 'getpaid-nonce', |
|
1120 | + 'getpaid-nonce' |
|
1121 | + ) |
|
1122 | + ); |
|
1123 | + ?> |
|
1124 | 1124 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1125 | 1125 | </td> |
1126 | 1126 | </tr> |
@@ -1133,14 +1133,14 @@ discard block |
||
1133 | 1133 | <td> |
1134 | 1134 | <a href=" |
1135 | 1135 | <?php |
1136 | - echo esc_url( |
|
1137 | - wp_nonce_url( |
|
1138 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1139 | - 'getpaid-nonce', |
|
1140 | - 'getpaid-nonce' |
|
1141 | - ) |
|
1142 | - ); |
|
1143 | - ?> |
|
1136 | + echo esc_url( |
|
1137 | + wp_nonce_url( |
|
1138 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1139 | + 'getpaid-nonce', |
|
1140 | + 'getpaid-nonce' |
|
1141 | + ) |
|
1142 | + ); |
|
1143 | + ?> |
|
1144 | 1144 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1145 | 1145 | </td> |
1146 | 1146 | </tr> |
@@ -1153,8 +1153,8 @@ discard block |
||
1153 | 1153 | <td> |
1154 | 1154 | <a href=" |
1155 | 1155 | <?php |
1156 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1157 | - ?> |
|
1156 | + echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1157 | + ?> |
|
1158 | 1158 | " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
1159 | 1159 | </td> |
1160 | 1160 | </tr> |
@@ -1168,19 +1168,19 @@ discard block |
||
1168 | 1168 | |
1169 | 1169 | |
1170 | 1170 | function wpinv_descriptive_text_callback( $args ) { |
1171 | - echo wp_kses_post( $args['desc'] ); |
|
1171 | + echo wp_kses_post( $args['desc'] ); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | function wpinv_raw_html_callback( $args ) { |
1175 | - echo wp_kses( $args['desc'], getpaid_allowed_html() ); |
|
1175 | + echo wp_kses( $args['desc'], getpaid_allowed_html() ); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | function wpinv_hook_callback( $args ) { |
1179 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1179 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | function wpinv_set_settings_cap() { |
1183 | - return wpinv_get_capability(); |
|
1183 | + return wpinv_get_capability(); |
|
1184 | 1184 | } |
1185 | 1185 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1186 | 1186 | |
@@ -1206,47 +1206,47 @@ discard block |
||
1206 | 1206 | * @return array |
1207 | 1207 | */ |
1208 | 1208 | function wpinv_get_email_merge_tags( $subscription = false ) { |
1209 | - $merge_tags = array( |
|
1210 | - '{site_title}' => __( 'Site Title', 'invoicing' ), |
|
1211 | - '{name}' => __( "Customer's full name", 'invoicing' ), |
|
1212 | - '{first_name}' => __( "Customer's first name", 'invoicing' ), |
|
1213 | - '{last_name}' => __( "Customer's last name", 'invoicing' ), |
|
1214 | - '{email}' => __( "Customer's email address", 'invoicing' ), |
|
1215 | - '{invoice_number}' => __( 'The invoice number', 'invoicing' ), |
|
1216 | - '{invoice_currency}' => __( 'The invoice currency', 'invoicing' ), |
|
1217 | - '{invoice_total}' => __( 'The invoice total', 'invoicing' ), |
|
1218 | - '{invoice_link}' => __( 'The invoice link', 'invoicing' ), |
|
1219 | - '{invoice_pay_link}' => __( 'The payment link', 'invoicing' ), |
|
1220 | - '{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ), |
|
1221 | - '{invoice_date}' => __( 'The date the invoice was created', 'invoicing' ), |
|
1222 | - '{invoice_due_date}' => __( 'The date the invoice is due', 'invoicing' ), |
|
1223 | - '{date}' => __( "Today's date", 'invoicing' ), |
|
1224 | - '{is_was}' => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ), |
|
1225 | - '{invoice_label}' => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ), |
|
1226 | - '{invoice_quote}' => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ), |
|
1227 | - '{invoice_description}' => __( 'The description of the invoice', 'invoicing' ), |
|
1228 | - ); |
|
1229 | - |
|
1230 | - if ( $subscription ) { |
|
1231 | - $merge_tags = array_merge( |
|
1232 | - $merge_tags, |
|
1233 | - array( |
|
1234 | - '{subscription_renewal_date}' => __( 'The next renewal date of the subscription', 'invoicing' ), |
|
1235 | - '{subscription_created}' => __( "The subscription's creation date", 'invoicing' ), |
|
1236 | - '{subscription_status}' => __( "The subscription's status", 'invoicing' ), |
|
1237 | - '{subscription_profile_id}' => __( "The subscription's remote profile id", 'invoicing' ), |
|
1238 | - '{subscription_id}' => __( "The subscription's id", 'invoicing' ), |
|
1239 | - '{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ), |
|
1240 | - '{subscription_initial_amount}' => __( 'The initial amount of the subscription', 'invoicing' ), |
|
1241 | - '{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ), |
|
1242 | - '{subscription_bill_times}' => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ), |
|
1243 | - '{subscription_url}' => __( 'The URL to manage a subscription', 'invoicing' ), |
|
1244 | - '{subscription_name}' => __( 'The name of the recurring item', 'invoicing' ), |
|
1245 | - ) |
|
1246 | - ); |
|
1247 | - } |
|
1248 | - |
|
1249 | - return $merge_tags; |
|
1209 | + $merge_tags = array( |
|
1210 | + '{site_title}' => __( 'Site Title', 'invoicing' ), |
|
1211 | + '{name}' => __( "Customer's full name", 'invoicing' ), |
|
1212 | + '{first_name}' => __( "Customer's first name", 'invoicing' ), |
|
1213 | + '{last_name}' => __( "Customer's last name", 'invoicing' ), |
|
1214 | + '{email}' => __( "Customer's email address", 'invoicing' ), |
|
1215 | + '{invoice_number}' => __( 'The invoice number', 'invoicing' ), |
|
1216 | + '{invoice_currency}' => __( 'The invoice currency', 'invoicing' ), |
|
1217 | + '{invoice_total}' => __( 'The invoice total', 'invoicing' ), |
|
1218 | + '{invoice_link}' => __( 'The invoice link', 'invoicing' ), |
|
1219 | + '{invoice_pay_link}' => __( 'The payment link', 'invoicing' ), |
|
1220 | + '{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ), |
|
1221 | + '{invoice_date}' => __( 'The date the invoice was created', 'invoicing' ), |
|
1222 | + '{invoice_due_date}' => __( 'The date the invoice is due', 'invoicing' ), |
|
1223 | + '{date}' => __( "Today's date", 'invoicing' ), |
|
1224 | + '{is_was}' => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ), |
|
1225 | + '{invoice_label}' => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ), |
|
1226 | + '{invoice_quote}' => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ), |
|
1227 | + '{invoice_description}' => __( 'The description of the invoice', 'invoicing' ), |
|
1228 | + ); |
|
1229 | + |
|
1230 | + if ( $subscription ) { |
|
1231 | + $merge_tags = array_merge( |
|
1232 | + $merge_tags, |
|
1233 | + array( |
|
1234 | + '{subscription_renewal_date}' => __( 'The next renewal date of the subscription', 'invoicing' ), |
|
1235 | + '{subscription_created}' => __( "The subscription's creation date", 'invoicing' ), |
|
1236 | + '{subscription_status}' => __( "The subscription's status", 'invoicing' ), |
|
1237 | + '{subscription_profile_id}' => __( "The subscription's remote profile id", 'invoicing' ), |
|
1238 | + '{subscription_id}' => __( "The subscription's id", 'invoicing' ), |
|
1239 | + '{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ), |
|
1240 | + '{subscription_initial_amount}' => __( 'The initial amount of the subscription', 'invoicing' ), |
|
1241 | + '{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ), |
|
1242 | + '{subscription_bill_times}' => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ), |
|
1243 | + '{subscription_url}' => __( 'The URL to manage a subscription', 'invoicing' ), |
|
1244 | + '{subscription_name}' => __( 'The name of the recurring item', 'invoicing' ), |
|
1245 | + ) |
|
1246 | + ); |
|
1247 | + } |
|
1248 | + |
|
1249 | + return $merge_tags; |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | |
@@ -1258,28 +1258,28 @@ discard block |
||
1258 | 1258 | * @return string |
1259 | 1259 | */ |
1260 | 1260 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
1261 | - $merge_tags = wpinv_get_email_merge_tags( $subscription ); |
|
1261 | + $merge_tags = wpinv_get_email_merge_tags( $subscription ); |
|
1262 | 1262 | |
1263 | - $output = '<div class="bsui">'; |
|
1263 | + $output = '<div class="bsui">'; |
|
1264 | 1264 | |
1265 | - $link = sprintf( |
|
1266 | - '<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>', |
|
1267 | - esc_html__( 'View available merge tags.', 'invoicing' ) |
|
1268 | - ); |
|
1265 | + $link = sprintf( |
|
1266 | + '<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>', |
|
1267 | + esc_html__( 'View available merge tags.', 'invoicing' ) |
|
1268 | + ); |
|
1269 | 1269 | |
1270 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1270 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1271 | 1271 | |
1272 | - $output .= "$description $link"; |
|
1272 | + $output .= "$description $link"; |
|
1273 | 1273 | |
1274 | - $output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">'; |
|
1275 | - $output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>'; |
|
1274 | + $output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">'; |
|
1275 | + $output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>'; |
|
1276 | 1276 | |
1277 | - $output .= '<ul class="p-0 m-0">'; |
|
1278 | - foreach($merge_tags as $tag => $tag_description) { |
|
1279 | - $output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> — $tag_description</li>"; |
|
1280 | - } |
|
1277 | + $output .= '<ul class="p-0 m-0">'; |
|
1278 | + foreach($merge_tags as $tag => $tag_description) { |
|
1279 | + $output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> — $tag_description</li>"; |
|
1280 | + } |
|
1281 | 1281 | |
1282 | - $output .= '</ul></div></div>'; |
|
1282 | + $output .= '</ul></div></div>'; |
|
1283 | 1283 | |
1284 | - return $output; |
|
1284 | + return $output; |
|
1285 | 1285 | } |