@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | 32 | // Set the currency position. |
33 | 33 | $position = wpinv_currency_position(); |
34 | 34 | |
35 | - if ( $position == 'left_space' ) { |
|
35 | + if ($position == 'left_space') { |
|
36 | 36 | $position = 'left'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $position == 'right_space' ) { |
|
39 | + if ($position == 'right_space') { |
|
40 | 40 | $position = 'right'; |
41 | 41 | } |
42 | 42 | |
43 | 43 | ?> |
44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
45 | 45 | <style> |
46 | 46 | #poststuff .input-group-text, |
47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | </style> |
56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
57 | 57 | |
58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
59 | 59 | <div class="form-group row"> |
60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' ); ?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing'); ?></span></label> |
|
61 | 61 | <div class="col-sm-8"> |
62 | 62 | <div class="row"> |
63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
64 | 64 | <div class="input-group input-group-sm"> |
65 | - <?php if ( 'left' == $position ) : ?> |
|
65 | + <?php if ('left' == $position) : ?> |
|
66 | 66 | <div class="input-group-prepend"> |
67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
71 | 71 | |
72 | - <?php if ( 'left' != $position ) : ?> |
|
72 | + <?php if ('left' != $position) : ?> |
|
73 | 73 | <div class="input-group-append"> |
74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
75 | 75 | </div> |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> |
81 | 81 | <?php |
82 | - _e( 'every' ); |
|
82 | + _e('every'); |
|
83 | 83 | echo ' '; |
84 | 84 | ?> |
85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
85 | + <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
86 | 86 | </div> |
87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> |
88 | 88 | <?php |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | array( |
91 | 91 | 'id' => 'wpinv_recurring_period', |
92 | 92 | 'name' => 'wpinv_recurring_period', |
93 | - 'label' => __( 'Period', 'invoicing' ), |
|
94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
95 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
93 | + 'label' => __('Period', 'invoicing'), |
|
94 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
95 | + 'value' => $item->get_recurring_period('edit'), |
|
96 | 96 | 'select2' => true, |
97 | 97 | 'data-allow-clear' => 'false', |
98 | 98 | 'options' => array( |
99 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
100 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
101 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
102 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
99 | + 'D' => __('day(s)', 'invoicing'), |
|
100 | + 'W' => __('week(s)', 'invoicing'), |
|
101 | + 'M' => __('month(s)', 'invoicing'), |
|
102 | + 'Y' => __('year(s)', 'invoicing'), |
|
103 | 103 | ), |
104 | 104 | ) |
105 | 105 | ); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | <?php |
112 | 112 | |
113 | 113 | // Dynamic pricing. |
114 | - if ( $item->supports_dynamic_pricing() ) { |
|
114 | + if ($item->supports_dynamic_pricing()) { |
|
115 | 115 | |
116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
116 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
117 | 117 | |
118 | 118 | // NYP toggle. |
119 | 119 | echo aui()->input( |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | 'id' => 'wpinv_name_your_price', |
122 | 122 | 'name' => 'wpinv_name_your_price', |
123 | 123 | 'type' => 'checkbox', |
124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
124 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
125 | 125 | 'value' => '1', |
126 | 126 | 'checked' => $item->user_can_set_their_price(), |
127 | 127 | 'no_wrap' => true, |
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
131 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Subscriptions. |
136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
136 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
137 | 137 | echo aui()->input( |
138 | 138 | array( |
139 | 139 | 'id' => 'wpinv_is_recurring', |
140 | 140 | 'name' => 'wpinv_is_recurring', |
141 | 141 | 'type' => 'checkbox', |
142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
142 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
143 | 143 | 'value' => '1', |
144 | 144 | 'checked' => $item->is_recurring(), |
145 | 145 | 'no_wrap' => true, |
146 | 146 | ) |
147 | 147 | ); |
148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
148 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
149 | 149 | |
150 | 150 | ?> |
151 | 151 | <div class="wpinv_show_if_recurring"> |
@@ -155,30 +155,30 @@ discard block |
||
155 | 155 | </div> |
156 | 156 | </div> |
157 | 157 | <div class="col-sm-1 pt-2 pl-0"> |
158 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
158 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
159 | 159 | </div> |
160 | 160 | </div> |
161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
161 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
162 | 162 | |
163 | - <?php if ( $item->supports_dynamic_pricing() ) : ?> |
|
164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
163 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
164 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
166 | 166 | |
167 | 167 | <div class="form-group row"> |
168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
169 | - <?php _e( 'Minimum Price', 'invoicing' ); ?> |
|
169 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
170 | 170 | </label> |
171 | 171 | <div class="col-sm-8"> |
172 | 172 | <div class="input-group input-group-sm"> |
173 | - <?php if ( 'left' == $position ) : ?> |
|
173 | + <?php if ('left' == $position) : ?> |
|
174 | 174 | <div class="input-group-prepend"> |
175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
176 | 176 | </div> |
177 | 177 | <?php endif; ?> |
178 | 178 | |
179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
179 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
180 | 180 | |
181 | - <?php if ( 'left' != $position ) : ?> |
|
181 | + <?php if ('left' != $position) : ?> |
|
182 | 182 | <div class="input-group-append"> |
183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
184 | 184 | </div> |
@@ -187,45 +187,45 @@ discard block |
||
187 | 187 | </div> |
188 | 188 | |
189 | 189 | <div class="col-sm-1 pt-2 pl-0"> |
190 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
190 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
191 | 191 | </div> |
192 | 192 | </div> |
193 | 193 | |
194 | 194 | </div> |
195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
195 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
196 | 196 | <?php endif; ?> |
197 | 197 | |
198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
198 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
200 | 200 | |
201 | 201 | <div class="form-group row"> |
202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
203 | - <?php _e( 'Maximum Renewals', 'invoicing' ); ?> |
|
203 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
204 | 204 | </label> |
205 | 205 | <div class="col-sm-8"> |
206 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
206 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
207 | 207 | </div> |
208 | 208 | <div class="col-sm-1 pt-2 pl-0"> |
209 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
209 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
210 | 210 | </div> |
211 | 211 | </div> |
212 | 212 | |
213 | 213 | </div> |
214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
214 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
215 | 215 | |
216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
216 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
218 | 218 | |
219 | 219 | <div class="form-group row"> |
220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' ); ?></label> |
|
220 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing'); ?></label> |
|
221 | 221 | |
222 | 222 | <div class="col-sm-8"> |
223 | 223 | <div class="row"> |
224 | 224 | <div class="col-sm-6"> |
225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0; ?> |
|
225 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
226 | 226 | |
227 | 227 | <div> |
228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
229 | 229 | </div> |
230 | 230 | </div> |
231 | 231 | <div class="col-sm-6"> |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | array( |
235 | 235 | 'id' => 'wpinv_trial_period', |
236 | 236 | 'name' => 'wpinv_trial_period', |
237 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
239 | - 'value' => $item->get_trial_period( 'edit' ), |
|
237 | + 'label' => __('Trial Period', 'invoicing'), |
|
238 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
239 | + 'value' => $item->get_trial_period('edit'), |
|
240 | 240 | 'select2' => true, |
241 | 241 | 'data-allow-clear' => 'false', |
242 | 242 | 'no_wrap' => true, |
243 | 243 | 'options' => array( |
244 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
245 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
246 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
247 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
244 | + 'D' => __('day(s)', 'invoicing'), |
|
245 | + 'W' => __('week(s)', 'invoicing'), |
|
246 | + 'M' => __('month(s)', 'invoicing'), |
|
247 | + 'Y' => __('year(s)', 'invoicing'), |
|
248 | 248 | ), |
249 | 249 | ) |
250 | 250 | ); |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | </div> |
256 | 256 | |
257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | |
261 | 261 | </div> |
262 | 262 | |
263 | 263 | </div> |
264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
264 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
265 | 265 | |
266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
266 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
267 | 267 | </div> |
268 | 268 | <?php |
269 | 269 | |
@@ -274,31 +274,31 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @param int $post_id |
276 | 276 | */ |
277 | - public static function save( $post_id ) { |
|
277 | + public static function save($post_id) { |
|
278 | 278 | |
279 | 279 | // Prepare the item. |
280 | - $item = new WPInv_Item( $post_id ); |
|
280 | + $item = new WPInv_Item($post_id); |
|
281 | 281 | |
282 | 282 | // Load new data. |
283 | 283 | $item->set_props( |
284 | 284 | array( |
285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null, |
|
286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
289 | - 'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ), |
|
290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null, |
|
291 | - 'is_recurring' => ! empty( $_POST['wpinv_is_recurring'] ), |
|
292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
285 | + 'price' => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null, |
|
286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
289 | + 'is_dynamic_pricing' => !empty($_POST['wpinv_name_your_price']), |
|
290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null, |
|
291 | + 'is_recurring' => !empty($_POST['wpinv_is_recurring']), |
|
292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
298 | 298 | ) |
299 | 299 | ); |
300 | 300 | |
301 | 301 | $item->save(); |
302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
302 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
303 | 303 | } |
304 | 304 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
|
32 | + <?php do_action('wpinv_item_before_info_metabox', $item); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_item_type form-group row"> |
35 | 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
36 | - <?php _e( 'Item Type', 'invoicing' ); ?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr( self::get_tooltip( $post ) ); ?>"></span> |
|
36 | + <?php _e('Item Type', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr(self::get_tooltip($post)); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | array( |
45 | 45 | 'id' => 'wpinv_item_type', |
46 | 46 | 'name' => 'wpinv_item_type', |
47 | - 'placeholder' => __( 'Select item type', 'invoicing' ), |
|
48 | - 'value' => $item->get_type( 'edit' ), |
|
47 | + 'placeholder' => __('Select item type', 'invoicing'), |
|
48 | + 'value' => $item->get_type('edit'), |
|
49 | 49 | 'select2' => true, |
50 | 50 | 'data-allow-clear' => 'false', |
51 | 51 | 'no_wrap' => true, |
@@ -57,59 +57,59 @@ discard block |
||
57 | 57 | </div> |
58 | 58 | </div> |
59 | 59 | |
60 | - <?php if ( 'fee' === $item->get_type( 'edit' ) || 'custom' === $item->get_type( 'edit' ) ) : ?> |
|
60 | + <?php if ('fee' === $item->get_type('edit') || 'custom' === $item->get_type('edit')) : ?> |
|
61 | 61 | |
62 | 62 | <div class="wpinv_item_shortcode form-group row"> |
63 | 63 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
64 | - <?php _e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
65 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
64 | + <?php _e('Payment Form Shortcode', 'invoicing'); ?> |
|
65 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
66 | 66 | </label> |
67 | 67 | |
68 | 68 | <div class="col-sm-12"> |
69 | - <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/> |
|
69 | + <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/> |
|
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | |
73 | 73 | <div class="wpinv_item_buy_shortcode form-group row"> |
74 | 74 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
75 | - <?php _e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
76 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
75 | + <?php _e('Payment Button Shortcode', 'invoicing'); ?> |
|
76 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
77 | 77 | </label> |
78 | 78 | |
79 | 79 | <div class="col-sm-12"> |
80 | - <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
80 | + <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
81 | 81 | <small class="form-text text-muted"> |
82 | - <?php _e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
83 | - <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code> |
|
82 | + <?php _e('Or use the following URL in a link:', 'invoicing'); ?> |
|
83 | + <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code> |
|
84 | 84 | </small> |
85 | 85 | </div> |
86 | 86 | </div> |
87 | 87 | |
88 | 88 | <div class="wpinv_item_buy_url form-group row"> |
89 | 89 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
90 | - <?php _e( 'Direct Payment URL', 'invoicing' ); ?> |
|
91 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
90 | + <?php _e('Direct Payment URL', 'invoicing'); ?> |
|
91 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
92 | 92 | </label> |
93 | 93 | |
94 | 94 | <div class="col-sm-12"> |
95 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/> |
|
95 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url(false, $item->get_id() . '|0')); ?>" style="width: 100%;" readonly/> |
|
96 | 96 | </div> |
97 | 97 | </div> |
98 | 98 | |
99 | 99 | <?php endif; ?> |
100 | 100 | |
101 | 101 | <div class="wpinv_item_custom_id form-group"> |
102 | - <?php _e( 'Custom ID', 'invoicing' ); ?> — <?php echo esc_html( $item->get_custom_id() ); ?> |
|
102 | + <?php _e('Custom ID', 'invoicing'); ?> — <?php echo esc_html($item->get_custom_id()); ?> |
|
103 | 103 | </div> |
104 | 104 | |
105 | - <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
|
106 | - <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
|
105 | + <?php do_action('wpinv_meta_values_metabox_before', $post); ?> |
|
106 | + <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?> |
|
107 | 107 | <div class="wpinv_item_custom_id form-group"> |
108 | - <?php echo esc_html( $meta_key ); ?> — <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
|
108 | + <?php echo esc_html($meta_key); ?> — <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?> |
|
109 | 109 | </div> |
110 | 110 | <?php endforeach; ?> |
111 | - <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
|
112 | - <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
|
111 | + <?php do_action('wpinv_meta_values_metabox_after', $post); ?> |
|
112 | + <?php do_action('wpinv_item_info_metabox', $item); ?> |
|
113 | 113 | </div> |
114 | 114 | <?php |
115 | 115 | |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | * Returns item type tolltip. |
120 | 120 | * |
121 | 121 | */ |
122 | - public static function get_tooltip( $post ) { |
|
122 | + public static function get_tooltip($post) { |
|
123 | 123 | |
124 | 124 | ob_start(); |
125 | 125 | ?> |
126 | 126 | |
127 | - <?php _e( 'Standard: Standard item type', 'invoicing' ); ?> |
|
128 | - <?php _e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' ); ?> |
|
127 | + <?php _e('Standard: Standard item type', 'invoicing'); ?> |
|
128 | + <?php _e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?> |
|
129 | 129 | |
130 | 130 | <?php |
131 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
131 | + do_action('wpinv_item_info_metabox_after', $post); |
|
132 | 132 | |
133 | 133 | return ob_get_clean(); |
134 | 134 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,54 +21,54 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the form. |
27 | - $form = new GetPaid_Payment_Form( $post ); |
|
27 | + $form = new GetPaid_Payment_Form($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?> |
|
32 | + <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_payment_form_shortcode form-group row"> |
35 | 35 | <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label"> |
36 | - <?php _e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
36 | + <?php _e('Payment Form Shortcode', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
41 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" /> |
|
41 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" /> |
|
42 | 42 | </div> |
43 | 43 | </div> |
44 | 44 | |
45 | 45 | <div class="wpinv_payment_form_buy_shortcode form-group row"> |
46 | 46 | <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label"> |
47 | - <?php _e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
48 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
47 | + <?php _e('Payment Button Shortcode', 'invoicing'); ?> |
|
48 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
49 | 49 | </label> |
50 | 50 | |
51 | 51 | <div class="col-sm-12"> |
52 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" /> |
|
52 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" /> |
|
53 | 53 | <small class="form-text text-muted"> |
54 | - <?php _e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
55 | - <code>#getpaid-form-<?php echo intval( $form->get_id() ); ?></code> |
|
54 | + <?php _e('Or use the following URL in a link:', 'invoicing'); ?> |
|
55 | + <code>#getpaid-form-<?php echo intval($form->get_id()); ?></code> |
|
56 | 56 | </small> |
57 | 57 | </div> |
58 | 58 | </div> |
59 | 59 | |
60 | 60 | <div class="wpinv_item_buy_url form-group row"> |
61 | 61 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
62 | - <?php _e( 'Direct Payment URL', 'invoicing' ); ?> |
|
63 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
62 | + <?php _e('Direct Payment URL', 'invoicing'); ?> |
|
63 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
64 | 64 | </label> |
65 | 65 | |
66 | 66 | <div class="col-sm-12"> |
67 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( $form->get_id(), false ) ); ?>" style="width: 100%;" readonly/> |
|
67 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url($form->get_id(), false)); ?>" style="width: 100%;" readonly/> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
71 | - <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?> |
|
71 | + <?php do_action('wpinv_payment_form_info_metabox', $form); ?> |
|
72 | 72 | </div> |
73 | 73 | <?php |
74 | 74 |
@@ -1,38 +1,38 @@ |
||
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_Notes { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
12 | 12 | |
13 | 13 | echo '<ul class="invoice_notes">'; |
14 | 14 | |
15 | - if ( $notes ) { |
|
16 | - foreach ( $notes as $note ) { |
|
17 | - wpinv_get_invoice_note_line_item( $note ); |
|
15 | + if ($notes) { |
|
16 | + foreach ($notes as $note) { |
|
17 | + wpinv_get_invoice_note_line_item($note); |
|
18 | 18 | } |
19 | 19 | } else { |
20 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
20 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | echo '</ul>'; |
24 | 24 | ?> |
25 | 25 | <div class="add_note"> |
26 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
26 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
27 | 27 | <p> |
28 | 28 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
29 | 29 | </p> |
30 | 30 | <p> |
31 | 31 | <select name="invoice_note_type" id="invoice_note_type" class="regular-text"> |
32 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
33 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
32 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
33 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
34 | 34 | </select> |
35 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
35 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
36 | 36 | </p> |
37 | 37 | </div> |
38 | 38 | <?php |
@@ -5,12 +5,12 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
12 | 12 | // Load WP_List_Table if not loaded |
13 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
13 | +if (!class_exists('WP_List_Table')) { |
|
14 | 14 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
15 | 15 | } |
16 | 16 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return string Column Name |
78 | 78 | */ |
79 | - public function column_default( $item, $column_name ) { |
|
80 | - $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
81 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
79 | + public function column_default($item, $column_name) { |
|
80 | + $value = esc_html(get_user_meta($item->ID, '_wpinv_' . $column_name, true)); |
|
81 | + return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string Column Name |
92 | 92 | */ |
93 | - public function column_country( $user ) { |
|
94 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
95 | - if ( $country ) { |
|
96 | - $country = wpinv_country_name( $country ); |
|
93 | + public function column_country($user) { |
|
94 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
95 | + if ($country) { |
|
96 | + $country = wpinv_country_name($country); |
|
97 | 97 | } |
98 | - return esc_html( $country ); |
|
98 | + return esc_html($country); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string Column Name |
109 | 109 | */ |
110 | - public function column_state( $user ) { |
|
111 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
110 | + public function column_state($user) { |
|
111 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
112 | 112 | $state = $user->_wpinv_state; |
113 | - if ( $state ) { |
|
114 | - $state = wpinv_state_name( $state, $country ); |
|
113 | + if ($state) { |
|
114 | + $state = wpinv_state_name($state, $country); |
|
115 | 115 | } |
116 | 116 | |
117 | - return esc_html( $state ); |
|
117 | + return esc_html($state); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return string Column Name |
128 | 128 | */ |
129 | - public function column_signup( $user ) { |
|
130 | - return getpaid_format_date_value( $user->user_registered ); |
|
129 | + public function column_signup($user) { |
|
130 | + return getpaid_format_date_value($user->user_registered); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return string Column Name |
141 | 141 | */ |
142 | - public function column_total( $user ) { |
|
143 | - return wpinv_price( $this->column_total_raw( $user ) ); |
|
142 | + public function column_total($user) { |
|
143 | + return wpinv_price($this->column_total_raw($user)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return float |
154 | 154 | */ |
155 | - public function column_total_raw( $user ) { |
|
155 | + public function column_total_raw($user) { |
|
156 | 156 | |
157 | 157 | $args = array( |
158 | 158 | 'data' => array( |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | |
169 | 169 | 'author' => array( |
170 | 170 | 'type' => 'post_data', |
171 | - 'value' => absint( $user->ID ), |
|
171 | + 'value' => absint($user->ID), |
|
172 | 172 | 'key' => 'posts.post_author', |
173 | 173 | 'operator' => '=', |
174 | 174 | ), |
175 | 175 | |
176 | 176 | ), |
177 | 177 | 'query_type' => 'get_var', |
178 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
178 | + 'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'), |
|
179 | 179 | ); |
180 | 180 | |
181 | - return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
181 | + return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string Column Name |
193 | 193 | */ |
194 | - public function column_invoices( $user ) { |
|
194 | + public function column_invoices($user) { |
|
195 | 195 | |
196 | 196 | $args = array( |
197 | 197 | 'data' => array( |
@@ -208,17 +208,17 @@ discard block |
||
208 | 208 | |
209 | 209 | 'author' => array( |
210 | 210 | 'type' => 'post_data', |
211 | - 'value' => absint( $user->ID ), |
|
211 | + 'value' => absint($user->ID), |
|
212 | 212 | 'key' => 'posts.post_author', |
213 | 213 | 'operator' => '=', |
214 | 214 | ), |
215 | 215 | |
216 | 216 | ), |
217 | 217 | 'query_type' => 'get_var', |
218 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
218 | + 'invoice_status' => array_keys(wpinv_get_invoice_statuses()), |
|
219 | 219 | ); |
220 | 220 | |
221 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
221 | + return absint(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @param int $item The user id. |
230 | 230 | */ |
231 | - public function single_row( $item ) { |
|
232 | - $item = get_user_by( 'id', $item ); |
|
231 | + public function single_row($item) { |
|
232 | + $item = get_user_by('id', $item); |
|
233 | 233 | |
234 | - if ( empty( $item ) ) { |
|
234 | + if (empty($item)) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | |
238 | 238 | echo '<tr>'; |
239 | - $this->single_row_columns( $item ); |
|
239 | + $this->single_row_columns($item); |
|
240 | 240 | echo '</tr>'; |
241 | 241 | } |
242 | 242 | |
@@ -246,30 +246,30 @@ discard block |
||
246 | 246 | * @param WP_User $customer customer. |
247 | 247 | * @return string |
248 | 248 | */ |
249 | - public function column_name( $customer ) { |
|
249 | + public function column_name($customer) { |
|
250 | 250 | |
251 | 251 | // Customer view URL. |
252 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
252 | + $view_url = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php'))); |
|
253 | 253 | $row_actions = $this->row_actions( |
254 | 254 | array( |
255 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
255 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
256 | 256 | ) |
257 | 257 | ); |
258 | 258 | |
259 | 259 | // Get user's address. |
260 | - $address = wpinv_get_user_address( $customer->ID ); |
|
260 | + $address = wpinv_get_user_address($customer->ID); |
|
261 | 261 | |
262 | 262 | // Customer email address. |
263 | - $email = sanitize_email( $customer->user_email ); |
|
263 | + $email = sanitize_email($customer->user_email); |
|
264 | 264 | |
265 | 265 | // Customer's avatar. |
266 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
266 | + $avatar = esc_url(get_avatar_url($email)); |
|
267 | 267 | $avatar = "<img src='$avatar' height='32' width='32'/>"; |
268 | 268 | |
269 | 269 | // Customer's name. |
270 | - $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
270 | + $name = esc_html("{$address['first_name']} {$address['last_name']}"); |
|
271 | 271 | |
272 | - if ( ! empty( $name ) ) { |
|
272 | + if (!empty($name)) { |
|
273 | 273 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
274 | 274 | } |
275 | 275 | |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | public function get_columns() { |
289 | 289 | |
290 | 290 | $columns = array( |
291 | - 'name' => __( 'Name', 'invoicing' ), |
|
292 | - 'country' => __( 'Country', 'invoicing' ), |
|
293 | - 'state' => __( 'State', 'invoicing' ), |
|
294 | - 'city' => __( 'City', 'invoicing' ), |
|
295 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
296 | - 'address' => __( 'Address', 'invoicing' ), |
|
297 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
298 | - 'company' => __( 'Company', 'invoicing' ), |
|
299 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
300 | - 'total' => __( 'Total Spend', 'invoicing' ), |
|
301 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
291 | + 'name' => __('Name', 'invoicing'), |
|
292 | + 'country' => __('Country', 'invoicing'), |
|
293 | + 'state' => __('State', 'invoicing'), |
|
294 | + 'city' => __('City', 'invoicing'), |
|
295 | + 'zip' => __('ZIP', 'invoicing'), |
|
296 | + 'address' => __('Address', 'invoicing'), |
|
297 | + 'phone' => __('Phone', 'invoicing'), |
|
298 | + 'company' => __('Company', 'invoicing'), |
|
299 | + 'invoices' => __('Invoices', 'invoicing'), |
|
300 | + 'total' => __('Total Spend', 'invoicing'), |
|
301 | + 'signup' => __('Date created', 'invoicing'), |
|
302 | 302 | ); |
303 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
303 | + return apply_filters('wpinv_customers_table_columns', $columns); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return int Current page number |
312 | 312 | */ |
313 | 313 | public function get_paged() { |
314 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
314 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @since 1.0.19 |
321 | 321 | * @return void |
322 | 322 | */ |
323 | - public function bulk_actions( $which = '' ) { |
|
323 | + public function bulk_actions($which = '') { |
|
324 | 324 | return array(); |
325 | 325 | } |
326 | 326 | |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | |
333 | 333 | $post_types = ''; |
334 | 334 | |
335 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
336 | - $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type ); |
|
335 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
336 | + $post_types .= $wpdb->prepare('post_type=%s OR ', $post_type); |
|
337 | 337 | } |
338 | 338 | |
339 | - $post_types = rtrim( $post_types, ' OR' ); |
|
339 | + $post_types = rtrim($post_types, ' OR'); |
|
340 | 340 | |
341 | 341 | // Maybe search. |
342 | - if ( ! empty( $_POST['s'] ) ) { |
|
342 | + if (!empty($_POST['s'])) { |
|
343 | 343 | $users = get_users( |
344 | 344 | array( |
345 | - 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
346 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
345 | + 'search' => '*' . sanitize_text_field(urldecode($_POST['s'])) . '*', |
|
346 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
347 | 347 | 'fields' => 'ID', |
348 | 348 | ) |
349 | 349 | ); |
350 | 350 | |
351 | - $users = implode( ', ', $users ); |
|
351 | + $users = implode(', ', $users); |
|
352 | 352 | $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
353 | 353 | } |
354 | 354 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | ); |
363 | 363 | |
364 | 364 | $this->items = $customers; |
365 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
365 | + $this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types"); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | $columns = $this->get_columns(); |
377 | 377 | $hidden = array(); // No hidden columns |
378 | 378 | $sortable = $this->get_sortable_columns(); |
379 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
379 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
380 | 380 | $this->prepare_query(); |
381 | 381 | |
382 | 382 | $this->set_pagination_args( |
383 | 383 | array( |
384 | 384 | 'total_items' => $this->total, |
385 | 385 | 'per_page' => $this->per_page, |
386 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
386 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
387 | 387 | ) |
388 | 388 | ); |
389 | 389 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | function wpinv_register_settings() { |
147 | 147 | |
148 | 148 | // Loop through all tabs. |
149 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
149 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
150 | 150 | |
151 | 151 | // In each tab, loop through sections. |
152 | - foreach ( $sections as $section => $settings ) { |
|
152 | + foreach ($sections as $section => $settings) { |
|
153 | 153 | |
154 | 154 | // Check for backwards compatibility |
155 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
156 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
155 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
156 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
157 | 157 | $section = 'main'; |
158 | 158 | $settings = $sections; |
159 | 159 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | 'wpinv_settings_' . $tab . '_' . $section |
167 | 167 | ); |
168 | 168 | |
169 | - foreach ( $settings as $option ) { |
|
170 | - if ( ! empty( $option['id'] ) ) { |
|
171 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
169 | + foreach ($settings as $option) { |
|
170 | + if (!empty($option['id'])) { |
|
171 | + wpinv_register_settings_option($tab, $section, $option); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Creates our settings in the options table. |
178 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
178 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
179 | 179 | } |
180 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
180 | +add_action('admin_init', 'wpinv_register_settings'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Register a single settings option. |
@@ -187,49 +187,49 @@ discard block |
||
187 | 187 | * @param string $option |
188 | 188 | * |
189 | 189 | */ |
190 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
190 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
191 | 191 | |
192 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
192 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
197 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
198 | + $tip = wpinv_clean($option['desc']); |
|
199 | 199 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
200 | - unset( $option['desc'] ); |
|
200 | + unset($option['desc']); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
205 | 205 | 'wpinv_settings[' . $option['id'] . ']', |
206 | 206 | $name, |
207 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
207 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
208 | 208 | $section, |
209 | 209 | $section, |
210 | 210 | array( |
211 | 211 | 'section' => $section, |
212 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
213 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
212 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
213 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
214 | 214 | 'name' => $name, |
215 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
216 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
217 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
218 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
219 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
220 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
221 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
222 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
223 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
224 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
225 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
226 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
227 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
215 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
216 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
217 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
218 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
219 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
220 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
221 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
222 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
223 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
224 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
225 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
226 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
227 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
228 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
229 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
230 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return array |
251 | 251 | */ |
252 | 252 | function getpaid_get_integration_settings() { |
253 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
253 | + return apply_filters('getpaid_integration_settings', array()); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,126 +258,126 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function wpinv_settings_sanitize( $input = array() ) { |
|
261 | +function wpinv_settings_sanitize($input = array()) { |
|
262 | 262 | |
263 | 263 | $wpinv_options = wpinv_get_options(); |
264 | 264 | $raw_referrer = wp_get_raw_referer(); |
265 | 265 | |
266 | - if ( empty( $raw_referrer ) ) { |
|
267 | - return array_merge( $wpinv_options, $input ); |
|
266 | + if (empty($raw_referrer)) { |
|
267 | + return array_merge($wpinv_options, $input); |
|
268 | 268 | } |
269 | 269 | |
270 | - wp_parse_str( $raw_referrer, $referrer ); |
|
270 | + wp_parse_str($raw_referrer, $referrer); |
|
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
272 | + if (in_array('gp-setup', $referrer)) { |
|
273 | + return array_merge($wpinv_options, $input); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
278 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
277 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
278 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
279 | 279 | |
280 | 280 | $input = $input ? $input : array(); |
281 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
282 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
281 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
282 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
283 | 283 | |
284 | 284 | // Loop through each setting being saved and pass it through a sanitization filter |
285 | - foreach ( $input as $key => $value ) { |
|
285 | + foreach ($input as $key => $value) { |
|
286 | 286 | |
287 | 287 | // Get the setting type (checkbox, select, etc) |
288 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
288 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
289 | 289 | |
290 | - if ( $type ) { |
|
290 | + if ($type) { |
|
291 | 291 | // Field type specific filter |
292 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
292 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
297 | 297 | |
298 | 298 | // Key specific filter. |
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
299 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
303 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
304 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
303 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
304 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
305 | 305 | |
306 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
306 | + $found_settings = array_merge($main_settings, $section_settings); |
|
307 | 307 | |
308 | - if ( ! empty( $found_settings ) ) { |
|
309 | - foreach ( $found_settings as $key => $value ) { |
|
308 | + if (!empty($found_settings)) { |
|
309 | + foreach ($found_settings as $key => $value) { |
|
310 | 310 | |
311 | 311 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
312 | - if ( is_numeric( $key ) ) { |
|
312 | + if (is_numeric($key)) { |
|
313 | 313 | $key = $value['id']; |
314 | 314 | } |
315 | 315 | |
316 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
317 | - unset( $wpinv_options[ $key ] ); |
|
316 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
317 | + unset($wpinv_options[$key]); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Merge our new settings with the existing |
323 | - $output = array_merge( $wpinv_options, $input ); |
|
323 | + $output = array_merge($wpinv_options, $input); |
|
324 | 324 | |
325 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
325 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
326 | 326 | |
327 | 327 | return $output; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
330 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
329 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
330 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
331 | 331 | |
332 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
332 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
337 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
338 | 338 | $tax_rates = array(); |
339 | 339 | |
340 | - foreach ( $new_rates as $rate ) { |
|
340 | + foreach ($new_rates as $rate) { |
|
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
342 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
343 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
344 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
345 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
346 | + $rate['global'] = empty($rate['state']); |
|
347 | 347 | $tax_rates[] = $rate; |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
351 | + update_option('wpinv_tax_rates', $tax_rates); |
|
352 | 352 | |
353 | 353 | return $input; |
354 | 354 | } |
355 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
355 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
356 | 356 | |
357 | 357 | function wpinv_get_settings_tabs() { |
358 | 358 | $tabs = array(); |
359 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
360 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
361 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
359 | + $tabs['general'] = __('General', 'invoicing'); |
|
360 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
361 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
362 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
363 | 363 | |
364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
364 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
365 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
366 | 366 | } |
367 | 367 | |
368 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
369 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
370 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
368 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
369 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
370 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
371 | 371 | |
372 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
372 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
373 | 373 | } |
374 | 374 | |
375 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
375 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
376 | 376 | $tabs = false; |
377 | 377 | $sections = wpinv_get_registered_settings_sections(); |
378 | 378 | |
379 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
380 | - $tabs = $sections[ $tab ]; |
|
379 | + if ($tab && !empty($sections[$tab])) { |
|
380 | + $tabs = $sections[$tab]; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $tabs; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | function wpinv_get_registered_settings_sections() { |
387 | 387 | static $sections = false; |
388 | 388 | |
389 | - if ( false !== $sections ) { |
|
389 | + if (false !== $sections) { |
|
390 | 390 | return $sections; |
391 | 391 | } |
392 | 392 | |
@@ -394,161 +394,161 @@ discard block |
||
394 | 394 | 'general' => apply_filters( |
395 | 395 | 'wpinv_settings_sections_general', |
396 | 396 | array( |
397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
397 | + 'main' => __('General Settings', 'invoicing'), |
|
398 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
399 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
400 | + 'labels' => __('Label Texts', 'invoicing'), |
|
401 | 401 | ) |
402 | 402 | ), |
403 | 403 | 'gateways' => apply_filters( |
404 | 404 | 'wpinv_settings_sections_gateways', |
405 | 405 | array( |
406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
406 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
407 | 407 | ) |
408 | 408 | ), |
409 | 409 | 'taxes' => apply_filters( |
410 | 410 | 'wpinv_settings_sections_taxes', |
411 | 411 | array( |
412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
412 | + 'main' => __('Tax Settings', 'invoicing'), |
|
413 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
414 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
415 | 415 | ) |
416 | 416 | ), |
417 | 417 | 'emails' => apply_filters( |
418 | 418 | 'wpinv_settings_sections_emails', |
419 | 419 | array( |
420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
420 | + 'main' => __('Email Settings', 'invoicing'), |
|
421 | 421 | ) |
422 | 422 | ), |
423 | 423 | |
424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
424 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
425 | 425 | |
426 | 426 | 'privacy' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_privacy', |
428 | 428 | array( |
429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | + 'main' => __('Privacy policy', 'invoicing'), |
|
430 | 430 | ) |
431 | 431 | ), |
432 | 432 | 'misc' => apply_filters( |
433 | 433 | 'wpinv_settings_sections_misc', |
434 | 434 | array( |
435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
435 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
436 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
437 | 437 | ) |
438 | 438 | ), |
439 | 439 | 'tools' => apply_filters( |
440 | 440 | 'wpinv_settings_sections_tools', |
441 | 441 | array( |
442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
442 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ); |
446 | 446 | |
447 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
447 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
448 | 448 | |
449 | 449 | return $sections; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
452 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
453 | 453 | $pages_options = array(); |
454 | 454 | |
455 | - if ( $default_label !== null && $default_label !== false ) { |
|
456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
455 | + if ($default_label !== null && $default_label !== false) { |
|
456 | + $pages_options = array('' => $default_label); // Blank option |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $pages = get_pages(); |
460 | - if ( $pages ) { |
|
461 | - foreach ( $pages as $page ) { |
|
460 | + if ($pages) { |
|
461 | + foreach ($pages as $page) { |
|
462 | 462 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
463 | - $pages_options[ $page->ID ] = $title; |
|
463 | + $pages_options[$page->ID] = $title; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | 467 | return $pages_options; |
468 | 468 | } |
469 | 469 | |
470 | -function wpinv_header_callback( $args ) { |
|
471 | - if ( ! empty( $args['desc'] ) ) { |
|
472 | - echo wp_kses_post( $args['desc'] ); |
|
470 | +function wpinv_header_callback($args) { |
|
471 | + if (!empty($args['desc'])) { |
|
472 | + echo wp_kses_post($args['desc']); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -function wpinv_hidden_callback( $args ) { |
|
476 | +function wpinv_hidden_callback($args) { |
|
477 | 477 | |
478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
478 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
479 | + $value = wpinv_get_option($args['id'], $std); |
|
480 | 480 | |
481 | - if ( isset( $args['set_value'] ) ) { |
|
481 | + if (isset($args['set_value'])) { |
|
482 | 482 | $value = $args['set_value']; |
483 | 483 | } |
484 | 484 | |
485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
485 | + if (isset($args['faux']) && true === $args['faux']) { |
|
486 | 486 | $args['readonly'] = true; |
487 | - $name = ''; |
|
487 | + $name = ''; |
|
488 | 488 | } else { |
489 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
489 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
490 | 490 | } |
491 | 491 | |
492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
497 | 497 | * Displays a checkbox settings callback. |
498 | 498 | */ |
499 | -function wpinv_checkbox_callback( $args ) { |
|
499 | +function wpinv_checkbox_callback($args) { |
|
500 | 500 | |
501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
503 | - $id = esc_attr( $args['id'] ); |
|
501 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
502 | + $std = wpinv_get_option($args['id'], $std); |
|
503 | + $id = esc_attr($args['id']); |
|
504 | 504 | |
505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
505 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
506 | 506 | ?> |
507 | 507 | <fieldset> |
508 | 508 | <label> |
509 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
510 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
509 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
510 | + <?php echo wp_kses_post($args['desc']); ?> |
|
511 | 511 | </label> |
512 | 512 | </fieldset> |
513 | 513 | <?php |
514 | 514 | } |
515 | 515 | |
516 | -function wpinv_multicheck_callback( $args ) { |
|
516 | +function wpinv_multicheck_callback($args) { |
|
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
519 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if (!empty($args['options'])) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
523 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
524 | + $value = wpinv_get_option($args['id'], $std); |
|
525 | 525 | |
526 | 526 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
527 | - foreach ( $args['options'] as $key => $option ) : |
|
528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
527 | + foreach ($args['options'] as $key => $option) : |
|
528 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
529 | + if (in_array($sanitize_key, $value)) { |
|
530 | 530 | $enabled = $sanitize_key; |
531 | 531 | } else { |
532 | 532 | $enabled = null; |
533 | 533 | } |
534 | - echo '<div class="wpi-mcheck-row"><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 ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
534 | + echo '<div class="wpi-mcheck-row"><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) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
536 | 536 | endforeach; |
537 | 537 | echo '</div>'; |
538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
538 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
542 | -function wpinv_payment_icons_callback( $args ) { |
|
542 | +function wpinv_payment_icons_callback($args) { |
|
543 | 543 | |
544 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
545 | - $value = wpinv_get_option( $args['id'], false ); |
|
544 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
545 | + $value = wpinv_get_option($args['id'], false); |
|
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach ( $args['options'] as $key => $option ) { |
|
549 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
547 | + if (!empty($args['options'])) { |
|
548 | + foreach ($args['options'] as $key => $option) { |
|
549 | + $sanitize_key = wpinv_sanitize_key($key); |
|
550 | 550 | |
551 | - if ( empty( $value ) ) { |
|
551 | + if (empty($value)) { |
|
552 | 552 | $enabled = $option; |
553 | 553 | } else { |
554 | 554 | $enabled = null; |
@@ -556,67 +556,67 @@ discard block |
||
556 | 556 | |
557 | 557 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
558 | 558 | |
559 | - 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 ) . '/> '; |
|
559 | + 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) . '/> '; |
|
560 | 560 | |
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | + if (wpinv_string_is_image_url($key)) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | 563 | } else { |
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
564 | + $card = strtolower(str_replace(' ', '', $option)); |
|
565 | 565 | |
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
566 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
567 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
568 | 568 | } else { |
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
569 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
570 | 570 | $content_dir = WP_CONTENT_DIR; |
571 | 571 | |
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
572 | + if (function_exists('wp_normalize_path')) { |
|
573 | 573 | // Replaces backslashes with forward slashes for Windows systems |
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
574 | + $image = wp_normalize_path($image); |
|
575 | + $content_dir = wp_normalize_path($content_dir); |
|
576 | 576 | } |
577 | 577 | |
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
578 | + $image = str_replace($content_dir, content_url(), $image); |
|
579 | 579 | } |
580 | 580 | |
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
581 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | 582 | } |
583 | 583 | echo $option . '</label>'; |
584 | 584 | } |
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
590 | 590 | * Displays a radio settings field. |
591 | 591 | */ |
592 | -function wpinv_radio_callback( $args ) { |
|
592 | +function wpinv_radio_callback($args) { |
|
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
594 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option($args['id'], $std); |
|
596 | 596 | ?> |
597 | 597 | <fieldset> |
598 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
599 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
598 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
599 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
600 | 600 | <li> |
601 | 601 | <label> |
602 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
603 | - <?php echo wp_kses_post( $option ); ?> |
|
602 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
603 | + <?php echo wp_kses_post($option); ?> |
|
604 | 604 | </label> |
605 | 605 | </li> |
606 | 606 | <?php endforeach; ?> |
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback($args); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Displays a description if available. |
615 | 615 | */ |
616 | -function getpaid_settings_description_callback( $args ) { |
|
616 | +function getpaid_settings_description_callback($args) { |
|
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
619 | - $description = wp_kses_post( $args['desc'] ); |
|
618 | + if (!empty($args['desc'])) { |
|
619 | + $description = wp_kses_post($args['desc']); |
|
620 | 620 | echo "<p class='description'>$description</p>"; |
621 | 621 | } |
622 | 622 | |
@@ -632,31 +632,31 @@ discard block |
||
632 | 632 | </tr> |
633 | 633 | <tr class="bsui"> |
634 | 634 | <td colspan="2" class="p-0"> |
635 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
635 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
636 | 636 | |
637 | 637 | <?php |
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_gateway_select_callback( $args ) { |
|
640 | +function wpinv_gateway_select_callback($args) { |
|
641 | 641 | |
642 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
643 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
642 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
643 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
644 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
645 | + $value = wpinv_get_option($args['id'], $std); |
|
646 | 646 | |
647 | 647 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
650 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
651 | - $selected = selected( $key, $args['selected'], false ); |
|
649 | + foreach ($args['options'] as $key => $option) : |
|
650 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
651 | + $selected = selected($key, $args['selected'], false); |
|
652 | 652 | } else { |
653 | - $selected = selected( $key, $value, false ); |
|
653 | + $selected = selected($key, $value, false); |
|
654 | 654 | } |
655 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
655 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
656 | 656 | endforeach; |
657 | 657 | |
658 | 658 | echo '</select>'; |
659 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
659 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
@@ -665,28 +665,28 @@ discard block |
||
665 | 665 | * @param array $args |
666 | 666 | * @return string |
667 | 667 | */ |
668 | -function wpinv_settings_attrs_helper( $args ) { |
|
668 | +function wpinv_settings_attrs_helper($args) { |
|
669 | 669 | |
670 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
671 | - $id = esc_attr( $args['id'] ); |
|
672 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
670 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
671 | + $id = esc_attr($args['id']); |
|
672 | + $placeholder = esc_attr($args['placeholder']); |
|
673 | 673 | |
674 | - if ( ! empty( $args['faux'] ) ) { |
|
674 | + if (!empty($args['faux'])) { |
|
675 | 675 | $args['readonly'] = true; |
676 | 676 | $name = ''; |
677 | 677 | } else { |
678 | - $value = wpinv_get_option( $args['id'], $value ); |
|
678 | + $value = wpinv_get_option($args['id'], $value); |
|
679 | 679 | $name = "wpinv_settings[$id]"; |
680 | 680 | } |
681 | 681 | |
682 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
683 | - $class = esc_attr( $args['class'] ); |
|
684 | - $style = esc_attr( $args['style'] ); |
|
685 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
682 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
683 | + $class = esc_attr($args['class']); |
|
684 | + $style = esc_attr($args['style']); |
|
685 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
686 | 686 | |
687 | 687 | $onchange = ''; |
688 | - if ( ! empty( $args['onchange'] ) ) { |
|
689 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
688 | + if (!empty($args['onchange'])) { |
|
689 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -695,14 +695,14 @@ discard block |
||
695 | 695 | /** |
696 | 696 | * Displays a text input settings callback. |
697 | 697 | */ |
698 | -function wpinv_text_callback( $args ) { |
|
698 | +function wpinv_text_callback($args) { |
|
699 | 699 | |
700 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
700 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
701 | 701 | |
702 | 702 | ?> |
703 | 703 | <label style="width: 100%;"> |
704 | - <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
|
705 | - <?php echo wp_kses_post( $desc ); ?> |
|
704 | + <input type="text" <?php echo wpinv_settings_attrs_helper($args); ?>> |
|
705 | + <?php echo wp_kses_post($desc); ?> |
|
706 | 706 | </label> |
707 | 707 | <?php |
708 | 708 | |
@@ -711,49 +711,49 @@ discard block |
||
711 | 711 | /** |
712 | 712 | * Displays a number input settings callback. |
713 | 713 | */ |
714 | -function wpinv_number_callback( $args ) { |
|
714 | +function wpinv_number_callback($args) { |
|
715 | 715 | |
716 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
717 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
716 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
717 | + $attr = wpinv_settings_attrs_helper($args); |
|
718 | 718 | |
719 | 719 | ?> |
720 | 720 | <label style="width: 100%;"> |
721 | - <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
|
722 | - <?php echo wp_kses_post( $desc ); ?> |
|
721 | + <input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php echo $attr; ?>> |
|
722 | + <?php echo wp_kses_post($desc); ?> |
|
723 | 723 | </label> |
724 | 724 | <?php |
725 | 725 | |
726 | 726 | } |
727 | 727 | |
728 | -function wpinv_textarea_callback( $args ) { |
|
728 | +function wpinv_textarea_callback($args) { |
|
729 | 729 | |
730 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
731 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
732 | - $value = wpinv_get_option( $args['id'], $std ); |
|
730 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
731 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
732 | + $value = wpinv_get_option($args['id'], $std); |
|
733 | 733 | |
734 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
735 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
734 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
735 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
736 | 736 | |
737 | - echo '<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>'; |
|
738 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
737 | + echo '<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>'; |
|
738 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
739 | 739 | |
740 | 740 | } |
741 | 741 | |
742 | -function wpinv_password_callback( $args ) { |
|
742 | +function wpinv_password_callback($args) { |
|
743 | 743 | |
744 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
745 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
746 | - $value = wpinv_get_option( $args['id'], $std ); |
|
744 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
745 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
746 | + $value = wpinv_get_option($args['id'], $std); |
|
747 | 747 | |
748 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
749 | - echo '<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 ) . '"/>'; |
|
750 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
748 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
749 | + echo '<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) . '"/>'; |
|
750 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
751 | 751 | |
752 | 752 | } |
753 | 753 | |
754 | -function wpinv_missing_callback( $args ) { |
|
754 | +function wpinv_missing_callback($args) { |
|
755 | 755 | printf( |
756 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
756 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
757 | 757 | '<strong>' . $args['id'] . '</strong>' |
758 | 758 | ); |
759 | 759 | } |
@@ -761,35 +761,35 @@ discard block |
||
761 | 761 | /** |
762 | 762 | * Displays a number input settings callback. |
763 | 763 | */ |
764 | -function wpinv_select_callback( $args ) { |
|
764 | +function wpinv_select_callback($args) { |
|
765 | 765 | |
766 | - $desc = wp_kses_post( $args['desc'] ); |
|
767 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
768 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
769 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
770 | - $value = wpinv_get_option( $args['id'], $value ); |
|
771 | - $rand = uniqid( 'random_id' ); |
|
766 | + $desc = wp_kses_post($args['desc']); |
|
767 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
768 | + $attr = wpinv_settings_attrs_helper($args); |
|
769 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
770 | + $value = wpinv_get_option($args['id'], $value); |
|
771 | + $rand = uniqid('random_id'); |
|
772 | 772 | |
773 | 773 | ?> |
774 | 774 | <label style="width: 100%;"> |
775 | 775 | <select <?php echo $attr; ?> data-allow-clear="true"> |
776 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
777 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
776 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
777 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
778 | 778 | <?php endforeach; ?> |
779 | 779 | </select> |
780 | 780 | |
781 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
782 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ); ?></a> |
|
781 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
782 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing'); ?></a> |
|
783 | 783 | <?php endif; ?> |
784 | 784 | |
785 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
786 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ); ?></a> |
|
785 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
786 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing'); ?></a> |
|
787 | 787 | <div id='<?php echo $rand; ?>' style='display:none;'> |
788 | 788 | <div> |
789 | - <h3><?php _e( 'Original Content', 'invoicing' ); ?></h3> |
|
790 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
791 | - <h3><?php _e( 'Current Content', 'invoicing' ); ?></h3> |
|
792 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
789 | + <h3><?php _e('Original Content', 'invoicing'); ?></h3> |
|
790 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
791 | + <h3><?php _e('Current Content', 'invoicing'); ?></h3> |
|
792 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
793 | 793 | </div> |
794 | 794 | </div> |
795 | 795 | <?php endif; ?> |
@@ -800,89 +800,89 @@ discard block |
||
800 | 800 | |
801 | 801 | } |
802 | 802 | |
803 | -function wpinv_color_select_callback( $args ) { |
|
803 | +function wpinv_color_select_callback($args) { |
|
804 | 804 | |
805 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
806 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
807 | - $value = wpinv_get_option( $args['id'], $std ); |
|
805 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
806 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
807 | + $value = wpinv_get_option($args['id'], $std); |
|
808 | 808 | |
809 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
809 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
810 | 810 | |
811 | - foreach ( $args['options'] as $option => $color ) { |
|
812 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
811 | + foreach ($args['options'] as $option => $color) { |
|
812 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | echo '</select>'; |
816 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
816 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
817 | 817 | |
818 | 818 | } |
819 | 819 | |
820 | -function wpinv_rich_editor_callback( $args ) { |
|
820 | +function wpinv_rich_editor_callback($args) { |
|
821 | 821 | global $wp_version; |
822 | 822 | |
823 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
823 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
824 | 824 | |
825 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
826 | - $value = wpinv_get_option( $args['id'], $std ); |
|
825 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
826 | + $value = wpinv_get_option($args['id'], $std); |
|
827 | 827 | |
828 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
828 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
829 | 829 | $value = $std; |
830 | 830 | } |
831 | 831 | |
832 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
832 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
833 | 833 | |
834 | 834 | echo '<div class="getpaid-settings-editor-input">'; |
835 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
835 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
836 | 836 | wp_editor( |
837 | - stripslashes( $value ), |
|
838 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
837 | + stripslashes($value), |
|
838 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
839 | 839 | array( |
840 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
841 | - 'textarea_rows' => absint( $rows ), |
|
840 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
841 | + 'textarea_rows' => absint($rows), |
|
842 | 842 | 'media_buttons' => false, |
843 | 843 | ) |
844 | 844 | ); |
845 | 845 | } else { |
846 | - echo '<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>'; |
|
846 | + echo '<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>'; |
|
847 | 847 | } |
848 | 848 | |
849 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
849 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
850 | 850 | |
851 | 851 | } |
852 | 852 | |
853 | -function wpinv_upload_callback( $args ) { |
|
853 | +function wpinv_upload_callback($args) { |
|
854 | 854 | |
855 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
855 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
856 | 856 | |
857 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
858 | - $value = wpinv_get_option( $args['id'], $std ); |
|
857 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
858 | + $value = wpinv_get_option($args['id'], $std); |
|
859 | 859 | |
860 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
861 | - echo '<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 ) ) . '"/>'; |
|
862 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
863 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
860 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
861 | + echo '<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)) . '"/>'; |
|
862 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
863 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
864 | 864 | |
865 | 865 | } |
866 | 866 | |
867 | -function wpinv_color_callback( $args ) { |
|
867 | +function wpinv_color_callback($args) { |
|
868 | 868 | |
869 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
870 | - $value = wpinv_get_option( $args['id'], $std ); |
|
871 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
869 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
870 | + $value = wpinv_get_option($args['id'], $std); |
|
871 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
872 | 872 | |
873 | - echo '<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( $std ) . '" />'; |
|
874 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
873 | + echo '<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($std) . '" />'; |
|
874 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
875 | 875 | |
876 | 876 | } |
877 | 877 | |
878 | -function wpinv_country_states_callback( $args ) { |
|
878 | +function wpinv_country_states_callback($args) { |
|
879 | 879 | |
880 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
881 | - $value = wpinv_get_option( $args['id'], $std ); |
|
880 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
881 | + $value = wpinv_get_option($args['id'], $std); |
|
882 | 882 | |
883 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
883 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
884 | 884 | |
885 | - if ( isset( $args['placeholder'] ) ) { |
|
885 | + if (isset($args['placeholder'])) { |
|
886 | 886 | $placeholder = $args['placeholder']; |
887 | 887 | } else { |
888 | 888 | $placeholder = ''; |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | |
891 | 891 | $states = wpinv_get_country_states(); |
892 | 892 | |
893 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
894 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
893 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
894 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
895 | 895 | |
896 | - foreach ( $states as $option => $name ) { |
|
897 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
896 | + foreach ($states as $option => $name) { |
|
897 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | echo '</select>'; |
901 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
901 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
902 | 902 | |
903 | 903 | } |
904 | 904 | |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | </tr> |
913 | 913 | <tr class="bsui"> |
914 | 914 | <td colspan="2" class="p-0"> |
915 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
915 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
916 | 916 | |
917 | 917 | <?php |
918 | 918 | |
@@ -921,14 +921,14 @@ discard block |
||
921 | 921 | /** |
922 | 922 | * Displays a tax rate' edit row. |
923 | 923 | */ |
924 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
924 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
925 | 925 | ob_start(); |
926 | 926 | |
927 | - $key = sanitize_key( $key ); |
|
928 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
929 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
927 | + $key = sanitize_key($key); |
|
928 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
929 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
930 | 930 | |
931 | - if ( $echo ) { |
|
931 | + if ($echo) { |
|
932 | 932 | echo ob_get_clean(); |
933 | 933 | } else { |
934 | 934 | return ob_get_clean(); |
@@ -937,154 +937,154 @@ discard block |
||
937 | 937 | } |
938 | 938 | |
939 | 939 | |
940 | -function wpinv_tools_callback( $args ) { |
|
940 | +function wpinv_tools_callback($args) { |
|
941 | 941 | ob_start(); |
942 | 942 | ?> |
943 | 943 | </td><tr> |
944 | 944 | <td colspan="2" class="wpinv_tools_tdbox"> |
945 | 945 | <?php |
946 | - if ( $args['desc'] ) { |
|
946 | + if ($args['desc']) { |
|
947 | 947 | ?> |
948 | 948 | <p><?php echo $args['desc']; ?></p><?php } ?> |
949 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
949 | + <?php do_action('wpinv_tools_before'); ?> |
|
950 | 950 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
951 | 951 | <thead> |
952 | 952 | <tr> |
953 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
954 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
955 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
953 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
954 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
955 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
956 | 956 | </tr> |
957 | 957 | </thead> |
958 | 958 | |
959 | 959 | <tbody> |
960 | 960 | <tr> |
961 | - <td><?php _e( 'Check Pages', 'invoicing' ); ?></td> |
|
961 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
962 | 962 | <td> |
963 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
963 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
964 | 964 | </td> |
965 | 965 | <td> |
966 | 966 | <a href=" |
967 | 967 | <?php |
968 | 968 | echo esc_url( |
969 | 969 | wp_nonce_url( |
970 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
970 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
971 | 971 | 'getpaid-nonce', |
972 | 972 | 'getpaid-nonce' |
973 | 973 | ) |
974 | 974 | ); |
975 | 975 | ?> |
976 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
976 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
977 | 977 | </td> |
978 | 978 | </tr> |
979 | 979 | <tr> |
980 | - <td><?php _e( 'Create Database Tables', 'invoicing' ); ?></td> |
|
980 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
981 | 981 | <td> |
982 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
982 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
983 | 983 | </td> |
984 | 984 | <td> |
985 | 985 | <a href=" |
986 | 986 | <?php |
987 | 987 | echo esc_url( |
988 | 988 | wp_nonce_url( |
989 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
989 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
990 | 990 | 'getpaid-nonce', |
991 | 991 | 'getpaid-nonce' |
992 | 992 | ) |
993 | 993 | ); |
994 | 994 | ?> |
995 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
995 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
996 | 996 | </td> |
997 | 997 | </tr> |
998 | 998 | <tr> |
999 | - <td><?php _e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
999 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
1000 | 1000 | <td> |
1001 | - <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1001 | + <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1002 | 1002 | </td> |
1003 | 1003 | <td> |
1004 | 1004 | <a href=" |
1005 | 1005 | <?php |
1006 | 1006 | echo esc_url( |
1007 | 1007 | wp_nonce_url( |
1008 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1008 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1009 | 1009 | 'getpaid-nonce', |
1010 | 1010 | 'getpaid-nonce' |
1011 | 1011 | ) |
1012 | 1012 | ); |
1013 | 1013 | ?> |
1014 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
1014 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1015 | 1015 | </td> |
1016 | 1016 | </tr> |
1017 | 1017 | |
1018 | 1018 | <tr> |
1019 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1019 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1020 | 1020 | <td> |
1021 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1021 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1022 | 1022 | </td> |
1023 | 1023 | <td> |
1024 | 1024 | <a href=" |
1025 | 1025 | <?php |
1026 | 1026 | echo esc_url( |
1027 | 1027 | wp_nonce_url( |
1028 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1028 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1029 | 1029 | 'getpaid-nonce', |
1030 | 1030 | 'getpaid-nonce' |
1031 | 1031 | ) |
1032 | 1032 | ); |
1033 | 1033 | ?> |
1034 | - " class="button button-primary"><?php _e( 'Run', 'invoicing' ); ?></a> |
|
1034 | + " class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1035 | 1035 | </td> |
1036 | 1036 | </tr> |
1037 | 1037 | |
1038 | 1038 | <tr> |
1039 | - <td><?php _e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1039 | + <td><?php _e('Set-up Wizard', 'invoicing'); ?></td> |
|
1040 | 1040 | <td> |
1041 | - <small><?php _e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1041 | + <small><?php _e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1042 | 1042 | </td> |
1043 | 1043 | <td> |
1044 | 1044 | <a href=" |
1045 | 1045 | <?php |
1046 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1046 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1047 | 1047 | ?> |
1048 | - " class="button button-primary"><?php _e( 'Launch', 'invoicing' ); ?></a> |
|
1048 | + " class="button button-primary"><?php _e('Launch', 'invoicing'); ?></a> |
|
1049 | 1049 | </td> |
1050 | 1050 | </tr> |
1051 | 1051 | |
1052 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1052 | + <?php do_action('wpinv_tools_row'); ?> |
|
1053 | 1053 | </tbody> |
1054 | 1054 | </table> |
1055 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1055 | + <?php do_action('wpinv_tools_after'); ?> |
|
1056 | 1056 | <?php |
1057 | 1057 | echo ob_get_clean(); |
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | |
1061 | -function wpinv_descriptive_text_callback( $args ) { |
|
1062 | - echo wp_kses_post( $args['desc'] ); |
|
1061 | +function wpinv_descriptive_text_callback($args) { |
|
1062 | + echo wp_kses_post($args['desc']); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | -function wpinv_raw_html_callback( $args ) { |
|
1065 | +function wpinv_raw_html_callback($args) { |
|
1066 | 1066 | echo $args['desc']; |
1067 | 1067 | } |
1068 | 1068 | |
1069 | -function wpinv_hook_callback( $args ) { |
|
1070 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1069 | +function wpinv_hook_callback($args) { |
|
1070 | + do_action('wpinv_' . $args['id'], $args); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | function wpinv_set_settings_cap() { |
1074 | 1074 | return wpinv_get_capability(); |
1075 | 1075 | } |
1076 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1076 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1077 | 1077 | |
1078 | 1078 | |
1079 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1080 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1081 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1079 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1080 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1081 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1082 | 1082 | |
1083 | - if ( $old != $new ) { |
|
1084 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1083 | + if ($old != $new) { |
|
1084 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1085 | 1085 | } |
1086 | 1086 | } |
1087 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1087 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1088 | 1088 | |
1089 | 1089 | /** |
1090 | 1090 | * Returns the merge tags help text. |
@@ -1093,16 +1093,16 @@ discard block |
||
1093 | 1093 | * |
1094 | 1094 | * @return string |
1095 | 1095 | */ |
1096 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1096 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1097 | 1097 | |
1098 | 1098 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1099 | 1099 | $link = sprintf( |
1100 | 1100 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1101 | 1101 | $url, |
1102 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1102 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1103 | 1103 | ); |
1104 | 1104 | |
1105 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1105 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1106 | 1106 | |
1107 | 1107 | return "$description $link"; |
1108 | 1108 |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; // Exit if accessed directly |
9 | 9 | } |
10 | 10 | |
11 | -if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
|
11 | +if (!class_exists('GetPaid_Admin_Profile', false)) : |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * GetPaid_Admin_Profile Class. |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | * Hook in tabs. |
20 | 20 | */ |
21 | 21 | public function __construct() { |
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
22 | + add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
23 | + add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
24 | 24 | |
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
25 | + add_action('personal_options_update', array($this, 'save_customer_meta_fields')); |
|
26 | + add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -37,54 +37,54 @@ discard block |
||
37 | 37 | 'getpaid_customer_meta_fields', |
38 | 38 | array( |
39 | 39 | 'billing' => array( |
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
40 | + 'title' => __('Billing Details (GetPaid)', 'invoicing'), |
|
41 | 41 | 'fields' => array( |
42 | 42 | '_wpinv_first_name' => array( |
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
43 | + 'label' => __('First name', 'invoicing'), |
|
44 | 44 | 'description' => '', |
45 | 45 | ), |
46 | 46 | '_wpinv_last_name' => array( |
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
47 | + 'label' => __('Last name', 'invoicing'), |
|
48 | 48 | 'description' => '', |
49 | 49 | ), |
50 | 50 | '_wpinv_company' => array( |
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
51 | + 'label' => __('Company', 'invoicing'), |
|
52 | 52 | 'description' => '', |
53 | 53 | ), |
54 | 54 | '_wpinv_company_id' => array( |
55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
55 | + 'label' => __('Company ID', 'invoicing'), |
|
56 | 56 | 'description' => '', |
57 | 57 | ), |
58 | 58 | '_wpinv_address' => array( |
59 | - 'label' => __( 'Address', 'invoicing' ), |
|
59 | + 'label' => __('Address', 'invoicing'), |
|
60 | 60 | 'description' => '', |
61 | 61 | ), |
62 | 62 | '_wpinv_city' => array( |
63 | - 'label' => __( 'City', 'invoicing' ), |
|
63 | + 'label' => __('City', 'invoicing'), |
|
64 | 64 | 'description' => '', |
65 | 65 | ), |
66 | 66 | '_wpinv_zip' => array( |
67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
67 | + 'label' => __('Postcode / ZIP', 'invoicing'), |
|
68 | 68 | 'description' => '', |
69 | 69 | ), |
70 | 70 | '_wpinv_country' => array( |
71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
71 | + 'label' => __('Country / Region', 'invoicing'), |
|
72 | 72 | 'description' => '', |
73 | 73 | 'class' => 'getpaid_js_field-country', |
74 | 74 | 'type' => 'select', |
75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
75 | + 'options' => array('' => __('Select a country / region…', 'invoicing')) + wpinv_get_country_list(), |
|
76 | 76 | ), |
77 | 77 | '_wpinv_state' => array( |
78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
78 | + 'label' => __('State / County', 'invoicing'), |
|
79 | + 'description' => __('State / County or state code', 'invoicing'), |
|
80 | 80 | 'class' => 'getpaid_js_field-state regular-text', |
81 | 81 | ), |
82 | 82 | '_wpinv_phone' => array( |
83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
83 | + 'label' => __('Phone', 'invoicing'), |
|
84 | 84 | 'description' => '', |
85 | 85 | ), |
86 | 86 | '_wpinv_vat_number' => array( |
87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
87 | + 'label' => __('VAT Number', 'invoicing'), |
|
88 | 88 | 'description' => '', |
89 | 89 | ), |
90 | 90 | ), |
@@ -99,39 +99,39 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param WP_User $user |
101 | 101 | */ |
102 | - public function add_customer_meta_fields( $user ) { |
|
102 | + public function add_customer_meta_fields($user) { |
|
103 | 103 | |
104 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
104 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $show_fields = $this->get_customer_meta_fields(); |
109 | 109 | |
110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
110 | + foreach ($show_fields as $fieldset_key => $fieldset) : |
|
111 | 111 | ?> |
112 | - <h2><?php echo esc_html( $fieldset['title'] ); ?></h2> |
|
113 | - <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
|
114 | - <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
|
112 | + <h2><?php echo esc_html($fieldset['title']); ?></h2> |
|
113 | + <table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>"> |
|
114 | + <?php foreach ($fieldset['fields'] as $key => $field) : ?> |
|
115 | 115 | <tr> |
116 | 116 | <th> |
117 | - <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
|
117 | + <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label> |
|
118 | 118 | </th> |
119 | 119 | <td> |
120 | - <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
|
121 | - <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
|
120 | + <?php if (!empty($field['type']) && 'select' === $field['type']) : ?> |
|
121 | + <select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;"> |
|
122 | 122 | <?php |
123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
124 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
123 | + $selected = esc_attr(get_user_meta($user->ID, $key, true)); |
|
124 | + foreach ($field['options'] as $option_key => $option_value) : |
|
125 | 125 | ?> |
126 | - <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
|
126 | + <option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option> |
|
127 | 127 | <?php endforeach; ?> |
128 | 128 | </select> |
129 | - <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> |
|
130 | - <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> /> |
|
129 | + <?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?> |
|
130 | + <input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> /> |
|
131 | 131 | <?php else : ?> |
132 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
132 | + <input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" /> |
|
133 | 133 | <?php endif; ?> |
134 | - <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> |
|
134 | + <p class="description"><?php echo wp_kses_post($field['description']); ?></p> |
|
135 | 135 | </td> |
136 | 136 | </tr> |
137 | 137 | <?php endforeach; ?> |
@@ -145,21 +145,21 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param int $user_id User ID of the user being saved |
147 | 147 | */ |
148 | - public function save_customer_meta_fields( $user_id ) { |
|
149 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
148 | + public function save_customer_meta_fields($user_id) { |
|
149 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $save_fields = $this->get_customer_meta_fields(); |
154 | 154 | |
155 | - foreach ( $save_fields as $fieldset ) { |
|
155 | + foreach ($save_fields as $fieldset) { |
|
156 | 156 | |
157 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
157 | + foreach ($fieldset['fields'] as $key => $field) { |
|
158 | 158 | |
159 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
160 | - update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) ); |
|
161 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
159 | + if (isset($field['type']) && 'checkbox' === $field['type']) { |
|
160 | + update_user_meta($user_id, $key, !empty($_POST[$key])); |
|
161 | + } elseif (isset($_POST[$key])) { |
|
162 | + update_user_meta($user_id, $key, wpinv_clean($_POST[$key])); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @param string $key Key for user meta field |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - protected function get_user_meta( $user_id, $key ) { |
|
177 | - $value = get_user_meta( $user_id, $key, true ); |
|
178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
179 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
176 | + protected function get_user_meta($user_id, $key) { |
|
177 | + $value = get_user_meta($user_id, $key, true); |
|
178 | + $existing_fields = array('_wpinv_first_name', '_wpinv_last_name'); |
|
179 | + if (!$value && in_array($key, $existing_fields)) { |
|
180 | + $value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $value; |
@@ -1,51 +1,51 @@ 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 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code': |
15 | - echo esc_html( $discount->get_code() ); |
|
15 | + echo esc_html($discount->get_code()); |
|
16 | 16 | break; |
17 | 17 | case 'amount': |
18 | - echo wp_kses_post( $discount->get_formatted_amount() ); |
|
18 | + echo wp_kses_post($discount->get_formatted_amount()); |
|
19 | 19 | break; |
20 | 20 | case 'usage': |
21 | - echo wp_kses_post( $discount->get_usage() ); |
|
21 | + echo wp_kses_post($discount->get_usage()); |
|
22 | 22 | break; |
23 | 23 | case 'start_date': |
24 | - echo wp_kses_post( getpaid_format_date_value( $discount->get_start_date() ) ); |
|
24 | + echo wp_kses_post(getpaid_format_date_value($discount->get_start_date())); |
|
25 | 25 | break; |
26 | 26 | case 'expiry_date': |
27 | - echo wp_kses_post( getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ) ); |
|
27 | + echo wp_kses_post(getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'))); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 ); |
|
33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
34 | - $post_type = ! empty( $post->post_type ) ? $post->post_type : ''; |
|
32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2); |
|
33 | +function wpinv_post_row_actions($actions, $post) { |
|
34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
35 | 35 | |
36 | - if ( $post_type == 'wpi_discount' ) { |
|
37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
36 | + if ($post_type == 'wpi_discount') { |
|
37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $actions; |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
44 | - $row_actions = array(); |
|
45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
44 | + $row_actions = array(); |
|
45 | + $edit_link = get_edit_post_link($discount->ID); |
|
46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
47 | 47 | |
48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
49 | 49 | |
50 | 50 | $url = wp_nonce_url( |
51 | 51 | add_query_arg( |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | 'getpaid-nonce', |
58 | 58 | 'getpaid-nonce' |
59 | 59 | ); |
60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
60 | + $anchor = __('Deactivate', 'invoicing'); |
|
61 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
63 | 63 | |
64 | - } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
64 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
65 | 65 | |
66 | - $url = wp_nonce_url( |
|
66 | + $url = wp_nonce_url( |
|
67 | 67 | add_query_arg( |
68 | 68 | array( |
69 | 69 | 'getpaid-admin-action' => 'activate_discount', |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | 'getpaid-nonce', |
74 | 74 | 'getpaid-nonce' |
75 | 75 | ); |
76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
76 | + $anchor = __('Activate', 'invoicing'); |
|
77 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $url = esc_url( |
|
82 | + $url = esc_url( |
|
83 | 83 | wp_nonce_url( |
84 | 84 | add_query_arg( |
85 | 85 | array( |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | 'getpaid-nonce' |
92 | 92 | ) |
93 | 93 | ); |
94 | - $anchor = __( 'Delete', 'invoicing' ); |
|
95 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
94 | + $anchor = __('Delete', 'invoicing'); |
|
95 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
96 | 96 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
97 | 97 | |
98 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
98 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
99 | 99 | |
100 | 100 | return $row_actions; |
101 | 101 | } |
@@ -103,68 +103,68 @@ discard block |
||
103 | 103 | function wpinv_restrict_manage_posts() { |
104 | 104 | global $typenow; |
105 | 105 | |
106 | - if ( 'wpi_discount' == $typenow ) { |
|
106 | + if ('wpi_discount' == $typenow) { |
|
107 | 107 | wpinv_discount_filters(); |
108 | 108 | } |
109 | 109 | } |
110 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
110 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
111 | 111 | |
112 | 112 | function wpinv_discount_filters() { |
113 | 113 | |
114 | 114 | ?> |
115 | 115 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
116 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
116 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
117 | 117 | <?php |
118 | 118 | $types = wpinv_get_discount_types(); |
119 | 119 | |
120 | - foreach ( $types as $name => $type ) { |
|
121 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
120 | + foreach ($types as $name => $type) { |
|
121 | + echo '<option value="' . esc_attr($name) . '"'; |
|
122 | 122 | |
123 | - if ( isset( $_GET['discount_type'] ) ) { |
|
124 | - selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
123 | + if (isset($_GET['discount_type'])) { |
|
124 | + selected($name, sanitize_text_field($_GET['discount_type'])); |
|
125 | 125 | } |
126 | 126 | |
127 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
127 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | </select> |
131 | 131 | <?php |
132 | 132 | } |
133 | 133 | |
134 | -function wpinv_request( $vars ) { |
|
134 | +function wpinv_request($vars) { |
|
135 | 135 | global $typenow, $wp_post_statuses; |
136 | 136 | |
137 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
138 | - if ( ! isset( $vars['post_status'] ) ) { |
|
139 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
137 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
138 | + if (!isset($vars['post_status'])) { |
|
139 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
140 | 140 | |
141 | - foreach ( $post_statuses as $status => $value ) { |
|
142 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
143 | - unset( $post_statuses[ $status ] ); |
|
141 | + foreach ($post_statuses as $status => $value) { |
|
142 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
143 | + unset($post_statuses[$status]); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
147 | + $vars['post_status'] = array_keys($post_statuses); |
|
148 | 148 | } |
149 | -} elseif ( 'wpi_discount' == $typenow ) { |
|
150 | - $meta_query = ! empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
149 | +} elseif ('wpi_discount' == $typenow) { |
|
150 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
151 | 151 | // Filter vat rule type |
152 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
152 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
153 | 153 | $meta_query[] = array( |
154 | 154 | 'key' => '_wpi_discount_type', |
155 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
155 | + 'value' => sanitize_key(urldecode($_GET['discount_type'])), |
|
156 | 156 | 'compare' => '=', |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! empty( $meta_query ) ) { |
|
160 | + if (!empty($meta_query)) { |
|
161 | 161 | $vars['meta_query'] = $meta_query; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | return $vars; |
166 | 166 | } |
167 | -add_filter( 'request', 'wpinv_request' ); |
|
167 | +add_filter('request', 'wpinv_request'); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Create a page and store the ID in an option. |
@@ -176,61 +176,61 @@ discard block |
||
176 | 176 | * @param int $post_parent (default: 0) Parent for the new page |
177 | 177 | * @return int page ID |
178 | 178 | */ |
179 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
179 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
180 | 180 | global $wpdb; |
181 | 181 | |
182 | - $option_value = wpinv_get_option( $option ); |
|
182 | + $option_value = wpinv_get_option($option); |
|
183 | 183 | |
184 | - if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) { |
|
185 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
184 | + if (!empty($option_value) && ($page_object = get_post($option_value))) { |
|
185 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
186 | 186 | // Valid page is already in place |
187 | 187 | return $page_object->ID; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if ( ! empty( $post_parent ) ) { |
|
192 | - $page = get_page_by_path( $post_parent ); |
|
193 | - if ( $page ) { |
|
191 | + if (!empty($post_parent)) { |
|
192 | + $page = get_page_by_path($post_parent); |
|
193 | + if ($page) { |
|
194 | 194 | $post_parent = $page->ID; |
195 | 195 | } else { |
196 | 196 | $post_parent = ''; |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - if ( strlen( $page_content ) > 0 ) { |
|
200 | + if (strlen($page_content) > 0) { |
|
201 | 201 | // Search for an existing page with the specified page content (typically a shortcode) |
202 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
202 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
203 | 203 | } else { |
204 | 204 | // Search for an existing page with the specified page slug |
205 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
205 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
206 | 206 | } |
207 | 207 | |
208 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
208 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
209 | 209 | |
210 | - if ( $valid_page_found ) { |
|
211 | - if ( $option ) { |
|
212 | - wpinv_update_option( $option, $valid_page_found ); |
|
210 | + if ($valid_page_found) { |
|
211 | + if ($option) { |
|
212 | + wpinv_update_option($option, $valid_page_found); |
|
213 | 213 | } |
214 | 214 | return $valid_page_found; |
215 | 215 | } |
216 | 216 | |
217 | 217 | // Search for a matching valid trashed page |
218 | - if ( strlen( $page_content ) > 0 ) { |
|
218 | + if (strlen($page_content) > 0) { |
|
219 | 219 | // Search for an existing page with the specified page content (typically a shortcode) |
220 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
220 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
221 | 221 | } else { |
222 | 222 | // Search for an existing page with the specified page slug |
223 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
223 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( $trashed_page_found ) { |
|
226 | + if ($trashed_page_found) { |
|
227 | 227 | $page_id = $trashed_page_found; |
228 | 228 | $page_data = array( |
229 | 229 | 'ID' => $page_id, |
230 | 230 | 'post_status' => 'publish', |
231 | 231 | 'post_parent' => $post_parent, |
232 | 232 | ); |
233 | - wp_update_post( $page_data ); |
|
233 | + wp_update_post($page_data); |
|
234 | 234 | } else { |
235 | 235 | $page_data = array( |
236 | 236 | 'post_status' => 'publish', |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | 'post_parent' => $post_parent, |
243 | 243 | 'comment_status' => 'closed', |
244 | 244 | ); |
245 | - $page_id = wp_insert_post( $page_data ); |
|
245 | + $page_id = wp_insert_post($page_data); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( $option ) { |
|
249 | - wpinv_update_option( $option, (int) $page_id ); |
|
248 | + if ($option) { |
|
249 | + wpinv_update_option($option, (int) $page_id); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $page_id; |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_add_aui_screens( $screen_ids ) { |
|
262 | +function wpinv_add_aui_screens($screen_ids) { |
|
263 | 263 | |
264 | 264 | // load on these pages if set |
265 | - $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() ); |
|
265 | + $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids()); |
|
266 | 266 | |
267 | 267 | return $screen_ids; |
268 | 268 | } |
269 | -add_filter( 'aui_screen_ids', 'wpinv_add_aui_screens' ); |
|
269 | +add_filter('aui_screen_ids', 'wpinv_add_aui_screens'); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) ); |
|
17 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
21 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
22 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
23 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_head', array($this, 'set_admin_menu_class')); |
|
17 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
18 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
19 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
20 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
21 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
22 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
23 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function set_admin_menu_class() { |
30 | 30 | global $current_screen, $parent_file, $submenu_file; |
31 | 31 | |
32 | - if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
|
32 | + if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) { |
|
33 | 33 | $parent_file = 'wpinv'; |
34 | 34 | $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
35 | 35 | } |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | public function admin_menu() { |
40 | 40 | |
41 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
41 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
42 | 42 | add_menu_page( |
43 | - __( 'GetPaid', 'invoicing' ), |
|
44 | - __( 'GetPaid', 'invoicing' ), |
|
43 | + __('GetPaid', 'invoicing'), |
|
44 | + __('GetPaid', 'invoicing'), |
|
45 | 45 | $capability, |
46 | 46 | 'wpinv', |
47 | 47 | null, |
48 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
48 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
49 | 49 | '54.123460' |
50 | 50 | ); |
51 | 51 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | public function add_customers_menu() { |
58 | 58 | add_submenu_page( |
59 | 59 | 'wpinv', |
60 | - __( 'Customers', 'invoicing' ), |
|
61 | - __( 'Customers', 'invoicing' ), |
|
60 | + __('Customers', 'invoicing'), |
|
61 | + __('Customers', 'invoicing'), |
|
62 | 62 | wpinv_get_capability(), |
63 | 63 | 'wpinv-customers', |
64 | - array( $this, 'customers_page' ) |
|
64 | + array($this, 'customers_page') |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | public function add_subscriptions_menu() { |
72 | 72 | add_submenu_page( |
73 | 73 | 'wpinv', |
74 | - __( 'Subscriptions', 'invoicing' ), |
|
75 | - __( 'Subscriptions', 'invoicing' ), |
|
74 | + __('Subscriptions', 'invoicing'), |
|
75 | + __('Subscriptions', 'invoicing'), |
|
76 | 76 | wpinv_get_capability(), |
77 | 77 | 'wpinv-subscriptions', |
78 | 78 | 'wpinv_subscriptions_page' |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | width: 30%; |
92 | 92 | } |
93 | 93 | </style> |
94 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?> <a href="<?php echo wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ); ?>" class="page-title-action"><?php _e( 'Export', 'invoicing' ); ?></a></h1> |
|
94 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?> <a href="<?php echo wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce'); ?>" class="page-title-action"><?php _e('Export', 'invoicing'); ?></a></h1> |
|
95 | 95 | <form method="post"> |
96 | 96 | <?php |
97 | 97 | $table = new WPInv_Customers_Table(); |
98 | 98 | $table->prepare_items(); |
99 | - $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' ); |
|
99 | + $table->search_box(__('Search Customers', 'invoicing'), 'search-customers'); |
|
100 | 100 | $table->display(); |
101 | 101 | ?> |
102 | 102 | </form> |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | public function add_settings_menu() { |
111 | 111 | add_submenu_page( |
112 | 112 | 'wpinv', |
113 | - __( 'Invoice Settings', 'invoicing' ), |
|
114 | - __( 'Settings', 'invoicing' ), |
|
115 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
113 | + __('Invoice Settings', 'invoicing'), |
|
114 | + __('Settings', 'invoicing'), |
|
115 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
116 | 116 | 'wpinv-settings', |
117 | - array( $this, 'options_page' ) |
|
117 | + array($this, 'options_page') |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 | |
121 | 121 | public function add_addons_menu() { |
122 | - if ( ! apply_filters( 'wpi_show_addons_page', true ) ) { |
|
122 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | add_submenu_page( |
127 | 127 | 'wpinv', |
128 | - __( 'Invoicing extensions', 'invoicing' ), |
|
129 | - __( 'Extensions', 'invoicing' ), |
|
128 | + __('Invoicing extensions', 'invoicing'), |
|
129 | + __('Extensions', 'invoicing'), |
|
130 | 130 | 'manage_options', |
131 | 131 | 'wpi-addons', |
132 | - array( $this, 'addons_page' ) |
|
132 | + array($this, 'addons_page') |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
@@ -140,29 +140,29 @@ discard block |
||
140 | 140 | |
141 | 141 | function options_page() { |
142 | 142 | |
143 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
143 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | 147 | $settings_tabs = wpinv_get_settings_tabs(); |
148 | - $settings_tabs = empty( $settings_tabs ) ? array() : $settings_tabs; |
|
149 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
150 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
148 | + $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
|
149 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
150 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
151 | 151 | $key = 'main'; |
152 | 152 | |
153 | - if ( is_array( $sections ) ) { |
|
154 | - $key = key( $sections ); |
|
153 | + if (is_array($sections)) { |
|
154 | + $key = key($sections); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | add_thickbox(); |
158 | 158 | |
159 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
160 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key; |
|
159 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
160 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key; |
|
161 | 161 | ?> |
162 | 162 | <div class="wrap"> |
163 | 163 | <h1 class="nav-tab-wrapper"> |
164 | 164 | <?php |
165 | - foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
165 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
166 | 166 | $tab_url = add_query_arg( |
167 | 167 | array( |
168 | 168 | 'settings-updated' => false, |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | ); |
173 | 173 | |
174 | 174 | // Remove the section from the tabs so we always end up at the main section |
175 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
176 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
175 | + $tab_url = remove_query_arg('section', $tab_url); |
|
176 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
177 | 177 | |
178 | 178 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
179 | 179 | |
180 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
181 | - echo esc_html( $tab_name ); |
|
180 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
181 | + echo esc_html($tab_name); |
|
182 | 182 | echo '</a>'; |
183 | 183 | } |
184 | 184 | ?> |
185 | 185 | </h1> |
186 | 186 | <?php |
187 | - $number_of_sections = count( $sections ); |
|
187 | + $number_of_sections = count($sections); |
|
188 | 188 | $number = 0; |
189 | - if ( $number_of_sections > 1 ) { |
|
189 | + if ($number_of_sections > 1) { |
|
190 | 190 | echo '<div><ul class="subsubsub">'; |
191 | - foreach ( $sections as $section_id => $section_name ) { |
|
191 | + foreach ($sections as $section_id => $section_name) { |
|
192 | 192 | echo '<li>'; |
193 | 193 | $number++; |
194 | 194 | $tab_url = add_query_arg( |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | 'tab' => $active_tab, |
198 | 198 | 'section' => $section_id, |
199 | 199 | ), |
200 | - admin_url( 'admin.php?page=wpinv-settings' ) |
|
200 | + admin_url('admin.php?page=wpinv-settings') |
|
201 | 201 | ); |
202 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
202 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
203 | 203 | $class = ''; |
204 | - if ( $section == $section_id ) { |
|
204 | + if ($section == $section_id) { |
|
205 | 205 | $class = 'current'; |
206 | 206 | } |
207 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
207 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
208 | 208 | |
209 | - if ( $number != $number_of_sections ) { |
|
209 | + if ($number != $number_of_sections) { |
|
210 | 210 | echo ' | '; |
211 | 211 | } |
212 | 212 | echo '</li>'; |
@@ -218,20 +218,20 @@ discard block |
||
218 | 218 | <form method="post" action="options.php"> |
219 | 219 | <table class="form-table"> |
220 | 220 | <?php |
221 | - settings_fields( 'wpinv_settings' ); |
|
221 | + settings_fields('wpinv_settings'); |
|
222 | 222 | |
223 | - if ( 'main' === $section ) { |
|
224 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
223 | + if ('main' === $section) { |
|
224 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
225 | 225 | } |
226 | 226 | |
227 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
228 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
229 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
230 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
227 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
228 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
229 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
230 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
231 | 231 | |
232 | 232 | // For backwards compatibility |
233 | - if ( 'main' === $section ) { |
|
234 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
233 | + if ('main' === $section) { |
|
234 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
235 | 235 | } |
236 | 236 | ?> |
237 | 237 | </table> |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | public function remove_admin_submenus() { |
246 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
246 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | |
254 | 254 | add_meta_box( |
255 | 255 | 'wpinv_endpoints_nav_link', |
256 | - __( 'GetPaid endpoints', 'invoicing' ), |
|
257 | - array( $this, 'nav_menu_links' ), |
|
256 | + __('GetPaid endpoints', 'invoicing'), |
|
257 | + array($this, 'nav_menu_links'), |
|
258 | 258 | 'nav-menus', |
259 | 259 | 'side', |
260 | 260 | 'low' |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | $endpoints = $this->get_menu_items(); |
270 | 270 | ?> |
271 | 271 | <div id="invoicing-endpoints" class="posttypediv"> |
272 | - <?php if ( ! empty( $endpoints['pages'] ) ) : ?> |
|
272 | + <?php if (!empty($endpoints['pages'])) : ?> |
|
273 | 273 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
274 | 274 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
275 | 275 | <?php |
276 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
277 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) ); |
|
276 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
277 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
278 | 278 | ?> |
279 | 279 | </ul> |
280 | 280 | </div> |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints"> |
284 | 284 | <span class="list-controls hide-if-no-js"> |
285 | 285 | <input type="checkbox" id="invoicing-endpoints-tab" class="select-all"> |
286 | - <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label> |
|
286 | + <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label> |
|
287 | 287 | </span> |
288 | 288 | |
289 | 289 | <span class="add-to-menu"> |
290 | - <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
290 | + <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
291 | 291 | <span class="spinner"></span> |
292 | 292 | </span> |
293 | 293 | </p> |
@@ -305,18 +305,18 @@ discard block |
||
305 | 305 | |
306 | 306 | $pages = array( |
307 | 307 | array( |
308 | - 'id' => wpinv_get_option( 'invoice_history_page' ), |
|
309 | - 'label' => __( 'My Invoices', 'invoicing' ), |
|
308 | + 'id' => wpinv_get_option('invoice_history_page'), |
|
309 | + 'label' => __('My Invoices', 'invoicing'), |
|
310 | 310 | ), |
311 | 311 | array( |
312 | - 'id' => wpinv_get_option( 'invoice_subscription_page' ), |
|
313 | - 'label' => __( 'My Subscriptions', 'invoicing' ), |
|
312 | + 'id' => wpinv_get_option('invoice_subscription_page'), |
|
313 | + 'label' => __('My Subscriptions', 'invoicing'), |
|
314 | 314 | ), |
315 | 315 | ); |
316 | 316 | |
317 | - foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) { |
|
317 | + foreach (apply_filters('getpaid_menu_pages', $pages) as $page) { |
|
318 | 318 | |
319 | - if ( (int) $page['id'] > 0 ) { |
|
319 | + if ((int) $page['id'] > 0) { |
|
320 | 320 | |
321 | 321 | $item = new stdClass(); |
322 | 322 | $item->object_id = (int) $page['id']; |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | $item->object = 'page'; |
325 | 325 | $item->menu_item_parent = 0; |
326 | 326 | $item->type = 'post_type'; |
327 | - $item->title = esc_html( $page['label'] ); |
|
328 | - $item->url = get_permalink( (int) $page['id'] ); |
|
327 | + $item->title = esc_html($page['label']); |
|
328 | + $item->url = get_permalink((int) $page['id']); |
|
329 | 329 | $item->target = ''; |
330 | 330 | $item->attr_title = ''; |
331 | - $item->classes = array( 'wpinv-menu-item' ); |
|
331 | + $item->classes = array('wpinv-menu-item'); |
|
332 | 332 | $item->xfn = ''; |
333 | 333 | |
334 | 334 | $items['pages'][] = $item; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
339 | + return apply_filters('wpinv_menu_items', $items); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |