@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_customers_page() { |
26 | 26 | $default_views = give_customer_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_customer_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_customer_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_customers_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_customer_views', $views ); |
|
45 | + return apply_filters('give_customer_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_customer_tabs', $tabs ); |
|
59 | + return apply_filters('give_customer_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_customers_list() { |
70 | - include( dirname( __FILE__ ) . '/class-customer-table.php' ); |
|
70 | + include(dirname(__FILE__).'/class-customer-table.php'); |
|
71 | 71 | |
72 | 72 | $customers_table = new Give_Customer_Reports_Table(); |
73 | 73 | $customers_table->prepare_items(); |
74 | 74 | ?> |
75 | 75 | <div class="wrap"> |
76 | - <h2><?php _e( 'Donors', 'give' ); ?></h2> |
|
77 | - <?php do_action( 'give_donors_table_top' ); ?> |
|
78 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
76 | + <h2><?php _e('Donors', 'give'); ?></h2> |
|
77 | + <?php do_action('give_donors_table_top'); ?> |
|
78 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
79 | 79 | <?php |
80 | - $customers_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' ); |
|
80 | + $customers_table->search_box(__('Search Donors', 'give'), 'give-donors'); |
|
81 | 81 | $customers_table->display(); |
82 | 82 | ?> |
83 | 83 | <input type="hidden" name="post_type" value="give_forms" /> |
84 | 84 | <input type="hidden" name="page" value="give-donors" /> |
85 | 85 | <input type="hidden" name="view" value="customers" /> |
86 | 86 | </form> |
87 | - <?php do_action( 'give_donors_table_bottom' ); ?> |
|
87 | + <?php do_action('give_donors_table_bottom'); ?> |
|
88 | 88 | </div> |
89 | 89 | <?php |
90 | 90 | } |
@@ -99,27 +99,27 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return void |
101 | 101 | */ |
102 | -function give_render_customer_view( $view, $callbacks ) { |
|
102 | +function give_render_customer_view($view, $callbacks) { |
|
103 | 103 | |
104 | 104 | $render = true; |
105 | 105 | |
106 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
106 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
107 | 107 | |
108 | - if ( ! current_user_can( $customer_view_role ) ) { |
|
109 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
108 | + if ( ! current_user_can($customer_view_role)) { |
|
109 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
110 | 110 | $render = false; |
111 | 111 | } |
112 | 112 | |
113 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
114 | - give_set_error( 'give-invalid_customer', __( 'Invalid Donor ID Provided.', 'give' ) ); |
|
113 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
114 | + give_set_error('give-invalid_customer', __('Invalid Donor ID Provided.', 'give')); |
|
115 | 115 | $render = false; |
116 | 116 | } |
117 | 117 | |
118 | 118 | $customer_id = (int) $_GET['id']; |
119 | - $customer = new Give_Customer( $customer_id ); |
|
119 | + $customer = new Give_Customer($customer_id); |
|
120 | 120 | |
121 | - if ( empty( $customer->id ) ) { |
|
122 | - give_set_error( 'give-invalid_customer', __( 'Invalid Donor ID Provided.', 'give' ) ); |
|
121 | + if (empty($customer->id)) { |
|
122 | + give_set_error('give-invalid_customer', __('Invalid Donor ID Provided.', 'give')); |
|
123 | 123 | $render = false; |
124 | 124 | } |
125 | 125 | |
@@ -128,27 +128,27 @@ discard block |
||
128 | 128 | |
129 | 129 | <div class='wrap'> |
130 | 130 | |
131 | - <?php if ( give_get_errors() ) : ?> |
|
131 | + <?php if (give_get_errors()) : ?> |
|
132 | 132 | <div class="error settings-error"> |
133 | - <?php give_print_errors( 0 ); ?> |
|
133 | + <?php give_print_errors(0); ?> |
|
134 | 134 | </div> |
135 | 135 | <?php endif; ?> |
136 | 136 | |
137 | - <?php if ( $customer && $render ) : ?> |
|
137 | + <?php if ($customer && $render) : ?> |
|
138 | 138 | |
139 | 139 | <div id="customer-tab-wrapper"> |
140 | 140 | <ul id="customer-tab-wrapper-list" class="nav-tab-wrapper"> |
141 | - <?php foreach ( $customer_tabs as $key => $tab ) : ?> |
|
141 | + <?php foreach ($customer_tabs as $key => $tab) : ?> |
|
142 | 142 | <?php $active = $key === $view ? true : false; ?> |
143 | 143 | <?php $class = $active ? 'active' : 'inactive'; ?> |
144 | 144 | |
145 | - <li class="<?php echo sanitize_html_class( $class ); ?>"> |
|
146 | - <?php if ( ! $active ) : ?> |
|
147 | - <a title="<?php echo esc_attr( $tab['title'] ); ?>" aria-label="<?php echo esc_attr( $tab['title'] ); ?>" href="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ); ?>"> |
|
145 | + <li class="<?php echo sanitize_html_class($class); ?>"> |
|
146 | + <?php if ( ! $active) : ?> |
|
147 | + <a title="<?php echo esc_attr($tab['title']); ?>" aria-label="<?php echo esc_attr($tab['title']); ?>" href="<?php echo esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)); ?>"> |
|
148 | 148 | <?php endif; ?> |
149 | 149 | |
150 | - <span class="dashicons <?php echo sanitize_html_class( $tab['dashicon'] ); ?>"></span> <?php echo esc_attr( $tab['title'] ); ?> |
|
151 | - <?php if ( ! $active ) : ?> |
|
150 | + <span class="dashicons <?php echo sanitize_html_class($tab['dashicon']); ?>"></span> <?php echo esc_attr($tab['title']); ?> |
|
151 | + <?php if ( ! $active) : ?> |
|
152 | 152 | </a> |
153 | 153 | <?php endif; ?> |
154 | 154 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | </div> |
161 | 161 | |
162 | 162 | <div id="give-customer-card-wrapper"> |
163 | - <?php $callbacks[ $view ]( $customer ) ?> |
|
163 | + <?php $callbacks[$view]($customer) ?> |
|
164 | 164 | </div> |
165 | 165 | |
166 | 166 | <?php endif; ?> |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return void |
182 | 182 | */ |
183 | -function give_customers_view( $customer ) { |
|
183 | +function give_customers_view($customer) { |
|
184 | 184 | |
185 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
185 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
186 | 186 | |
187 | 187 | ?> |
188 | 188 | |
189 | - <?php do_action( 'give_donor_card_top', $customer ); ?> |
|
189 | + <?php do_action('give_donor_card_top', $customer); ?> |
|
190 | 190 | |
191 | 191 | <div id="donor-summary" class="info-wrapper customer-section postbox"> |
192 | 192 | |
193 | - <form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>"> |
|
193 | + <form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>"> |
|
194 | 194 | |
195 | 195 | <div class="customer-info"> |
196 | 196 | |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | <div class="donor-bio-header clearfix"> |
199 | 199 | |
200 | 200 | <div class="avatar-wrap left" id="customer-avatar"> |
201 | - <?php echo get_avatar( $customer->email ); ?> |
|
201 | + <?php echo get_avatar($customer->email); ?> |
|
202 | 202 | </div> |
203 | 203 | |
204 | 204 | <div class="customer-id" class="left"> |
205 | 205 | #<?php echo $customer->id; ?> |
206 | 206 | </div> |
207 | 207 | <div id="customer-name-wrap" class="left"> |
208 | - <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php _e( 'Donor Name', 'give' ); ?>" /></span> |
|
208 | + <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php _e('Donor Name', 'give'); ?>" /></span> |
|
209 | 209 | <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span> |
210 | 210 | </div> |
211 | 211 | <p class="customer-since info-item"> |
212 | - <?php _e( 'Donor since', 'give' ); ?> |
|
213 | - <?php echo date_i18n( get_option( 'date_format' ), strtotime( $customer->date_created ) ) ?> |
|
212 | + <?php _e('Donor since', 'give'); ?> |
|
213 | + <?php echo date_i18n(get_option('date_format'), strtotime($customer->date_created)) ?> |
|
214 | 214 | </p> |
215 | - <?php if ( current_user_can( $customer_edit_role ) ): ?> |
|
216 | - <a title="<?php _e( 'Edit Donor', 'give' ); ?>" href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php _e( 'Edit Donor', 'give' ); ?></a> |
|
215 | + <?php if (current_user_can($customer_edit_role)): ?> |
|
216 | + <a title="<?php _e('Edit Donor', 'give'); ?>" href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php _e('Edit Donor', 'give'); ?></a> |
|
217 | 217 | <?php endif; ?> |
218 | 218 | </div> |
219 | 219 | <!-- /donor-bio-header --> |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | <table class="widefat"> |
224 | 224 | <tbody> |
225 | 225 | <tr> |
226 | - <td><label for="tablecell"><?php esc_attr_e( 'Email', 'give' ); ?></label>:</td> |
|
226 | + <td><label for="tablecell"><?php esc_attr_e('Email', 'give'); ?></label>:</td> |
|
227 | 227 | <td class="row-title"> |
228 | - <span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php echo $customer->email; ?>" placeholder="<?php _e( 'Donor Email', 'give' ); ?>" /></span> |
|
228 | + <span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php echo $customer->email; ?>" placeholder="<?php _e('Donor Email', 'give'); ?>" /></span> |
|
229 | 229 | <span class="customer-email info-item editable" data-key="email"><?php echo $customer->email; ?></span> |
230 | 230 | </td> |
231 | 231 | </tr> |
232 | 232 | <tr class="alternate"> |
233 | - <td><label for="tablecell"><?php esc_attr_e( 'User ID', 'give' ); ?></label>:</td> |
|
233 | + <td><label for="tablecell"><?php esc_attr_e('User ID', 'give'); ?></label>:</td> |
|
234 | 234 | <td class="row-title"> |
235 | 235 | <span class="customer-user-id info-item edit-item"> |
236 | 236 | <?php |
@@ -246,38 +246,38 @@ discard block |
||
246 | 246 | 'data' => $data_atts, |
247 | 247 | ); |
248 | 248 | |
249 | - if ( ! empty( $user_id ) ) { |
|
250 | - $userdata = get_userdata( $user_id ); |
|
249 | + if ( ! empty($user_id)) { |
|
250 | + $userdata = get_userdata($user_id); |
|
251 | 251 | $user_args['value'] = $userdata->user_login; |
252 | 252 | } |
253 | 253 | |
254 | - echo Give()->html->ajax_user_search( $user_args ); |
|
254 | + echo Give()->html->ajax_user_search($user_args); |
|
255 | 255 | ?> |
256 | 256 | <input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" /> |
257 | 257 | </span> |
258 | 258 | |
259 | 259 | <span class="customer-user-id info-item editable"> |
260 | - <?php if ( intval( $customer->user_id ) > 0 ) : ?> |
|
260 | + <?php if (intval($customer->user_id) > 0) : ?> |
|
261 | 261 | <span data-key="user_id"><?php echo $customer->user_id; ?></span> |
262 | 262 | <?php else : ?> |
263 | - <span data-key="user_id"><?php _e( 'None', 'give' ); ?></span> |
|
263 | + <span data-key="user_id"><?php _e('None', 'give'); ?></span> |
|
264 | 264 | <?php endif; ?> |
265 | - <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) : ?> |
|
266 | - <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php _e( 'Disconnects the current user ID from this customer record', 'give' ); ?>"><?php _e( 'Disconnect User', 'give' ); ?></a></span> |
|
265 | + <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) : ?> |
|
266 | + <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php _e('Disconnects the current user ID from this customer record', 'give'); ?>"><?php _e('Disconnect User', 'give'); ?></a></span> |
|
267 | 267 | <?php endif; ?> |
268 | 268 | </span> |
269 | 269 | </td> |
270 | 270 | </tr> |
271 | - <?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?> |
|
271 | + <?php if (isset($customer->user_id) && $customer->user_id > 0) : ?> |
|
272 | 272 | |
273 | 273 | <tr> |
274 | - <td><?php esc_attr_e( 'Address', 'give' ); ?>:</td> |
|
274 | + <td><?php esc_attr_e('Address', 'give'); ?>:</td> |
|
275 | 275 | <td class="row-title"> |
276 | 276 | |
277 | 277 | <div class="customer-address-wrapper"> |
278 | 278 | |
279 | 279 | <?php |
280 | - $address = get_user_meta( $customer->user_id, '_give_user_address', true ); |
|
280 | + $address = get_user_meta($customer->user_id, '_give_user_address', true); |
|
281 | 281 | $defaults = array( |
282 | 282 | 'line1' => '', |
283 | 283 | 'line2' => '', |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | 'zip' => '' |
288 | 288 | ); |
289 | 289 | |
290 | - $address = wp_parse_args( $address, $defaults ); |
|
290 | + $address = wp_parse_args($address, $defaults); |
|
291 | 291 | ?> |
292 | 292 | |
293 | - <?php if ( ! empty( $address ) ) { ?> |
|
293 | + <?php if ( ! empty($address)) { ?> |
|
294 | 294 | <span class="customer-address info-item editable"> |
295 | 295 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
296 | 296 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -301,38 +301,38 @@ discard block |
||
301 | 301 | </span> |
302 | 302 | <?php } ?> |
303 | 303 | <span class="customer-address info-item edit-item"> |
304 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
305 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
306 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
304 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
305 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
306 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
307 | 307 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
308 | 308 | <?php |
309 | 309 | |
310 | 310 | $selected_country = $address['country']; |
311 | 311 | |
312 | 312 | $countries = give_get_country_list(); |
313 | - foreach ( $countries as $country_code => $country ) { |
|
314 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
313 | + foreach ($countries as $country_code => $country) { |
|
314 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
315 | 315 | } |
316 | 316 | ?> |
317 | 317 | </select> |
318 | 318 | <?php |
319 | 319 | $selected_state = give_get_state(); |
320 | - $states = give_get_states( $selected_country ); |
|
320 | + $states = give_get_states($selected_country); |
|
321 | 321 | |
322 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
322 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
323 | 323 | |
324 | - if ( ! empty( $states ) ) : ?> |
|
324 | + if ( ! empty($states)) : ?> |
|
325 | 325 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
326 | 326 | <?php |
327 | - foreach ( $states as $state_code => $state ) { |
|
328 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
327 | + foreach ($states as $state_code => $state) { |
|
328 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
329 | 329 | } |
330 | 330 | ?> |
331 | 331 | </select> |
332 | 332 | <?php else : ?> |
333 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php _e( 'State / Province', 'give' ); ?>" /> |
|
333 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php _e('State / Province', 'give'); ?>" /> |
|
334 | 334 | <?php endif; ?> |
335 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e( 'Postal', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
335 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e('Postal', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
336 | 336 | </span> |
337 | 337 | |
338 | 338 | </div> |
@@ -350,120 +350,120 @@ discard block |
||
350 | 350 | |
351 | 351 | <span id="customer-edit-actions" class="edit-item"> |
352 | 352 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" /> |
353 | - <?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?> |
|
353 | + <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> |
|
354 | 354 | <input type="hidden" name="give_action" value="edit-customer" /> |
355 | - <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php _e( 'Update Donor', 'give' ); ?>" /> |
|
356 | - <a id="give-edit-customer-cancel" href="" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
355 | + <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php _e('Update Donor', 'give'); ?>" /> |
|
356 | + <a id="give-edit-customer-cancel" href="" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
357 | 357 | </span> |
358 | 358 | |
359 | 359 | </form> |
360 | 360 | </div> |
361 | 361 | |
362 | - <?php do_action( 'give_donor_before_stats', $customer ); ?> |
|
362 | + <?php do_action('give_donor_before_stats', $customer); ?> |
|
363 | 363 | |
364 | 364 | <div id="customer-stats-wrapper" class="customer-section postbox clear"> |
365 | 365 | <ul> |
366 | 366 | <li> |
367 | - <a title="<?php _e( 'View All Donations', 'give' ); ?>" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>"> |
|
367 | + <a title="<?php _e('View All Donations', 'give'); ?>" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>"> |
|
368 | 368 | <span class="dashicons dashicons-heart"></span> |
369 | 369 | <?php |
370 | 370 | //Completed Donations |
371 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count ); |
|
372 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer ); |
|
371 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); |
|
372 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer); |
|
373 | 373 | ?> |
374 | 374 | </a> |
375 | 375 | </li> |
376 | 376 | <li> |
377 | 377 | <span class="dashicons dashicons-chart-area"></span> |
378 | - <?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?> |
|
378 | + <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php _e('Lifetime Donations', 'give'); ?> |
|
379 | 379 | </li> |
380 | - <?php do_action( 'give_donor_stats_list', $customer ); ?> |
|
380 | + <?php do_action('give_donor_stats_list', $customer); ?> |
|
381 | 381 | </ul> |
382 | 382 | </div> |
383 | 383 | |
384 | - <?php do_action( 'give_donor_before_tables_wrapper', $customer ); ?> |
|
384 | + <?php do_action('give_donor_before_tables_wrapper', $customer); ?> |
|
385 | 385 | |
386 | 386 | <div id="customer-tables-wrapper" class="customer-section"> |
387 | 387 | |
388 | - <?php do_action( 'give_donor_before_tables', $customer ); ?> |
|
388 | + <?php do_action('give_donor_before_tables', $customer); ?> |
|
389 | 389 | |
390 | - <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
|
390 | + <h3><?php _e('Recent Donations', 'give'); ?></h3> |
|
391 | 391 | <?php |
392 | - $payment_ids = explode( ',', $customer->payment_ids ); |
|
393 | - $payments = give_get_payments( array( 'post__in' => $payment_ids ) ); |
|
394 | - $payments = array_slice( $payments, 0, 10 ); |
|
392 | + $payment_ids = explode(',', $customer->payment_ids); |
|
393 | + $payments = give_get_payments(array('post__in' => $payment_ids)); |
|
394 | + $payments = array_slice($payments, 0, 10); |
|
395 | 395 | ?> |
396 | 396 | <table class="wp-list-table widefat striped payments"> |
397 | 397 | <thead> |
398 | 398 | <tr> |
399 | - <th><?php _e( 'ID', 'give' ); ?></th> |
|
400 | - <th><?php _e( 'Amount', 'give' ); ?></th> |
|
401 | - <th><?php _e( 'Date', 'give' ); ?></th> |
|
402 | - <th><?php _e( 'Status', 'give' ); ?></th> |
|
403 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
399 | + <th><?php _e('ID', 'give'); ?></th> |
|
400 | + <th><?php _e('Amount', 'give'); ?></th> |
|
401 | + <th><?php _e('Date', 'give'); ?></th> |
|
402 | + <th><?php _e('Status', 'give'); ?></th> |
|
403 | + <th><?php _e('Actions', 'give'); ?></th> |
|
404 | 404 | </tr> |
405 | 405 | </thead> |
406 | 406 | <tbody> |
407 | - <?php if ( ! empty( $payments ) ) : ?> |
|
408 | - <?php foreach ( $payments as $payment ) : ?> |
|
407 | + <?php if ( ! empty($payments)) : ?> |
|
408 | + <?php foreach ($payments as $payment) : ?> |
|
409 | 409 | <tr> |
410 | 410 | <td><?php echo $payment->ID; ?></td> |
411 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
412 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $payment->post_date ) ); ?></td> |
|
413 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
411 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
412 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($payment->post_date)); ?></td> |
|
413 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
414 | 414 | <td> |
415 | - <a title="<?php _e( 'View Details for Donation', 'give' ); |
|
416 | - echo ' ' . $payment->ID; ?>" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ); ?>"> |
|
417 | - <?php _e( 'View Details', 'give' ); ?> |
|
415 | + <a title="<?php _e('View Details for Donation', 'give'); |
|
416 | + echo ' '.$payment->ID; ?>" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID); ?>"> |
|
417 | + <?php _e('View Details', 'give'); ?> |
|
418 | 418 | </a> |
419 | - <?php do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); ?> |
|
419 | + <?php do_action('give_donor_recent_purchases_actions', $customer, $payment); ?> |
|
420 | 420 | </td> |
421 | 421 | </tr> |
422 | 422 | <?php endforeach; ?> |
423 | 423 | <?php else: ?> |
424 | 424 | <tr> |
425 | - <td colspan="5"><?php _e( 'No Donations Found', 'give' ); ?></td> |
|
425 | + <td colspan="5"><?php _e('No Donations Found', 'give'); ?></td> |
|
426 | 426 | </tr> |
427 | 427 | <?php endif; ?> |
428 | 428 | </tbody> |
429 | 429 | </table> |
430 | 430 | |
431 | - <h3><?php _e( 'Completed Donations', 'give' ); ?></h3> |
|
431 | + <h3><?php _e('Completed Donations', 'give'); ?></h3> |
|
432 | 432 | <?php |
433 | - $donations = give_get_users_completed_donations( $customer->email ); |
|
433 | + $donations = give_get_users_completed_donations($customer->email); |
|
434 | 434 | ?> |
435 | 435 | <table class="wp-list-table widefat striped donations"> |
436 | 436 | <thead> |
437 | 437 | <tr> |
438 | 438 | <th><?php echo give_get_forms_label_singular(); ?></th> |
439 | - <th width="120px"><?php _e( 'Actions', 'give' ); ?></th> |
|
439 | + <th width="120px"><?php _e('Actions', 'give'); ?></th> |
|
440 | 440 | </tr> |
441 | 441 | </thead> |
442 | 442 | <tbody> |
443 | - <?php if ( ! empty( $donations ) ) : ?> |
|
444 | - <?php foreach ( $donations as $donation ) : ?> |
|
443 | + <?php if ( ! empty($donations)) : ?> |
|
444 | + <?php foreach ($donations as $donation) : ?> |
|
445 | 445 | <tr> |
446 | 446 | <td><?php echo $donation->post_title; ?></td> |
447 | 447 | <td> |
448 | - <a title="<?php echo esc_attr( sprintf( __( 'View %s', 'give' ), $donation->post_title ) ); ?>" href="<?php echo esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ); ?>"> |
|
449 | - <?php printf( __( 'View %s', 'give' ), give_get_forms_label_singular() ); ?> |
|
448 | + <a title="<?php echo esc_attr(sprintf(__('View %s', 'give'), $donation->post_title)); ?>" href="<?php echo esc_url(admin_url('post.php?action=edit&post='.$donation->ID)); ?>"> |
|
449 | + <?php printf(__('View %s', 'give'), give_get_forms_label_singular()); ?> |
|
450 | 450 | </a> |
451 | 451 | </td> |
452 | 452 | </tr> |
453 | 453 | <?php endforeach; ?> |
454 | 454 | <?php else: ?> |
455 | 455 | <tr> |
456 | - <td colspan="2"><?php _e( 'No Completed Donations Found', 'give' ); ?></td> |
|
456 | + <td colspan="2"><?php _e('No Completed Donations Found', 'give'); ?></td> |
|
457 | 457 | </tr> |
458 | 458 | <?php endif; ?> |
459 | 459 | </tbody> |
460 | 460 | </table> |
461 | 461 | |
462 | - <?php do_action( 'give_donor_after_tables', $customer ); ?> |
|
462 | + <?php do_action('give_donor_after_tables', $customer); ?> |
|
463 | 463 | |
464 | 464 | </div> |
465 | 465 | |
466 | - <?php do_action( 'give_donor_card_bottom', $customer ); ?> |
|
466 | + <?php do_action('give_donor_card_bottom', $customer); ?> |
|
467 | 467 | |
468 | 468 | <?php |
469 | 469 | } |
@@ -477,30 +477,30 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return void |
479 | 479 | */ |
480 | -function give_customer_notes_view( $customer ) { |
|
480 | +function give_customer_notes_view($customer) { |
|
481 | 481 | |
482 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
483 | - $paged = absint( $paged ); |
|
482 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
483 | + $paged = absint($paged); |
|
484 | 484 | $note_count = $customer->get_notes_count(); |
485 | - $per_page = apply_filters( 'give_customer_notes_per_page', 20 ); |
|
486 | - $total_pages = ceil( $note_count / $per_page ); |
|
487 | - $customer_notes = $customer->get_notes( $per_page, $paged ); |
|
485 | + $per_page = apply_filters('give_customer_notes_per_page', 20); |
|
486 | + $total_pages = ceil($note_count / $per_page); |
|
487 | + $customer_notes = $customer->get_notes($per_page, $paged); |
|
488 | 488 | ?> |
489 | 489 | |
490 | 490 | <div id="customer-notes-wrapper"> |
491 | 491 | <div class="customer-notes-header"> |
492 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
492 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
493 | 493 | </div> |
494 | - <h3><?php _e( 'Notes', 'give' ); ?></h3> |
|
494 | + <h3><?php _e('Notes', 'give'); ?></h3> |
|
495 | 495 | |
496 | - <?php if ( 1 == $paged ) : ?> |
|
496 | + <?php if (1 == $paged) : ?> |
|
497 | 497 | <div style="display: block; margin-bottom: 55px;"> |
498 | - <form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>"> |
|
498 | + <form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>"> |
|
499 | 499 | <textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea> |
500 | 500 | <br /> |
501 | 501 | <input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" /> |
502 | 502 | <input type="hidden" name="give_action" value="add-customer-note" /> |
503 | - <?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?> |
|
503 | + <?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?> |
|
504 | 504 | <input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" /> |
505 | 505 | </form> |
506 | 506 | </div> |
@@ -515,46 +515,46 @@ discard block |
||
515 | 515 | 'show_all' => true |
516 | 516 | ); |
517 | 517 | |
518 | - echo paginate_links( $pagination_args ); |
|
518 | + echo paginate_links($pagination_args); |
|
519 | 519 | ?> |
520 | 520 | |
521 | 521 | <div id="give-customer-notes" class="postbox"> |
522 | - <?php if ( count( $customer_notes ) > 0 ) : ?> |
|
523 | - <?php foreach ( $customer_notes as $key => $note ) : ?> |
|
522 | + <?php if (count($customer_notes) > 0) : ?> |
|
523 | + <?php foreach ($customer_notes as $key => $note) : ?> |
|
524 | 524 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
525 | 525 | <span class="note-content-wrap"> |
526 | - <?php echo stripslashes( $note ); ?> |
|
526 | + <?php echo stripslashes($note); ?> |
|
527 | 527 | </span> |
528 | 528 | </div> |
529 | 529 | <?php endforeach; ?> |
530 | 530 | <?php else: ?> |
531 | 531 | <div class="give-no-customer-notes"> |
532 | - <?php _e( 'No Donor Notes', 'give' ); ?> |
|
532 | + <?php _e('No Donor Notes', 'give'); ?> |
|
533 | 533 | </div> |
534 | 534 | <?php endif; ?> |
535 | 535 | </div> |
536 | 536 | |
537 | - <?php echo paginate_links( $pagination_args ); ?> |
|
537 | + <?php echo paginate_links($pagination_args); ?> |
|
538 | 538 | |
539 | 539 | </div> |
540 | 540 | |
541 | 541 | <?php |
542 | 542 | } |
543 | 543 | |
544 | -function give_customers_delete_view( $customer ) { |
|
544 | +function give_customers_delete_view($customer) { |
|
545 | 545 | |
546 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
546 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
547 | 547 | |
548 | 548 | ?> |
549 | 549 | |
550 | - <?php do_action( 'give_customer_delete_top', $customer ); ?> |
|
550 | + <?php do_action('give_customer_delete_top', $customer); ?> |
|
551 | 551 | |
552 | 552 | <div class="info-wrapper customer-section"> |
553 | 553 | |
554 | - <form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>"> |
|
554 | + <form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>"> |
|
555 | 555 | |
556 | 556 | <div class="customer-notes-header"> |
557 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
557 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
558 | 558 | </div> |
559 | 559 | |
560 | 560 | |
@@ -562,27 +562,27 @@ discard block |
||
562 | 562 | |
563 | 563 | <span class="delete-customer-options"> |
564 | 564 | <p> |
565 | - <?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?> |
|
566 | - <label for="give-customer-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
565 | + <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?> |
|
566 | + <label for="give-customer-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
567 | 567 | </p> |
568 | 568 | |
569 | 569 | <p> |
570 | - <?php echo Give()->html->checkbox( array( |
|
570 | + <?php echo Give()->html->checkbox(array( |
|
571 | 571 | 'name' => 'give-customer-delete-records', |
572 | - 'options' => array( 'disabled' => true ) |
|
573 | - ) ); ?> |
|
574 | - <label for="give-customer-delete-records"><?php _e( 'Delete all associated payments and records?', 'give' ); ?></label> |
|
572 | + 'options' => array('disabled' => true) |
|
573 | + )); ?> |
|
574 | + <label for="give-customer-delete-records"><?php _e('Delete all associated payments and records?', 'give'); ?></label> |
|
575 | 575 | </p> |
576 | 576 | |
577 | - <?php do_action( 'give_customer_delete_inputs', $customer ); ?> |
|
577 | + <?php do_action('give_customer_delete_inputs', $customer); ?> |
|
578 | 578 | </span> |
579 | 579 | |
580 | 580 | <span id="customer-edit-actions"> |
581 | 581 | <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" /> |
582 | - <?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?> |
|
582 | + <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> |
|
583 | 583 | <input type="hidden" name="give_action" value="delete-customer" /> |
584 | - <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php _e( 'Delete Donor', 'give' ); ?>" /> |
|
585 | - <a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
584 | + <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php _e('Delete Donor', 'give'); ?>" /> |
|
585 | + <a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
586 | 586 | </span> |
587 | 587 | |
588 | 588 | </div> |
@@ -592,5 +592,5 @@ discard block |
||
592 | 592 | |
593 | 593 | <?php |
594 | 594 | |
595 | - do_action( 'give_customer_delete_bottom', $customer ); |
|
595 | + do_action('give_customer_delete_bottom', $customer); |
|
596 | 596 | } |
@@ -259,8 +259,11 @@ discard block |
||
259 | 259 | <span class="customer-user-id info-item editable"> |
260 | 260 | <?php if ( intval( $customer->user_id ) > 0 ) : ?> |
261 | 261 | <span data-key="user_id"><?php echo $customer->user_id; ?></span> |
262 | - <?php else : ?> |
|
263 | - <span data-key="user_id"><?php _e( 'None', 'give' ); ?></span> |
|
262 | + <?php else { |
|
263 | + : ?> |
|
264 | + <span data-key="user_id"><?php _e( 'None', 'give' ); |
|
265 | +} |
|
266 | +?></span> |
|
264 | 267 | <?php endif; ?> |
265 | 268 | <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) : ?> |
266 | 269 | <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php _e( 'Disconnects the current user ID from this customer record', 'give' ); ?>"><?php _e( 'Disconnect User', 'give' ); ?></a></span> |
@@ -329,8 +332,11 @@ discard block |
||
329 | 332 | } |
330 | 333 | ?> |
331 | 334 | </select> |
332 | - <?php else : ?> |
|
333 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php _e( 'State / Province', 'give' ); ?>" /> |
|
335 | + <?php else { |
|
336 | + : ?> |
|
337 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php _e( 'State / Province', 'give' ); |
|
338 | +} |
|
339 | +?>" /> |
|
334 | 340 | <?php endif; ?> |
335 | 341 | <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e( 'Postal', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
336 | 342 | </span> |
@@ -420,9 +426,12 @@ discard block |
||
420 | 426 | </td> |
421 | 427 | </tr> |
422 | 428 | <?php endforeach; ?> |
423 | - <?php else: ?> |
|
429 | + <?php else { |
|
430 | + : ?> |
|
424 | 431 | <tr> |
425 | - <td colspan="5"><?php _e( 'No Donations Found', 'give' ); ?></td> |
|
432 | + <td colspan="5"><?php _e( 'No Donations Found', 'give' ); |
|
433 | +} |
|
434 | +?></td> |
|
426 | 435 | </tr> |
427 | 436 | <?php endif; ?> |
428 | 437 | </tbody> |
@@ -451,9 +460,12 @@ discard block |
||
451 | 460 | </td> |
452 | 461 | </tr> |
453 | 462 | <?php endforeach; ?> |
454 | - <?php else: ?> |
|
463 | + <?php else { |
|
464 | + : ?> |
|
455 | 465 | <tr> |
456 | - <td colspan="2"><?php _e( 'No Completed Donations Found', 'give' ); ?></td> |
|
466 | + <td colspan="2"><?php _e( 'No Completed Donations Found', 'give' ); |
|
467 | +} |
|
468 | +?></td> |
|
457 | 469 | </tr> |
458 | 470 | <?php endif; ?> |
459 | 471 | </tbody> |
@@ -527,9 +539,12 @@ discard block |
||
527 | 539 | </span> |
528 | 540 | </div> |
529 | 541 | <?php endforeach; ?> |
530 | - <?php else: ?> |
|
542 | + <?php else { |
|
543 | + : ?> |
|
531 | 544 | <div class="give-no-customer-notes"> |
532 | - <?php _e( 'No Donor Notes', 'give' ); ?> |
|
545 | + <?php _e( 'No Donor Notes', 'give' ); |
|
546 | +} |
|
547 | +?> |
|
533 | 548 | </div> |
534 | 549 | <?php endif; ?> |
535 | 550 | </div> |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return string $output Give forms dropdown |
35 | 35 | */ |
36 | - public function forms_dropdown( $args = array() ) { |
|
36 | + public function forms_dropdown($args = array()) { |
|
37 | 37 | |
38 | 38 | $defaults = array( |
39 | 39 | 'name' => 'forms', |
@@ -43,43 +43,43 @@ discard block |
||
43 | 43 | 'selected' => 0, |
44 | 44 | 'chosen' => false, |
45 | 45 | 'number' => 30, |
46 | - 'placeholder' => sprintf( __( 'Select a %s', 'give' ), give_get_forms_label_singular() ) |
|
46 | + 'placeholder' => sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()) |
|
47 | 47 | ); |
48 | 48 | |
49 | - $args = wp_parse_args( $args, $defaults ); |
|
49 | + $args = wp_parse_args($args, $defaults); |
|
50 | 50 | |
51 | - $forms = get_posts( array( |
|
51 | + $forms = get_posts(array( |
|
52 | 52 | 'post_type' => 'give_forms', |
53 | 53 | 'orderby' => 'title', |
54 | 54 | 'order' => 'ASC', |
55 | 55 | 'posts_per_page' => $args['number'] |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | $options = array(); |
59 | 59 | |
60 | - if ( $forms ) { |
|
61 | - $options[0] = sprintf( __( 'Select a %s', 'give' ), give_get_forms_label_singular() ); |
|
62 | - foreach ( $forms as $form ) { |
|
63 | - $options[ absint( $form->ID ) ] = esc_html( $form->post_title ); |
|
60 | + if ($forms) { |
|
61 | + $options[0] = sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()); |
|
62 | + foreach ($forms as $form) { |
|
63 | + $options[absint($form->ID)] = esc_html($form->post_title); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $options[0] = __( 'No Give Forms Found', 'give' ); |
|
66 | + $options[0] = __('No Give Forms Found', 'give'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // This ensures that any selected forms are included in the drop down |
70 | - if ( is_array( $args['selected'] ) ) { |
|
71 | - foreach ( $args['selected'] as $item ) { |
|
72 | - if ( ! in_array( $item, $options ) ) { |
|
73 | - $options[ $item ] = get_the_title( $item ); |
|
70 | + if (is_array($args['selected'])) { |
|
71 | + foreach ($args['selected'] as $item) { |
|
72 | + if ( ! in_array($item, $options)) { |
|
73 | + $options[$item] = get_the_title($item); |
|
74 | 74 | } |
75 | 75 | } |
76 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
77 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
78 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
76 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
77 | + if ( ! in_array($args['selected'], $options)) { |
|
78 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - $output = $this->select( array( |
|
82 | + $output = $this->select(array( |
|
83 | 83 | 'name' => $args['name'], |
84 | 84 | 'selected' => $args['selected'], |
85 | 85 | 'id' => $args['id'], |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'placeholder' => $args['placeholder'], |
91 | 91 | 'show_option_all' => false, |
92 | 92 | 'show_option_none' => false |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | 95 | return $output; |
96 | 96 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string $output Donor dropdown |
107 | 107 | */ |
108 | - public function donor_dropdown( $args = array() ) { |
|
108 | + public function donor_dropdown($args = array()) { |
|
109 | 109 | |
110 | 110 | $defaults = array( |
111 | 111 | 'name' => 'customers', |
@@ -114,38 +114,38 @@ discard block |
||
114 | 114 | 'multiple' => false, |
115 | 115 | 'selected' => 0, |
116 | 116 | 'chosen' => true, |
117 | - 'placeholder' => __( 'Select a Donor', 'give' ), |
|
117 | + 'placeholder' => __('Select a Donor', 'give'), |
|
118 | 118 | 'number' => 30 |
119 | 119 | ); |
120 | 120 | |
121 | - $args = wp_parse_args( $args, $defaults ); |
|
121 | + $args = wp_parse_args($args, $defaults); |
|
122 | 122 | |
123 | - $customers = Give()->customers->get_customers( array( |
|
123 | + $customers = Give()->customers->get_customers(array( |
|
124 | 124 | 'number' => $args['number'] |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | |
127 | 127 | $options = array(); |
128 | 128 | |
129 | - if ( $customers ) { |
|
130 | - $options[0] = __( 'No donor attached', 'give' ); |
|
131 | - foreach ( $customers as $customer ) { |
|
132 | - $options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
129 | + if ($customers) { |
|
130 | + $options[0] = __('No donor attached', 'give'); |
|
131 | + foreach ($customers as $customer) { |
|
132 | + $options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')'); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | - $options[0] = __( 'No donors found', 'give' ); |
|
135 | + $options[0] = __('No donors found', 'give'); |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( ! empty( $args['selected'] ) ) { |
|
138 | + if ( ! empty($args['selected'])) { |
|
139 | 139 | |
140 | 140 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed |
141 | 141 | |
142 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
142 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
143 | 143 | |
144 | - $customer = new Give_Customer( $args['selected'] ); |
|
144 | + $customer = new Give_Customer($args['selected']); |
|
145 | 145 | |
146 | - if ( $customer ) { |
|
146 | + if ($customer) { |
|
147 | 147 | |
148 | - $options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
148 | + $options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')'); |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | - $output = $this->select( array( |
|
156 | + $output = $this->select(array( |
|
157 | 157 | 'name' => $args['name'], |
158 | 158 | 'selected' => $args['selected'], |
159 | 159 | 'id' => $args['id'], |
160 | - 'class' => $args['class'] . ' give-customer-select', |
|
160 | + 'class' => $args['class'].' give-customer-select', |
|
161 | 161 | 'options' => $options, |
162 | 162 | 'multiple' => $args['multiple'], |
163 | 163 | 'chosen' => $args['chosen'], |
164 | 164 | 'show_option_all' => false, |
165 | 165 | 'show_option_none' => false |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | |
168 | 168 | return $output; |
169 | 169 | } |
@@ -180,21 +180,21 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string $output Category dropdown |
182 | 182 | */ |
183 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0 ) { |
|
184 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
183 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0) { |
|
184 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
185 | 185 | $options = array(); |
186 | 186 | |
187 | - foreach ( $categories as $category ) { |
|
188 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
187 | + foreach ($categories as $category) { |
|
188 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
189 | 189 | } |
190 | 190 | |
191 | - $output = $this->select( array( |
|
191 | + $output = $this->select(array( |
|
192 | 192 | 'name' => $name, |
193 | 193 | 'selected' => $selected, |
194 | 194 | 'options' => $options, |
195 | - 'show_option_all' => __( 'All Categories', 'give' ), |
|
195 | + 'show_option_all' => __('All Categories', 'give'), |
|
196 | 196 | 'show_option_none' => false |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | |
199 | 199 | return $output; |
200 | 200 | } |
@@ -212,25 +212,25 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string $output Year dropdown |
214 | 214 | */ |
215 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
216 | - $current = date( 'Y' ); |
|
217 | - $start_year = $current - absint( $years_before ); |
|
218 | - $end_year = $current + absint( $years_after ); |
|
219 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
215 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
216 | + $current = date('Y'); |
|
217 | + $start_year = $current - absint($years_before); |
|
218 | + $end_year = $current + absint($years_after); |
|
219 | + $selected = empty($selected) ? date('Y') : $selected; |
|
220 | 220 | $options = array(); |
221 | 221 | |
222 | - while ( $start_year <= $end_year ) { |
|
223 | - $options[ absint( $start_year ) ] = $start_year; |
|
224 | - $start_year ++; |
|
222 | + while ($start_year <= $end_year) { |
|
223 | + $options[absint($start_year)] = $start_year; |
|
224 | + $start_year++; |
|
225 | 225 | } |
226 | 226 | |
227 | - $output = $this->select( array( |
|
227 | + $output = $this->select(array( |
|
228 | 228 | 'name' => $name, |
229 | 229 | 'selected' => $selected, |
230 | 230 | 'options' => $options, |
231 | 231 | 'show_option_all' => false, |
232 | 232 | 'show_option_none' => false |
233 | - ) ); |
|
233 | + )); |
|
234 | 234 | |
235 | 235 | return $output; |
236 | 236 | } |
@@ -247,23 +247,23 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return string $output Month dropdown |
249 | 249 | */ |
250 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
250 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
251 | 251 | $month = 1; |
252 | 252 | $options = array(); |
253 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
253 | + $selected = empty($selected) ? date('n') : $selected; |
|
254 | 254 | |
255 | - while ( $month <= 12 ) { |
|
256 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
257 | - $month ++; |
|
255 | + while ($month <= 12) { |
|
256 | + $options[absint($month)] = give_month_num_to_name($month); |
|
257 | + $month++; |
|
258 | 258 | } |
259 | 259 | |
260 | - $output = $this->select( array( |
|
260 | + $output = $this->select(array( |
|
261 | 261 | 'name' => $name, |
262 | 262 | 'selected' => $selected, |
263 | 263 | 'options' => $options, |
264 | 264 | 'show_option_all' => false, |
265 | 265 | 'show_option_none' => false |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | |
268 | 268 | return $output; |
269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public function select( $args = array() ) { |
|
280 | + public function select($args = array()) { |
|
281 | 281 | $defaults = array( |
282 | 282 | 'options' => array(), |
283 | 283 | 'name' => null, |
@@ -287,60 +287,60 @@ discard block |
||
287 | 287 | 'chosen' => false, |
288 | 288 | 'placeholder' => null, |
289 | 289 | 'multiple' => false, |
290 | - 'show_option_all' => __( 'All', 'give' ), |
|
291 | - 'show_option_none' => __( 'None', 'give' ) |
|
290 | + 'show_option_all' => __('All', 'give'), |
|
291 | + 'show_option_none' => __('None', 'give') |
|
292 | 292 | ); |
293 | 293 | |
294 | - $args = wp_parse_args( $args, $defaults ); |
|
294 | + $args = wp_parse_args($args, $defaults); |
|
295 | 295 | |
296 | 296 | |
297 | - if ( $args['multiple'] ) { |
|
297 | + if ($args['multiple']) { |
|
298 | 298 | $multiple = ' MULTIPLE'; |
299 | 299 | } else { |
300 | 300 | $multiple = ''; |
301 | 301 | } |
302 | 302 | |
303 | - if ( $args['chosen'] ) { |
|
303 | + if ($args['chosen']) { |
|
304 | 304 | $args['class'] .= ' give-select-chosen'; |
305 | 305 | } |
306 | 306 | |
307 | - if ( $args['placeholder'] ) { |
|
307 | + if ($args['placeholder']) { |
|
308 | 308 | $placeholder = $args['placeholder']; |
309 | 309 | } else { |
310 | 310 | $placeholder = ''; |
311 | 311 | } |
312 | 312 | |
313 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">'; |
|
313 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' data-placeholder="'.$placeholder.'">'; |
|
314 | 314 | |
315 | - if ( $args['show_option_all'] ) { |
|
316 | - if ( $args['multiple'] ) { |
|
317 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
315 | + if ($args['show_option_all']) { |
|
316 | + if ($args['multiple']) { |
|
317 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
318 | 318 | } else { |
319 | - $selected = selected( $args['selected'], 0, false ); |
|
319 | + $selected = selected($args['selected'], 0, false); |
|
320 | 320 | } |
321 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
321 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( ! empty( $args['options'] ) ) { |
|
324 | + if ( ! empty($args['options'])) { |
|
325 | 325 | |
326 | - if ( $args['show_option_none'] ) { |
|
327 | - if ( $args['multiple'] ) { |
|
328 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
326 | + if ($args['show_option_none']) { |
|
327 | + if ($args['multiple']) { |
|
328 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
329 | 329 | } else { |
330 | - $selected = selected( $args['selected'], - 1, false ); |
|
330 | + $selected = selected($args['selected'], - 1, false); |
|
331 | 331 | } |
332 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
332 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
333 | 333 | } |
334 | 334 | |
335 | - foreach ( $args['options'] as $key => $option ) { |
|
335 | + foreach ($args['options'] as $key => $option) { |
|
336 | 336 | |
337 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
338 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
337 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
338 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
339 | 339 | } else { |
340 | - $selected = selected( $args['selected'], $key, false ); |
|
340 | + $selected = selected($args['selected'], $key, false); |
|
341 | 341 | } |
342 | 342 | |
343 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
343 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function checkbox( $args = array() ) { |
|
361 | + public function checkbox($args = array()) { |
|
362 | 362 | $defaults = array( |
363 | 363 | 'name' => null, |
364 | 364 | 'current' => null, |
@@ -369,16 +369,16 @@ discard block |
||
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | |
372 | - $args = wp_parse_args( $args, $defaults ); |
|
372 | + $args = wp_parse_args($args, $defaults); |
|
373 | 373 | |
374 | 374 | $options = ''; |
375 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
375 | + if ( ! empty($args['options']['disabled'])) { |
|
376 | 376 | $options .= ' disabled="disabled"'; |
377 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
377 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
378 | 378 | $options .= ' readonly'; |
379 | 379 | } |
380 | 380 | |
381 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
381 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
382 | 382 | |
383 | 383 | return $output; |
384 | 384 | } |
@@ -392,22 +392,22 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @return string Text field |
394 | 394 | */ |
395 | - public function text( $args = array() ) { |
|
395 | + public function text($args = array()) { |
|
396 | 396 | // Backwards compatabliity |
397 | - if ( func_num_args() > 1 ) { |
|
397 | + if (func_num_args() > 1) { |
|
398 | 398 | $args = func_get_args(); |
399 | 399 | |
400 | 400 | $name = $args[0]; |
401 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
402 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
403 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
401 | + $value = isset($args[1]) ? $args[1] : ''; |
|
402 | + $label = isset($args[2]) ? $args[2] : ''; |
|
403 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | $defaults = array( |
407 | - 'name' => isset( $name ) ? $name : 'text', |
|
408 | - 'value' => isset( $value ) ? $value : null, |
|
409 | - 'label' => isset( $label ) ? $label : null, |
|
410 | - 'desc' => isset( $desc ) ? $desc : null, |
|
407 | + 'name' => isset($name) ? $name : 'text', |
|
408 | + 'value' => isset($value) ? $value : null, |
|
409 | + 'label' => isset($label) ? $label : null, |
|
410 | + 'desc' => isset($desc) ? $desc : null, |
|
411 | 411 | 'placeholder' => '', |
412 | 412 | 'class' => 'regular-text', |
413 | 413 | 'disabled' => false, |
@@ -415,29 +415,29 @@ discard block |
||
415 | 415 | 'data' => false |
416 | 416 | ); |
417 | 417 | |
418 | - $args = wp_parse_args( $args, $defaults ); |
|
418 | + $args = wp_parse_args($args, $defaults); |
|
419 | 419 | |
420 | 420 | $disabled = ''; |
421 | - if ( $args['disabled'] ) { |
|
421 | + if ($args['disabled']) { |
|
422 | 422 | $disabled = ' disabled="disabled"'; |
423 | 423 | } |
424 | 424 | |
425 | 425 | $data = ''; |
426 | - if ( ! empty( $args['data'] ) ) { |
|
427 | - foreach ( $args['data'] as $key => $value ) { |
|
428 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
426 | + if ( ! empty($args['data'])) { |
|
427 | + foreach ($args['data'] as $key => $value) { |
|
428 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
432 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
433 | 433 | |
434 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
434 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
435 | 435 | |
436 | - if ( ! empty( $args['desc'] ) ) { |
|
437 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
436 | + if ( ! empty($args['desc'])) { |
|
437 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
438 | 438 | } |
439 | 439 | |
440 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
440 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
441 | 441 | |
442 | 442 | $output .= '</span>'; |
443 | 443 | |
@@ -453,15 +453,15 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @return string Datepicker field |
455 | 455 | */ |
456 | - public function date_field( $args = array() ) { |
|
456 | + public function date_field($args = array()) { |
|
457 | 457 | |
458 | - if ( empty( $args['class'] ) ) { |
|
458 | + if (empty($args['class'])) { |
|
459 | 459 | $args['class'] = 'give_datepicker'; |
460 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
460 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
461 | 461 | $args['class'] .= ' give_datepicker'; |
462 | 462 | } |
463 | 463 | |
464 | - return $this->text( $args ); |
|
464 | + return $this->text($args); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return string textarea |
476 | 476 | */ |
477 | - public function textarea( $args = array() ) { |
|
477 | + public function textarea($args = array()) { |
|
478 | 478 | $defaults = array( |
479 | 479 | 'name' => 'textarea', |
480 | 480 | 'value' => null, |
@@ -484,21 +484,21 @@ discard block |
||
484 | 484 | 'disabled' => false |
485 | 485 | ); |
486 | 486 | |
487 | - $args = wp_parse_args( $args, $defaults ); |
|
487 | + $args = wp_parse_args($args, $defaults); |
|
488 | 488 | |
489 | 489 | $disabled = ''; |
490 | - if ( $args['disabled'] ) { |
|
490 | + if ($args['disabled']) { |
|
491 | 491 | $disabled = ' disabled="disabled"'; |
492 | 492 | } |
493 | 493 | |
494 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
494 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
495 | 495 | |
496 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
496 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
497 | 497 | |
498 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
498 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
499 | 499 | |
500 | - if ( ! empty( $args['desc'] ) ) { |
|
501 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
500 | + if ( ! empty($args['desc'])) { |
|
501 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | $output .= '</span>'; |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @return string text field with ajax search |
517 | 517 | */ |
518 | - public function ajax_user_search( $args = array() ) { |
|
518 | + public function ajax_user_search($args = array()) { |
|
519 | 519 | |
520 | 520 | $defaults = array( |
521 | 521 | 'name' => 'user_id', |
522 | 522 | 'value' => null, |
523 | - 'placeholder' => __( 'Enter username', 'give' ), |
|
523 | + 'placeholder' => __('Enter username', 'give'), |
|
524 | 524 | 'label' => null, |
525 | 525 | 'desc' => null, |
526 | 526 | 'class' => '', |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | 'data' => false |
530 | 530 | ); |
531 | 531 | |
532 | - $args = wp_parse_args( $args, $defaults ); |
|
532 | + $args = wp_parse_args($args, $defaults); |
|
533 | 533 | |
534 | - $args['class'] = 'give-ajax-user-search ' . $args['class']; |
|
534 | + $args['class'] = 'give-ajax-user-search '.$args['class']; |
|
535 | 535 | |
536 | 536 | $output = '<span class="give_user_search_wrap">'; |
537 | - $output .= $this->text( $args ); |
|
538 | - $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" title="' . __( 'Cancel', 'give' ) . '" aria-label="' . __( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>'; |
|
537 | + $output .= $this->text($args); |
|
538 | + $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" title="'.__('Cancel', 'give').'" aria-label="'.__('Cancel', 'give').'" href="#">x</a><span></span></span>'; |
|
539 | 539 | $output .= '</span>'; |
540 | 540 | |
541 | 541 | return $output; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array $output Response messages |
25 | 25 | */ |
26 | -function give_edit_customer( $args ) { |
|
26 | +function give_edit_customer($args) { |
|
27 | 27 | |
28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( empty( $args ) ) { |
|
34 | + if (empty($args)) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
40 | 40 | $nonce = $args['_wpnonce']; |
41 | 41 | |
42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
43 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
43 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
44 | 44 | } |
45 | 45 | |
46 | - $customer = new Give_Customer( $customer_id ); |
|
47 | - if ( empty( $customer->id ) ) { |
|
46 | + $customer = new Give_Customer($customer_id); |
|
47 | + if (empty($customer->id)) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | 'user_id' => 0 |
55 | 55 | ); |
56 | 56 | |
57 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
57 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
58 | 58 | |
59 | - if ( ! is_email( $customer_info['email'] ) ) { |
|
60 | - give_set_error( 'give-invalid-email', __( 'Please enter a valid email address.', 'give' ) ); |
|
59 | + if ( ! is_email($customer_info['email'])) { |
|
60 | + give_set_error('give-invalid-email', __('Please enter a valid email address.', 'give')); |
|
61 | 61 | } |
62 | 62 | |
63 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
63 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
64 | 64 | |
65 | 65 | // Make sure we don't already have this user attached to a customer |
66 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
67 | - give_set_error( 'give-invalid-customer-user_id', sprintf( __( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
66 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
67 | + give_set_error('give-invalid-customer-user_id', sprintf(__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Make sure it's actually a user |
71 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
72 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
73 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
71 | + $user = get_user_by('id', $customer_info['user_id']); |
|
72 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
73 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -78,82 +78,82 @@ discard block |
||
78 | 78 | // Record this for later |
79 | 79 | $previous_user_id = $customer->user_id; |
80 | 80 | |
81 | - if ( give_get_errors() ) { |
|
81 | + if (give_get_errors()) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Setup the customer address, if present |
86 | 86 | $address = array(); |
87 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
87 | + if (intval($customer_info['user_id']) > 0) { |
|
88 | 88 | |
89 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
89 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
90 | 90 | |
91 | - if ( false === $current_address ) { |
|
92 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
93 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
94 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
95 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
96 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
97 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
91 | + if (false === $current_address) { |
|
92 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
93 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
94 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
95 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
96 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
97 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
98 | 98 | } else { |
99 | - $current_address = wp_parse_args( $current_address, array( |
|
99 | + $current_address = wp_parse_args($current_address, array( |
|
100 | 100 | 'line1', |
101 | 101 | 'line2', |
102 | 102 | 'city', |
103 | 103 | 'zip', |
104 | 104 | 'state', |
105 | 105 | 'country' |
106 | - ) ); |
|
107 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
110 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
111 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
106 | + )); |
|
107 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
110 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
111 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Sanitize the inputs |
118 | 118 | $customer_data = array(); |
119 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
119 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
120 | 120 | $customer_data['email'] = $customer_info['email']; |
121 | 121 | $customer_data['user_id'] = $customer_info['user_id']; |
122 | 122 | |
123 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
124 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
123 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
124 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
125 | 125 | |
126 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
127 | - $address = array_map( 'sanitize_text_field', $address ); |
|
126 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
127 | + $address = array_map('sanitize_text_field', $address); |
|
128 | 128 | |
129 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
129 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
130 | 130 | |
131 | 131 | $output = array(); |
132 | 132 | $previous_email = $customer->email; |
133 | 133 | |
134 | - if ( $customer->update( $customer_data ) ) { |
|
134 | + if ($customer->update($customer_data)) { |
|
135 | 135 | |
136 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
137 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
136 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
137 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Update some payment meta if we need to |
141 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
141 | + $payments_array = explode(',', $customer->payment_ids); |
|
142 | 142 | |
143 | - if ( $customer->email != $previous_email ) { |
|
144 | - foreach ( $payments_array as $payment_id ) { |
|
145 | - give_update_payment_meta( $payment_id, 'email', $customer->email ); |
|
143 | + if ($customer->email != $previous_email) { |
|
144 | + foreach ($payments_array as $payment_id) { |
|
145 | + give_update_payment_meta($payment_id, 'email', $customer->email); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ( $customer->user_id != $previous_user_id ) { |
|
150 | - foreach ( $payments_array as $payment_id ) { |
|
151 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
149 | + if ($customer->user_id != $previous_user_id) { |
|
150 | + foreach ($payments_array as $payment_id) { |
|
151 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | 155 | $output['success'] = true; |
156 | - $customer_data = array_merge( $customer_data, $address ); |
|
156 | + $customer_data = array_merge($customer_data, $address); |
|
157 | 157 | $output['customer_info'] = $customer_data; |
158 | 158 | |
159 | 159 | } else { |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
165 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
166 | 166 | |
167 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
168 | - header( 'Content-Type: application/json' ); |
|
169 | - echo json_encode( $output ); |
|
167 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
168 | + header('Content-Type: application/json'); |
|
169 | + echo json_encode($output); |
|
170 | 170 | wp_die(); |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | } |
176 | 176 | |
177 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
177 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
178 | 178 | |
179 | 179 | /** |
180 | 180 | * Save a customer note being added |
@@ -185,53 +185,53 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return int The Note ID that was saved, or 0 if nothing was saved |
187 | 187 | */ |
188 | -function give_customer_save_note( $args ) { |
|
188 | +function give_customer_save_note($args) { |
|
189 | 189 | |
190 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
190 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
191 | 191 | |
192 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
193 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
192 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
193 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
194 | 194 | } |
195 | 195 | |
196 | - if ( empty( $args ) ) { |
|
196 | + if (empty($args)) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
200 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
201 | 201 | $customer_id = (int) $args['customer_id']; |
202 | 202 | $nonce = $args['add_customer_note_nonce']; |
203 | 203 | |
204 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
205 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
204 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
205 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( empty( $customer_note ) ) { |
|
209 | - give_set_error( 'empty-customer-note', __( 'A note is required', 'give' ) ); |
|
208 | + if (empty($customer_note)) { |
|
209 | + give_set_error('empty-customer-note', __('A note is required', 'give')); |
|
210 | 210 | } |
211 | 211 | |
212 | - if ( give_get_errors() ) { |
|
212 | + if (give_get_errors()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $customer = new Give_Customer( $customer_id ); |
|
217 | - $new_note = $customer->add_note( $customer_note ); |
|
216 | + $customer = new Give_Customer($customer_id); |
|
217 | + $new_note = $customer->add_note($customer_note); |
|
218 | 218 | |
219 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
219 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
220 | 220 | |
221 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
221 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
222 | 222 | |
223 | 223 | ob_start(); |
224 | 224 | ?> |
225 | 225 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
226 | 226 | <span class="note-content-wrap"> |
227 | - <?php echo stripslashes( $new_note ); ?> |
|
227 | + <?php echo stripslashes($new_note); ?> |
|
228 | 228 | </span> |
229 | 229 | </div> |
230 | 230 | <?php |
231 | 231 | $output = ob_get_contents(); |
232 | 232 | ob_end_clean(); |
233 | 233 | |
234 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
234 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
235 | 235 | echo $output; |
236 | 236 | exit; |
237 | 237 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | } |
246 | 246 | |
247 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
247 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Delete a customer |
@@ -255,87 +255,87 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return int Whether it was a successful deletion |
257 | 257 | */ |
258 | -function give_customer_delete( $args ) { |
|
258 | +function give_customer_delete($args) { |
|
259 | 259 | |
260 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
260 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
261 | 261 | |
262 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
263 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ) ); |
|
262 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
263 | + wp_die(__('You do not have permission to delete donors.', 'give')); |
|
264 | 264 | } |
265 | 265 | |
266 | - if ( empty( $args ) ) { |
|
266 | + if (empty($args)) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $customer_id = (int) $args['customer_id']; |
271 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
272 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
271 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
272 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
273 | 273 | $nonce = $args['_wpnonce']; |
274 | 274 | |
275 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
276 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
275 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
276 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
277 | 277 | } |
278 | 278 | |
279 | - if ( ! $confirm ) { |
|
280 | - give_set_error( 'customer-delete-no-confirm', __( 'Please confirm you want to delete this donor', 'give' ) ); |
|
279 | + if ( ! $confirm) { |
|
280 | + give_set_error('customer-delete-no-confirm', __('Please confirm you want to delete this donor', 'give')); |
|
281 | 281 | } |
282 | 282 | |
283 | - if ( give_get_errors() ) { |
|
284 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
283 | + if (give_get_errors()) { |
|
284 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
285 | 285 | exit; |
286 | 286 | } |
287 | 287 | |
288 | - $customer = new Give_Customer( $customer_id ); |
|
288 | + $customer = new Give_Customer($customer_id); |
|
289 | 289 | |
290 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
290 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
291 | 291 | |
292 | 292 | $success = false; |
293 | 293 | |
294 | - if ( $customer->id > 0 ) { |
|
294 | + if ($customer->id > 0) { |
|
295 | 295 | |
296 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
297 | - $success = Give()->customers->delete( $customer->id ); |
|
296 | + $payments_array = explode(',', $customer->payment_ids); |
|
297 | + $success = Give()->customers->delete($customer->id); |
|
298 | 298 | |
299 | - if ( $success ) { |
|
299 | + if ($success) { |
|
300 | 300 | |
301 | - if ( $remove_data ) { |
|
301 | + if ($remove_data) { |
|
302 | 302 | |
303 | 303 | // Remove all payments, logs, etc |
304 | - foreach ( $payments_array as $payment_id ) { |
|
305 | - give_delete_purchase( $payment_id ); |
|
304 | + foreach ($payments_array as $payment_id) { |
|
305 | + give_delete_purchase($payment_id); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | } else { |
309 | 309 | |
310 | 310 | // Just set the payments to customer_id of 0 |
311 | - foreach ( $payments_array as $payment_id ) { |
|
312 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
311 | + foreach ($payments_array as $payment_id) { |
|
312 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
317 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
318 | 318 | |
319 | 319 | } else { |
320 | 320 | |
321 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor', 'give' ) ); |
|
322 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
321 | + give_set_error('give-donor-delete-failed', __('Error deleting donor', 'give')); |
|
322 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | 326 | } else { |
327 | 327 | |
328 | - give_set_error( 'give-customer-delete-invalid-id', __( 'Invalid Donor ID', 'give' ) ); |
|
329 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
328 | + give_set_error('give-customer-delete-invalid-id', __('Invalid Donor ID', 'give')); |
|
329 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | |
333 | - wp_redirect( $redirect ); |
|
333 | + wp_redirect($redirect); |
|
334 | 334 | exit; |
335 | 335 | |
336 | 336 | } |
337 | 337 | |
338 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
338 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Disconnect a user ID from a donor |
@@ -346,39 +346,39 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return bool If the disconnect was successful |
348 | 348 | */ |
349 | -function give_disconnect_customer_user_id( $args ) { |
|
349 | +function give_disconnect_customer_user_id($args) { |
|
350 | 350 | |
351 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
351 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
352 | 352 | |
353 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
354 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
353 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
354 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
355 | 355 | } |
356 | 356 | |
357 | - if ( empty( $args ) ) { |
|
357 | + if (empty($args)) { |
|
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | 361 | $customer_id = (int) $args['customer_id']; |
362 | 362 | $nonce = $args['_wpnonce']; |
363 | 363 | |
364 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
365 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
364 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
365 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
366 | 366 | } |
367 | 367 | |
368 | - $customer = new Give_Customer( $customer_id ); |
|
369 | - if ( empty( $customer->id ) ) { |
|
368 | + $customer = new Give_Customer($customer_id); |
|
369 | + if (empty($customer->id)) { |
|
370 | 370 | return false; |
371 | 371 | } |
372 | 372 | |
373 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id ); |
|
373 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id); |
|
374 | 374 | |
375 | - $customer_args = array( 'user_id' => 0 ); |
|
375 | + $customer_args = array('user_id' => 0); |
|
376 | 376 | |
377 | - if ( $customer->update( $customer_args ) ) { |
|
377 | + if ($customer->update($customer_args)) { |
|
378 | 378 | global $wpdb; |
379 | 379 | |
380 | - if ( ! empty( $customer->payment_ids ) ) { |
|
381 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
380 | + if ( ! empty($customer->payment_ids)) { |
|
381 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | $output['success'] = true; |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | } else { |
387 | 387 | |
388 | 388 | $output['success'] = false; |
389 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor', 'give' ) ); |
|
389 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor', 'give')); |
|
390 | 390 | } |
391 | 391 | |
392 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
392 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
393 | 393 | |
394 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
395 | - header( 'Content-Type: application/json' ); |
|
396 | - echo json_encode( $output ); |
|
394 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
395 | + header('Content-Type: application/json'); |
|
396 | + echo json_encode($output); |
|
397 | 397 | wp_die(); |
398 | 398 | } |
399 | 399 | |
@@ -401,4 +401,4 @@ discard block |
||
401 | 401 | |
402 | 402 | } |
403 | 403 | |
404 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
404 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_show_upgrade_notices() { |
27 | 27 | |
28 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
28 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
29 | 29 | return; |
30 | 30 | } // Don't show notices on the upgrades page |
31 | 31 | |
32 | - $give_version = get_option( 'give_version' ); |
|
32 | + $give_version = get_option('give_version'); |
|
33 | 33 | |
34 | - if ( ! $give_version ) { |
|
34 | + if ( ! $give_version) { |
|
35 | 35 | // 1.0 is the first version to use this option so we must add it |
36 | 36 | $give_version = '1.0'; |
37 | 37 | } |
38 | 38 | |
39 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
39 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
40 | 40 | |
41 | 41 | /* |
42 | 42 | * NOTICE: |
@@ -47,18 +47,18 @@ discard block |
||
47 | 47 | */ |
48 | 48 | |
49 | 49 | //v1.3.2 Upgrades |
50 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
50 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
51 | 51 | printf( |
52 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
53 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
52 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
53 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
57 | 57 | //v1.3.4 Upgrades //ensure the user has gone through 1.3.4 |
58 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
58 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
59 | 59 | printf( |
60 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
61 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
60 | + '<div class="updated"><p>'.__('Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
61 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
71 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Triggers all upgrade functions |
@@ -80,26 +80,26 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function give_trigger_upgrades() { |
82 | 82 | |
83 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
84 | - wp_die( __( 'You do not have permission to do Give upgrades.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
83 | + if ( ! current_user_can('manage_give_settings')) { |
|
84 | + wp_die(__('You do not have permission to do Give upgrades.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
85 | 85 | } |
86 | 86 | |
87 | - $give_version = get_option( 'give_version' ); |
|
87 | + $give_version = get_option('give_version'); |
|
88 | 88 | |
89 | - if ( ! $give_version ) { |
|
89 | + if ( ! $give_version) { |
|
90 | 90 | // 1.0 is the first version to use this option so we must add it |
91 | 91 | $give_version = '1.0'; |
92 | - add_option( 'give_version', $give_version ); |
|
92 | + add_option('give_version', $give_version); |
|
93 | 93 | } |
94 | 94 | |
95 | - update_option( 'give_version', GIVE_VERSION ); |
|
95 | + update_option('give_version', GIVE_VERSION); |
|
96 | 96 | |
97 | - if ( DOING_AJAX ) { |
|
98 | - die( 'complete' ); |
|
97 | + if (DOING_AJAX) { |
|
98 | + die('complete'); |
|
99 | 99 | } // Let AJAX know that the upgrade is complete |
100 | 100 | } |
101 | 101 | |
102 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
102 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Check if the upgrade routine has been run for a specific action |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool If the action has been added to the completed actions array |
112 | 112 | */ |
113 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
113 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
114 | 114 | |
115 | - if ( empty( $upgrade_action ) ) { |
|
115 | + if (empty($upgrade_action)) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $completed_upgrades = give_get_completed_upgrades(); |
120 | 120 | |
121 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
121 | + return in_array($upgrade_action, $completed_upgrades); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool If the function was successfully added |
133 | 133 | */ |
134 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
134 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
135 | 135 | |
136 | - if ( empty( $upgrade_action ) ) { |
|
136 | + if (empty($upgrade_action)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | $completed_upgrades[] = $upgrade_action; |
142 | 142 | |
143 | 143 | // Remove any blanks, and only show uniques |
144 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
144 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
145 | 145 | |
146 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
146 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function give_get_completed_upgrades() { |
156 | 156 | |
157 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
157 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
158 | 158 | |
159 | - if ( false === $completed_upgrades ) { |
|
159 | + if (false === $completed_upgrades) { |
|
160 | 160 | $completed_upgrades = array(); |
161 | 161 | } |
162 | 162 | |
@@ -175,30 +175,30 @@ discard block |
||
175 | 175 | */ |
176 | 176 | function give_v132_upgrade_give_payment_customer_id() { |
177 | 177 | global $wpdb; |
178 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
179 | - wp_die( __( 'You do not have permission to do Give upgrades.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
178 | + if ( ! current_user_can('manage_give_settings')) { |
|
179 | + wp_die(__('You do not have permission to do Give upgrades.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
180 | 180 | } |
181 | 181 | |
182 | - ignore_user_abort( true ); |
|
182 | + ignore_user_abort(true); |
|
183 | 183 | |
184 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
185 | - @set_time_limit( 0 ); |
|
184 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
185 | + @set_time_limit(0); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | //UPDATE DB METAKEYS |
189 | 189 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
190 | - $query = $wpdb->query( $sql ); |
|
190 | + $query = $wpdb->query($sql); |
|
191 | 191 | |
192 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
193 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
194 | - delete_option( 'give_doing_upgrade' ); |
|
195 | - wp_redirect( admin_url() ); |
|
192 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
193 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
194 | + delete_option('give_doing_upgrade'); |
|
195 | + wp_redirect(admin_url()); |
|
196 | 196 | exit; |
197 | 197 | |
198 | 198 | |
199 | 199 | } |
200 | 200 | |
201 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
201 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Upgrades the Offline Status |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | |
213 | 213 | global $wpdb; |
214 | 214 | |
215 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
216 | - wp_die( __( 'You do not have permission to do Give upgrades.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
215 | + if ( ! current_user_can('manage_give_settings')) { |
|
216 | + wp_die(__('You do not have permission to do Give upgrades.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
217 | 217 | } |
218 | 218 | |
219 | - ignore_user_abort( true ); |
|
219 | + ignore_user_abort(true); |
|
220 | 220 | |
221 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
222 | - @set_time_limit( 0 ); |
|
221 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
222 | + @set_time_limit(0); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | // Get abandoned offline payments |
@@ -229,35 +229,35 @@ discard block |
||
229 | 229 | $where .= "AND ( p.post_status = 'abandoned' )"; |
230 | 230 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
231 | 231 | |
232 | - $sql = $select . $join . $where; |
|
233 | - $found_payments = $wpdb->get_col( $sql ); |
|
232 | + $sql = $select.$join.$where; |
|
233 | + $found_payments = $wpdb->get_col($sql); |
|
234 | 234 | |
235 | 235 | |
236 | - foreach ( $found_payments as $payment ) { |
|
236 | + foreach ($found_payments as $payment) { |
|
237 | 237 | |
238 | 238 | //Only change ones marked abandoned since our release last week |
239 | 239 | //because the admin may have marked some abandoned themselves |
240 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
240 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
241 | 241 | |
242 | 242 | //1450124863 = 12/10/2015 20:42:25 |
243 | - if ( $modified_time >= 1450124863 ) { |
|
243 | + if ($modified_time >= 1450124863) { |
|
244 | 244 | |
245 | - give_update_payment_status( $payment, 'pending' ); |
|
245 | + give_update_payment_status($payment, 'pending'); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
252 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
253 | - delete_option( 'give_doing_upgrade' ); |
|
254 | - wp_redirect( admin_url() ); |
|
251 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
252 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
253 | + delete_option('give_doing_upgrade'); |
|
254 | + wp_redirect(admin_url()); |
|
255 | 255 | exit; |
256 | 256 | |
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
260 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
261 | 261 | |
262 | 262 | |
263 | 263 | /** |
@@ -269,17 +269,17 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function give_v152_cleanup_users() { |
271 | 271 | |
272 | - $give_version = get_option( 'give_version' ); |
|
272 | + $give_version = get_option('give_version'); |
|
273 | 273 | |
274 | - if ( ! $give_version ) { |
|
274 | + if ( ! $give_version) { |
|
275 | 275 | // 1.0 is the first version to use this option so we must add it |
276 | 276 | $give_version = '1.0'; |
277 | 277 | } |
278 | 278 | |
279 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
279 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
280 | 280 | |
281 | 281 | //v1.5.2 Upgrades |
282 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
282 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
283 | 283 | |
284 | 284 | //Delete all caps with "ss" |
285 | 285 | //Also delete all unused "campaign" roles |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | ); |
327 | 327 | |
328 | 328 | global $wp_roles; |
329 | - foreach ( $delete_caps as $cap ) { |
|
330 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
331 | - $wp_roles->remove_cap( $role, $cap ); |
|
329 | + foreach ($delete_caps as $cap) { |
|
330 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
331 | + $wp_roles->remove_cap($role, $cap); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | $roles->add_caps(); |
339 | 339 | |
340 | 340 | //The Update Ran |
341 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
342 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
343 | - delete_option( 'give_doing_upgrade' ); |
|
341 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
342 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
343 | + delete_option('give_doing_upgrade'); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | 347 | } |
348 | 348 | |
349 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
350 | 349 | \ No newline at end of file |
350 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
351 | 351 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return void |
25 | 25 | */ |
26 | -function give_trigger_donation_receipt( $payment_id ) { |
|
26 | +function give_trigger_donation_receipt($payment_id) { |
|
27 | 27 | // Make sure we don't send a purchase receipt while editing a payment |
28 | - if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) { |
|
28 | + if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Send email |
33 | - give_email_donation_receipt( $payment_id ); |
|
33 | + give_email_donation_receipt($payment_id); |
|
34 | 34 | } |
35 | 35 | |
36 | -add_action( 'give_complete_purchase', 'give_trigger_donation_receipt', 999, 1 ); |
|
36 | +add_action('give_complete_purchase', 'give_trigger_donation_receipt', 999, 1); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Resend the Email Purchase Receipt. (This can be done from the Payment History page) |
@@ -44,29 +44,29 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return void |
46 | 46 | */ |
47 | -function give_resend_donation_receipt( $data ) { |
|
47 | +function give_resend_donation_receipt($data) { |
|
48 | 48 | |
49 | - $purchase_id = absint( $data['purchase_id'] ); |
|
49 | + $purchase_id = absint($data['purchase_id']); |
|
50 | 50 | |
51 | - if ( empty( $purchase_id ) ) { |
|
51 | + if (empty($purchase_id)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) { |
|
56 | - wp_die( __( 'You do not have permission to edit payment records.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
55 | + if ( ! current_user_can('edit_give_payments', $purchase_id)) { |
|
56 | + wp_die(__('You do not have permission to edit payment records.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
57 | 57 | } |
58 | 58 | |
59 | - give_email_donation_receipt( $purchase_id, false ); |
|
59 | + give_email_donation_receipt($purchase_id, false); |
|
60 | 60 | |
61 | - wp_redirect( add_query_arg( array( |
|
61 | + wp_redirect(add_query_arg(array( |
|
62 | 62 | 'give-message' => 'email_sent', |
63 | 63 | 'give-action' => false, |
64 | 64 | 'purchase_id' => false |
65 | - ) ) ); |
|
65 | + ))); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_email_links', 'give_resend_donation_receipt' ); |
|
69 | +add_action('give_email_links', 'give_resend_donation_receipt'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Trigger the sending of a Test Email |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return void |
79 | 79 | */ |
80 | -function give_send_test_email( $data ) { |
|
81 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) { |
|
80 | +function give_send_test_email($data) { |
|
81 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | give_email_test_donation_receipt(); |
87 | 87 | |
88 | 88 | // Remove the test email query arg |
89 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
89 | + wp_redirect(remove_query_arg('give_action')); |
|
90 | 90 | exit; |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'give_send_test_email', 'give_send_test_email' ); |
|
93 | +add_action('give_send_test_email', 'give_send_test_email'); |