@@ -11,49 +11,49 @@ discard block |
||
11 | 11 | * @since 1.0.0 |
12 | 12 | */ |
13 | 13 | function wpinv_automatic_upgrade() { |
14 | - $wpi_version = get_option( 'wpinv_version' ); |
|
14 | + $wpi_version = get_option('wpinv_version'); |
|
15 | 15 | |
16 | - if ( $wpi_version == WPINV_VERSION ) { |
|
16 | + if ($wpi_version == WPINV_VERSION) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | - if ( version_compare( $wpi_version, '0.0.5', '<' ) ) { |
|
20 | + if (version_compare($wpi_version, '0.0.5', '<')) { |
|
21 | 21 | wpinv_v005_upgrades(); |
22 | 22 | } |
23 | 23 | |
24 | - if ( version_compare( $wpi_version, '1.0.3', '<' ) ) { |
|
24 | + if (version_compare($wpi_version, '1.0.3', '<')) { |
|
25 | 25 | wpinv_v103_upgrades(); |
26 | 26 | } |
27 | 27 | |
28 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
28 | + update_option('wpinv_version', WPINV_VERSION); |
|
29 | 29 | } |
30 | -add_action( 'admin_init', 'wpinv_automatic_upgrade' ); |
|
30 | +add_action('admin_init', 'wpinv_automatic_upgrade'); |
|
31 | 31 | |
32 | 32 | function wpinv_v005_upgrades() { |
33 | 33 | global $wpdb; |
34 | 34 | |
35 | 35 | // Invoices status |
36 | - $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
37 | - if ( !empty( $results ) ) { |
|
38 | - $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
36 | + $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
37 | + if (!empty($results)) { |
|
38 | + $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
39 | 39 | |
40 | 40 | // Clean post cache |
41 | - foreach ( $results as $row ) { |
|
42 | - clean_post_cache( $row->ID ); |
|
41 | + foreach ($results as $row) { |
|
42 | + clean_post_cache($row->ID); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item meta key changes |
47 | 47 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
48 | - $results = $wpdb->get_results( $query ); |
|
48 | + $results = $wpdb->get_results($query); |
|
49 | 49 | |
50 | - if ( !empty( $results ) ) { |
|
51 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
52 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
53 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
50 | + if (!empty($results)) { |
|
51 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
52 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
53 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
54 | 54 | |
55 | - foreach ( $results as $row ) { |
|
56 | - clean_post_cache( $row->post_id ); |
|
55 | + foreach ($results as $row) { |
|
56 | + clean_post_cache($row->post_id); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -74,79 +74,79 @@ discard block |
||
74 | 74 | function wpinv_convert_old_subscriptions() { |
75 | 75 | global $wpdb; |
76 | 76 | |
77 | - $query = "SELECT ". $wpdb->posts .".ID FROM ". $wpdb->posts ." INNER JOIN ". $wpdb->postmeta ." ON ( ". $wpdb->posts .".ID = ". $wpdb->postmeta .".post_id ) WHERE 1=1 AND ". $wpdb->postmeta .".meta_key = '_wpinv_subscr_status' AND (". $wpdb->postmeta .".meta_value = 'pending' OR ". $wpdb->postmeta .".meta_value = 'active' OR ". $wpdb->postmeta .".meta_value = 'cancelled' OR ". $wpdb->postmeta .".meta_value = 'completed' OR ". $wpdb->postmeta .".meta_value = 'expired' OR ". $wpdb->postmeta .".meta_value = 'trialling' OR ". $wpdb->postmeta .".meta_value = 'failing') AND ". $wpdb->posts .".post_type = 'wpi_invoice' GROUP BY ". $wpdb->posts .".ID ORDER BY ". $wpdb->posts .".ID ASC"; |
|
77 | + $query = "SELECT " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON ( " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ) WHERE 1=1 AND " . $wpdb->postmeta . ".meta_key = '_wpinv_subscr_status' AND (" . $wpdb->postmeta . ".meta_value = 'pending' OR " . $wpdb->postmeta . ".meta_value = 'active' OR " . $wpdb->postmeta . ".meta_value = 'cancelled' OR " . $wpdb->postmeta . ".meta_value = 'completed' OR " . $wpdb->postmeta . ".meta_value = 'expired' OR " . $wpdb->postmeta . ".meta_value = 'trialling' OR " . $wpdb->postmeta . ".meta_value = 'failing') AND " . $wpdb->posts . ".post_type = 'wpi_invoice' GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC"; |
|
78 | 78 | |
79 | - $results = $wpdb->get_results( $query ); |
|
79 | + $results = $wpdb->get_results($query); |
|
80 | 80 | |
81 | - if ( empty( $results ) ) { |
|
81 | + if (empty($results)) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - foreach ( $results as $row ) { |
|
86 | - $invoice = new WPInv_Invoice( $row->ID ); |
|
85 | + foreach ($results as $row) { |
|
86 | + $invoice = new WPInv_Invoice($row->ID); |
|
87 | 87 | |
88 | - if ( empty( $invoice->ID ) ) { |
|
88 | + if (empty($invoice->ID)) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
92 | - if ( $invoice->has_status( 'wpi-renewal' ) ) { |
|
92 | + if ($invoice->has_status('wpi-renewal')) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | |
96 | - $item = $invoice->get_recurring( true ); |
|
96 | + $item = $invoice->get_recurring(true); |
|
97 | 97 | |
98 | - if ( empty( $item ) ) { |
|
98 | + if (empty($item)) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | 102 | $is_free_trial = $invoice->is_free_trial(); |
103 | - $profile_id = get_post_meta( $invoice->ID, '_wpinv_subscr_profile_id', true ); |
|
104 | - $subscription_status = get_post_meta( $invoice->ID, '_wpinv_subscr_status', true ); |
|
103 | + $profile_id = get_post_meta($invoice->ID, '_wpinv_subscr_profile_id', true); |
|
104 | + $subscription_status = get_post_meta($invoice->ID, '_wpinv_subscr_status', true); |
|
105 | 105 | $transaction_id = $invoice->get_transaction_id(); |
106 | 106 | |
107 | 107 | // Last invoice |
108 | - $query = "SELECT ID, post_date FROM ". $wpdb->posts ." WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1"; |
|
109 | - $last_payment = $wpdb->get_row( $query ); |
|
108 | + $query = "SELECT ID, post_date FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1"; |
|
109 | + $last_payment = $wpdb->get_row($query); |
|
110 | 110 | |
111 | - if ( !empty( $last_payment ) ) { |
|
112 | - $invoice_date = $last_payment->post_date; |
|
111 | + if (!empty($last_payment)) { |
|
112 | + $invoice_date = $last_payment->post_date; |
|
113 | 113 | |
114 | - $meta_profile_id = get_post_meta( $last_payment->ID, '_wpinv_subscr_profile_id', true ); |
|
115 | - $meta_transaction_id = get_post_meta( $last_payment->ID, '_wpinv_transaction_id', true ); |
|
114 | + $meta_profile_id = get_post_meta($last_payment->ID, '_wpinv_subscr_profile_id', true); |
|
115 | + $meta_transaction_id = get_post_meta($last_payment->ID, '_wpinv_transaction_id', true); |
|
116 | 116 | |
117 | - if ( !empty( $meta_profile_id ) ) { |
|
118 | - $profile_id = $meta_profile_id; |
|
117 | + if (!empty($meta_profile_id)) { |
|
118 | + $profile_id = $meta_profile_id; |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( !empty( $meta_transaction_id ) ) { |
|
122 | - $transaction_id = $meta_transaction_id; |
|
121 | + if (!empty($meta_transaction_id)) { |
|
122 | + $transaction_id = $meta_transaction_id; |
|
123 | 123 | } |
124 | 124 | } else { |
125 | - $invoice_date = $invoice->get_invoice_date( false ); |
|
125 | + $invoice_date = $invoice->get_invoice_date(false); |
|
126 | 126 | } |
127 | 127 | |
128 | - $profile_id = empty( $profile_id ) ? $invoice->ID : $profile_id; |
|
129 | - $status = empty( $subscription_status ) ? 'pending' : $subscription_status; |
|
128 | + $profile_id = empty($profile_id) ? $invoice->ID : $profile_id; |
|
129 | + $status = empty($subscription_status) ? 'pending' : $subscription_status; |
|
130 | 130 | |
131 | - $period = $item->get_recurring_period( true ); |
|
131 | + $period = $item->get_recurring_period(true); |
|
132 | 132 | $interval = $item->get_recurring_interval(); |
133 | 133 | $bill_times = (int)$item->get_recurring_limit(); |
134 | 134 | $add_period = $interval . ' ' . $period; |
135 | 135 | $trial_period = ''; |
136 | 136 | |
137 | - if ( $invoice->is_free_trial() ) { |
|
138 | - $trial_period = $item->get_trial_period( true ); |
|
137 | + if ($invoice->is_free_trial()) { |
|
138 | + $trial_period = $item->get_trial_period(true); |
|
139 | 139 | $free_interval = $item->get_trial_interval(); |
140 | 140 | $trial_period = $free_interval . ' ' . $trial_period; |
141 | 141 | |
142 | - if ( empty( $last_payment ) ) { |
|
142 | + if (empty($last_payment)) { |
|
143 | 143 | $add_period = $trial_period; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period . ' 23:59:59', strtotime( $invoice_date ) ) ); |
|
148 | - if ( strtotime( $expiration ) < strtotime( date_i18n( 'Y-m-d' ) ) ) { |
|
149 | - if ( $status == 'active' || $status == 'trialling' || $status == 'pending' ) { |
|
147 | + $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date))); |
|
148 | + if (strtotime($expiration) < strtotime(date_i18n('Y-m-d'))) { |
|
149 | + if ($status == 'active' || $status == 'trialling' || $status == 'pending') { |
|
150 | 150 | $status = 'expired'; |
151 | 151 | } |
152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'frequency' => $interval, |
160 | 160 | 'period' => $period, |
161 | 161 | 'initial_amount' => $invoice->get_total(), |
162 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
162 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
163 | 163 | 'bill_times' => $bill_times, |
164 | 164 | 'created' => $invoice_date, |
165 | 165 | 'expiration' => $expiration, |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | $subs_db = new WPInv_Subscriptions_DB; |
172 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->ID, 'number' => 1 ) ); |
|
173 | - $subscription = reset( $subs ); |
|
172 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1)); |
|
173 | + $subscription = reset($subs); |
|
174 | 174 | |
175 | - if ( empty( $subscription ) || $subscription->id <= 0 ) { |
|
175 | + if (empty($subscription) || $subscription->id <= 0) { |
|
176 | 176 | $subscription = new WPInv_Subscription(); |
177 | - $new_sub = $subscription->create( $args ); |
|
177 | + $new_sub = $subscription->create($args); |
|
178 | 178 | |
179 | - if ( !empty( $bill_times ) && $new_sub->get_times_billed() >= $bill_times && ( 'active' == $new_sub->status || 'trialling' == $new_sub->status ) ) { |
|
179 | + if (!empty($bill_times) && $new_sub->get_times_billed() >= $bill_times && ('active' == $new_sub->status || 'trialling' == $new_sub->status)) { |
|
180 | 180 | $new_sub->complete(); // Mark completed if all times billed |
181 | 181 | } |
182 | 182 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | function wpinv_update_new_email_settings() { |
187 | 187 | global $wpinv_options; |
188 | 188 | |
189 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
189 | + $current_options = get_option('wpinv_settings', array()); |
|
190 | 190 | $options = array(); |
191 | 191 | |
192 | 192 | // Populate some default values |
193 | - foreach( wpinv_get_registered_settings() as $tab => $sections ) { |
|
194 | - foreach( $sections as $section => $settings) { |
|
193 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
194 | + foreach ($sections as $section => $settings) { |
|
195 | 195 | // Check for backwards compatibility |
196 | - $tab_sections = wpinv_get_settings_tab_sections( $tab ); |
|
197 | - if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) { |
|
196 | + $tab_sections = wpinv_get_settings_tab_sections($tab); |
|
197 | + if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) { |
|
198 | 198 | $section = 'main'; |
199 | 199 | $settings = $sections; |
200 | 200 | } |
201 | 201 | |
202 | - foreach ( $settings as $option ) { |
|
203 | - if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) { |
|
204 | - if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) { |
|
205 | - $options[ $option['id'] ] = '1'; |
|
206 | - } else if ( !empty( $option['std'] ) ) { |
|
207 | - $options[ $option['id'] ] = $option['std']; |
|
202 | + foreach ($settings as $option) { |
|
203 | + if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) { |
|
204 | + if ('checkbox' == $option['type'] && !empty($option['std'])) { |
|
205 | + $options[$option['id']] = '1'; |
|
206 | + } else if (!empty($option['std'])) { |
|
207 | + $options[$option['id']] = $option['std']; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - $merged_options_current = array_merge( $wpinv_options, $options ); |
|
215 | - $merged_options = array_merge( $merged_options_current, $current_options ); |
|
214 | + $merged_options_current = array_merge($wpinv_options, $options); |
|
215 | + $merged_options = array_merge($merged_options_current, $current_options); |
|
216 | 216 | $wpinv_options = $merged_options; |
217 | 217 | |
218 | - update_option( 'wpinv_settings', $merged_options ); |
|
218 | + update_option('wpinv_settings', $merged_options); |
|
219 | 219 | } |
220 | 220 | \ No newline at end of file |
@@ -1,66 +1,66 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
7 | +function wpinv_get_option($key = '', $default = false) { |
|
8 | 8 | global $wpinv_options; |
9 | 9 | |
10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
12 | 12 | |
13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
14 | 14 | } |
15 | 15 | |
16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
16 | +function wpinv_update_option($key = '', $value = false) { |
|
17 | 17 | // If no key, exit |
18 | - if ( empty( $key ) ) { |
|
18 | + if (empty($key)) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | - if ( empty( $value ) ) { |
|
23 | - $remove_option = wpinv_delete_option( $key ); |
|
22 | + if (empty($value)) { |
|
23 | + $remove_option = wpinv_delete_option($key); |
|
24 | 24 | return $remove_option; |
25 | 25 | } |
26 | 26 | |
27 | 27 | // First let's grab the current settings |
28 | - $options = get_option( 'wpinv_settings' ); |
|
28 | + $options = get_option('wpinv_settings'); |
|
29 | 29 | |
30 | 30 | // Let other plugin alter the value |
31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
32 | 32 | |
33 | 33 | // Next let's try to update the value |
34 | - $options[ $key ] = $value; |
|
35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
34 | + $options[$key] = $value; |
|
35 | + $did_update = update_option('wpinv_settings', $options); |
|
36 | 36 | |
37 | 37 | // If it's updated, let's update the global variable |
38 | - if ( $did_update ) { |
|
38 | + if ($did_update) { |
|
39 | 39 | global $wpinv_options; |
40 | - $wpinv_options[ $key ] = $value; |
|
40 | + $wpinv_options[$key] = $value; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $did_update; |
44 | 44 | } |
45 | 45 | |
46 | -function wpinv_delete_option( $key = '' ) { |
|
46 | +function wpinv_delete_option($key = '') { |
|
47 | 47 | // If no key, exit |
48 | - if ( empty( $key ) ) { |
|
48 | + if (empty($key)) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // First let's grab the current settings |
53 | - $options = get_option( 'wpinv_settings' ); |
|
53 | + $options = get_option('wpinv_settings'); |
|
54 | 54 | |
55 | 55 | // Next let's try to update the value |
56 | - if( isset( $options[ $key ] ) ) { |
|
57 | - unset( $options[ $key ] ); |
|
56 | + if (isset($options[$key])) { |
|
57 | + unset($options[$key]); |
|
58 | 58 | } |
59 | 59 | |
60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
60 | + $did_update = update_option('wpinv_settings', $options); |
|
61 | 61 | |
62 | 62 | // If it updated, let's update the global variable |
63 | - if ( $did_update ){ |
|
63 | + if ($did_update) { |
|
64 | 64 | global $wpinv_options; |
65 | 65 | $wpinv_options = $options; |
66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_get_settings() { |
72 | - $settings = get_option( 'wpinv_settings' ); |
|
72 | + $settings = get_option('wpinv_settings'); |
|
73 | 73 | |
74 | - if ( empty( $settings ) ) { |
|
74 | + if (empty($settings)) { |
|
75 | 75 | // Update old settings with new single option |
76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
82 | 82 | |
83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
84 | 84 | |
85 | - update_option( 'wpinv_settings', $settings ); |
|
85 | + update_option('wpinv_settings', $settings); |
|
86 | 86 | |
87 | 87 | } |
88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
88 | + return apply_filters('wpinv_get_settings', $settings); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_register_settings() { |
92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
93 | - add_option( 'wpinv_settings' ); |
|
92 | + if (false == get_option('wpinv_settings')) { |
|
93 | + add_option('wpinv_settings'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $register_settings = wpinv_get_registered_settings(); |
97 | 97 | |
98 | - foreach ( $register_settings as $tab => $sections ) { |
|
99 | - foreach ( $sections as $section => $settings) { |
|
98 | + foreach ($register_settings as $tab => $sections) { |
|
99 | + foreach ($sections as $section => $settings) { |
|
100 | 100 | // Check for backwards compatibility |
101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
103 | 103 | $section = 'main'; |
104 | 104 | $settings = $sections; |
105 | 105 | } |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
112 | 112 | ); |
113 | 113 | |
114 | - foreach ( $settings as $option ) { |
|
114 | + foreach ($settings as $option) { |
|
115 | 115 | // For backwards compatibility |
116 | - if ( empty( $option['id'] ) ) { |
|
116 | + if (empty($option['id'])) { |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
121 | 121 | |
122 | 122 | add_settings_field( |
123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
124 | 124 | $name, |
125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
128 | 128 | array( |
129 | 129 | 'section' => $section, |
130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
140 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
141 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
142 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
143 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
144 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
145 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
146 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
147 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
148 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
140 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
141 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
142 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
143 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
144 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
145 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
146 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
147 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
148 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
@@ -153,182 +153,182 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | // Creates our settings in the options table |
156 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
156 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
157 | 157 | } |
158 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
158 | +add_action('admin_init', 'wpinv_register_settings'); |
|
159 | 159 | |
160 | 160 | function wpinv_get_registered_settings() { |
161 | - $pages = wpinv_get_pages( true ); |
|
161 | + $pages = wpinv_get_pages(true); |
|
162 | 162 | |
163 | 163 | $currencies = wpinv_get_currencies(); |
164 | 164 | |
165 | 165 | $currency_code_options = array(); |
166 | - foreach ( $currencies as $code => $name ) { |
|
167 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
166 | + foreach ($currencies as $code => $name) { |
|
167 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $due_payment_options = array(); |
171 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
172 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
171 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
172 | + for ($i = 1; $i <= 30; $i++) { |
|
173 | 173 | $due_payment_options[$i] = $i; |
174 | 174 | } |
175 | 175 | |
176 | 176 | $invoice_number_padd_options = array(); |
177 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
177 | + for ($i = 0; $i <= 20; $i++) { |
|
178 | 178 | $invoice_number_padd_options[$i] = $i; |
179 | 179 | } |
180 | 180 | |
181 | 181 | $currency_symbol = wpinv_currency_symbol(); |
182 | 182 | |
183 | 183 | $last_number = ''; |
184 | - if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
185 | - $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number ); |
|
184 | + if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
185 | + $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number); |
|
186 | 186 | |
187 | - if ( !empty( $last_invoice_number ) ) { |
|
188 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
187 | + if (!empty($last_invoice_number)) { |
|
188 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | $alert_wrapper_start = '<p style="color: #F00">'; |
193 | 193 | $alert_wrapper_close = '</p>'; |
194 | 194 | $wpinv_settings = array( |
195 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
195 | + 'general' => apply_filters('wpinv_settings_general', |
|
196 | 196 | array( |
197 | 197 | 'main' => array( |
198 | 198 | 'location_settings' => array( |
199 | 199 | 'id' => 'location_settings', |
200 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
200 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
201 | 201 | 'desc' => '', |
202 | 202 | 'type' => 'header', |
203 | 203 | ), |
204 | 204 | 'default_country' => array( |
205 | 205 | 'id' => 'default_country', |
206 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
207 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
206 | + 'name' => __('Default Country', 'invoicing'), |
|
207 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
208 | 208 | 'type' => 'select', |
209 | 209 | 'options' => wpinv_get_country_list(), |
210 | 210 | 'std' => 'GB', |
211 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
211 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
212 | 212 | ), |
213 | 213 | 'default_state' => array( |
214 | 214 | 'id' => 'default_state', |
215 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
216 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
215 | + 'name' => __('Default State / Province', 'invoicing'), |
|
216 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
217 | 217 | 'type' => 'country_states', |
218 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
218 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
219 | 219 | ), |
220 | 220 | 'store_name' => array( |
221 | 221 | 'id' => 'store_name', |
222 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
223 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
222 | + 'name' => __('Store Name', 'invoicing'), |
|
223 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
224 | 224 | 'std' => get_option('blogname'), |
225 | 225 | 'type' => 'text', |
226 | 226 | ), |
227 | 227 | 'logo' => array( |
228 | 228 | 'id' => 'logo', |
229 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
230 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
229 | + 'name' => __('Logo URL', 'invoicing'), |
|
230 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
231 | 231 | 'type' => 'text', |
232 | 232 | ), |
233 | 233 | 'store_address' => array( |
234 | 234 | 'id' => 'store_address', |
235 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
236 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
235 | + 'name' => __('Store Address', 'invoicing'), |
|
236 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
237 | 237 | 'type' => 'textarea', |
238 | 238 | ), |
239 | 239 | 'page_settings' => array( |
240 | 240 | 'id' => 'page_settings', |
241 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
241 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
242 | 242 | 'desc' => '', |
243 | 243 | 'type' => 'header', |
244 | 244 | ), |
245 | 245 | 'checkout_page' => array( |
246 | 246 | 'id' => 'checkout_page', |
247 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
248 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
247 | + 'name' => __('Checkout Page', 'invoicing'), |
|
248 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
249 | 249 | 'type' => 'select', |
250 | 250 | 'options' => $pages, |
251 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
251 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
252 | 252 | ), |
253 | 253 | 'success_page' => array( |
254 | 254 | 'id' => 'success_page', |
255 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
256 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
255 | + 'name' => __('Success Page', 'invoicing'), |
|
256 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
257 | 257 | 'type' => 'select', |
258 | 258 | 'options' => $pages, |
259 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
259 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
260 | 260 | ), |
261 | 261 | 'failure_page' => array( |
262 | 262 | 'id' => 'failure_page', |
263 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
264 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
263 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
264 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
265 | 265 | 'type' => 'select', |
266 | 266 | 'options' => $pages, |
267 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
267 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
268 | 268 | ), |
269 | 269 | 'invoice_history_page' => array( |
270 | 270 | 'id' => 'invoice_history_page', |
271 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
272 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
271 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
272 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
273 | 273 | 'type' => 'select', |
274 | 274 | 'options' => $pages, |
275 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
275 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
276 | 276 | ), |
277 | 277 | 'invoice_subscription_page' => array( |
278 | 278 | 'id' => 'invoice_subscription_page', |
279 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
280 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
279 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
280 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
281 | 281 | 'type' => 'select', |
282 | 282 | 'options' => $pages, |
283 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
283 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
284 | 284 | ) |
285 | 285 | ), |
286 | 286 | 'currency_section' => array( |
287 | 287 | 'currency_settings' => array( |
288 | 288 | 'id' => 'currency_settings', |
289 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
289 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
290 | 290 | 'desc' => '', |
291 | 291 | 'type' => 'header', |
292 | 292 | ), |
293 | 293 | 'currency' => array( |
294 | 294 | 'id' => 'currency', |
295 | - 'name' => __( 'Currency', 'invoicing' ), |
|
296 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
295 | + 'name' => __('Currency', 'invoicing'), |
|
296 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
297 | 297 | 'type' => 'select', |
298 | 298 | 'options' => $currency_code_options, |
299 | 299 | ), |
300 | 300 | 'currency_position' => array( |
301 | 301 | 'id' => 'currency_position', |
302 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
303 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
302 | + 'name' => __('Currency Position', 'invoicing'), |
|
303 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
304 | 304 | 'type' => 'select', |
305 | 305 | 'options' => array( |
306 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
307 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
308 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
309 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
306 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
307 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
308 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
309 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
310 | 310 | ) |
311 | 311 | ), |
312 | 312 | 'thousands_separator' => array( |
313 | 313 | 'id' => 'thousands_separator', |
314 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
315 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
314 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
315 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
316 | 316 | 'type' => 'text', |
317 | 317 | 'size' => 'small', |
318 | 318 | 'std' => ',', |
319 | 319 | ), |
320 | 320 | 'decimal_separator' => array( |
321 | 321 | 'id' => 'decimal_separator', |
322 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
323 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
322 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
323 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
324 | 324 | 'type' => 'text', |
325 | 325 | 'size' => 'small', |
326 | 326 | 'std' => '.', |
327 | 327 | ), |
328 | 328 | 'decimals' => array( |
329 | 329 | 'id' => 'decimals', |
330 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
331 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
330 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
331 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
332 | 332 | 'type' => 'number', |
333 | 333 | 'size' => 'small', |
334 | 334 | 'std' => '2', |
@@ -340,29 +340,29 @@ discard block |
||
340 | 340 | 'labels' => array( |
341 | 341 | 'labels' => array( |
342 | 342 | 'id' => 'labels_settings', |
343 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
343 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
344 | 344 | 'desc' => '', |
345 | 345 | 'type' => 'header', |
346 | 346 | ), |
347 | 347 | 'vat_name' => array( |
348 | 348 | 'id' => 'vat_name', |
349 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
350 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
349 | + 'name' => __('VAT Name', 'invoicing'), |
|
350 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
351 | 351 | 'type' => 'text', |
352 | 352 | 'size' => 'regular', |
353 | 353 | 'std' => 'VAT' |
354 | 354 | ), |
355 | 355 | 'vat_invoice_notice_label' => array( |
356 | 356 | 'id' => 'vat_invoice_notice_label', |
357 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
358 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
357 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
358 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
359 | 359 | 'type' => 'text', |
360 | 360 | 'size' => 'regular', |
361 | 361 | ), |
362 | 362 | 'vat_invoice_notice' => array( |
363 | 363 | 'id' => 'vat_invoice_notice', |
364 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
365 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
364 | + 'name' => __('Invoice notice', 'invoicing'), |
|
365 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
366 | 366 | 'type' => 'text', |
367 | 367 | 'size' => 'regular', |
368 | 368 | ) |
@@ -374,22 +374,22 @@ discard block |
||
374 | 374 | 'main' => array( |
375 | 375 | 'gateway_settings' => array( |
376 | 376 | 'id' => 'api_header', |
377 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
377 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
378 | 378 | 'desc' => '', |
379 | 379 | 'type' => 'header', |
380 | 380 | ), |
381 | 381 | 'gateways' => array( |
382 | 382 | 'id' => 'gateways', |
383 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
384 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
383 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
384 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
385 | 385 | 'type' => 'gateways', |
386 | 386 | 'std' => array('manual'=>1), |
387 | 387 | 'options' => wpinv_get_payment_gateways(), |
388 | 388 | ), |
389 | 389 | 'default_gateway' => array( |
390 | 390 | 'id' => 'default_gateway', |
391 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
392 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
391 | + 'name' => __('Default Gateway', 'invoicing'), |
|
392 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
393 | 393 | 'type' => 'gateway_select', |
394 | 394 | 'std' => 'manual', |
395 | 395 | 'options' => wpinv_get_payment_gateways(), |
@@ -403,19 +403,19 @@ discard block |
||
403 | 403 | 'main' => array( |
404 | 404 | 'tax_settings' => array( |
405 | 405 | 'id' => 'tax_settings', |
406 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
406 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
407 | 407 | 'type' => 'header', |
408 | 408 | ), |
409 | 409 | 'enable_taxes' => array( |
410 | 410 | 'id' => 'enable_taxes', |
411 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
412 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
411 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
412 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
413 | 413 | 'type' => 'checkbox', |
414 | 414 | ), |
415 | 415 | 'tax_rate' => array( |
416 | 416 | 'id' => 'tax_rate', |
417 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
418 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
417 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
418 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
419 | 419 | 'type' => 'number', |
420 | 420 | 'size' => 'small', |
421 | 421 | 'min' => '0', |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | 'rates' => array( |
428 | 428 | 'tax_rates' => array( |
429 | 429 | 'id' => 'tax_rates', |
430 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
431 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
430 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
431 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
432 | 432 | 'type' => 'tax_rates', |
433 | 433 | ), |
434 | 434 | ) |
@@ -440,61 +440,61 @@ discard block |
||
440 | 440 | 'main' => array( |
441 | 441 | 'email_settings_header' => array( |
442 | 442 | 'id' => 'email_settings_header', |
443 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
443 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
444 | 444 | 'type' => 'header', |
445 | 445 | ), |
446 | 446 | 'email_from_name' => array( |
447 | 447 | 'id' => 'email_from_name', |
448 | - 'name' => __( 'From Name', 'invoicing' ), |
|
449 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
450 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
448 | + 'name' => __('From Name', 'invoicing'), |
|
449 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
450 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
451 | 451 | 'type' => 'text', |
452 | 452 | ), |
453 | 453 | 'email_from' => array( |
454 | 454 | 'id' => 'email_from', |
455 | - 'name' => __( 'From Email', 'invoicing' ), |
|
456 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
457 | - 'std' => get_option( 'admin_email' ), |
|
455 | + 'name' => __('From Email', 'invoicing'), |
|
456 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
457 | + 'std' => get_option('admin_email'), |
|
458 | 458 | 'type' => 'text', |
459 | 459 | ), |
460 | 460 | 'overdue_settings_header' => array( |
461 | 461 | 'id' => 'overdue_settings_header', |
462 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
462 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
463 | 463 | 'type' => 'header', |
464 | 464 | ), |
465 | 465 | 'overdue_active' => array( |
466 | 466 | 'id' => 'overdue_active', |
467 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
468 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
467 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
468 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
469 | 469 | 'type' => 'checkbox', |
470 | 470 | 'std' => false, |
471 | 471 | ), |
472 | 472 | 'overdue_days' => array( |
473 | 473 | 'id' => 'overdue_days', |
474 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
475 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
474 | + 'name' => __('Default Due Date', 'invoicing'), |
|
475 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
476 | 476 | 'type' => 'select', |
477 | 477 | 'options' => $due_payment_options, |
478 | 478 | 'std' => 0, |
479 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
479 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
480 | 480 | ), |
481 | 481 | 'email_template_header' => array( |
482 | 482 | 'id' => 'email_template_header', |
483 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
483 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
484 | 484 | 'type' => 'header', |
485 | 485 | ), |
486 | 486 | 'email_header_image' => array( |
487 | 487 | 'id' => 'email_header_image', |
488 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
489 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
488 | + 'name' => __('Header Image', 'invoicing'), |
|
489 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
490 | 490 | 'std' => '', |
491 | 491 | 'type' => 'text', |
492 | 492 | ), |
493 | 493 | 'email_footer_text' => array( |
494 | 494 | 'id' => 'email_footer_text', |
495 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
496 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
497 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
495 | + 'name' => __('Footer Text', 'invoicing'), |
|
496 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
497 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
498 | 498 | 'type' => 'textarea', |
499 | 499 | 'class' => 'regular-text', |
500 | 500 | 'rows' => 2, |
@@ -502,29 +502,29 @@ discard block |
||
502 | 502 | ), |
503 | 503 | 'email_base_color' => array( |
504 | 504 | 'id' => 'email_base_color', |
505 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
506 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
505 | + 'name' => __('Base Color', 'invoicing'), |
|
506 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
507 | 507 | 'std' => '#557da2', |
508 | 508 | 'type' => 'color', |
509 | 509 | ), |
510 | 510 | 'email_background_color' => array( |
511 | 511 | 'id' => 'email_background_color', |
512 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
513 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
512 | + 'name' => __('Background Color', 'invoicing'), |
|
513 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
514 | 514 | 'std' => '#f5f5f5', |
515 | 515 | 'type' => 'color', |
516 | 516 | ), |
517 | 517 | 'email_body_background_color' => array( |
518 | 518 | 'id' => 'email_body_background_color', |
519 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
520 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
519 | + 'name' => __('Body Background Color', 'invoicing'), |
|
520 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
521 | 521 | 'std' => '#fdfdfd', |
522 | 522 | 'type' => 'color', |
523 | 523 | ), |
524 | 524 | 'email_text_color' => array( |
525 | 525 | 'id' => 'email_text_color', |
526 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
527 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
526 | + 'name' => __('Body Text Color', 'invoicing'), |
|
527 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
528 | 528 | 'std' => '#505050', |
529 | 529 | 'type' => 'color', |
530 | 530 | ), |
@@ -543,19 +543,19 @@ discard block |
||
543 | 543 | 'main' => array( |
544 | 544 | 'invoice_number_format_settings' => array( |
545 | 545 | 'id' => 'invoice_number_format_settings', |
546 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
546 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
547 | 547 | 'type' => 'header', |
548 | 548 | ), |
549 | 549 | 'sequential_invoice_number' => array( |
550 | 550 | 'id' => 'sequential_invoice_number', |
551 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
552 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ), |
|
551 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
552 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'), |
|
553 | 553 | 'type' => 'checkbox', |
554 | 554 | ), |
555 | 555 | 'invoice_sequence_start' => array( |
556 | 556 | 'id' => 'invoice_sequence_start', |
557 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
558 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
557 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
558 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
559 | 559 | 'type' => 'number', |
560 | 560 | 'size' => 'small', |
561 | 561 | 'std' => '1', |
@@ -563,16 +563,16 @@ discard block |
||
563 | 563 | ), |
564 | 564 | 'invoice_number_padd' => array( |
565 | 565 | 'id' => 'invoice_number_padd', |
566 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
567 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
566 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
567 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
568 | 568 | 'type' => 'select', |
569 | 569 | 'options' => $invoice_number_padd_options, |
570 | 570 | 'std' => 5, |
571 | 571 | ), |
572 | 572 | 'invoice_number_prefix' => array( |
573 | 573 | 'id' => 'invoice_number_prefix', |
574 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
575 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
574 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
575 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
576 | 576 | 'type' => 'text', |
577 | 577 | 'size' => 'regular', |
578 | 578 | 'std' => 'WPINV-', |
@@ -580,32 +580,32 @@ discard block |
||
580 | 580 | ), |
581 | 581 | 'invoice_number_postfix' => array( |
582 | 582 | 'id' => 'invoice_number_postfix', |
583 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
584 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
583 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
584 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
585 | 585 | 'type' => 'text', |
586 | 586 | 'size' => 'regular', |
587 | 587 | 'std' => '' |
588 | 588 | ), |
589 | 589 | 'checkout_settings' => array( |
590 | 590 | 'id' => 'checkout_settings', |
591 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
591 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
592 | 592 | 'type' => 'header', |
593 | 593 | ), |
594 | 594 | 'login_to_checkout' => array( |
595 | 595 | 'id' => 'login_to_checkout', |
596 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
597 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
596 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
597 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
598 | 598 | 'type' => 'checkbox', |
599 | 599 | ), |
600 | 600 | 'uninstall_settings' => array( |
601 | 601 | 'id' => 'uninstall_settings', |
602 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
602 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
603 | 603 | 'type' => 'header', |
604 | 604 | ), |
605 | 605 | 'remove_data_on_unistall' => array( |
606 | 606 | 'id' => 'remove_data_on_unistall', |
607 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
608 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
607 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
608 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
609 | 609 | 'type' => 'checkbox', |
610 | 610 | 'std' => '' |
611 | 611 | ), |
@@ -613,74 +613,74 @@ discard block |
||
613 | 613 | 'fields' => array( |
614 | 614 | 'fields_settings' => array( |
615 | 615 | 'id' => 'fields_settings', |
616 | - 'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>', |
|
617 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
616 | + 'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>', |
|
617 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
618 | 618 | 'type' => 'header', |
619 | 619 | ), |
620 | 620 | 'fname_mandatory' => array( |
621 | 621 | 'id' => 'fname_mandatory', |
622 | - 'name' => __( 'First Name', 'invoicing' ), |
|
622 | + 'name' => __('First Name', 'invoicing'), |
|
623 | 623 | 'type' => 'checkbox', |
624 | 624 | 'std' => true, |
625 | 625 | ), |
626 | 626 | 'lname_mandatory' => array( |
627 | 627 | 'id' => 'lname_mandatory', |
628 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
628 | + 'name' => __('Last Name', 'invoicing'), |
|
629 | 629 | 'type' => 'checkbox', |
630 | 630 | 'std' => true, |
631 | 631 | ), |
632 | 632 | 'address_mandatory' => array( |
633 | 633 | 'id' => 'address_mandatory', |
634 | - 'name' => __( 'Address', 'invoicing' ), |
|
634 | + 'name' => __('Address', 'invoicing'), |
|
635 | 635 | 'type' => 'checkbox', |
636 | 636 | 'std' => true, |
637 | 637 | ), |
638 | 638 | 'city_mandatory' => array( |
639 | 639 | 'id' => 'city_mandatory', |
640 | - 'name' => __( 'City', 'invoicing' ), |
|
640 | + 'name' => __('City', 'invoicing'), |
|
641 | 641 | 'type' => 'checkbox', |
642 | 642 | 'std' => true, |
643 | 643 | ), |
644 | 644 | 'country_mandatory' => array( |
645 | 645 | 'id' => 'country_mandatory', |
646 | - 'name' => __( 'Country', 'invoicing' ), |
|
646 | + 'name' => __('Country', 'invoicing'), |
|
647 | 647 | 'type' => 'checkbox', |
648 | 648 | 'std' => true, |
649 | 649 | ), |
650 | 650 | 'state_mandatory' => array( |
651 | 651 | 'id' => 'state_mandatory', |
652 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
652 | + 'name' => __('State / Province', 'invoicing'), |
|
653 | 653 | 'type' => 'checkbox', |
654 | 654 | 'std' => true, |
655 | 655 | ), |
656 | 656 | 'zip_mandatory' => array( |
657 | 657 | 'id' => 'zip_mandatory', |
658 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
658 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
659 | 659 | 'type' => 'checkbox', |
660 | 660 | 'std' => true, |
661 | 661 | ), |
662 | 662 | 'phone_mandatory' => array( |
663 | 663 | 'id' => 'phone_mandatory', |
664 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
664 | + 'name' => __('Phone Number', 'invoicing'), |
|
665 | 665 | 'type' => 'checkbox', |
666 | 666 | 'std' => true, |
667 | 667 | ), |
668 | 668 | 'address_autofill_settings' => array( |
669 | 669 | 'id' => 'address_autofill_settings', |
670 | - 'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>', |
|
670 | + 'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>', |
|
671 | 671 | 'type' => 'header', |
672 | 672 | ), |
673 | 673 | 'address_autofill_active' => array( |
674 | 674 | 'id' => 'address_autofill_active', |
675 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
676 | - 'desc' => __( 'Enable google address auto complete', 'invoicing' ), |
|
675 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
676 | + 'desc' => __('Enable google address auto complete', 'invoicing'), |
|
677 | 677 | 'type' => 'checkbox', |
678 | 678 | 'std' => 0 |
679 | 679 | ), |
680 | 680 | 'address_autofill_api' => array( |
681 | 681 | 'id' => 'address_autofill_api', |
682 | - 'name' => __( 'Google Place API Key', 'invoicing' ), |
|
683 | - 'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ), |
|
682 | + 'name' => __('Google Place API Key', 'invoicing'), |
|
683 | + 'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'), |
|
684 | 684 | 'type' => 'text', |
685 | 685 | 'size' => 'regular', |
686 | 686 | 'std' => '' |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | 'main' => array( |
695 | 695 | 'tool_settings' => array( |
696 | 696 | 'id' => 'tool_settings', |
697 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
698 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
697 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
698 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
699 | 699 | 'type' => 'tools', |
700 | 700 | ), |
701 | 701 | ), |
@@ -703,135 +703,135 @@ discard block |
||
703 | 703 | ) |
704 | 704 | ); |
705 | 705 | |
706 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
706 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
707 | 707 | } |
708 | 708 | |
709 | -function wpinv_settings_sanitize( $input = array() ) { |
|
709 | +function wpinv_settings_sanitize($input = array()) { |
|
710 | 710 | global $wpinv_options; |
711 | 711 | |
712 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
712 | + if (empty($_POST['_wp_http_referer'])) { |
|
713 | 713 | return $input; |
714 | 714 | } |
715 | 715 | |
716 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
716 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
717 | 717 | |
718 | 718 | $settings = wpinv_get_registered_settings(); |
719 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
720 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
719 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
720 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
721 | 721 | |
722 | 722 | $input = $input ? $input : array(); |
723 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
724 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
723 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
724 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
725 | 725 | |
726 | 726 | // Loop through each setting being saved and pass it through a sanitization filter |
727 | - foreach ( $input as $key => $value ) { |
|
727 | + foreach ($input as $key => $value) { |
|
728 | 728 | // Get the setting type (checkbox, select, etc) |
729 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
729 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
730 | 730 | |
731 | - if ( $type ) { |
|
731 | + if ($type) { |
|
732 | 732 | // Field type specific filter |
733 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
733 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | // General filter |
737 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
737 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | // Loop through the whitelist and unset any that are empty for the tab being saved |
741 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
742 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
741 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
742 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
743 | 743 | |
744 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
744 | + $found_settings = array_merge($main_settings, $section_settings); |
|
745 | 745 | |
746 | - if ( ! empty( $found_settings ) ) { |
|
747 | - foreach ( $found_settings as $key => $value ) { |
|
746 | + if (!empty($found_settings)) { |
|
747 | + foreach ($found_settings as $key => $value) { |
|
748 | 748 | |
749 | 749 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
750 | - if ( is_numeric( $key ) ) { |
|
750 | + if (is_numeric($key)) { |
|
751 | 751 | $key = $value['id']; |
752 | 752 | } |
753 | 753 | |
754 | - if ( empty( $input[ $key ] ) ) { |
|
755 | - unset( $wpinv_options[ $key ] ); |
|
754 | + if (empty($input[$key])) { |
|
755 | + unset($wpinv_options[$key]); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
760 | 760 | // Merge our new settings with the existing |
761 | - $output = array_merge( $wpinv_options, $input ); |
|
761 | + $output = array_merge($wpinv_options, $input); |
|
762 | 762 | |
763 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
763 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
764 | 764 | |
765 | 765 | return $output; |
766 | 766 | } |
767 | 767 | |
768 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
768 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
769 | 769 | global $wpinv_options, $wpi_session; |
770 | 770 | |
771 | - if ( !current_user_can( 'manage_options' ) ) { |
|
771 | + if (!current_user_can('manage_options')) { |
|
772 | 772 | return $input; |
773 | 773 | } |
774 | 774 | |
775 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
775 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
776 | 776 | // Shows an admin notice about upgrading previous order numbers |
777 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
777 | + $wpi_session->set('upgrade_sequential', '1'); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | return $input; |
781 | 781 | } |
782 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
782 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
783 | 783 | |
784 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
785 | - if( !current_user_can( 'manage_options' ) ) { |
|
784 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
785 | + if (!current_user_can('manage_options')) { |
|
786 | 786 | return $input; |
787 | 787 | } |
788 | 788 | |
789 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
789 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
790 | 790 | |
791 | 791 | $tax_rates = array(); |
792 | 792 | |
793 | - if ( !empty( $new_rates ) ) { |
|
794 | - foreach ( $new_rates as $rate ) { |
|
795 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
793 | + if (!empty($new_rates)) { |
|
794 | + foreach ($new_rates as $rate) { |
|
795 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
796 | 796 | continue; |
797 | 797 | } |
798 | 798 | |
799 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
799 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
800 | 800 | |
801 | 801 | $tax_rates[] = $rate; |
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
805 | + update_option('wpinv_tax_rates', $tax_rates); |
|
806 | 806 | |
807 | 807 | return $input; |
808 | 808 | } |
809 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
809 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
810 | 810 | |
811 | -function wpinv_sanitize_text_field( $input ) { |
|
812 | - return trim( $input ); |
|
811 | +function wpinv_sanitize_text_field($input) { |
|
812 | + return trim($input); |
|
813 | 813 | } |
814 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
814 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
815 | 815 | |
816 | 816 | function wpinv_get_settings_tabs() { |
817 | 817 | $tabs = array(); |
818 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
819 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
820 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
821 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
822 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
823 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
824 | - |
|
825 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
818 | + $tabs['general'] = __('General', 'invoicing'); |
|
819 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
820 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
821 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
822 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
823 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
824 | + |
|
825 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
826 | 826 | } |
827 | 827 | |
828 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
828 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
829 | 829 | $tabs = false; |
830 | 830 | $sections = wpinv_get_registered_settings_sections(); |
831 | 831 | |
832 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
833 | - $tabs = $sections[ $tab ]; |
|
834 | - } else if ( $tab ) { |
|
832 | + if ($tab && !empty($sections[$tab])) { |
|
833 | + $tabs = $sections[$tab]; |
|
834 | + } else if ($tab) { |
|
835 | 835 | $tabs = false; |
836 | 836 | } |
837 | 837 | |
@@ -841,136 +841,136 @@ discard block |
||
841 | 841 | function wpinv_get_registered_settings_sections() { |
842 | 842 | static $sections = false; |
843 | 843 | |
844 | - if ( false !== $sections ) { |
|
844 | + if (false !== $sections) { |
|
845 | 845 | return $sections; |
846 | 846 | } |
847 | 847 | |
848 | 848 | $sections = array( |
849 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
850 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
851 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
852 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
853 | - ) ), |
|
854 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
855 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
856 | - ) ), |
|
857 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
858 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
859 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
860 | - ) ), |
|
861 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
862 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
863 | - ) ), |
|
864 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
865 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
866 | - 'fields' => __( 'Fields Settings', 'invoicing' ), |
|
867 | - ) ), |
|
868 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
869 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
870 | - ) ), |
|
849 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
850 | + 'main' => __('General Settings', 'invoicing'), |
|
851 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
852 | + 'labels' => __('Label Texts', 'invoicing'), |
|
853 | + )), |
|
854 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
855 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
856 | + )), |
|
857 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
858 | + 'main' => __('Tax Settings', 'invoicing'), |
|
859 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
860 | + )), |
|
861 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
862 | + 'main' => __('Email Settings', 'invoicing'), |
|
863 | + )), |
|
864 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
865 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
866 | + 'fields' => __('Fields Settings', 'invoicing'), |
|
867 | + )), |
|
868 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
869 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
870 | + )), |
|
871 | 871 | ); |
872 | 872 | |
873 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
873 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
874 | 874 | |
875 | 875 | return $sections; |
876 | 876 | } |
877 | 877 | |
878 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
878 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
879 | 879 | $pages_options = array(); |
880 | 880 | |
881 | - if( $default_label !== NULL && $default_label !== false ) { |
|
882 | - $pages_options = array( '' => $default_label ); // Blank option |
|
881 | + if ($default_label !== NULL && $default_label !== false) { |
|
882 | + $pages_options = array('' => $default_label); // Blank option |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | $pages = get_pages(); |
886 | - if ( $pages ) { |
|
887 | - foreach ( $pages as $page ) { |
|
886 | + if ($pages) { |
|
887 | + foreach ($pages as $page) { |
|
888 | 888 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
889 | - $pages_options[ $page->ID ] = $title; |
|
889 | + $pages_options[$page->ID] = $title; |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | |
893 | 893 | return $pages_options; |
894 | 894 | } |
895 | 895 | |
896 | -function wpinv_header_callback( $args ) { |
|
897 | - if ( !empty( $args['desc'] ) ) { |
|
896 | +function wpinv_header_callback($args) { |
|
897 | + if (!empty($args['desc'])) { |
|
898 | 898 | echo $args['desc']; |
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | -function wpinv_hidden_callback( $args ) { |
|
902 | +function wpinv_hidden_callback($args) { |
|
903 | 903 | global $wpinv_options; |
904 | 904 | |
905 | - if ( isset( $args['set_value'] ) ) { |
|
905 | + if (isset($args['set_value'])) { |
|
906 | 906 | $value = $args['set_value']; |
907 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
908 | - $value = $wpinv_options[ $args['id'] ]; |
|
907 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
908 | + $value = $wpinv_options[$args['id']]; |
|
909 | 909 | } else { |
910 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
910 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
911 | 911 | } |
912 | 912 | |
913 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
913 | + if (isset($args['faux']) && true === $args['faux']) { |
|
914 | 914 | $args['readonly'] = true; |
915 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
915 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
916 | 916 | $name = ''; |
917 | 917 | } else { |
918 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
918 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
919 | 919 | } |
920 | 920 | |
921 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
921 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
922 | 922 | |
923 | 923 | echo $html; |
924 | 924 | } |
925 | 925 | |
926 | -function wpinv_checkbox_callback( $args ) { |
|
926 | +function wpinv_checkbox_callback($args) { |
|
927 | 927 | global $wpinv_options; |
928 | 928 | |
929 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
929 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
930 | 930 | |
931 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
931 | + if (isset($args['faux']) && true === $args['faux']) { |
|
932 | 932 | $name = ''; |
933 | 933 | } else { |
934 | 934 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
935 | 935 | } |
936 | 936 | |
937 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
937 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
938 | 938 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
939 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
939 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
940 | 940 | |
941 | 941 | echo $html; |
942 | 942 | } |
943 | 943 | |
944 | -function wpinv_multicheck_callback( $args ) { |
|
944 | +function wpinv_multicheck_callback($args) { |
|
945 | 945 | global $wpinv_options; |
946 | 946 | |
947 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
947 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
948 | 948 | |
949 | - if ( ! empty( $args['options'] ) ) { |
|
950 | - foreach( $args['options'] as $key => $option ): |
|
951 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
952 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
949 | + if (!empty($args['options'])) { |
|
950 | + foreach ($args['options'] as $key => $option): |
|
951 | + $sanitize_key = wpinv_sanitize_key($key); |
|
952 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
953 | 953 | $enabled = $sanitize_key; |
954 | 954 | } else { |
955 | 955 | $enabled = NULL; |
956 | 956 | } |
957 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
958 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
957 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
958 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
959 | 959 | endforeach; |
960 | 960 | echo '<p class="description">' . $args['desc'] . '</p>'; |
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
964 | -function wpinv_payment_icons_callback( $args ) { |
|
964 | +function wpinv_payment_icons_callback($args) { |
|
965 | 965 | global $wpinv_options; |
966 | 966 | |
967 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
967 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
968 | 968 | |
969 | - if ( ! empty( $args['options'] ) ) { |
|
970 | - foreach( $args['options'] as $key => $option ) { |
|
971 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
969 | + if (!empty($args['options'])) { |
|
970 | + foreach ($args['options'] as $key => $option) { |
|
971 | + $sanitize_key = wpinv_sanitize_key($key); |
|
972 | 972 | |
973 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
973 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
974 | 974 | $enabled = $option; |
975 | 975 | } else { |
976 | 976 | $enabled = NULL; |
@@ -978,196 +978,196 @@ discard block |
||
978 | 978 | |
979 | 979 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
980 | 980 | |
981 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
981 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
982 | 982 | |
983 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
984 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
983 | + if (wpinv_string_is_image_url($key)) { |
|
984 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
985 | 985 | } else { |
986 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
986 | + $card = strtolower(str_replace(' ', '', $option)); |
|
987 | 987 | |
988 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
989 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
988 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
989 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
990 | 990 | } else { |
991 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
991 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
992 | 992 | $content_dir = WP_CONTENT_DIR; |
993 | 993 | |
994 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
994 | + if (function_exists('wp_normalize_path')) { |
|
995 | 995 | // Replaces backslashes with forward slashes for Windows systems |
996 | - $image = wp_normalize_path( $image ); |
|
997 | - $content_dir = wp_normalize_path( $content_dir ); |
|
996 | + $image = wp_normalize_path($image); |
|
997 | + $content_dir = wp_normalize_path($content_dir); |
|
998 | 998 | } |
999 | 999 | |
1000 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
1000 | + $image = str_replace($content_dir, content_url(), $image); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1003 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1004 | 1004 | } |
1005 | 1005 | echo $option . '</label>'; |
1006 | 1006 | } |
1007 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1007 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | |
1011 | -function wpinv_radio_callback( $args ) { |
|
1011 | +function wpinv_radio_callback($args) { |
|
1012 | 1012 | global $wpinv_options; |
1013 | 1013 | |
1014 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1014 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1015 | 1015 | |
1016 | - foreach ( $args['options'] as $key => $option ) : |
|
1017 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1016 | + foreach ($args['options'] as $key => $option) : |
|
1017 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1018 | 1018 | |
1019 | 1019 | $checked = false; |
1020 | 1020 | |
1021 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1021 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
1022 | 1022 | $checked = true; |
1023 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1023 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
1024 | 1024 | $checked = true; |
1025 | 1025 | |
1026 | 1026 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
1027 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1027 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
1028 | 1028 | endforeach; |
1029 | 1029 | |
1030 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1030 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | -function wpinv_gateways_callback( $args ) { |
|
1033 | +function wpinv_gateways_callback($args) { |
|
1034 | 1034 | global $wpinv_options; |
1035 | 1035 | |
1036 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1036 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1037 | 1037 | |
1038 | - foreach ( $args['options'] as $key => $option ) : |
|
1039 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1038 | + foreach ($args['options'] as $key => $option) : |
|
1039 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1040 | 1040 | |
1041 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
1041 | + if (isset($wpinv_options['gateways'][$key])) |
|
1042 | 1042 | $enabled = '1'; |
1043 | 1043 | else |
1044 | 1044 | $enabled = null; |
1045 | 1045 | |
1046 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1047 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1046 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1047 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
1048 | 1048 | endforeach; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | function wpinv_gateway_select_callback($args) { |
1052 | 1052 | global $wpinv_options; |
1053 | 1053 | |
1054 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1054 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1055 | 1055 | |
1056 | 1056 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
1057 | 1057 | |
1058 | - foreach ( $args['options'] as $key => $option ) : |
|
1059 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1060 | - $selected = selected( $key, $args['selected'], false ); |
|
1058 | + foreach ($args['options'] as $key => $option) : |
|
1059 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1060 | + $selected = selected($key, $args['selected'], false); |
|
1061 | 1061 | } else { |
1062 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
1062 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
1063 | 1063 | } |
1064 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1064 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
1065 | 1065 | endforeach; |
1066 | 1066 | |
1067 | 1067 | echo '</select>'; |
1068 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1068 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | -function wpinv_text_callback( $args ) { |
|
1071 | +function wpinv_text_callback($args) { |
|
1072 | 1072 | global $wpinv_options; |
1073 | 1073 | |
1074 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1074 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1075 | 1075 | |
1076 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1077 | - $value = $wpinv_options[ $args['id'] ]; |
|
1076 | + if (isset($wpinv_options[$args['id']])) { |
|
1077 | + $value = $wpinv_options[$args['id']]; |
|
1078 | 1078 | } else { |
1079 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1079 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1082 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1083 | 1083 | $args['readonly'] = true; |
1084 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1084 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1085 | 1085 | $name = ''; |
1086 | 1086 | } else { |
1087 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1087 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1088 | 1088 | } |
1089 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1089 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1090 | 1090 | |
1091 | 1091 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
1092 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1093 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1094 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1092 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1093 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
1094 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1095 | 1095 | |
1096 | 1096 | echo $html; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | -function wpinv_number_callback( $args ) { |
|
1099 | +function wpinv_number_callback($args) { |
|
1100 | 1100 | global $wpinv_options; |
1101 | 1101 | |
1102 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1102 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1103 | 1103 | |
1104 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1105 | - $value = $wpinv_options[ $args['id'] ]; |
|
1104 | + if (isset($wpinv_options[$args['id']])) { |
|
1105 | + $value = $wpinv_options[$args['id']]; |
|
1106 | 1106 | } else { |
1107 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1107 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1110 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1111 | 1111 | $args['readonly'] = true; |
1112 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1112 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1113 | 1113 | $name = ''; |
1114 | 1114 | } else { |
1115 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1115 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1119 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1120 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1121 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1118 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
1119 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
1120 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
1121 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1122 | 1122 | |
1123 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1124 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1125 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1123 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1124 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1125 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1126 | 1126 | |
1127 | 1127 | echo $html; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | -function wpinv_textarea_callback( $args ) { |
|
1130 | +function wpinv_textarea_callback($args) { |
|
1131 | 1131 | global $wpinv_options; |
1132 | 1132 | |
1133 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1133 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1134 | 1134 | |
1135 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1136 | - $value = $wpinv_options[ $args['id'] ]; |
|
1135 | + if (isset($wpinv_options[$args['id']])) { |
|
1136 | + $value = $wpinv_options[$args['id']]; |
|
1137 | 1137 | } else { |
1138 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1138 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1142 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
1141 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1142 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
1143 | 1143 | |
1144 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1145 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1144 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
1145 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1146 | 1146 | |
1147 | 1147 | echo $html; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | -function wpinv_password_callback( $args ) { |
|
1150 | +function wpinv_password_callback($args) { |
|
1151 | 1151 | global $wpinv_options; |
1152 | 1152 | |
1153 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1153 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1154 | 1154 | |
1155 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1156 | - $value = $wpinv_options[ $args['id'] ]; |
|
1155 | + if (isset($wpinv_options[$args['id']])) { |
|
1156 | + $value = $wpinv_options[$args['id']]; |
|
1157 | 1157 | } else { |
1158 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1158 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1162 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1163 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1161 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1162 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
1163 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1164 | 1164 | |
1165 | 1165 | echo $html; |
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | function wpinv_missing_callback($args) { |
1169 | 1169 | printf( |
1170 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1170 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
1171 | 1171 | '<strong>' . $args['id'] . '</strong>' |
1172 | 1172 | ); |
1173 | 1173 | } |
@@ -1175,131 +1175,131 @@ discard block |
||
1175 | 1175 | function wpinv_select_callback($args) { |
1176 | 1176 | global $wpinv_options; |
1177 | 1177 | |
1178 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1178 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1179 | 1179 | |
1180 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1181 | - $value = $wpinv_options[ $args['id'] ]; |
|
1180 | + if (isset($wpinv_options[$args['id']])) { |
|
1181 | + $value = $wpinv_options[$args['id']]; |
|
1182 | 1182 | } else { |
1183 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1183 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1186 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1187 | 1187 | $value = $args['selected']; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - if ( isset( $args['placeholder'] ) ) { |
|
1190 | + if (isset($args['placeholder'])) { |
|
1191 | 1191 | $placeholder = $args['placeholder']; |
1192 | 1192 | } else { |
1193 | 1193 | $placeholder = ''; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - if( !empty( $args['onchange'] ) ) { |
|
1197 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
1196 | + if (!empty($args['onchange'])) { |
|
1197 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
1198 | 1198 | } else { |
1199 | 1199 | $onchange = ''; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1202 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
1203 | 1203 | |
1204 | - foreach ( $args['options'] as $option => $name ) { |
|
1205 | - $selected = selected( $option, $value, false ); |
|
1206 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1204 | + foreach ($args['options'] as $option => $name) { |
|
1205 | + $selected = selected($option, $value, false); |
|
1206 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | $html .= '</select>'; |
1210 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1210 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1211 | 1211 | |
1212 | 1212 | echo $html; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | -function wpinv_color_select_callback( $args ) { |
|
1215 | +function wpinv_color_select_callback($args) { |
|
1216 | 1216 | global $wpinv_options; |
1217 | 1217 | |
1218 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1218 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1219 | 1219 | |
1220 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1221 | - $value = $wpinv_options[ $args['id'] ]; |
|
1220 | + if (isset($wpinv_options[$args['id']])) { |
|
1221 | + $value = $wpinv_options[$args['id']]; |
|
1222 | 1222 | } else { |
1223 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1223 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1226 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
1227 | 1227 | |
1228 | - foreach ( $args['options'] as $option => $color ) { |
|
1229 | - $selected = selected( $option, $value, false ); |
|
1230 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1228 | + foreach ($args['options'] as $option => $color) { |
|
1229 | + $selected = selected($option, $value, false); |
|
1230 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | $html .= '</select>'; |
1234 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1234 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1235 | 1235 | |
1236 | 1236 | echo $html; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | -function wpinv_rich_editor_callback( $args ) { |
|
1239 | +function wpinv_rich_editor_callback($args) { |
|
1240 | 1240 | global $wpinv_options, $wp_version; |
1241 | 1241 | |
1242 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1242 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1243 | 1243 | |
1244 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1245 | - $value = $wpinv_options[ $args['id'] ]; |
|
1244 | + if (isset($wpinv_options[$args['id']])) { |
|
1245 | + $value = $wpinv_options[$args['id']]; |
|
1246 | 1246 | |
1247 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1248 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1247 | + if (empty($args['allow_blank']) && empty($value)) { |
|
1248 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1249 | 1249 | } |
1250 | 1250 | } else { |
1251 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1251 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1254 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
1255 | 1255 | |
1256 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1256 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
1257 | 1257 | ob_start(); |
1258 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
1258 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
1259 | 1259 | $html = ob_get_clean(); |
1260 | 1260 | } else { |
1261 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1261 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1264 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1265 | 1265 | |
1266 | 1266 | echo $html; |
1267 | 1267 | } |
1268 | 1268 | |
1269 | -function wpinv_upload_callback( $args ) { |
|
1269 | +function wpinv_upload_callback($args) { |
|
1270 | 1270 | global $wpinv_options; |
1271 | 1271 | |
1272 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1272 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1273 | 1273 | |
1274 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1274 | + if (isset($wpinv_options[$args['id']])) { |
|
1275 | 1275 | $value = $wpinv_options[$args['id']]; |
1276 | 1276 | } else { |
1277 | 1277 | $value = isset($args['std']) ? $args['std'] : ''; |
1278 | 1278 | } |
1279 | 1279 | |
1280 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1281 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1282 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1283 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1280 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1281 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1282 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
1283 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1284 | 1284 | |
1285 | 1285 | echo $html; |
1286 | 1286 | } |
1287 | 1287 | |
1288 | -function wpinv_color_callback( $args ) { |
|
1288 | +function wpinv_color_callback($args) { |
|
1289 | 1289 | global $wpinv_options; |
1290 | 1290 | |
1291 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1291 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1292 | 1292 | |
1293 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1294 | - $value = $wpinv_options[ $args['id'] ]; |
|
1293 | + if (isset($wpinv_options[$args['id']])) { |
|
1294 | + $value = $wpinv_options[$args['id']]; |
|
1295 | 1295 | } else { |
1296 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1296 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1299 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
1300 | 1300 | |
1301 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1302 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1301 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
1302 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1303 | 1303 | |
1304 | 1304 | echo $html; |
1305 | 1305 | } |
@@ -1307,9 +1307,9 @@ discard block |
||
1307 | 1307 | function wpinv_country_states_callback($args) { |
1308 | 1308 | global $wpinv_options; |
1309 | 1309 | |
1310 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1310 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1311 | 1311 | |
1312 | - if ( isset( $args['placeholder'] ) ) { |
|
1312 | + if (isset($args['placeholder'])) { |
|
1313 | 1313 | $placeholder = $args['placeholder']; |
1314 | 1314 | } else { |
1315 | 1315 | $placeholder = ''; |
@@ -1317,16 +1317,16 @@ discard block |
||
1317 | 1317 | |
1318 | 1318 | $states = wpinv_get_country_states(); |
1319 | 1319 | |
1320 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ''; |
|
1321 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1320 | + $class = empty($states) ? ' class="wpinv-no-states"' : ''; |
|
1321 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
1322 | 1322 | |
1323 | - foreach ( $states as $option => $name ) { |
|
1324 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1325 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1323 | + foreach ($states as $option => $name) { |
|
1324 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
1325 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | $html .= '</select>'; |
1329 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1329 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1330 | 1330 | |
1331 | 1331 | echo $html; |
1332 | 1332 | } |
@@ -1341,95 +1341,95 @@ discard block |
||
1341 | 1341 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
1342 | 1342 | <thead> |
1343 | 1343 | <tr> |
1344 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
1345 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
1346 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
1347 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
1348 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
1349 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
1344 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
1345 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
1346 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
1347 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
1348 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
1349 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
1350 | 1350 | </tr> |
1351 | 1351 | </thead> |
1352 | 1352 | <tbody> |
1353 | - <?php if( !empty( $rates ) ) : ?> |
|
1354 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
1353 | + <?php if (!empty($rates)) : ?> |
|
1354 | + <?php foreach ($rates as $key => $rate) : ?> |
|
1355 | 1355 | <?php |
1356 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
1356 | + $sanitized_key = wpinv_sanitize_key($key); |
|
1357 | 1357 | ?> |
1358 | 1358 | <tr> |
1359 | 1359 | <td class="wpinv_tax_country"> |
1360 | 1360 | <?php |
1361 | - echo wpinv_html_select( array( |
|
1362 | - 'options' => wpinv_get_country_list( true ), |
|
1361 | + echo wpinv_html_select(array( |
|
1362 | + 'options' => wpinv_get_country_list(true), |
|
1363 | 1363 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
1364 | 1364 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1365 | 1365 | 'selected' => $rate['country'], |
1366 | 1366 | 'show_option_all' => false, |
1367 | 1367 | 'show_option_none' => false, |
1368 | 1368 | 'class' => 'wpinv-tax-country', |
1369 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1370 | - ) ); |
|
1369 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1370 | + )); |
|
1371 | 1371 | ?> |
1372 | 1372 | </td> |
1373 | 1373 | <td class="wpinv_tax_state"> |
1374 | 1374 | <?php |
1375 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1376 | - if( !empty( $states ) ) { |
|
1377 | - echo wpinv_html_select( array( |
|
1378 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1375 | + $states = wpinv_get_country_states($rate['country']); |
|
1376 | + if (!empty($states)) { |
|
1377 | + echo wpinv_html_select(array( |
|
1378 | + 'options' => array_merge(array('' => ''), $states), |
|
1379 | 1379 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
1380 | 1380 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1381 | 1381 | 'selected' => $rate['state'], |
1382 | 1382 | 'show_option_all' => false, |
1383 | 1383 | 'show_option_none' => false, |
1384 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1385 | - ) ); |
|
1384 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
1385 | + )); |
|
1386 | 1386 | } else { |
1387 | - echo wpinv_html_text( array( |
|
1387 | + echo wpinv_html_text(array( |
|
1388 | 1388 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
1389 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1389 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
1390 | 1390 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1391 | - ) ); |
|
1391 | + )); |
|
1392 | 1392 | } |
1393 | 1393 | ?> |
1394 | 1394 | </td> |
1395 | 1395 | <td class="wpinv_tax_global"> |
1396 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
1397 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1396 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
1397 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1398 | 1398 | </td> |
1399 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
1400 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
1401 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1399 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
1400 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
1401 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1402 | 1402 | </tr> |
1403 | 1403 | <?php endforeach; ?> |
1404 | 1404 | <?php else : ?> |
1405 | 1405 | <tr> |
1406 | 1406 | <td class="wpinv_tax_country"> |
1407 | 1407 | <?php |
1408 | - echo wpinv_html_select( array( |
|
1409 | - 'options' => wpinv_get_country_list( true ), |
|
1408 | + echo wpinv_html_select(array( |
|
1409 | + 'options' => wpinv_get_country_list(true), |
|
1410 | 1410 | 'name' => 'tax_rates[0][country]', |
1411 | 1411 | 'show_option_all' => false, |
1412 | 1412 | 'show_option_none' => false, |
1413 | 1413 | 'class' => 'wpinv-tax-country', |
1414 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1415 | - ) ); ?> |
|
1414 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1415 | + )); ?> |
|
1416 | 1416 | </td> |
1417 | 1417 | <td class="wpinv_tax_state"> |
1418 | - <?php echo wpinv_html_text( array( |
|
1418 | + <?php echo wpinv_html_text(array( |
|
1419 | 1419 | 'name' => 'tax_rates[0][state]' |
1420 | - ) ); ?> |
|
1420 | + )); ?> |
|
1421 | 1421 | </td> |
1422 | 1422 | <td class="wpinv_tax_global"> |
1423 | 1423 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
1424 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1424 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1425 | 1425 | </td> |
1426 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
1426 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
1427 | 1427 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
1428 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1428 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1429 | 1429 | </tr> |
1430 | 1430 | <?php endif; ?> |
1431 | 1431 | </tbody> |
1432 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
1432 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
1433 | 1433 | </table> |
1434 | 1434 | <?php |
1435 | 1435 | echo ob_get_clean(); |
@@ -1440,76 +1440,76 @@ discard block |
||
1440 | 1440 | ob_start(); ?> |
1441 | 1441 | </td><tr> |
1442 | 1442 | <td colspan="2" class="wpinv_tools_tdbox"> |
1443 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1444 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1443 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1444 | + <?php do_action('wpinv_tools_before'); ?> |
|
1445 | 1445 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1446 | 1446 | <thead> |
1447 | 1447 | <tr> |
1448 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1449 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1450 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1448 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1449 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1450 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1451 | 1451 | </tr> |
1452 | 1452 | </thead> |
1453 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1453 | + <?php do_action('wpinv_tools_row'); ?> |
|
1454 | 1454 | <tbody> |
1455 | 1455 | </tbody> |
1456 | 1456 | </table> |
1457 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1457 | + <?php do_action('wpinv_tools_after'); ?> |
|
1458 | 1458 | <?php |
1459 | 1459 | echo ob_get_clean(); |
1460 | 1460 | } |
1461 | 1461 | |
1462 | -function wpinv_descriptive_text_callback( $args ) { |
|
1463 | - echo wp_kses_post( $args['desc'] ); |
|
1462 | +function wpinv_descriptive_text_callback($args) { |
|
1463 | + echo wp_kses_post($args['desc']); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | -function wpinv_hook_callback( $args ) { |
|
1467 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1466 | +function wpinv_hook_callback($args) { |
|
1467 | + do_action('wpinv_' . $args['id'], $args); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | function wpinv_set_settings_cap() { |
1471 | 1471 | return 'manage_options'; |
1472 | 1472 | } |
1473 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1473 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1474 | 1474 | |
1475 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1476 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1477 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1475 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1476 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1477 | + $value = wpinv_sanitize_amount($value, 4); |
|
1478 | 1478 | $value = $value >= 100 ? 99 : $value; |
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | return $value; |
1482 | 1482 | } |
1483 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1483 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1484 | 1484 | |
1485 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1486 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1487 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1485 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1486 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1487 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1488 | 1488 | |
1489 | - if ( $old != $new ) { |
|
1490 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1489 | + if ($old != $new) { |
|
1490 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1491 | 1491 | } |
1492 | 1492 | } |
1493 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1494 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1495 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1496 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1497 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1498 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1499 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1500 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1501 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1502 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1503 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1504 | - |
|
1505 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1493 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1494 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1495 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1496 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1497 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1498 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1499 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1500 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1501 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1502 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1503 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1504 | + |
|
1505 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1506 | 1506 | ?> |
1507 | 1507 | <div class="wpinv-email-wc-row "> |
1508 | 1508 | <div class="wpinv-email-wc-td"> |
1509 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1509 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1510 | 1510 | <p class="wpinv-email-wc-description"> |
1511 | 1511 | <?php |
1512 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1512 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1513 | 1513 | <strong>{site_title} :</strong> Site Title<br> |
1514 | 1514 | <strong>{name} :</strong> Customer\'s full name<br> |
1515 | 1515 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1524 | 1524 | <strong>{date} :</strong> Today\'s date.<br> |
1525 | 1525 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1526 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1526 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1527 | 1527 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1528 | 1528 | ?> |
1529 | 1529 | </p> |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -75,44 +75,44 @@ discard block |
||
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | 77 | <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]"> |
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,89 +183,89 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | - ) ); |
|
192 | + )); |
|
193 | 193 | ?> |
194 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
194 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | 195 | <?php } ?> |
196 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
197 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
196 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
197 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <?php |
201 | 201 | } |
202 | 202 | |
203 | - public static function prices( $post ) { |
|
203 | + public static function prices($post) { |
|
204 | 204 | $symbol = wpinv_currency_symbol(); |
205 | 205 | $position = wpinv_currency_position(); |
206 | - $item = new WPInv_Item( $post->ID ); |
|
206 | + $item = new WPInv_Item($post->ID); |
|
207 | 207 | |
208 | 208 | $price = $item->get_price(); |
209 | 209 | $is_recurring = $item->is_recurring(); |
210 | 210 | $period = $item->get_recurring_period(); |
211 | - $interval = absint( $item->get_recurring_interval() ); |
|
212 | - $times = absint( $item->get_recurring_limit() ); |
|
211 | + $interval = absint($item->get_recurring_interval()); |
|
212 | + $times = absint($item->get_recurring_limit()); |
|
213 | 213 | $free_trial = $item->has_free_trial(); |
214 | 214 | $trial_interval = $item->get_trial_interval(); |
215 | 215 | $trial_period = $item->get_trial_period(); |
216 | 216 | |
217 | 217 | $intervals = array(); |
218 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
218 | + for ($i = 1; $i <= 90; $i++) { |
|
219 | 219 | $intervals[$i] = $i; |
220 | 220 | } |
221 | 221 | |
222 | - $interval = $interval > 0 ? $interval : 1; |
|
222 | + $interval = $interval > 0 ? $interval : 1; |
|
223 | 223 | |
224 | 224 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
225 | 225 | ?> |
226 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
227 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
226 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
227 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
228 | 228 | </p> |
229 | 229 | <p class="wpinv-row-is-recurring"> |
230 | 230 | <label for="wpinv_is_recurring"> |
231 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
232 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
231 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
232 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
233 | 233 | </label> |
234 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
234 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
235 | 235 | </p> |
236 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
237 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
238 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
236 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
237 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
238 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
239 | 239 | 'options' => $intervals, |
240 | 240 | 'name' => 'wpinv_recurring_interval', |
241 | 241 | 'id' => 'wpinv_recurring_interval', |
242 | 242 | 'selected' => $interval, |
243 | 243 | 'show_option_all' => false, |
244 | 244 | 'show_option_none' => false |
245 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
246 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
245 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
246 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
247 | 247 | <span class="clear wpi-trial-clr"></span> |
248 | 248 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
249 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
250 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
249 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
250 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
251 | 251 | </label> |
252 | 252 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
253 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
253 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
254 | 254 | </label> |
255 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
255 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
256 | 256 | </p> |
257 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
258 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
257 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
258 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
259 | 259 | <?php |
260 | 260 | } |
261 | 261 | |
262 | - public static function vat_rules( $post ) { |
|
262 | + public static function vat_rules($post) { |
|
263 | 263 | global $wpinv_euvat; |
264 | 264 | |
265 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
265 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
266 | 266 | ?> |
267 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
268 | - <?php echo wpinv_html_select( array( |
|
267 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
268 | + <?php echo wpinv_html_select(array( |
|
269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
270 | 270 | 'name' => 'wpinv_vat_rules', |
271 | 271 | 'id' => 'wpinv_vat_rules', |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | 'show_option_all' => false, |
274 | 274 | 'show_option_none' => false, |
275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
276 | - ) ); ?> |
|
276 | + )); ?> |
|
277 | 277 | </p> |
278 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
279 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
278 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
279 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
280 | 280 | <?php |
281 | 281 | } |
282 | 282 | |
283 | - public static function vat_classes( $post ) { |
|
283 | + public static function vat_classes($post) { |
|
284 | 284 | global $wpinv_euvat; |
285 | 285 | |
286 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
286 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
287 | 287 | ?> |
288 | - <p><?php echo wpinv_html_select( array( |
|
288 | + <p><?php echo wpinv_html_select(array( |
|
289 | 289 | 'options' => $wpinv_euvat->get_all_classes(), |
290 | 290 | 'name' => 'wpinv_vat_class', |
291 | 291 | 'id' => 'wpinv_vat_class', |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | 'show_option_all' => false, |
294 | 294 | 'show_option_none' => false, |
295 | 295 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
296 | - ) ); ?> |
|
296 | + )); ?> |
|
297 | 297 | </p> |
298 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
298 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
299 | 299 | <?php |
300 | 300 | } |
301 | 301 | |
302 | - public static function item_info( $post ) { |
|
303 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
304 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
302 | + public static function item_info($post) { |
|
303 | + $item_type = wpinv_get_item_type($post->ID); |
|
304 | + do_action('wpinv_item_info_metabox_before', $post); |
|
305 | 305 | ?> |
306 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
307 | - <?php echo wpinv_html_select( array( |
|
306 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
307 | + <?php echo wpinv_html_select(array( |
|
308 | 308 | 'options' => wpinv_get_item_types(), |
309 | 309 | 'name' => 'wpinv_item_type', |
310 | 310 | 'id' => 'wpinv_item_type', |
@@ -312,114 +312,114 @@ discard block |
||
312 | 312 | 'show_option_all' => false, |
313 | 313 | 'show_option_none' => false, |
314 | 314 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
315 | - ) ); ?> |
|
315 | + )); ?> |
|
316 | 316 | </p> |
317 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
317 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
318 | 318 | <?php |
319 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
319 | + do_action('wpinv_item_info_metabox_after', $post); |
|
320 | 320 | } |
321 | 321 | |
322 | - public static function meta_values( $post ) { |
|
323 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
322 | + public static function meta_values($post) { |
|
323 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
324 | 324 | 'type', |
325 | 325 | 'custom_id' |
326 | - ) ); |
|
326 | + )); |
|
327 | 327 | |
328 | - if ( empty( $meta_keys ) ) { |
|
328 | + if (empty($meta_keys)) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
332 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
333 | 333 | |
334 | - foreach ( $meta_keys as $meta_key ) { |
|
334 | + foreach ($meta_keys as $meta_key) { |
|
335 | 335 | ?> |
336 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
336 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
337 | 337 | <?php |
338 | 338 | } |
339 | 339 | |
340 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
340 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
341 | 341 | } |
342 | 342 | |
343 | - public static function save( $post_id, $data, $post ) { |
|
344 | - $invoice = new WPInv_Invoice( $post_id ); |
|
343 | + public static function save($post_id, $data, $post) { |
|
344 | + $invoice = new WPInv_Invoice($post_id); |
|
345 | 345 | |
346 | 346 | // Billing |
347 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
348 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
349 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
350 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
351 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
352 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
353 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
354 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
355 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
356 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
347 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
348 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
349 | + $company = sanitize_text_field($data['wpinv_company']); |
|
350 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
351 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
352 | + $address = sanitize_text_field($data['wpinv_address']); |
|
353 | + $city = sanitize_text_field($data['wpinv_city']); |
|
354 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
355 | + $country = sanitize_text_field($data['wpinv_country']); |
|
356 | + $state = sanitize_text_field($data['wpinv_state']); |
|
357 | 357 | |
358 | 358 | // Details |
359 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
360 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
361 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
362 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
359 | + $status = sanitize_text_field($data['wpinv_status']); |
|
360 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
361 | + $number = sanitize_text_field($data['wpinv_number']); |
|
362 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
363 | 363 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
364 | 364 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
365 | 365 | |
366 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
366 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
367 | 367 | |
368 | - $invoice->set( 'due_date', $due_date ); |
|
369 | - $invoice->set( 'first_name', $first_name ); |
|
370 | - $invoice->set( 'last_name', $last_name ); |
|
371 | - $invoice->set( 'company', $company ); |
|
372 | - $invoice->set( 'vat_number', $vat_number ); |
|
373 | - $invoice->set( 'phone', $phone ); |
|
374 | - $invoice->set( 'address', $address ); |
|
375 | - $invoice->set( 'city', $city ); |
|
376 | - $invoice->set( 'zip', $zip ); |
|
377 | - $invoice->set( 'country', $country ); |
|
378 | - $invoice->set( 'state', $state ); |
|
379 | - $invoice->set( 'status', $status ); |
|
368 | + $invoice->set('due_date', $due_date); |
|
369 | + $invoice->set('first_name', $first_name); |
|
370 | + $invoice->set('last_name', $last_name); |
|
371 | + $invoice->set('company', $company); |
|
372 | + $invoice->set('vat_number', $vat_number); |
|
373 | + $invoice->set('phone', $phone); |
|
374 | + $invoice->set('address', $address); |
|
375 | + $invoice->set('city', $city); |
|
376 | + $invoice->set('zip', $zip); |
|
377 | + $invoice->set('country', $country); |
|
378 | + $invoice->set('state', $state); |
|
379 | + $invoice->set('status', $status); |
|
380 | 380 | //$invoice->set( 'number', $number ); |
381 | 381 | //$invoice->set( 'discounts', $discounts ); |
382 | 382 | //$invoice->set( 'discount', $discount ); |
383 | - $invoice->set( 'ip', $ip ); |
|
383 | + $invoice->set('ip', $ip); |
|
384 | 384 | $invoice->old_status = $_POST['original_post_status']; |
385 | 385 | $invoice->currency = wpinv_get_currency(); |
386 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
387 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
386 | + if (!empty($data['wpinv_gateway'])) { |
|
387 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
388 | 388 | } |
389 | 389 | $saved = $invoice->save(); |
390 | 390 | |
391 | 391 | // Check for payment notes |
392 | - if ( !empty( $data['invoice_note'] ) ) { |
|
393 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
394 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
392 | + if (!empty($data['invoice_note'])) { |
|
393 | + $note = wp_kses($data['invoice_note'], array()); |
|
394 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
395 | 395 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
396 | 396 | |
397 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
397 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | // Update user address if empty. |
401 | - if ( $saved && !empty( $invoice ) ) { |
|
402 | - if ( $user_id = $invoice->get_user_id() ) { |
|
403 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
401 | + if ($saved && !empty($invoice)) { |
|
402 | + if ($user_id = $invoice->get_user_id()) { |
|
403 | + $user_address = wpinv_get_user_address($user_id, false); |
|
404 | 404 | |
405 | 405 | if (empty($user_address['first_name'])) { |
406 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
407 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
406 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
407 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
408 | 408 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
409 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
409 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
413 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
414 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
415 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
416 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
417 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
418 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
413 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
414 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
415 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
416 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
417 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
418 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
422 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | return $saved; |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
10 | 10 | $statuses = wpinv_get_invoice_statuses(); |
11 | 11 | |
12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
13 | + $invoice = new WPInv_Invoice($post_id); |
|
14 | 14 | |
15 | - $status = $invoice->get_status( false ); // Current status |
|
15 | + $status = $invoice->get_status(false); // Current status |
|
16 | 16 | $discount = $invoice->get_discount(); |
17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
18 | 18 | $invoice_number = $invoice->get_number(); |
19 | 19 | |
20 | 20 | $date_created = $invoice->get_created_date(); |
21 | - $datetime_created = strtotime( $date_created ); |
|
22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
21 | + $datetime_created = strtotime($date_created); |
|
22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
23 | 23 | $date_completed = $invoice->get_completed_date(); |
24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
25 | - $title['status'] = __( 'Invoice Status:', 'invoicing' ); |
|
26 | - $title['number'] = __( 'Invoice Number:', 'invoicing' ); |
|
27 | - $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing' ); |
|
24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
25 | + $title['status'] = __('Invoice Status:', 'invoicing'); |
|
26 | + $title['number'] = __('Invoice Number:', 'invoicing'); |
|
27 | + $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing'); |
|
28 | 28 | |
29 | 29 | $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice); |
30 | 30 | $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice); |
@@ -34,35 +34,35 @@ discard block |
||
34 | 34 | <div class="gdmbx2-wrap form-table"> |
35 | 35 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
36 | 36 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
37 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
38 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
37 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
38 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
39 | 39 | </div> |
40 | - <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
40 | + <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?> |
|
41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
42 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
42 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
43 | 43 | <div class="gdmbx-td"> |
44 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
44 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | <?php } ?> |
48 | - <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?> |
|
49 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
48 | + <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?> |
|
49 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
50 | 50 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
51 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
52 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
51 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
52 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
53 | 53 | </div> |
54 | 54 | <?php } ?> |
55 | - <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?> |
|
55 | + <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?> |
|
56 | 56 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed"> |
57 | - <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div> |
|
58 | - <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div> |
|
57 | + <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div> |
|
58 | + <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div> |
|
59 | 59 | </div> |
60 | 60 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
61 | 61 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
62 | 62 | <div class="gdmbx-td"> |
63 | 63 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
64 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
65 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
64 | + <?php foreach ($statuses as $value => $label) { ?> |
|
65 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
66 | 66 | <?php } ?> |
67 | 67 | </select> |
68 | 68 | </div> |
@@ -70,117 +70,117 @@ discard block |
||
70 | 70 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
71 | 71 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
72 | 72 | <div class="gdmbx-td"> |
73 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
73 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
74 | 74 | </div> |
75 | 75 | </div> |
76 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); |
|
76 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); |
|
77 | 77 | $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id); |
78 | 78 | ?> |
79 | - <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?> |
|
79 | + <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?> |
|
80 | 80 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
81 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
81 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
82 | 82 | <div class="gdmbx-td"> |
83 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
83 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
84 | 84 | </div> |
85 | 85 | </div> |
86 | 86 | <?php } ?> |
87 | 87 | </div> |
88 | 88 | </div> |
89 | 89 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
90 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label> |
|
90 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label> |
|
91 | 91 | <select id="wpi_save_send" name="wpi_save_send"> |
92 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
93 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
92 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
93 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
94 | 94 | </select> |
95 | 95 | </p> |
96 | 96 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
97 | 97 | </div> |
98 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
98 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
99 | 99 | <?php |
100 | 100 | } |
101 | 101 | |
102 | - public static function resend_invoice( $post ) { |
|
102 | + public static function resend_invoice($post) { |
|
103 | 103 | global $wpi_mb_invoice; |
104 | 104 | |
105 | - if ( empty( $wpi_mb_invoice ) ) { |
|
105 | + if (empty($wpi_mb_invoice)) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $text = array( |
110 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
111 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
110 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
111 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
115 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
115 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
116 | 116 | |
117 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
117 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
118 | 118 | $email_actions = array(); |
119 | - $email_actions['email_url'] = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ); |
|
120 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
119 | + $email_actions['email_url'] = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))); |
|
120 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
121 | 121 | |
122 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
122 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
123 | 123 | ?> |
124 | 124 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
125 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
126 | - <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
127 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
125 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
126 | + <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
127 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
128 | 128 | <?php } ?> |
129 | 129 | <?php |
130 | 130 | } |
131 | 131 | |
132 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
132 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
133 | 133 | } |
134 | 134 | |
135 | - public static function subscriptions( $post ) { |
|
136 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
135 | + public static function subscriptions($post) { |
|
136 | + $invoice = wpinv_get_invoice($post->ID); |
|
137 | 137 | |
138 | - if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
139 | - $subscription = wpinv_get_subscription( $invoice ); |
|
138 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
139 | + $subscription = wpinv_get_subscription($invoice); |
|
140 | 140 | |
141 | - if ( empty( $subscription ) ) { |
|
141 | + if (empty($subscription)) { |
|
142 | 142 | ?> |
143 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p> |
|
143 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p> |
|
144 | 144 | <?php |
145 | 145 | return; |
146 | 146 | } |
147 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
148 | - $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
149 | - $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
147 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
148 | + $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
149 | + $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
150 | 150 | $payments = $subscription->get_child_payments(); |
151 | 151 | ?> |
152 | 152 | <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
153 | - <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?> |
|
153 | + <?php if (!empty($subscription) && !empty($subscription->id)) { ?> |
|
154 | 154 | <p class="wpi-meta-row wpi-sub-id"> |
155 | - <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
155 | + <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
156 | 156 | <?php } ?> |
157 | 157 | <p class="wpi-meta-row wpi-bill-cycle"> |
158 | - <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?> |
|
158 | + <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?> |
|
159 | 159 | </p> |
160 | 160 | <p class="wpi-meta-row wpi-billed-times"> |
161 | - <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
161 | + <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?> |
|
162 | 162 | </p> |
163 | 163 | <p class="wpi-meta-row wpi-start-date"> |
164 | - <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
164 | + <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?> |
|
165 | 165 | </p> |
166 | 166 | <p class="wpi-meta-row wpi-end-date"> |
167 | - <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
167 | + <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?> |
|
168 | 168 | </p> |
169 | - <?php if ( $subscription->status ) { ?> |
|
169 | + <?php if ($subscription->status) { ?> |
|
170 | 170 | <p class="wpi-meta-row wpi-sub-status"> |
171 | - <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
171 | + <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
172 | 172 | </p> |
173 | 173 | <?php } ?> |
174 | - <?php if ( !empty( $payments ) ) { ?> |
|
175 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
174 | + <?php if (!empty($payments)) { ?> |
|
175 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
176 | 176 | <ul id="wpi-sub-payments"> |
177 | - <?php foreach ( $payments as $payment ) { |
|
177 | + <?php foreach ($payments as $payment) { |
|
178 | 178 | $invoice_id = $payment->ID; |
179 | 179 | ?> |
180 | 180 | <li> |
181 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
182 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
183 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
181 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
182 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
183 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
184 | 184 | </li> |
185 | 185 | <?php } ?> |
186 | 186 | </ul> |
@@ -188,50 +188,50 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - public static function renewals( $post ) { |
|
192 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
191 | + public static function renewals($post) { |
|
192 | + $invoice = wpinv_get_invoice($post->ID); |
|
193 | 193 | |
194 | - if ( wpinv_is_subscription_payment( $invoice ) ) { |
|
195 | - $parent_url = get_edit_post_link( $invoice->parent_invoice ); |
|
196 | - $parent_id = wpinv_get_invoice_number( $invoice->parent_invoice ); |
|
197 | - $subscription = wpinv_get_subscription( $invoice ); |
|
194 | + if (wpinv_is_subscription_payment($invoice)) { |
|
195 | + $parent_url = get_edit_post_link($invoice->parent_invoice); |
|
196 | + $parent_id = wpinv_get_invoice_number($invoice->parent_invoice); |
|
197 | + $subscription = wpinv_get_subscription($invoice); |
|
198 | 198 | ?> |
199 | - <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
200 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
199 | + <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
200 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - public static function payment_meta( $post ) { |
|
205 | + public static function payment_meta($post) { |
|
206 | 206 | global $wpi_mb_invoice; |
207 | 207 | |
208 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
209 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) { |
|
208 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
209 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) { |
|
210 | 210 | $set_dateway = true; |
211 | 211 | } |
212 | 212 | |
213 | 213 | ?> |
214 | 214 | <p class="wpi-meta-row"> |
215 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
216 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
215 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
216 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
217 | 217 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
218 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
219 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
218 | + <?php foreach ($gateways as $name => $gateway) { |
|
219 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | ?> |
223 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
223 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
224 | 224 | <?php } ?> |
225 | 225 | </select> |
226 | 226 | <?php } else { |
227 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) ); |
|
227 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway)); |
|
228 | 228 | } ?> |
229 | 229 | </p> |
230 | - <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?> |
|
231 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p> |
|
230 | + <?php if ($key = $wpi_mb_invoice->get_key()) { ?> |
|
231 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p> |
|
232 | 232 | <?php } ?> |
233 | - <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?> |
|
234 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
233 | + <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?> |
|
234 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
235 | 235 | <?php } ?> |
236 | 236 | <?php |
237 | 237 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if (!empty($_GET['id'])) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
23 | 23 | </h1> |
24 | 24 | <?php |
25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <input type="hidden" name="post_type" value="download" /> |
32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
33 | 33 | <?php $subscribers_table->views(); ?> |
34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
35 | 35 | <?php $subscribers_table->display(); ?> |
36 | 36 | |
37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
49 | 49 | |
50 | 50 | $render = true; |
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
52 | + if (!current_user_can('manage_invoicing')) { |
|
53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
58 | 58 | } |
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int)$_GET['id']; |
|
61 | + $sub = new WPInv_Subscription($sub_id); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
63 | + if (empty($sub)) { |
|
64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | ?> |
68 | 68 | <div class="wrap"> |
69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
70 | 70 | |
71 | - <?php if ( $sub ) : ?> |
|
71 | + <?php if ($sub) : ?> |
|
72 | 72 | |
73 | 73 | <div id="wpinv-item-card-wrapper"> |
74 | 74 | |
75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
76 | 76 | |
77 | 77 | <div class="info-wrapper item-section"> |
78 | 78 | |
79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
80 | 80 | |
81 | 81 | <div class="item-info"> |
82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td class="row-title"> |
87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
95 | 95 | ?> |
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
99 | 99 | <td class="row-title"> |
100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
101 | 101 | </td> |
102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
103 | 103 | </tr> |
104 | 104 | <tr> |
105 | 105 | <td class="row-title"> |
106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
107 | 107 | </td> |
108 | 108 | <td> |
109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
110 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&view=overview&id=' . $subscriber->ID ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
110 | + <a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&view=overview&id=' . $subscriber->ID)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
111 | 111 | </td> |
112 | 112 | </tr> |
113 | 113 | <tr> |
114 | 114 | <td class="row-title"> |
115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
116 | 116 | </td> |
117 | 117 | <td> |
118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
119 | 119 | </tr> |
120 | 120 | <tr> |
121 | 121 | <td class="row-title"> |
122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
123 | 123 | </td> |
124 | 124 | <td> |
125 | 125 | <?php |
126 | - echo wpinv_item_dropdown( array( |
|
126 | + echo wpinv_item_dropdown(array( |
|
127 | 127 | 'name' => 'product_id', |
128 | 128 | 'id' => 'wpinv_invoice_item', |
129 | 129 | 'with_packages' => false, |
130 | 130 | 'show_recurring' => true, |
131 | 131 | 'selected' => $sub->product_id, |
132 | 132 | 'class' => 'wpinv-sub-product-id', |
133 | - ) ); |
|
133 | + )); |
|
134 | 134 | |
135 | 135 | ?> |
136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
137 | 137 | 'post' => $sub->product_id, |
138 | 138 | 'action' => 'edit' |
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
143 | 143 | <td class="row-title"> |
144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
145 | 145 | </td> |
146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
147 | 147 | </tr> |
148 | 148 | <tr> |
149 | 149 | <td class="row-title"> |
150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
151 | 151 | </td> |
152 | 152 | <td> |
153 | 153 | <span class="wpinv-sub-profile-id"> |
154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
155 | 155 | </span> |
156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
157 | 157 | <span> – </span> |
158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | 161 | <tr> |
162 | 162 | <td class="row-title"> |
163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
164 | 164 | </td> |
165 | 165 | <td> |
166 | 166 | <span class="wpinv-sub-transaction-id"><?php echo $sub->get_transaction_id(); ?></span> |
167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
168 | 168 | <span> – </span> |
169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
170 | 170 | </td> |
171 | 171 | </tr> |
172 | 172 | <tr> |
173 | 173 | <td class="row-title"> |
174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
175 | 175 | </td> |
176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
177 | 177 | </tr> |
178 | 178 | <tr> |
179 | 179 | <td class="row-title"> |
180 | 180 | <label for="tablecell"> |
181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
181 | + <?php if ('trialling' == $sub->status) : ?> |
|
182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
183 | 183 | <?php else: ?> |
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
185 | 185 | <?php endif; ?> |
186 | 186 | </label> |
187 | 187 | </td> |
188 | 188 | <td> |
189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | 192 | <tr> |
193 | 193 | <td class="row-title"> |
194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
195 | 195 | </td> |
196 | 196 | <td> |
197 | 197 | <select name="status"> |
198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
205 | 205 | </select> |
206 | 206 | </td> |
207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
209 | 209 | </table> |
210 | 210 | </div> |
211 | 211 | <div id="wpinv-sub-notices"> |
212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
214 | 214 | </div> |
215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
219 | - <?php if( $sub->can_cancel() ) : ?> |
|
220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
219 | + <?php if ($sub->can_cancel()) : ?> |
|
220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
221 | 221 | <?php endif; ?> |
222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
223 | 223 | </div> |
224 | 224 | |
225 | 225 | </form> |
226 | 226 | </div> |
227 | 227 | |
228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
229 | 229 | |
230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
231 | 231 | |
232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
233 | 233 | |
234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
235 | 235 | |
236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
240 | 240 | <?php endif; ?> |
241 | 241 | <table class="wp-list-table widefat striped payments"> |
242 | 242 | <thead> |
243 | 243 | <tr> |
244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
250 | 250 | </tr> |
251 | 251 | </thead> |
252 | 252 | <tbody> |
253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
253 | + <?php if (!empty($payments)) : ?> |
|
254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
255 | 255 | <tr> |
256 | 256 | <td><?php echo $payment->ID; ?></td> |
257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
260 | 260 | <td> |
261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
263 | 263 | </td> |
264 | 264 | <td class="column-wpi_actions"> |
265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
266 | 266 | </a> |
267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
268 | 268 | </td> |
269 | 269 | </tr> |
270 | 270 | <?php endforeach; ?> |
271 | 271 | <?php else: ?> |
272 | 272 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
274 | 274 | </tr> |
275 | 275 | <?php endif; ?> |
276 | 276 | </tbody> |
277 | 277 | <tfoot></tfoot> |
278 | 278 | </table> |
279 | 279 | |
280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
281 | 281 | |
282 | 282 | </div> |
283 | 283 | |
284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
285 | 285 | </div> |
286 | 286 | |
287 | 287 | <?php endif; ?> |
@@ -299,38 +299,38 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
302 | + if (empty($_POST['sub_id'])) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
310 | + if (!current_user_can('manage_invoicing')) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
316 | 316 | } |
317 | 317 | |
318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | - $product_id = absint( $_POST['product_id'] ); |
|
322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | - $subscription->update( array( |
|
324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
318 | + $expiration = date('Y-m-d 23:59:59', strtotime($_POST['expiration'])); |
|
319 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
320 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
321 | + $product_id = absint($_POST['product_id']); |
|
322 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
323 | + $subscription->update(array( |
|
324 | + 'status' => sanitize_text_field($_POST['status']), |
|
325 | 325 | 'expiration' => $expiration, |
326 | 326 | 'profile_id' => $profile_id, |
327 | 327 | 'product_id' => $product_id, |
328 | 328 | 'transaction_id' => $transaction_id, |
329 | - ) ); |
|
329 | + )); |
|
330 | 330 | |
331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
331 | + $status = sanitize_text_field($_POST['status']); |
|
332 | 332 | |
333 | - switch( $status ) { |
|
333 | + switch ($status) { |
|
334 | 334 | |
335 | 335 | case 'cancelled' : |
336 | 336 | |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
352 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
353 | 353 | exit; |
354 | 354 | |
355 | 355 | } |
356 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
356 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Handles subscription deletion |
@@ -364,30 +364,30 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
366 | 366 | |
367 | - if( empty( $_POST['sub_id'] ) ) { |
|
367 | + if (empty($_POST['sub_id'])) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
371 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
375 | + if (!current_user_can('manage_invoicing')) { |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
380 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
381 | 381 | } |
382 | 382 | |
383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
383 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
384 | 384 | |
385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
385 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
386 | 386 | |
387 | 387 | $subscription->delete(); |
388 | 388 | |
389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
389 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
390 | 390 | exit; |
391 | 391 | |
392 | 392 | } |
393 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
393 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,92 +72,92 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
86 | 86 | |
87 | - if ( !$allowed ) { |
|
87 | + if (!$allowed) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $field == '_wpinv_price' ) { |
|
92 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
91 | + if ($field == '_wpinv_price') { |
|
92 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
93 | 93 | } else { |
94 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
94 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
95 | 95 | } |
96 | 96 | |
97 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
98 | - update_post_meta( $post_id, $field, $value ); |
|
97 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
98 | + update_post_meta($post_id, $field, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
103 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
102 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
103 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
108 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
109 | 109 | |
110 | 110 | function wpinv_register_item_meta_boxes() { |
111 | 111 | global $wpinv_euvat; |
112 | 112 | |
113 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
113 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
114 | 114 | |
115 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
116 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
115 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
116 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
120 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
119 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
120 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
121 | 121 | } |
122 | 122 | |
123 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
124 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
123 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
124 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function wpinv_register_discount_meta_boxes() { |
128 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
128 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_discount_metabox_details( $post ) { |
|
131 | +function wpinv_discount_metabox_details($post) { |
|
132 | 132 | $discount_id = $post->ID; |
133 | - $discount = wpinv_get_discount( $discount_id ); |
|
133 | + $discount = wpinv_get_discount($discount_id); |
|
134 | 134 | |
135 | - $type = wpinv_get_discount_type( $discount_id ); |
|
136 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
137 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
138 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
139 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
140 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
141 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
142 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
143 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
144 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
135 | + $type = wpinv_get_discount_type($discount_id); |
|
136 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
137 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
138 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
139 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
140 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
141 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
142 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
143 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
144 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
145 | 145 | |
146 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
147 | - $start_time = strtotime( $start_date ); |
|
148 | - $start_h = date_i18n( 'H', $start_time ); |
|
149 | - $start_m = date_i18n( 'i', $start_time ); |
|
150 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
146 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
147 | + $start_time = strtotime($start_date); |
|
148 | + $start_h = date_i18n('H', $start_time); |
|
149 | + $start_m = date_i18n('i', $start_time); |
|
150 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
151 | 151 | } else { |
152 | 152 | $start_h = '00'; |
153 | 153 | $start_m = '00'; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
157 | - $expiration_time = strtotime( $expiration_date ); |
|
158 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
159 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
160 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
156 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
157 | + $expiration_time = strtotime($expiration_date); |
|
158 | + $expiration_h = date_i18n('H', $expiration_time); |
|
159 | + $expiration_m = date_i18n('i', $expiration_time); |
|
160 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
161 | 161 | } else { |
162 | 162 | $expiration_h = '23'; |
163 | 163 | $expiration_m = '59'; |
@@ -167,207 +167,207 @@ discard block |
||
167 | 167 | $max_total = $max_total > 0 ? $max_total : ''; |
168 | 168 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
169 | 169 | ?> |
170 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
171 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
170 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
171 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
172 | 172 | <table class="form-table wpi-form-table"> |
173 | 173 | <tbody> |
174 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
175 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
182 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
182 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
183 | 183 | </td> |
184 | 184 | </tr> |
185 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
186 | 186 | <tr> |
187 | 187 | <th valign="top" scope="row"> |
188 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
188 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
189 | 189 | </th> |
190 | 190 | <td> |
191 | 191 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
192 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
193 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
192 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
193 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
194 | 194 | <?php } ?> |
195 | 195 | </select> |
196 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
196 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
197 | 197 | </td> |
198 | 198 | </tr> |
199 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
199 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
200 | 200 | <tr> |
201 | 201 | <th valign="top" scope="row"> |
202 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
202 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
203 | 203 | </th> |
204 | 204 | <td> |
205 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
206 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
207 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
205 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
206 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
207 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <p><?php echo wpinv_item_dropdown( array( |
|
216 | + <p><?php echo wpinv_item_dropdown(array( |
|
217 | 217 | 'name' => 'items[]', |
218 | 218 | 'id' => 'items', |
219 | 219 | 'selected' => $item_reqs, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'class' => 'medium-text', |
222 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
222 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
223 | 223 | 'show_recurring' => true, |
224 | - ) ); ?> |
|
224 | + )); ?> |
|
225 | 225 | </p> |
226 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
226 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <p><?php echo wpinv_item_dropdown( array( |
|
235 | + <p><?php echo wpinv_item_dropdown(array( |
|
236 | 236 | 'name' => 'excluded_items[]', |
237 | 237 | 'id' => 'excluded_items', |
238 | 238 | 'selected' => $excluded_items, |
239 | 239 | 'multiple' => true, |
240 | 240 | 'class' => 'medium-text', |
241 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
242 | 242 | 'show_recurring' => true, |
243 | - ) ); ?> |
|
243 | + )); ?> |
|
244 | 244 | </p> |
245 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
245 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
246 | 246 | </td> |
247 | 247 | </tr> |
248 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
248 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
249 | 249 | <tr> |
250 | 250 | <th valign="top" scope="row"> |
251 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
251 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
252 | 252 | </th> |
253 | 253 | <td> |
254 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
256 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
254 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
256 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
257 | 257 | <?php } ?> |
258 | 258 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
259 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
260 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
259 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
260 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
261 | 261 | <?php } ?> |
262 | 262 | </select> |
263 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
274 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
272 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
274 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
275 | 275 | <?php } ?> |
276 | 276 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
277 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
278 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
277 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
278 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
279 | 279 | <?php } ?> |
280 | 280 | </select> |
281 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
281 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
282 | 282 | </td> |
283 | 283 | </tr> |
284 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
284 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
285 | 285 | <tr> |
286 | 286 | <th valign="top" scope="row"> |
287 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
287 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
288 | 288 | </th> |
289 | 289 | <td> |
290 | 290 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
291 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
291 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
292 | 292 | </td> |
293 | 293 | </tr> |
294 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
294 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
295 | 295 | <tr> |
296 | 296 | <th valign="top" scope="row"> |
297 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
297 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
298 | 298 | </th> |
299 | 299 | <td> |
300 | 300 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
301 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
301 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
302 | 302 | </td> |
303 | 303 | </tr> |
304 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
304 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
305 | 305 | <tr> |
306 | 306 | <th valign="top" scope="row"> |
307 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
307 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
308 | 308 | </th> |
309 | 309 | <td> |
310 | 310 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
311 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
312 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
311 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
312 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
313 | 313 | </select> |
314 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
314 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
315 | 315 | </td> |
316 | 316 | </tr> |
317 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
317 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
318 | 318 | <tr> |
319 | 319 | <th valign="top" scope="row"> |
320 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
320 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
321 | 321 | </th> |
322 | 322 | <td> |
323 | 323 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
324 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
324 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
325 | 325 | </td> |
326 | 326 | </tr> |
327 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
328 | 328 | <tr> |
329 | 329 | <th valign="top" scope="row"> |
330 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
330 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
331 | 331 | </th> |
332 | 332 | <td> |
333 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
334 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
333 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
334 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
335 | 335 | </td> |
336 | 336 | </tr> |
337 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
337 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
338 | 338 | </tbody> |
339 | 339 | </table> |
340 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
340 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
341 | 341 | <?php |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
345 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
344 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
345 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
346 | 346 | |
347 | - if ( $post_type != 'wpi_discount' ) { |
|
347 | + if ($post_type != 'wpi_discount') { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
351 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
355 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
359 | + if (!current_user_can('manage_options', $post_id)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
363 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
364 | 364 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
367 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
368 | 368 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
369 | 369 | } |
370 | 370 | |
371 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
371 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
372 | 372 | } |
373 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
374 | 373 | \ No newline at end of file |
374 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
375 | 375 | \ No newline at end of file |
@@ -7,264 +7,264 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'number' => __( 'Number', 'invoicing' ), |
|
18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
22 | - 'status' => __( 'Status', 'invoicing' ), |
|
23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
22 | + 'status' => __('Status', 'invoicing'), |
|
23 | + 'ID' => __('ID', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
40 | 40 | |
41 | -function wpinv_sortable_columns( $columns ) { |
|
41 | +function wpinv_sortable_columns($columns) { |
|
42 | 42 | $columns = array( |
43 | - 'ID' => array( 'ID', true ), |
|
44 | - 'number' => array( 'number', false ), |
|
45 | - 'amount' => array( 'amount', false ), |
|
46 | - 'invoice_date' => array( 'date', false ), |
|
47 | - 'payment_date' => array( 'payment_date', true ), |
|
48 | - 'customer' => array( 'customer', false ), |
|
49 | - 'status' => array( 'status', false ), |
|
43 | + 'ID' => array('ID', true), |
|
44 | + 'number' => array('number', false), |
|
45 | + 'amount' => array('amount', false), |
|
46 | + 'invoice_date' => array('date', false), |
|
47 | + 'payment_date' => array('payment_date', true), |
|
48 | + 'customer' => array('customer', false), |
|
49 | + 'status' => array('status', false), |
|
50 | 50 | ); |
51 | 51 | |
52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
53 | 53 | } |
54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
55 | 55 | |
56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
58 | 58 | global $post, $wpi_invoice; |
59 | 59 | |
60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $value = NULL; |
65 | 65 | |
66 | - switch ( $column_name ) { |
|
66 | + switch ($column_name) { |
|
67 | 67 | case 'email' : |
68 | - $value = $wpi_invoice->get_email(); |
|
68 | + $value = $wpi_invoice->get_email(); |
|
69 | 69 | break; |
70 | 70 | case 'customer' : |
71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
74 | + if ($email = $wpi_invoice->get_email()) { |
|
75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'amount' : |
79 | - echo $wpi_invoice->get_total( true ); |
|
79 | + echo $wpi_invoice->get_total(true); |
|
80 | 80 | break; |
81 | 81 | case 'invoice_date' : |
82 | - $date_format = get_option( 'date_format' ); |
|
83 | - $time_format = get_option( 'time_format' ); |
|
84 | - $date_time_format = $date_format . ' '. $time_format; |
|
82 | + $date_format = get_option('date_format'); |
|
83 | + $time_format = get_option('time_format'); |
|
84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
85 | 85 | |
86 | - $t_time = get_the_time( $date_time_format ); |
|
86 | + $t_time = get_the_time($date_time_format); |
|
87 | 87 | $m_time = $post->post_date; |
88 | - $h_time = mysql2date( $date_format, $m_time ); |
|
88 | + $h_time = mysql2date($date_format, $m_time); |
|
89 | 89 | |
90 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
90 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
91 | 91 | break; |
92 | 92 | case 'payment_date' : |
93 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
94 | - $date_format = get_option( 'date_format' ); |
|
95 | - $time_format = get_option( 'time_format' ); |
|
96 | - $date_time_format = $date_format . ' '. $time_format; |
|
93 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
94 | + $date_format = get_option('date_format'); |
|
95 | + $time_format = get_option('time_format'); |
|
96 | + $date_time_format = $date_format . ' ' . $time_format; |
|
97 | 97 | |
98 | - $t_time = get_the_time( $date_time_format ); |
|
98 | + $t_time = get_the_time($date_time_format); |
|
99 | 99 | $m_time = $date_completed; |
100 | - $h_time = mysql2date( $date_format, $m_time ); |
|
100 | + $h_time = mysql2date($date_format, $m_time); |
|
101 | 101 | |
102 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
102 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
103 | 103 | } else { |
104 | 104 | $value = '-'; |
105 | 105 | } |
106 | 106 | break; |
107 | 107 | case 'status' : |
108 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
109 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
110 | - if ( 1 == $is_viewed ) { |
|
111 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
108 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
109 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
110 | + if (1 == $is_viewed) { |
|
111 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
112 | 112 | } |
113 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) { |
|
114 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
113 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) { |
|
114 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
115 | 115 | } |
116 | 116 | break; |
117 | 117 | case 'number' : |
118 | - $edit_link = get_edit_post_link( $post->ID ); |
|
119 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
118 | + $edit_link = get_edit_post_link($post->ID); |
|
119 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
120 | 120 | break; |
121 | 121 | case 'wpi_actions' : |
122 | 122 | $value = ''; |
123 | - if ( !empty( $post->post_name ) ) { |
|
124 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
123 | + if (!empty($post->post_name)) { |
|
124 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( $email = $wpi_invoice->get_email() ) { |
|
128 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
127 | + if ($email = $wpi_invoice->get_email()) { |
|
128 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | break; |
132 | 132 | default: |
133 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
133 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
134 | 134 | break; |
135 | 135 | |
136 | 136 | } |
137 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
137 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
138 | 138 | |
139 | - if ( $value !== NULL ) { |
|
139 | + if ($value !== NULL) { |
|
140 | 140 | echo $value; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | -function wpinv_admin_post_id( $id = 0 ) { |
|
144 | +function wpinv_admin_post_id($id = 0) { |
|
145 | 145 | global $post; |
146 | 146 | |
147 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
147 | + if (isset($id) && !empty($id)) { |
|
148 | 148 | return (int)$id; |
149 | - } else if ( get_the_ID() ) { |
|
150 | - return (int) get_the_ID(); |
|
151 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
152 | - return (int) $post->ID; |
|
153 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
154 | - return (int) $_GET['post']; |
|
155 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
156 | - return (int) $_GET['id']; |
|
157 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
158 | - return (int) $_POST['id']; |
|
149 | + } else if (get_the_ID()) { |
|
150 | + return (int)get_the_ID(); |
|
151 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
152 | + return (int)$post->ID; |
|
153 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
154 | + return (int)$_GET['post']; |
|
155 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
156 | + return (int)$_GET['id']; |
|
157 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
158 | + return (int)$_POST['id']; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return null; |
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_admin_post_type( $id = 0 ) { |
|
165 | - if ( !$id ) { |
|
164 | +function wpinv_admin_post_type($id = 0) { |
|
165 | + if (!$id) { |
|
166 | 166 | $id = wpinv_admin_post_id(); |
167 | 167 | } |
168 | 168 | |
169 | - $type = get_post_type( $id ); |
|
169 | + $type = get_post_type($id); |
|
170 | 170 | |
171 | - if ( !$type ) { |
|
172 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
171 | + if (!$type) { |
|
172 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
173 | 173 | } |
174 | 174 | |
175 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
175 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | 179 | global $wpinv_options, $pagenow, $post; |
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
181 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
182 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
185 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
186 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
189 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
190 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
193 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
194 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
197 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
198 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
201 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
202 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
203 | 203 | } |
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
205 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
206 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
210 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
213 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
214 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
215 | 215 | } |
216 | 216 | |
217 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
218 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
217 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
218 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
221 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
222 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
225 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
226 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
229 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
230 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
231 | 231 | } |
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
234 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
236 | + if (!empty($message)) { |
|
237 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors('wpinv-notices'); |
|
242 | 242 | } |
243 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
243 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
244 | 244 | |
245 | -function wpinv_items_columns( $existing_columns ) { |
|
245 | +function wpinv_items_columns($existing_columns) { |
|
246 | 246 | global $wpinv_euvat; |
247 | 247 | |
248 | 248 | $columns = array(); |
249 | 249 | $columns['cb'] = $existing_columns['cb']; |
250 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
251 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
252 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
253 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
250 | + $columns['title'] = __('Title', 'invoicing'); |
|
251 | + $columns['price'] = __('Price', 'invoicing'); |
|
252 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
253 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
254 | 254 | } |
255 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
256 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
255 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
256 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
257 | 257 | } |
258 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
259 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
260 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
261 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
258 | + $columns['type'] = __('Type', 'invoicing'); |
|
259 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
260 | + $columns['date'] = __('Date', 'invoicing'); |
|
261 | + $columns['id'] = __('ID', 'invoicing'); |
|
262 | 262 | |
263 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
263 | + return apply_filters('wpinv_items_columns', $columns); |
|
264 | 264 | } |
265 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
265 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
266 | 266 | |
267 | -function wpinv_items_sortable_columns( $columns ) { |
|
267 | +function wpinv_items_sortable_columns($columns) { |
|
268 | 268 | $columns['price'] = 'price'; |
269 | 269 | $columns['vat_rule'] = 'vat_rule'; |
270 | 270 | $columns['vat_class'] = 'vat_class'; |
@@ -274,151 +274,151 @@ discard block |
||
274 | 274 | |
275 | 275 | return $columns; |
276 | 276 | } |
277 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
277 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
278 | 278 | |
279 | -function wpinv_items_table_custom_column( $column ) { |
|
279 | +function wpinv_items_table_custom_column($column) { |
|
280 | 280 | global $wpinv_euvat, $post, $wpi_item; |
281 | 281 | |
282 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
283 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
282 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
283 | + $wpi_item = new WPInv_Item($post->ID); |
|
284 | 284 | } |
285 | 285 | |
286 | - switch ( $column ) { |
|
286 | + switch ($column) { |
|
287 | 287 | case 'price' : |
288 | - echo wpinv_item_price( $post->ID ); |
|
288 | + echo wpinv_item_price($post->ID); |
|
289 | 289 | break; |
290 | 290 | case 'vat_rule' : |
291 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
291 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
292 | 292 | break; |
293 | 293 | case 'vat_class' : |
294 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
294 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
295 | 295 | break; |
296 | 296 | case 'type' : |
297 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
297 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
298 | 298 | break; |
299 | 299 | case 'recurring' : |
300 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
300 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | 304 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
305 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
306 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
307 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
305 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
306 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
307 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
308 | 308 | } |
309 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
310 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
309 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
310 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
311 | 311 | } |
312 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
312 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
313 | 313 | </div>'; |
314 | 314 | break; |
315 | 315 | } |
316 | 316 | |
317 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
317 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
318 | 318 | } |
319 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
319 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
320 | 320 | |
321 | 321 | function wpinv_add_items_filters() { |
322 | 322 | global $wpinv_euvat, $typenow; |
323 | 323 | |
324 | 324 | // Checks if the current post type is 'item' |
325 | - if ( $typenow == 'wpi_item') { |
|
326 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
327 | - echo wpinv_html_select( array( |
|
328 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
325 | + if ($typenow == 'wpi_item') { |
|
326 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
327 | + echo wpinv_html_select(array( |
|
328 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
329 | 329 | 'name' => 'vat_rule', |
330 | 330 | 'id' => 'vat_rule', |
331 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
331 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
332 | 332 | 'show_option_all' => false, |
333 | 333 | 'show_option_none' => false, |
334 | 334 | 'class' => 'gdmbx2-text-medium', |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | } |
337 | 337 | |
338 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
339 | - echo wpinv_html_select( array( |
|
340 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
338 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
339 | + echo wpinv_html_select(array( |
|
340 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
341 | 341 | 'name' => 'vat_class', |
342 | 342 | 'id' => 'vat_class', |
343 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
343 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false, |
346 | 346 | 'class' => 'gdmbx2-text-medium', |
347 | - ) ); |
|
347 | + )); |
|
348 | 348 | } |
349 | 349 | |
350 | - echo wpinv_html_select( array( |
|
351 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
350 | + echo wpinv_html_select(array( |
|
351 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
352 | 352 | 'name' => 'type', |
353 | 353 | 'id' => 'type', |
354 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
354 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
355 | 355 | 'show_option_all' => false, |
356 | 356 | 'show_option_none' => false, |
357 | 357 | 'class' => 'gdmbx2-text-medium', |
358 | - ) ); |
|
358 | + )); |
|
359 | 359 | |
360 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
360 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
361 | 361 | echo '<input type="hidden" name="all_posts" value="1" />'; |
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
365 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
365 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
366 | 366 | |
367 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
368 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
367 | +function wpinv_send_invoice_after_save($invoice) { |
|
368 | + if (empty($_POST['wpi_save_send'])) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
373 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
372 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
373 | + wpinv_user_invoice_notification($invoice->ID); |
|
374 | 374 | } |
375 | 375 | } |
376 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
376 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
377 | 377 | |
378 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
379 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
380 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
381 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
378 | +function wpinv_send_register_new_user($data, $postarr) { |
|
379 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
380 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
381 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
382 | 382 | |
383 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
384 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
385 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
386 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
387 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
388 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
383 | + if ($is_new_user && $email && !email_exists($email)) { |
|
384 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
385 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
386 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
387 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
388 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
389 | 389 | |
390 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
391 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
390 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
391 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
392 | 392 | $new_user_login = strstr($email, '@', true); |
393 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
394 | - $user_login = sanitize_user($new_user_login, true ); |
|
393 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
394 | + $user_login = sanitize_user($new_user_login, true); |
|
395 | 395 | } |
396 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
397 | - $user_append_text = rand(10,1000); |
|
398 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
396 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
397 | + $user_append_text = rand(10, 1000); |
|
398 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
399 | 399 | } |
400 | 400 | |
401 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
401 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
402 | 402 | $user_login = $email; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | 406 | $userdata = array( |
407 | 407 | 'user_login' => $user_login, |
408 | - 'user_pass' => wp_generate_password( 12, false ), |
|
409 | - 'user_email' => sanitize_text_field( $email ), |
|
408 | + 'user_pass' => wp_generate_password(12, false), |
|
409 | + 'user_email' => sanitize_text_field($email), |
|
410 | 410 | 'first_name' => $first_name, |
411 | 411 | 'last_name' => $last_name, |
412 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
412 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
413 | 413 | 'nickname' => $display_name, |
414 | 414 | 'display_name' => $display_name, |
415 | 415 | ); |
416 | 416 | |
417 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
417 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
418 | 418 | |
419 | - $new_user_id = wp_insert_user( $userdata ); |
|
419 | + $new_user_id = wp_insert_user($userdata); |
|
420 | 420 | |
421 | - if ( !is_wp_error( $new_user_id ) ) { |
|
421 | + if (!is_wp_error($new_user_id)) { |
|
422 | 422 | $data['post_author'] = $new_user_id; |
423 | 423 | $_POST['post_author'] = $new_user_id; |
424 | 424 | $_POST['post_author_override'] = $new_user_id; |
@@ -439,69 +439,69 @@ discard block |
||
439 | 439 | |
440 | 440 | $meta = array(); |
441 | 441 | ///$meta['_wpinv_user_id'] = $new_user_id; |
442 | - foreach ( $meta_fields as $field ) { |
|
443 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
442 | + foreach ($meta_fields as $field) { |
|
443 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
444 | 444 | } |
445 | 445 | |
446 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
446 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
447 | 447 | |
448 | 448 | // Update user meta. |
449 | - foreach ( $meta as $key => $value ) { |
|
450 | - update_user_meta( $new_user_id, $key, $value ); |
|
449 | + foreach ($meta as $key => $value) { |
|
450 | + update_user_meta($new_user_id, $key, $value); |
|
451 | 451 | } |
452 | 452 | |
453 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
453 | + if (function_exists('wp_send_new_user_notifications')) { |
|
454 | 454 | // Send email notifications related to the creation of new user. |
455 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
455 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
456 | 456 | } |
457 | 457 | } else { |
458 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
458 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | 463 | return $data; |
464 | 464 | } |
465 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
465 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
466 | 466 | |
467 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
467 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
468 | 468 | $all_gateways = wpinv_get_payment_gateways(); |
469 | 469 | |
470 | - if ( !empty( $all_gateways ) ) { |
|
470 | + if (!empty($all_gateways)) { |
|
471 | 471 | $gateways = array(); |
472 | 472 | |
473 | - foreach ( $all_gateways as $key => $gateway ) { |
|
474 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
473 | + foreach ($all_gateways as $key => $gateway) { |
|
474 | + if (wpinv_gateway_support_subscription($key)) { |
|
475 | 475 | $gateways[] = $gateway['admin_label']; |
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
479 | - if ( !empty( $gateways ) ) { |
|
479 | + if (!empty($gateways)) { |
|
480 | 480 | ?> |
481 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
481 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
482 | 482 | <?php |
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
486 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
487 | 487 | |
488 | -function wpinv_post_updated_messages( $messages ) { |
|
488 | +function wpinv_post_updated_messages($messages) { |
|
489 | 489 | global $post, $post_ID; |
490 | 490 | |
491 | 491 | $messages['wpi_discount'] = array( |
492 | 492 | 0 => '', |
493 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
494 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
495 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
496 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
497 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
498 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
499 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
500 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
501 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
502 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
493 | + 1 => __('Discount updated.', 'invoicing'), |
|
494 | + 2 => __('Custom field updated.', 'invoicing'), |
|
495 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
496 | + 4 => __('Discount updated.', 'invoicing'), |
|
497 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
498 | + 6 => __('Discount updated.', 'invoicing'), |
|
499 | + 7 => __('Discount saved.', 'invoicing'), |
|
500 | + 8 => __('Discount submitted.', 'invoicing'), |
|
501 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
502 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
503 | 503 | ); |
504 | 504 | |
505 | 505 | return $messages; |
506 | 506 | } |
507 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
508 | 507 | \ No newline at end of file |
508 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
509 | 509 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | public function __construct() { |
12 | 12 | global $bp; |
13 | 13 | |
14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
14 | + if (!defined('WPINV_BP_SLUG')) { |
|
15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
16 | 16 | } |
17 | 17 | |
18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
21 | 21 | $this->slug = WPINV_BP_SLUG; |
22 | 22 | |
23 | 23 | parent::start( |
24 | 24 | 'invoicing', |
25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
26 | - trailingslashit( dirname( __FILE__ ) ), |
|
25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
26 | + trailingslashit(dirname(__FILE__)), |
|
27 | 27 | array( |
28 | 28 | 'adminbar_myaccount_order' => $this->position |
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - public function includes( $includes = array() ) { |
|
34 | - parent::includes( $includes ); |
|
33 | + public function includes($includes = array()) { |
|
34 | + parent::includes($includes); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function setup_globals( $args = array() ) { |
|
37 | + public function setup_globals($args = array()) { |
|
38 | 38 | global $bp; |
39 | 39 | |
40 | 40 | $args = array( |
41 | 41 | 'slug' => $this->slug, |
42 | 42 | ); |
43 | 43 | |
44 | - parent::setup_globals( $args ); |
|
44 | + parent::setup_globals($args); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
48 | - if ( !bp_is_my_profile() ) { |
|
47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
48 | + if (!bp_is_my_profile()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->setup_invoice_count(); |
57 | 57 | |
58 | 58 | $user_domain = bp_loggedin_user_domain(); |
59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
61 | 61 | |
62 | 62 | $main_nav_name = sprintf( |
63 | - __( 'My Invoices %s', 'invoicing' ), |
|
63 | + __('My Invoices %s', 'invoicing'), |
|
64 | 64 | sprintf( |
65 | 65 | '<span class="%s">%s</span>', |
66 | - esc_attr( $class ), |
|
67 | - bp_core_number_format( $this->count ) |
|
66 | + esc_attr($class), |
|
67 | + bp_core_number_format($this->count) |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
72 | 72 | 'name' => $main_nav_name, |
73 | 73 | 'slug' => $this->slug, |
74 | 74 | 'position' => $this->position, |
75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
76 | 76 | 'default_subnav_slug' => 'invoices', |
77 | 77 | 'item_css_id' => $this->id |
78 | 78 | ); |
79 | 79 | |
80 | 80 | $sub_nav[] = array( |
81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
82 | 82 | 'slug' => 'invoices', |
83 | 83 | 'parent_url' => $invoices_link, |
84 | 84 | 'parent_slug' => $this->slug, |
85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
86 | 86 | 'position' => 10, |
87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
88 | 88 | ); |
89 | 89 | |
90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
90 | + parent::setup_nav($main_nav, $sub_nav); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setup_title() { |
94 | 94 | // Adjust title. |
95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
96 | 96 | global $bp; |
97 | 97 | |
98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | parent::setup_title(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function invoices_screen() { |
105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | global $bp; |
110 | 110 | |
111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
112 | 112 | |
113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
114 | 114 | |
115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function invoices_content() { |
119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
120 | 120 | global $invoices_template; |
121 | 121 | |
122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
122 | + do_action('wpinv_bp_invoices_before_content'); |
|
123 | 123 | ?> |
124 | 124 | <div class="wpi-bp-invoices invoices invoicing" style="position:relative"> |
125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,61 +133,61 @@ discard block |
||
133 | 133 | <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0"> |
134 | 134 | <thead> |
135 | 135 | <tr> |
136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
137 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
137 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
138 | 138 | <?php endforeach; ?> |
139 | 139 | </tr> |
140 | 140 | </thead> |
141 | 141 | <tbody> |
142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
143 | 143 | ?> |
144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
146 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
149 | - |
|
150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
146 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
149 | + |
|
150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
153 | 153 | </a> |
154 | 154 | |
155 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
155 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
157 | 157 | |
158 | - <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?> |
|
159 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
158 | + <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?> |
|
159 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
160 | 160 | |
161 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
162 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
161 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
162 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
163 | 163 | |
164 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
165 | - <?php echo $invoice->get_total( true ); ?> |
|
164 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
165 | + <?php echo $invoice->get_total(true); ?> |
|
166 | 166 | |
167 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
167 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
168 | 168 | <?php |
169 | 169 | $actions = array( |
170 | 170 | 'pay' => array( |
171 | 171 | 'url' => $invoice->get_checkout_payment_url(), |
172 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
172 | + 'name' => __('Pay Now', 'invoicing'), |
|
173 | 173 | 'class' => 'btn-success' |
174 | 174 | ), |
175 | 175 | 'print' => array( |
176 | 176 | 'url' => $invoice->get_view_url(), |
177 | - 'name' => __( 'Print', 'invoicing' ), |
|
177 | + 'name' => __('Print', 'invoicing'), |
|
178 | 178 | 'class' => 'btn-primary', |
179 | 179 | 'attrs' => 'target="_blank"' |
180 | 180 | ) |
181 | 181 | ); |
182 | 182 | |
183 | - if ( ! $invoice->needs_payment() ) { |
|
184 | - unset( $actions['pay'] ); |
|
183 | + if (!$invoice->needs_payment()) { |
|
184 | + unset($actions['pay']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
188 | - foreach ( $actions as $key => $action ) { |
|
187 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
188 | + foreach ($actions as $key => $action) { |
|
189 | 189 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
190 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
190 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | ?> |
@@ -215,64 +215,64 @@ discard block |
||
215 | 215 | </div> |
216 | 216 | <?php |
217 | 217 | |
218 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
218 | + do_action('wpinv_bp_invoices_after_content'); |
|
219 | 219 | } else { |
220 | 220 | ?> |
221 | 221 | <div id="message" class="info"> |
222 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
222 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
223 | 223 | </div> |
224 | 224 | <?php |
225 | 225 | } |
226 | 226 | |
227 | - if ( defined( 'DOING_AJAX' ) ) { |
|
227 | + if (defined('DOING_AJAX')) { |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - public function has_invoices( $args = '' ) { |
|
232 | + public function has_invoices($args = '') { |
|
233 | 233 | global $invoices_template; |
234 | 234 | |
235 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
235 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
236 | 236 | // Parse arguments. |
237 | - $r = bp_parse_args( $args, array( |
|
237 | + $r = bp_parse_args($args, array( |
|
238 | 238 | 'status' => 'all', |
239 | 239 | 'page_arg' => 'bpage', |
240 | 240 | 'page' => 1, |
241 | 241 | 'per_page' => $per_page > 0 ? $per_page : 20, |
242 | 242 | 'max' => false, |
243 | 243 | 'user_id' => bp_loggedin_user_id(), |
244 | - ), 'has_invoices' ); |
|
244 | + ), 'has_invoices'); |
|
245 | 245 | |
246 | 246 | |
247 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
247 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
248 | 248 | $r['per_page'] = (int)$r['max']; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Get the invoices. |
252 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
252 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
253 | 253 | |
254 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
254 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | public function setup_invoice_count() { |
258 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
259 | - $invoices = wpinv_get_invoices( $query ); |
|
258 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
259 | + $invoices = wpinv_get_invoices($query); |
|
260 | 260 | |
261 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
261 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public function pagination_count() { |
265 | 265 | global $invoices_template; |
266 | 266 | |
267 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
268 | - $from_num = bp_core_number_format( $start_num ); |
|
269 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
270 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
267 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
268 | + $from_num = bp_core_number_format($start_num); |
|
269 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
270 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
271 | 271 | |
272 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
273 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
272 | + if (1 == $invoices_template->total_invoice_count) { |
|
273 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
274 | 274 | } else { |
275 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
275 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $message; |
@@ -281,32 +281,32 @@ discard block |
||
281 | 281 | function pagination_links() { |
282 | 282 | global $invoices_template; |
283 | 283 | |
284 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
284 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
285 | 285 | } |
286 | 286 | |
287 | - public function bp_section( $settings = array() ) { |
|
288 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
287 | + public function bp_section($settings = array()) { |
|
288 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
289 | 289 | return $settings; |
290 | 290 | } |
291 | 291 | |
292 | - public function bp_settings( $settings = array() ) { |
|
292 | + public function bp_settings($settings = array()) { |
|
293 | 293 | $settings['wpinv_bp'] = array( |
294 | 294 | 'wpinv_bp_labels' => array( |
295 | 295 | 'id' => 'wpinv_bp_settings', |
296 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
296 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
297 | 297 | 'desc' => '', |
298 | 298 | 'type' => 'header', |
299 | 299 | ), |
300 | 300 | 'wpinv_bp_hide_menu' => array( |
301 | 301 | 'id' => 'wpinv_bp_hide_menu', |
302 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
303 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
302 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
303 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
304 | 304 | 'type' => 'checkbox', |
305 | 305 | ), |
306 | 306 | 'wpinv_menu_position' => array( |
307 | 307 | 'id' => 'wpinv_menu_position', |
308 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
309 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
308 | + 'name' => __('Menu position', 'invoicing'), |
|
309 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
310 | 310 | 'type' => 'number', |
311 | 311 | 'size' => 'small', |
312 | 312 | 'min' => '1', |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | ), |
317 | 317 | 'wpinv_bp_per_page' => array( |
318 | 318 | 'id' => 'wpinv_bp_per_page', |
319 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
320 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
319 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
320 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
321 | 321 | 'type' => 'number', |
322 | 322 | 'size' => 'small', |
323 | 323 | 'min' => '1', |
@@ -342,25 +342,25 @@ discard block |
||
342 | 342 | public $pag_links = ''; |
343 | 343 | public $total_invoice_count = 0; |
344 | 344 | |
345 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
346 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
345 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
346 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
347 | 347 | |
348 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
349 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
350 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
348 | + $this->pag_arg = sanitize_key($page_arg); |
|
349 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
350 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
351 | 351 | |
352 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
353 | - if ( !empty( $status ) && $status != 'all' ) { |
|
352 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
353 | + if (!empty($status) && $status != 'all') { |
|
354 | 354 | $query_args['status'] = $status; |
355 | 355 | } |
356 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
356 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
357 | 357 | |
358 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
359 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
358 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
359 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
360 | 360 | $this->invoices['total'] = $invoices->found_posts; |
361 | 361 | } |
362 | 362 | |
363 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
363 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
364 | 364 | $this->total_invoice_count = (int)$this->invoices['total']; |
365 | 365 | } else { |
366 | 366 | $this->total_invoice_count = (int)$max; |
@@ -368,52 +368,52 @@ discard block |
||
368 | 368 | |
369 | 369 | $this->invoices = $this->invoices['invoices']; |
370 | 370 | |
371 | - $invoice_count = count( $this->invoices ); |
|
371 | + $invoice_count = count($this->invoices); |
|
372 | 372 | |
373 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
373 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
374 | 374 | $this->invoice_count = (int)$invoice_count; |
375 | 375 | } else { |
376 | 376 | $this->invoice_count = (int)$max; |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
380 | - $this->pag_links = paginate_links( array( |
|
381 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
379 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
380 | + $this->pag_links = paginate_links(array( |
|
381 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
382 | 382 | 'format' => '', |
383 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
383 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
384 | 384 | 'current' => (int)$this->pag_page, |
385 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
386 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
385 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
386 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
387 | 387 | 'mid_size' => 1, |
388 | 388 | 'add_args' => array(), |
389 | - ) ); |
|
389 | + )); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | 393 | public function has_invoices() { |
394 | - return (bool) ! empty( $this->invoice_count ); |
|
394 | + return (bool)!empty($this->invoice_count); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | public function next_invoice() { |
398 | 398 | $this->current_invoice++; |
399 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
399 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
400 | 400 | |
401 | 401 | return $this->invoice; |
402 | 402 | } |
403 | 403 | |
404 | 404 | public function rewind_invoices() { |
405 | 405 | $this->current_invoice = -1; |
406 | - if ( $this->invoice_count > 0 ) { |
|
406 | + if ($this->invoice_count > 0) { |
|
407 | 407 | $this->invoice = $this->invoices[0]; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | 411 | public function invoices() { |
412 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
412 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
413 | 413 | return true; |
414 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
414 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
415 | 415 | |
416 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
416 | + do_action('wpinv_bp_invoice_loop_end'); |
|
417 | 417 | |
418 | 418 | $this->rewind_invoices(); |
419 | 419 | } |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | $this->in_the_loop = true; |
428 | 428 | $this->invoice = $this->next_invoice(); |
429 | 429 | |
430 | - if ( 0 === $this->current_invoice ) { |
|
431 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
430 | + if (0 === $this->current_invoice) { |
|
431 | + do_action('wpinv_bp_invoice_loop_start'); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
@@ -438,9 +438,9 @@ discard block |
||
438 | 438 | |
439 | 439 | $bp->invoicing = new WPInv_BP_Component(); |
440 | 440 | |
441 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
442 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
443 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
444 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
441 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
442 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
443 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
444 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
445 | 445 | } |
446 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
447 | 446 | \ No newline at end of file |
447 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
448 | 448 | \ No newline at end of file |
@@ -7,28 +7,28 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Ajax { |
15 | 15 | public static function init() { |
16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
18 | 18 | self::add_ajax_events(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function define_ajax() { |
22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
24 | - define( 'DOING_AJAX', true ); |
|
22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
23 | + if (!defined('DOING_AJAX')) { |
|
24 | + define('DOING_AJAX', true); |
|
25 | 25 | } |
26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
27 | - define( 'WC_DOING_AJAX', true ); |
|
26 | + if (!defined('WC_DOING_AJAX')) { |
|
27 | + define('WC_DOING_AJAX', true); |
|
28 | 28 | } |
29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
31 | - @ini_set( 'display_errors', 0 ); |
|
30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
31 | + @ini_set('display_errors', 0); |
|
32 | 32 | } |
33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | public static function do_wpinv_ajax() { |
38 | 38 | global $wp_query; |
39 | 39 | |
40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
42 | 42 | } |
43 | 43 | |
44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
45 | 45 | self::wpinv_ajax_headers(); |
46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function wpinv_ajax_headers() { |
52 | 52 | send_origin_headers(); |
53 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
54 | - @header( 'X-Robots-Tag: noindex' ); |
|
53 | + @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
54 | + @header('X-Robots-Tag: noindex'); |
|
55 | 55 | send_nosniff_header(); |
56 | 56 | nocache_headers(); |
57 | - status_header( 200 ); |
|
57 | + status_header(200); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function add_ajax_events() { |
@@ -77,39 +77,39 @@ discard block |
||
77 | 77 | 'buy_items' => true, |
78 | 78 | ); |
79 | 79 | |
80 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
81 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
80 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
81 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
82 | 82 | |
83 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
84 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
83 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
84 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
85 | 85 | } |
86 | 86 | |
87 | - if ( $nopriv ) { |
|
88 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
87 | + if ($nopriv) { |
|
88 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
89 | 89 | |
90 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
90 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | 95 | public static function add_note() { |
96 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
96 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
97 | 97 | |
98 | - if ( !current_user_can( 'manage_options' ) ) { |
|
98 | + if (!current_user_can('manage_options')) { |
|
99 | 99 | die(-1); |
100 | 100 | } |
101 | 101 | |
102 | - $post_id = absint( $_POST['post_id'] ); |
|
103 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
104 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
102 | + $post_id = absint($_POST['post_id']); |
|
103 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
104 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
105 | 105 | |
106 | 106 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
107 | 107 | |
108 | - if ( $post_id > 0 ) { |
|
109 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
108 | + if ($post_id > 0) { |
|
109 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
110 | 110 | |
111 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
112 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
111 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
112 | + wpinv_get_invoice_note_line_item($note_id); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | public static function delete_note() { |
120 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
120 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
121 | 121 | |
122 | - if ( !current_user_can( 'manage_options' ) ) { |
|
122 | + if (!current_user_can('manage_options')) { |
|
123 | 123 | die(-1); |
124 | 124 | } |
125 | 125 | |
126 | 126 | $note_id = (int)$_POST['note_id']; |
127 | 127 | |
128 | - if ( $note_id > 0 ) { |
|
129 | - wp_delete_comment( $note_id, true ); |
|
128 | + if ($note_id > 0) { |
|
129 | + wp_delete_comment($note_id, true); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | die(); |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | public static function checkout() { |
142 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
143 | - define( 'WPINV_CHECKOUT', true ); |
|
142 | + if (!defined('WPINV_CHECKOUT')) { |
|
143 | + define('WPINV_CHECKOUT', true); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | wpinv_process_checkout(); |
@@ -149,53 +149,53 @@ discard block |
||
149 | 149 | |
150 | 150 | public static function add_invoice_item() { |
151 | 151 | global $wpi_userID, $wpinv_ip_address_country; |
152 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
153 | - if ( !current_user_can( 'manage_options' ) ) { |
|
152 | + check_ajax_referer('invoice-item', '_nonce'); |
|
153 | + if (!current_user_can('manage_options')) { |
|
154 | 154 | die(-1); |
155 | 155 | } |
156 | 156 | |
157 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
158 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
157 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
158 | + $invoice_id = absint($_POST['invoice_id']); |
|
159 | 159 | |
160 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
160 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
161 | 161 | die(); |
162 | 162 | } |
163 | 163 | |
164 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
165 | - if ( empty( $invoice ) ) { |
|
164 | + $invoice = wpinv_get_invoice($invoice_id); |
|
165 | + if (empty($invoice)) { |
|
166 | 166 | die(); |
167 | 167 | } |
168 | 168 | |
169 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
169 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
170 | 170 | die(); // Don't allow modify items for paid invoice. |
171 | 171 | } |
172 | 172 | |
173 | - if ( !empty( $_POST['user_id'] ) ) { |
|
174 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
173 | + if (!empty($_POST['user_id'])) { |
|
174 | + $wpi_userID = absint($_POST['user_id']); |
|
175 | 175 | } |
176 | 176 | |
177 | - $item = new WPInv_Item( $item_id ); |
|
178 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
177 | + $item = new WPInv_Item($item_id); |
|
178 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
179 | 179 | die(); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Validate item before adding to invoice because recurring item must be paid individually. |
183 | - if ( !empty( $invoice->cart_details ) ) { |
|
183 | + if (!empty($invoice->cart_details)) { |
|
184 | 184 | $valid = true; |
185 | 185 | |
186 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
187 | - if ( $recurring_item != $item_id ) { |
|
186 | + if ($recurring_item = $invoice->get_recurring()) { |
|
187 | + if ($recurring_item != $item_id) { |
|
188 | 188 | $valid = false; |
189 | 189 | } |
190 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
190 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
191 | 191 | $valid = false; |
192 | 192 | } |
193 | 193 | |
194 | - if ( !$valid ) { |
|
194 | + if (!$valid) { |
|
195 | 195 | $response = array(); |
196 | 196 | $response['success'] = false; |
197 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
198 | - wp_send_json( $response ); |
|
197 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
198 | + wp_send_json($response); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | |
204 | 204 | $data = array(); |
205 | 205 | $data['invoice_id'] = $invoice_id; |
206 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
206 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
207 | 207 | |
208 | - wpinv_set_checkout_session( $data ); |
|
208 | + wpinv_set_checkout_session($data); |
|
209 | 209 | |
210 | 210 | $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
211 | 211 | |
@@ -220,21 +220,21 @@ discard block |
||
220 | 220 | 'fees' => array() |
221 | 221 | ); |
222 | 222 | |
223 | - $invoice->add_item( $item_id, $args ); |
|
223 | + $invoice->add_item($item_id, $args); |
|
224 | 224 | $invoice->save(); |
225 | 225 | |
226 | - if ( empty( $_POST['country'] ) ) { |
|
226 | + if (empty($_POST['country'])) { |
|
227 | 227 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
228 | 228 | } |
229 | - if ( empty( $_POST['state'] ) ) { |
|
229 | + if (empty($_POST['state'])) { |
|
230 | 230 | $_POST['state'] = $invoice->state; |
231 | 231 | } |
232 | 232 | |
233 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
234 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
233 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
234 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
235 | 235 | |
236 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
237 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
236 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
237 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
238 | 238 | |
239 | 239 | $wpinv_ip_address_country = $invoice->country; |
240 | 240 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $response = array(); |
244 | 244 | $response['success'] = true; |
245 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
245 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
246 | 246 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
247 | 247 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
248 | 248 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -254,40 +254,40 @@ discard block |
||
254 | 254 | |
255 | 255 | wpinv_set_checkout_session($checkout_session); |
256 | 256 | |
257 | - wp_send_json( $response ); |
|
257 | + wp_send_json($response); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | public static function remove_invoice_item() { |
261 | 261 | global $wpi_userID, $wpinv_ip_address_country; |
262 | 262 | |
263 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
264 | - if ( !current_user_can( 'manage_options' ) ) { |
|
263 | + check_ajax_referer('invoice-item', '_nonce'); |
|
264 | + if (!current_user_can('manage_options')) { |
|
265 | 265 | die(-1); |
266 | 266 | } |
267 | 267 | |
268 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
269 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
270 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
268 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
269 | + $invoice_id = absint($_POST['invoice_id']); |
|
270 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
271 | 271 | |
272 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
272 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
273 | 273 | die(); |
274 | 274 | } |
275 | 275 | |
276 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
277 | - if ( empty( $invoice ) ) { |
|
276 | + $invoice = wpinv_get_invoice($invoice_id); |
|
277 | + if (empty($invoice)) { |
|
278 | 278 | die(); |
279 | 279 | } |
280 | 280 | |
281 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
281 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
282 | 282 | die(); // Don't allow modify items for paid invoice. |
283 | 283 | } |
284 | 284 | |
285 | - if ( !empty( $_POST['user_id'] ) ) { |
|
286 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
285 | + if (!empty($_POST['user_id'])) { |
|
286 | + $wpi_userID = absint($_POST['user_id']); |
|
287 | 287 | } |
288 | 288 | |
289 | - $item = new WPInv_Item( $item_id ); |
|
290 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
289 | + $item = new WPInv_Item($item_id); |
|
290 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
291 | 291 | die(); |
292 | 292 | } |
293 | 293 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | |
296 | 296 | $data = array(); |
297 | 297 | $data['invoice_id'] = $invoice_id; |
298 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
298 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
299 | 299 | |
300 | - wpinv_set_checkout_session( $data ); |
|
300 | + wpinv_set_checkout_session($data); |
|
301 | 301 | |
302 | 302 | $args = array( |
303 | 303 | 'id' => $item_id, |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | 'cart_index' => $cart_index |
306 | 306 | ); |
307 | 307 | |
308 | - $invoice->remove_item( $item_id, $args ); |
|
308 | + $invoice->remove_item($item_id, $args); |
|
309 | 309 | $invoice->save(); |
310 | 310 | |
311 | - if ( empty( $_POST['country'] ) ) { |
|
311 | + if (empty($_POST['country'])) { |
|
312 | 312 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
313 | 313 | } |
314 | - if ( empty( $_POST['state'] ) ) { |
|
314 | + if (empty($_POST['state'])) { |
|
315 | 315 | $_POST['state'] = $invoice->state; |
316 | 316 | } |
317 | 317 | |
318 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
319 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
318 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
319 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
320 | 320 | |
321 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
322 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
321 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
322 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
323 | 323 | |
324 | 324 | $wpinv_ip_address_country = $invoice->country; |
325 | 325 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | $response = array(); |
329 | 329 | $response['success'] = true; |
330 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
330 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
331 | 331 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
332 | 332 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
333 | 333 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -339,40 +339,40 @@ discard block |
||
339 | 339 | |
340 | 340 | wpinv_set_checkout_session($checkout_session); |
341 | 341 | |
342 | - wp_send_json( $response ); |
|
342 | + wp_send_json($response); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | public static function create_invoice_item() { |
346 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
347 | - if ( !current_user_can( 'manage_options' ) ) { |
|
346 | + check_ajax_referer('invoice-item', '_nonce'); |
|
347 | + if (!current_user_can('manage_options')) { |
|
348 | 348 | die(-1); |
349 | 349 | } |
350 | 350 | |
351 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
351 | + $invoice_id = absint($_POST['invoice_id']); |
|
352 | 352 | |
353 | 353 | // Find the item |
354 | - if ( !is_numeric( $invoice_id ) ) { |
|
354 | + if (!is_numeric($invoice_id)) { |
|
355 | 355 | die(); |
356 | 356 | } |
357 | 357 | |
358 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
359 | - if ( empty( $invoice ) ) { |
|
358 | + $invoice = wpinv_get_invoice($invoice_id); |
|
359 | + if (empty($invoice)) { |
|
360 | 360 | die(); |
361 | 361 | } |
362 | 362 | |
363 | 363 | // Validate item before adding to invoice because recurring item must be paid individually. |
364 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
364 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
365 | 365 | $response = array(); |
366 | 366 | $response['success'] = false; |
367 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
368 | - wp_send_json( $response ); |
|
367 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
368 | + wp_send_json($response); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $save_item = $_POST['_wpinv_quick']; |
372 | 372 | |
373 | 373 | $meta = array(); |
374 | 374 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
375 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
375 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
376 | 376 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
377 | 377 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
378 | 378 | |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | $data['meta'] = $meta; |
383 | 383 | |
384 | 384 | $item = new WPInv_Item(); |
385 | - $item->create( $data ); |
|
385 | + $item->create($data); |
|
386 | 386 | |
387 | - if ( !empty( $item ) ) { |
|
387 | + if (!empty($item)) { |
|
388 | 388 | $_POST['item_id'] = $item->ID; |
389 | 389 | $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
390 | 390 | |
@@ -394,15 +394,15 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | public static function get_billing_details() { |
397 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
397 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
398 | 398 | |
399 | - if ( !current_user_can( 'manage_options' ) ) { |
|
399 | + if (!current_user_can('manage_options')) { |
|
400 | 400 | die(-1); |
401 | 401 | } |
402 | 402 | |
403 | 403 | $user_id = (int)$_POST['user_id']; |
404 | 404 | $billing_details = wpinv_get_user_address($user_id); |
405 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
405 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
406 | 406 | |
407 | 407 | if (isset($billing_details['user_id'])) { |
408 | 408 | unset($billing_details['user_id']); |
@@ -416,20 +416,20 @@ discard block |
||
416 | 416 | $response['success'] = true; |
417 | 417 | $response['data']['billing_details'] = $billing_details; |
418 | 418 | |
419 | - wp_send_json( $response ); |
|
419 | + wp_send_json($response); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | public static function admin_recalculate_totals() { |
423 | 423 | global $wpi_userID, $wpinv_ip_address_country; |
424 | 424 | |
425 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
426 | - if ( !current_user_can( 'manage_options' ) ) { |
|
425 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
426 | + if (!current_user_can('manage_options')) { |
|
427 | 427 | die(-1); |
428 | 428 | } |
429 | 429 | |
430 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
431 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
432 | - if ( empty( $invoice ) ) { |
|
430 | + $invoice_id = absint($_POST['invoice_id']); |
|
431 | + $invoice = wpinv_get_invoice($invoice_id); |
|
432 | + if (empty($invoice)) { |
|
433 | 433 | die(); |
434 | 434 | } |
435 | 435 | |
@@ -437,23 +437,23 @@ discard block |
||
437 | 437 | |
438 | 438 | $data = array(); |
439 | 439 | $data['invoice_id'] = $invoice_id; |
440 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
440 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
441 | 441 | |
442 | - wpinv_set_checkout_session( $data ); |
|
442 | + wpinv_set_checkout_session($data); |
|
443 | 443 | |
444 | - if ( !empty( $_POST['user_id'] ) ) { |
|
445 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
444 | + if (!empty($_POST['user_id'])) { |
|
445 | + $wpi_userID = absint($_POST['user_id']); |
|
446 | 446 | } |
447 | 447 | |
448 | - if ( empty( $_POST['country'] ) ) { |
|
448 | + if (empty($_POST['country'])) { |
|
449 | 449 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
450 | 450 | } |
451 | 451 | |
452 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
453 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
454 | - if ( isset( $_POST['state'] ) ) { |
|
455 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
456 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
452 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
453 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
454 | + if (isset($_POST['state'])) { |
|
455 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
456 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $wpinv_ip_address_country = $invoice->country; |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | |
463 | 463 | $response = array(); |
464 | 464 | $response['success'] = true; |
465 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
465 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
466 | 466 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
467 | 467 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
468 | 468 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -474,25 +474,25 @@ discard block |
||
474 | 474 | |
475 | 475 | wpinv_set_checkout_session($checkout_session); |
476 | 476 | |
477 | - wp_send_json( $response ); |
|
477 | + wp_send_json($response); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | public static function admin_apply_discount() { |
481 | 481 | global $wpi_userID; |
482 | 482 | |
483 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
484 | - if ( !current_user_can( 'manage_options' ) ) { |
|
483 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
484 | + if (!current_user_can('manage_options')) { |
|
485 | 485 | die(-1); |
486 | 486 | } |
487 | 487 | |
488 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
489 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
490 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
488 | + $invoice_id = absint($_POST['invoice_id']); |
|
489 | + $discount_code = sanitize_text_field($_POST['code']); |
|
490 | + if (empty($invoice_id) || empty($discount_code)) { |
|
491 | 491 | die(); |
492 | 492 | } |
493 | 493 | |
494 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
495 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
494 | + $invoice = wpinv_get_invoice($invoice_id); |
|
495 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
496 | 496 | die(); |
497 | 497 | } |
498 | 498 | |
@@ -500,49 +500,49 @@ discard block |
||
500 | 500 | |
501 | 501 | $data = array(); |
502 | 502 | $data['invoice_id'] = $invoice_id; |
503 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
503 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
504 | 504 | |
505 | - wpinv_set_checkout_session( $data ); |
|
505 | + wpinv_set_checkout_session($data); |
|
506 | 506 | |
507 | 507 | $response = array(); |
508 | 508 | $response['success'] = false; |
509 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
509 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
510 | 510 | $response['data']['code'] = $discount_code; |
511 | 511 | |
512 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
513 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
512 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
513 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
514 | 514 | |
515 | 515 | $response['success'] = true; |
516 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
517 | - } else { |
|
516 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
517 | + } else { |
|
518 | 518 | $errors = wpinv_get_errors(); |
519 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
519 | + if (!empty($errors['wpinv-discount-error'])) { |
|
520 | 520 | $response['msg'] = $errors['wpinv-discount-error']; |
521 | 521 | } |
522 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
522 | + wpinv_unset_error('wpinv-discount-error'); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | wpinv_set_checkout_session($checkout_session); |
526 | 526 | |
527 | - wp_send_json( $response ); |
|
527 | + wp_send_json($response); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | public static function admin_remove_discount() { |
531 | 531 | global $wpi_userID; |
532 | 532 | |
533 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
534 | - if ( !current_user_can( 'manage_options' ) ) { |
|
533 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
534 | + if (!current_user_can('manage_options')) { |
|
535 | 535 | die(-1); |
536 | 536 | } |
537 | 537 | |
538 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
539 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
540 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
538 | + $invoice_id = absint($_POST['invoice_id']); |
|
539 | + $discount_code = sanitize_text_field($_POST['code']); |
|
540 | + if (empty($invoice_id) || empty($discount_code)) { |
|
541 | 541 | die(); |
542 | 542 | } |
543 | 543 | |
544 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
545 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
544 | + $invoice = wpinv_get_invoice($invoice_id); |
|
545 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
546 | 546 | die(); |
547 | 547 | } |
548 | 548 | |
@@ -550,38 +550,38 @@ discard block |
||
550 | 550 | |
551 | 551 | $data = array(); |
552 | 552 | $data['invoice_id'] = $invoice_id; |
553 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
553 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
554 | 554 | |
555 | - wpinv_set_checkout_session( $data ); |
|
555 | + wpinv_set_checkout_session($data); |
|
556 | 556 | |
557 | 557 | $response = array(); |
558 | 558 | $response['success'] = false; |
559 | 559 | $response['msg'] = NULL; |
560 | 560 | |
561 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
561 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
562 | 562 | $response['success'] = true; |
563 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
563 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
564 | 564 | |
565 | 565 | wpinv_set_checkout_session($checkout_session); |
566 | 566 | |
567 | - wp_send_json( $response ); |
|
567 | + wp_send_json($response); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | public static function check_email() { |
571 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
572 | - if ( !current_user_can( 'manage_options' ) ) { |
|
571 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
572 | + if (!current_user_can('manage_options')) { |
|
573 | 573 | die(-1); |
574 | 574 | } |
575 | 575 | |
576 | - $email = sanitize_text_field( $_POST['email'] ); |
|
576 | + $email = sanitize_text_field($_POST['email']); |
|
577 | 577 | |
578 | 578 | $response = array(); |
579 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
579 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
580 | 580 | $user_id = $user_data->ID; |
581 | 581 | $user_login = $user_data->user_login; |
582 | 582 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
583 | 583 | $billing_details = wpinv_get_user_address($user_id); |
584 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
584 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
585 | 585 | |
586 | 586 | if (isset($billing_details['user_id'])) { |
587 | 587 | unset($billing_details['user_id']); |
@@ -597,54 +597,54 @@ discard block |
||
597 | 597 | $response['data']['billing_details'] = $billing_details; |
598 | 598 | } |
599 | 599 | |
600 | - wp_send_json( $response ); |
|
600 | + wp_send_json($response); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | public static function run_tool() { |
604 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
605 | - if ( !current_user_can( 'manage_options' ) ) { |
|
604 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
605 | + if (!current_user_can('manage_options')) { |
|
606 | 606 | die(-1); |
607 | 607 | } |
608 | 608 | |
609 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
609 | + $tool = sanitize_text_field($_POST['tool']); |
|
610 | 610 | |
611 | - do_action( 'wpinv_run_tool' ); |
|
611 | + do_action('wpinv_run_tool'); |
|
612 | 612 | |
613 | - if ( !empty( $tool ) ) { |
|
614 | - do_action( 'wpinv_tool_' . $tool ); |
|
613 | + if (!empty($tool)) { |
|
614 | + do_action('wpinv_tool_' . $tool); |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | |
618 | 618 | public static function apply_discount() { |
619 | 619 | global $wpi_userID; |
620 | 620 | |
621 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
621 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
622 | 622 | |
623 | 623 | $response = array(); |
624 | 624 | |
625 | - if ( isset( $_POST['code'] ) ) { |
|
626 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
625 | + if (isset($_POST['code'])) { |
|
626 | + $discount_code = sanitize_text_field($_POST['code']); |
|
627 | 627 | |
628 | 628 | $response['success'] = false; |
629 | 629 | $response['msg'] = ''; |
630 | 630 | $response['data']['code'] = $discount_code; |
631 | 631 | |
632 | 632 | $invoice = wpinv_get_invoice_cart(); |
633 | - if ( empty( $invoice->ID ) ) { |
|
634 | - $response['msg'] = __( 'Invalid checkout request.', 'invoicing' ); |
|
635 | - wp_send_json( $response ); |
|
633 | + if (empty($invoice->ID)) { |
|
634 | + $response['msg'] = __('Invalid checkout request.', 'invoicing'); |
|
635 | + wp_send_json($response); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | $wpi_userID = $invoice->get_user_id(); |
639 | 639 | |
640 | - if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) { |
|
641 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
642 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
643 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
644 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
645 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
640 | + if (wpinv_is_discount_valid($discount_code, $wpi_userID)) { |
|
641 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
642 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
643 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
644 | + $total = wpinv_get_cart_total(null, $discounts); |
|
645 | + $cart_totals = wpinv_recalculate_tax(true); |
|
646 | 646 | |
647 | - if ( !empty( $cart_totals ) ) { |
|
647 | + if (!empty($cart_totals)) { |
|
648 | 648 | $response['success'] = true; |
649 | 649 | $response['data'] = $cart_totals; |
650 | 650 | $response['data']['code'] = $discount_code; |
@@ -653,29 +653,29 @@ discard block |
||
653 | 653 | } |
654 | 654 | } else { |
655 | 655 | $errors = wpinv_get_errors(); |
656 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
657 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
656 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
657 | + wpinv_unset_error('wpinv-discount-error'); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | // Allow for custom discount code handling |
661 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
661 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
662 | 662 | } |
663 | 663 | |
664 | - wp_send_json( $response ); |
|
664 | + wp_send_json($response); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | public static function remove_discount() { |
668 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
668 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
669 | 669 | |
670 | 670 | $response = array(); |
671 | 671 | |
672 | - if ( isset( $_POST['code'] ) ) { |
|
673 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
674 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
675 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
676 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
672 | + if (isset($_POST['code'])) { |
|
673 | + $discount_code = sanitize_text_field($_POST['code']); |
|
674 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
675 | + $total = wpinv_get_cart_total(null, $discounts); |
|
676 | + $cart_totals = wpinv_recalculate_tax(true); |
|
677 | 677 | |
678 | - if ( !empty( $cart_totals ) ) { |
|
678 | + if (!empty($cart_totals)) { |
|
679 | 679 | $response['success'] = true; |
680 | 680 | $response['data'] = $cart_totals; |
681 | 681 | $response['data']['code'] = $discount_code; |
@@ -684,10 +684,10 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | // Allow for custom discount code handling |
687 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
687 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
688 | 688 | } |
689 | 689 | |
690 | - wp_send_json( $response ); |
|
690 | + wp_send_json($response); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | |
@@ -699,53 +699,53 @@ discard block |
||
699 | 699 | public static function buy_items() { |
700 | 700 | $user_id = get_current_user_id(); |
701 | 701 | |
702 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
703 | - wp_send_json( array( |
|
704 | - 'success' => wp_login_url( wp_get_referer() ) |
|
705 | - ) ); |
|
702 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
703 | + wp_send_json(array( |
|
704 | + 'success' => wp_login_url(wp_get_referer()) |
|
705 | + )); |
|
706 | 706 | } else { |
707 | 707 | // Only check nonce if logged in as it could be cached when logged out. |
708 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
709 | - wp_send_json( array( |
|
710 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
711 | - ) ); |
|
708 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
709 | + wp_send_json(array( |
|
710 | + 'error' => __('Security checks failed.', 'invoicing') |
|
711 | + )); |
|
712 | 712 | wp_die(); |
713 | 713 | } |
714 | 714 | |
715 | 715 | // allow to set a custom price through post_id |
716 | 716 | $items = $_POST['items']; |
717 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
718 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
717 | + $related_post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : 0; |
|
718 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
719 | 719 | |
720 | 720 | $cart_items = array(); |
721 | - if ( $items ) { |
|
722 | - $items = explode( ',', $items ); |
|
721 | + if ($items) { |
|
722 | + $items = explode(',', $items); |
|
723 | 723 | |
724 | - foreach( $items as $item ) { |
|
724 | + foreach ($items as $item) { |
|
725 | 725 | $item_id = $item; |
726 | 726 | $quantity = 1; |
727 | 727 | |
728 | - if ( strpos( $item, '|' ) !== false ) { |
|
729 | - $item_parts = explode( '|', $item ); |
|
728 | + if (strpos($item, '|') !== false) { |
|
729 | + $item_parts = explode('|', $item); |
|
730 | 730 | $item_id = $item_parts[0]; |
731 | 731 | $quantity = $item_parts[1]; |
732 | 732 | } |
733 | 733 | |
734 | - if ( $item_id && $quantity ) { |
|
734 | + if ($item_id && $quantity) { |
|
735 | 735 | $cart_items_arr = array( |
736 | 736 | 'id' => (int)$item_id, |
737 | 737 | 'quantity' => (int)$quantity |
738 | 738 | ); |
739 | 739 | |
740 | 740 | // If there is a related post id then add it to meta |
741 | - if ( $related_post_id ) { |
|
741 | + if ($related_post_id) { |
|
742 | 742 | $cart_items_arr['meta'] = array( |
743 | 743 | 'post_id' => $related_post_id |
744 | 744 | ); |
745 | 745 | } |
746 | 746 | |
747 | 747 | // If there is a custom price then set it. |
748 | - if ( $custom_item_price ) { |
|
748 | + if ($custom_item_price) { |
|
749 | 749 | $cart_items_arr['custom_price'] = $custom_item_price; |
750 | 750 | } |
751 | 751 | |
@@ -761,37 +761,37 @@ discard block |
||
761 | 761 | * @param int $related_post_id The related post id if any. |
762 | 762 | * @since 1.0.0 |
763 | 763 | */ |
764 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
764 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
765 | 765 | |
766 | 766 | // Make sure its not in the cart already, if it is then redirect to checkout. |
767 | 767 | $cart_invoice = wpinv_get_invoice_cart(); |
768 | 768 | |
769 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
770 | - wp_send_json( array( |
|
769 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
770 | + wp_send_json(array( |
|
771 | 771 | 'success' => $cart_invoice->get_checkout_payment_url() |
772 | - ) ); |
|
772 | + )); |
|
773 | 773 | wp_die(); |
774 | 774 | } |
775 | 775 | |
776 | 776 | // Check if user has invoice with same items waiting to be paid. |
777 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
778 | - if ( !empty( $user_invoices ) ) { |
|
779 | - foreach( $user_invoices as $user_invoice ) { |
|
777 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
778 | + if (!empty($user_invoices)) { |
|
779 | + foreach ($user_invoices as $user_invoice) { |
|
780 | 780 | $user_cart_details = array(); |
781 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
781 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
782 | 782 | $cart_details = $invoice->get_cart_details(); |
783 | 783 | |
784 | - if ( !empty( $cart_details ) ) { |
|
785 | - foreach ( $cart_details as $invoice_item ) { |
|
784 | + if (!empty($cart_details)) { |
|
785 | + foreach ($cart_details as $invoice_item) { |
|
786 | 786 | $ii_arr = array(); |
787 | 787 | $ii_arr['id'] = (int)$invoice_item['id']; |
788 | 788 | $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
789 | 789 | |
790 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
790 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
791 | 791 | $ii_arr['meta'] = $invoice_item['meta']; |
792 | 792 | } |
793 | 793 | |
794 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
794 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
795 | 795 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
796 | 796 | } |
797 | 797 | |
@@ -799,17 +799,17 @@ discard block |
||
799 | 799 | } |
800 | 800 | } |
801 | 801 | |
802 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
803 | - wp_send_json( array( |
|
802 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
803 | + wp_send_json(array( |
|
804 | 804 | 'success' => $invoice->get_checkout_payment_url() |
805 | - ) ); |
|
805 | + )); |
|
806 | 806 | wp_die(); |
807 | 807 | } |
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
811 | 811 | // Create invoice and send user to checkout |
812 | - if ( !empty( $cart_items ) ) { |
|
812 | + if (!empty($cart_items)) { |
|
813 | 813 | $invoice_data = array( |
814 | 814 | 'status' => 'wpi-pending', |
815 | 815 | 'created_via' => 'wpi', |
@@ -817,21 +817,21 @@ discard block |
||
817 | 817 | 'cart_details' => $cart_items, |
818 | 818 | ); |
819 | 819 | |
820 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
820 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
821 | 821 | |
822 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
823 | - wp_send_json( array( |
|
822 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
823 | + wp_send_json(array( |
|
824 | 824 | 'success' => $invoice->get_checkout_payment_url() |
825 | - ) ); |
|
825 | + )); |
|
826 | 826 | } else { |
827 | - wp_send_json( array( |
|
828 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
829 | - ) ); |
|
827 | + wp_send_json(array( |
|
828 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
829 | + )); |
|
830 | 830 | } |
831 | 831 | } else { |
832 | - wp_send_json( array( |
|
833 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
834 | - ) ); |
|
832 | + wp_send_json(array( |
|
833 | + 'error' => __('Items not valid.', 'invoicing') |
|
834 | + )); |
|
835 | 835 | } |
836 | 836 | } |
837 | 837 |