@@ -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 | - <h1><?php esc_html_e( 'Donors', 'give' ); ?></h1> |
|
76 | + <h1><?php esc_html_e('Donors', 'give'); ?></h1> |
|
77 | 77 | <?php |
78 | 78 | /** |
79 | 79 | * Fires in donors screen, above the table. |
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $customers_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_customer_view( $view, $callbacks ) { |
|
116 | +function give_render_customer_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
120 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $customer_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($customer_view_role)) { |
|
123 | + give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID Provided.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID Provided.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $customer_id = (int) $_GET['id']; |
133 | - $customer = new Give_Customer( $customer_id ); |
|
133 | + $customer = new Give_Customer($customer_id); |
|
134 | 134 | |
135 | - if ( empty( $customer->id ) ) { |
|
136 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID Provided.', 'give' ) ); |
|
135 | + if (empty($customer->id)) { |
|
136 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID Provided.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php give_print_errors( 0 ); ?> |
|
147 | + <?php give_print_errors(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <?php if ( $customer && $render ) : ?> |
|
151 | + <?php if ($customer && $render) : ?> |
|
152 | 152 | |
153 | 153 | <div id="customer-tab-wrapper"> |
154 | 154 | <ul id="customer-tab-wrapper-list" class="nav-tab-wrapper"> |
155 | - <?php foreach ( $customer_tabs as $key => $tab ) : ?> |
|
155 | + <?php foreach ($customer_tabs as $key => $tab) : ?> |
|
156 | 156 | <?php $active = $key === $view ? true : false; ?> |
157 | 157 | <?php $class = $active ? 'active' : 'inactive'; ?> |
158 | 158 | |
159 | - <li class="<?php echo sanitize_html_class( $class ); ?>"> |
|
160 | - <?php if ( ! $active ) : ?> |
|
161 | - <a title="<?php esc_attr_e( $tab['title'] ); ?>" aria-label="<?php esc_attr_e( $tab['title'] ); ?>" href="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ); ?>"> |
|
159 | + <li class="<?php echo sanitize_html_class($class); ?>"> |
|
160 | + <?php if ( ! $active) : ?> |
|
161 | + <a title="<?php esc_attr_e($tab['title']); ?>" aria-label="<?php esc_attr_e($tab['title']); ?>" href="<?php echo esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)); ?>"> |
|
162 | 162 | <?php endif; ?> |
163 | 163 | |
164 | - <span class="dashicons <?php echo sanitize_html_class( $tab['dashicon'] ); ?>"></span> <?php esc_html_e( $tab['title'] ); ?> |
|
165 | - <?php if ( ! $active ) : ?> |
|
164 | + <span class="dashicons <?php echo sanitize_html_class($tab['dashicon']); ?>"></span> <?php esc_html_e($tab['title']); ?> |
|
165 | + <?php if ( ! $active) : ?> |
|
166 | 166 | </a> |
167 | 167 | <?php endif; ?> |
168 | 168 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | </div> |
175 | 175 | |
176 | 176 | <div id="give-customer-card-wrapper"> |
177 | - <?php $callbacks[ $view ]( $customer ) ?> |
|
177 | + <?php $callbacks[$view]($customer) ?> |
|
178 | 178 | </div> |
179 | 179 | |
180 | 180 | <?php endif; ?> |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return void |
196 | 196 | */ |
197 | -function give_customers_view( $customer ) { |
|
197 | +function give_customers_view($customer) { |
|
198 | 198 | |
199 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
199 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Fires in donor profile screen, above the donor card. |
@@ -205,32 +205,32 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @param object $customer The customer object being displayed. |
207 | 207 | */ |
208 | - do_action( 'give_donor_card_top', $customer ); |
|
208 | + do_action('give_donor_card_top', $customer); |
|
209 | 209 | ?> |
210 | 210 | |
211 | 211 | <div id="donor-summary" class="info-wrapper customer-section postbox"> |
212 | 212 | |
213 | - <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 ); ?>"> |
|
213 | + <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); ?>"> |
|
214 | 214 | |
215 | 215 | <div class="customer-info"> |
216 | 216 | |
217 | 217 | <div class="donor-bio-header clearfix"> |
218 | 218 | |
219 | 219 | <div class="avatar-wrap left" id="customer-avatar"> |
220 | - <?php echo get_avatar( $customer->email ); ?> |
|
220 | + <?php echo get_avatar($customer->email); ?> |
|
221 | 221 | </div> |
222 | 222 | |
223 | 223 | <div id="customer-name-wrap" class="left"> |
224 | 224 | <span class="customer-id">#<?php echo $customer->id; ?></span> |
225 | - <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php esc_attr_e( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
225 | + <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php esc_attr_e($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
226 | 226 | <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span> |
227 | 227 | </div> |
228 | 228 | <p class="customer-since info-item"> |
229 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
230 | - <?php echo date_i18n( get_option( 'date_format' ), strtotime( $customer->date_created ) ) ?> |
|
229 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
230 | + <?php echo date_i18n(get_option('date_format'), strtotime($customer->date_created)) ?> |
|
231 | 231 | </p> |
232 | - <?php if ( current_user_can( $customer_edit_role ) ): ?> |
|
233 | - <a title="<?php esc_attr_e( 'Edit Donor', 'give' ); ?>" href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
232 | + <?php if (current_user_can($customer_edit_role)): ?> |
|
233 | + <a title="<?php esc_attr_e('Edit Donor', 'give'); ?>" href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
234 | 234 | <?php endif; ?> |
235 | 235 | </div> |
236 | 236 | <!-- /donor-bio-header --> |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | <table class="widefat"> |
241 | 241 | <tbody> |
242 | 242 | <tr> |
243 | - <td><label for="tablecell"><?php esc_html_e( 'Email', 'give' ); ?></label>:</td> |
|
243 | + <td><label for="tablecell"><?php esc_html_e('Email', 'give'); ?></label>:</td> |
|
244 | 244 | <td class="row-title"> |
245 | - <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 esc_attr_e( 'Donor Email', 'give' ); ?>" /></span> |
|
245 | + <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 esc_attr_e('Donor Email', 'give'); ?>" /></span> |
|
246 | 246 | <span class="customer-email info-item editable" data-key="email"><?php echo $customer->email; ?></span> |
247 | 247 | </td> |
248 | 248 | </tr> |
249 | 249 | <tr class="alternate"> |
250 | - <td><label for="tablecell"><?php esc_html_e( 'User ID', 'give' ); ?></label>:</td> |
|
250 | + <td><label for="tablecell"><?php esc_html_e('User ID', 'give'); ?></label>:</td> |
|
251 | 251 | <td class="row-title"> |
252 | 252 | <span class="customer-user-id info-item edit-item"> |
253 | 253 | <?php |
@@ -263,38 +263,38 @@ discard block |
||
263 | 263 | 'data' => $data_atts, |
264 | 264 | ); |
265 | 265 | |
266 | - if ( ! empty( $user_id ) ) { |
|
267 | - $userdata = get_userdata( $user_id ); |
|
266 | + if ( ! empty($user_id)) { |
|
267 | + $userdata = get_userdata($user_id); |
|
268 | 268 | $user_args['value'] = $userdata->user_login; |
269 | 269 | } |
270 | 270 | |
271 | - echo Give()->html->ajax_user_search( $user_args ); |
|
271 | + echo Give()->html->ajax_user_search($user_args); |
|
272 | 272 | ?> |
273 | 273 | <input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" /> |
274 | 274 | </span> |
275 | 275 | |
276 | 276 | <span class="customer-user-id info-item editable"> |
277 | - <?php if ( intval( $customer->user_id ) > 0 ) : ?> |
|
277 | + <?php if (intval($customer->user_id) > 0) : ?> |
|
278 | 278 | <span data-key="user_id"><?php echo $customer->user_id; ?></span> |
279 | 279 | <?php else : ?> |
280 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
280 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
281 | 281 | <?php endif; ?> |
282 | - <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) : ?> |
|
283 | - <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php esc_attr_e( 'Disconnects the current user ID from this customer record', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
282 | + <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) : ?> |
|
283 | + <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php esc_attr_e('Disconnects the current user ID from this customer record', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
284 | 284 | <?php endif; ?> |
285 | 285 | </span> |
286 | 286 | </td> |
287 | 287 | </tr> |
288 | - <?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?> |
|
288 | + <?php if (isset($customer->user_id) && $customer->user_id > 0) : ?> |
|
289 | 289 | |
290 | 290 | <tr> |
291 | - <td><?php esc_html_e( 'Address', 'give' ); ?>:</td> |
|
291 | + <td><?php esc_html_e('Address', 'give'); ?>:</td> |
|
292 | 292 | <td class="row-title"> |
293 | 293 | |
294 | 294 | <div class="customer-address-wrapper"> |
295 | 295 | |
296 | 296 | <?php |
297 | - $address = get_user_meta( $customer->user_id, '_give_user_address', true ); |
|
297 | + $address = get_user_meta($customer->user_id, '_give_user_address', true); |
|
298 | 298 | $defaults = array( |
299 | 299 | 'line1' => '', |
300 | 300 | 'line2' => '', |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | 'zip' => '' |
305 | 305 | ); |
306 | 306 | |
307 | - $address = wp_parse_args( $address, $defaults ); |
|
307 | + $address = wp_parse_args($address, $defaults); |
|
308 | 308 | ?> |
309 | 309 | |
310 | - <?php if ( ! empty( $address ) ) { ?> |
|
310 | + <?php if ( ! empty($address)) { ?> |
|
311 | 311 | <span class="customer-address info-item editable"> |
312 | 312 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
313 | 313 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -318,38 +318,38 @@ discard block |
||
318 | 318 | </span> |
319 | 319 | <?php } ?> |
320 | 320 | <span class="customer-address info-item edit-item"> |
321 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
322 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
323 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
321 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
322 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
323 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
324 | 324 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
325 | 325 | <?php |
326 | 326 | |
327 | 327 | $selected_country = $address['country']; |
328 | 328 | |
329 | 329 | $countries = give_get_country_list(); |
330 | - foreach ( $countries as $country_code => $country ) { |
|
331 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
330 | + foreach ($countries as $country_code => $country) { |
|
331 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
332 | 332 | } |
333 | 333 | ?> |
334 | 334 | </select> |
335 | 335 | <?php |
336 | 336 | $selected_state = give_get_state(); |
337 | - $states = give_get_states( $selected_country ); |
|
337 | + $states = give_get_states($selected_country); |
|
338 | 338 | |
339 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
339 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
340 | 340 | |
341 | - if ( ! empty( $states ) ) : ?> |
|
341 | + if ( ! empty($states)) : ?> |
|
342 | 342 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
343 | 343 | <?php |
344 | - foreach ( $states as $state_code => $state ) { |
|
345 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
344 | + foreach ($states as $state_code => $state) { |
|
345 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
346 | 346 | } |
347 | 347 | ?> |
348 | 348 | </select> |
349 | 349 | <?php else : ?> |
350 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
|
350 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" /> |
|
351 | 351 | <?php endif; ?> |
352 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Postal', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
352 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Postal', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
353 | 353 | </span> |
354 | 354 | |
355 | 355 | </div> |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | |
367 | 367 | <span id="customer-edit-actions" class="edit-item"> |
368 | 368 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" /> |
369 | - <?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?> |
|
369 | + <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> |
|
370 | 370 | <input type="hidden" name="give_action" value="edit-customer" /> |
371 | - <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
372 | - <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
371 | + <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
372 | + <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
373 | 373 | </span> |
374 | 374 | |
375 | 375 | </form> |
@@ -384,24 +384,24 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @param object $customer The customer object being displayed. |
386 | 386 | */ |
387 | - do_action( 'give_donor_before_stats', $customer ); |
|
387 | + do_action('give_donor_before_stats', $customer); |
|
388 | 388 | ?> |
389 | 389 | |
390 | 390 | <div id="customer-stats-wrapper" class="customer-section postbox clear"> |
391 | 391 | <ul> |
392 | 392 | <li> |
393 | - <a title="<?php esc_attr_e( 'View All Donations', 'give' ); ?>" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>"> |
|
393 | + <a title="<?php esc_attr_e('View All Donations', 'give'); ?>" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>"> |
|
394 | 394 | <span class="dashicons dashicons-heart"></span> |
395 | 395 | <?php |
396 | 396 | //Completed Donations |
397 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count ); |
|
398 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer ); |
|
397 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); |
|
398 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer); |
|
399 | 399 | ?> |
400 | 400 | </a> |
401 | 401 | </li> |
402 | 402 | <li> |
403 | 403 | <span class="dashicons dashicons-chart-area"></span> |
404 | - <?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
404 | + <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
405 | 405 | </li> |
406 | 406 | <?php |
407 | 407 | /** |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @param object $customer The customer object being displayed. |
415 | 415 | */ |
416 | - do_action( 'give_donor_stats_list', $customer ); |
|
416 | + do_action('give_donor_stats_list', $customer); |
|
417 | 417 | ?> |
418 | 418 | </ul> |
419 | 419 | </div> |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @param object $customer The customer object being displayed. |
428 | 428 | */ |
429 | - do_action( 'give_donor_before_tables_wrapper', $customer ); |
|
429 | + do_action('give_donor_before_tables_wrapper', $customer); |
|
430 | 430 | ?> |
431 | 431 | |
432 | 432 | <div id="customer-tables-wrapper" class="customer-section"> |
@@ -439,37 +439,37 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param object $customer The customer object being displayed. |
441 | 441 | */ |
442 | - do_action( 'give_donor_before_tables', $customer ); |
|
442 | + do_action('give_donor_before_tables', $customer); |
|
443 | 443 | ?> |
444 | 444 | |
445 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
445 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
446 | 446 | <?php |
447 | - $payment_ids = explode( ',', $customer->payment_ids ); |
|
448 | - $payments = give_get_payments( array( 'post__in' => $payment_ids ) ); |
|
449 | - $payments = array_slice( $payments, 0, 10 ); |
|
447 | + $payment_ids = explode(',', $customer->payment_ids); |
|
448 | + $payments = give_get_payments(array('post__in' => $payment_ids)); |
|
449 | + $payments = array_slice($payments, 0, 10); |
|
450 | 450 | ?> |
451 | 451 | <table class="wp-list-table widefat striped payments"> |
452 | 452 | <thead> |
453 | 453 | <tr> |
454 | - <th><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
455 | - <th><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
456 | - <th><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
457 | - <th><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
458 | - <th><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
454 | + <th><?php esc_html_e('ID', 'give'); ?></th> |
|
455 | + <th><?php esc_html_e('Amount', 'give'); ?></th> |
|
456 | + <th><?php esc_html_e('Date', 'give'); ?></th> |
|
457 | + <th><?php esc_html_e('Status', 'give'); ?></th> |
|
458 | + <th><?php esc_html_e('Actions', 'give'); ?></th> |
|
459 | 459 | </tr> |
460 | 460 | </thead> |
461 | 461 | <tbody> |
462 | - <?php if ( ! empty( $payments ) ) : ?> |
|
463 | - <?php foreach ( $payments as $payment ) : ?> |
|
462 | + <?php if ( ! empty($payments)) : ?> |
|
463 | + <?php foreach ($payments as $payment) : ?> |
|
464 | 464 | <tr> |
465 | 465 | <td><?php echo $payment->ID; ?></td> |
466 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
467 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $payment->post_date ) ); ?></td> |
|
468 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
466 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
467 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($payment->post_date)); ?></td> |
|
468 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
469 | 469 | <td> |
470 | - <a title="<?php esc_attr_e( 'View Details for Donation', 'give' ); |
|
471 | - 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 ); ?>"> |
|
472 | - <?php esc_html_e( 'View Details', 'give' ); ?> |
|
470 | + <a title="<?php esc_attr_e('View Details for Donation', 'give'); |
|
471 | + 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); ?>"> |
|
472 | + <?php esc_html_e('View Details', 'give'); ?> |
|
473 | 473 | </a> |
474 | 474 | <?php |
475 | 475 | /** |
@@ -482,47 +482,47 @@ discard block |
||
482 | 482 | * @param object $customer The customer object being displayed. |
483 | 483 | * @param object $payment The payment object being displayed. |
484 | 484 | */ |
485 | - do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); |
|
485 | + do_action('give_donor_recent_purchases_actions', $customer, $payment); |
|
486 | 486 | ?> |
487 | 487 | </td> |
488 | 488 | </tr> |
489 | 489 | <?php endforeach; ?> |
490 | 490 | <?php else: ?> |
491 | 491 | <tr> |
492 | - <td colspan="5"><?php esc_html_e( 'No Donations Found', 'give' ); ?></td> |
|
492 | + <td colspan="5"><?php esc_html_e('No Donations Found', 'give'); ?></td> |
|
493 | 493 | </tr> |
494 | 494 | <?php endif; ?> |
495 | 495 | </tbody> |
496 | 496 | </table> |
497 | 497 | |
498 | - <h3><?php esc_html_e( 'Completed Donations', 'give' ); ?></h3> |
|
498 | + <h3><?php esc_html_e('Completed Donations', 'give'); ?></h3> |
|
499 | 499 | <?php |
500 | - $donations = give_get_users_completed_donations( $customer->email ); |
|
500 | + $donations = give_get_users_completed_donations($customer->email); |
|
501 | 501 | ?> |
502 | 502 | <table class="wp-list-table widefat striped donations"> |
503 | 503 | <thead> |
504 | 504 | <tr> |
505 | 505 | <th><?php echo give_get_forms_label_singular(); ?></th> |
506 | - <th width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
506 | + <th width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
507 | 507 | </tr> |
508 | 508 | </thead> |
509 | 509 | <tbody> |
510 | - <?php if ( ! empty( $donations ) ) : ?> |
|
511 | - <?php foreach ( $donations as $donation ) : ?> |
|
510 | + <?php if ( ! empty($donations)) : ?> |
|
511 | + <?php foreach ($donations as $donation) : ?> |
|
512 | 512 | <tr> |
513 | 513 | <td><?php echo $donation->post_title; ?></td> |
514 | 514 | <td> |
515 | 515 | <a title="<?php |
516 | 516 | printf( |
517 | 517 | /* translators: %s: post title */ |
518 | - esc_attr__( 'View %s', 'give' ), |
|
518 | + esc_attr__('View %s', 'give'), |
|
519 | 519 | $donation->post_title |
520 | - ); ?>" href="<?php echo esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ); |
|
520 | + ); ?>" href="<?php echo esc_url(admin_url('post.php?action=edit&post='.$donation->ID)); |
|
521 | 521 | ?>"> |
522 | 522 | <?php |
523 | 523 | printf( |
524 | 524 | /* translators: %s: forms singular label */ |
525 | - esc_html__( 'View %s', 'give' ), |
|
525 | + esc_html__('View %s', 'give'), |
|
526 | 526 | give_get_forms_label_singular() |
527 | 527 | ); |
528 | 528 | ?> |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | <?php endforeach; ?> |
533 | 533 | <?php else: ?> |
534 | 534 | <tr> |
535 | - <td colspan="2"><?php esc_html_e( 'No Completed Donations Found', 'give' ); ?></td> |
|
535 | + <td colspan="2"><?php esc_html_e('No Completed Donations Found', 'give'); ?></td> |
|
536 | 536 | </tr> |
537 | 537 | <?php endif; ?> |
538 | 538 | </tbody> |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * |
547 | 547 | * @param object $customer The customer object being displayed. |
548 | 548 | */ |
549 | - do_action( 'give_donor_after_tables', $customer ); |
|
549 | + do_action('give_donor_after_tables', $customer); |
|
550 | 550 | ?> |
551 | 551 | |
552 | 552 | </div> |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @param object $customer The customer object being displayed. |
561 | 561 | */ |
562 | - do_action( 'give_donor_card_bottom', $customer ); |
|
562 | + do_action('give_donor_card_bottom', $customer); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -572,30 +572,30 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return void |
574 | 574 | */ |
575 | -function give_customer_notes_view( $customer ) { |
|
575 | +function give_customer_notes_view($customer) { |
|
576 | 576 | |
577 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
578 | - $paged = absint( $paged ); |
|
577 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
578 | + $paged = absint($paged); |
|
579 | 579 | $note_count = $customer->get_notes_count(); |
580 | - $per_page = apply_filters( 'give_customer_notes_per_page', 20 ); |
|
581 | - $total_pages = ceil( $note_count / $per_page ); |
|
582 | - $customer_notes = $customer->get_notes( $per_page, $paged ); |
|
580 | + $per_page = apply_filters('give_customer_notes_per_page', 20); |
|
581 | + $total_pages = ceil($note_count / $per_page); |
|
582 | + $customer_notes = $customer->get_notes($per_page, $paged); |
|
583 | 583 | ?> |
584 | 584 | |
585 | 585 | <div id="customer-notes-wrapper"> |
586 | 586 | <div class="customer-notes-header"> |
587 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
587 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
588 | 588 | </div> |
589 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
589 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
590 | 590 | |
591 | - <?php if ( 1 == $paged ) : ?> |
|
591 | + <?php if (1 == $paged) : ?> |
|
592 | 592 | <div style="display: block; margin-bottom: 55px;"> |
593 | - <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 ); ?>"> |
|
593 | + <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); ?>"> |
|
594 | 594 | <textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea> |
595 | 595 | <br /> |
596 | 596 | <input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" /> |
597 | 597 | <input type="hidden" name="give_action" value="add-customer-note" /> |
598 | - <?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?> |
|
598 | + <?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?> |
|
599 | 599 | <input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" /> |
600 | 600 | </form> |
601 | 601 | </div> |
@@ -610,26 +610,26 @@ discard block |
||
610 | 610 | 'show_all' => true |
611 | 611 | ); |
612 | 612 | |
613 | - echo paginate_links( $pagination_args ); |
|
613 | + echo paginate_links($pagination_args); |
|
614 | 614 | ?> |
615 | 615 | |
616 | 616 | <div id="give-customer-notes" class="postbox"> |
617 | - <?php if ( count( $customer_notes ) > 0 ) : ?> |
|
618 | - <?php foreach ( $customer_notes as $key => $note ) : ?> |
|
617 | + <?php if (count($customer_notes) > 0) : ?> |
|
618 | + <?php foreach ($customer_notes as $key => $note) : ?> |
|
619 | 619 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
620 | 620 | <span class="note-content-wrap"> |
621 | - <?php echo stripslashes( $note ); ?> |
|
621 | + <?php echo stripslashes($note); ?> |
|
622 | 622 | </span> |
623 | 623 | </div> |
624 | 624 | <?php endforeach; ?> |
625 | 625 | <?php else: ?> |
626 | 626 | <div class="give-no-customer-notes"> |
627 | - <?php esc_html_e( 'No Donor Notes', 'give' ); ?> |
|
627 | + <?php esc_html_e('No Donor Notes', 'give'); ?> |
|
628 | 628 | </div> |
629 | 629 | <?php endif; ?> |
630 | 630 | </div> |
631 | 631 | |
632 | - <?php echo paginate_links( $pagination_args ); ?> |
|
632 | + <?php echo paginate_links($pagination_args); ?> |
|
633 | 633 | |
634 | 634 | </div> |
635 | 635 | |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @return void |
647 | 647 | */ |
648 | -function give_customers_delete_view( $customer ) { |
|
648 | +function give_customers_delete_view($customer) { |
|
649 | 649 | |
650 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
650 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
651 | 651 | |
652 | 652 | /** |
653 | 653 | * Fires in donor delete screen, above the content. |
@@ -656,15 +656,15 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @param object $customer The customer object being displayed. |
658 | 658 | */ |
659 | - do_action( 'give_customer_delete_top', $customer ); |
|
659 | + do_action('give_customer_delete_top', $customer); |
|
660 | 660 | ?> |
661 | 661 | |
662 | 662 | <div class="info-wrapper customer-section"> |
663 | 663 | |
664 | - <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 ); ?>"> |
|
664 | + <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); ?>"> |
|
665 | 665 | |
666 | 666 | <div class="customer-notes-header"> |
667 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
667 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
668 | 668 | </div> |
669 | 669 | |
670 | 670 | |
@@ -672,16 +672,16 @@ discard block |
||
672 | 672 | |
673 | 673 | <span class="delete-customer-options"> |
674 | 674 | <p> |
675 | - <?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?> |
|
676 | - <label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
675 | + <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?> |
|
676 | + <label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
677 | 677 | </p> |
678 | 678 | |
679 | 679 | <p> |
680 | - <?php echo Give()->html->checkbox( array( |
|
680 | + <?php echo Give()->html->checkbox(array( |
|
681 | 681 | 'name' => 'give-customer-delete-records', |
682 | - 'options' => array( 'disabled' => true ) |
|
683 | - ) ); ?> |
|
684 | - <label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated payments and records?', 'give' ); ?></label> |
|
682 | + 'options' => array('disabled' => true) |
|
683 | + )); ?> |
|
684 | + <label for="give-customer-delete-records"><?php esc_html_e('Delete all associated payments and records?', 'give'); ?></label> |
|
685 | 685 | </p> |
686 | 686 | |
687 | 687 | <?php |
@@ -694,16 +694,16 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @param object $customer The customer object being displayed. |
696 | 696 | */ |
697 | - do_action( 'give_customer_delete_inputs', $customer ); |
|
697 | + do_action('give_customer_delete_inputs', $customer); |
|
698 | 698 | ?> |
699 | 699 | </span> |
700 | 700 | |
701 | 701 | <span id="customer-edit-actions"> |
702 | 702 | <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" /> |
703 | - <?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?> |
|
703 | + <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> |
|
704 | 704 | <input type="hidden" name="give_action" value="delete-customer" /> |
705 | - <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
706 | - <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 esc_html_e( 'Cancel', 'give' ); ?></a> |
|
705 | + <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
706 | + <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 esc_html_e('Cancel', 'give'); ?></a> |
|
707 | 707 | </span> |
708 | 708 | |
709 | 709 | </div> |
@@ -719,5 +719,5 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @param object $customer The customer object being displayed. |
721 | 721 | */ |
722 | - do_action( 'give_customer_delete_bottom', $customer ); |
|
722 | + do_action('give_customer_delete_bottom', $customer); |
|
723 | 723 | } |
@@ -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( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
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( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
43 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
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', esc_html__( 'Please enter a valid email address.', 'give' ) ); |
|
59 | + if ( ! is_email($customer_info['email'])) { |
|
60 | + give_set_error('give-invalid-email', esc_html__('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( esc_html__( '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(esc_html__('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( esc_html__( '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(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -78,53 +78,53 @@ 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 | 129 | |
130 | 130 | /** |
@@ -136,34 +136,34 @@ discard block |
||
136 | 136 | * @param array $customer_data The customer data. |
137 | 137 | * @param array $address The customer address. |
138 | 138 | */ |
139 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
139 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
140 | 140 | |
141 | 141 | $output = array(); |
142 | 142 | $previous_email = $customer->email; |
143 | 143 | |
144 | - if ( $customer->update( $customer_data ) ) { |
|
144 | + if ($customer->update($customer_data)) { |
|
145 | 145 | |
146 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
147 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
146 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
147 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Update some payment meta if we need to |
151 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
151 | + $payments_array = explode(',', $customer->payment_ids); |
|
152 | 152 | |
153 | - if ( $customer->email != $previous_email ) { |
|
154 | - foreach ( $payments_array as $payment_id ) { |
|
155 | - give_update_payment_meta( $payment_id, 'email', $customer->email ); |
|
153 | + if ($customer->email != $previous_email) { |
|
154 | + foreach ($payments_array as $payment_id) { |
|
155 | + give_update_payment_meta($payment_id, 'email', $customer->email); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - if ( $customer->user_id != $previous_user_id ) { |
|
160 | - foreach ( $payments_array as $payment_id ) { |
|
161 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
159 | + if ($customer->user_id != $previous_user_id) { |
|
160 | + foreach ($payments_array as $payment_id) { |
|
161 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | $output['success'] = true; |
166 | - $customer_data = array_merge( $customer_data, $address ); |
|
166 | + $customer_data = array_merge($customer_data, $address); |
|
167 | 167 | $output['customer_info'] = $customer_data; |
168 | 168 | |
169 | 169 | } else { |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | * @param int $customer_id The ID of the customer. |
181 | 181 | * @param array $customer_data The customer data. |
182 | 182 | */ |
183 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
183 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
184 | 184 | |
185 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
186 | - header( 'Content-Type: application/json' ); |
|
187 | - echo json_encode( $output ); |
|
185 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
186 | + header('Content-Type: application/json'); |
|
187 | + echo json_encode($output); |
|
188 | 188 | wp_die(); |
189 | 189 | } |
190 | 190 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
195 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Save a customer note being added |
@@ -203,36 +203,36 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return int The Note ID that was saved, or 0 if nothing was saved |
205 | 205 | */ |
206 | -function give_customer_save_note( $args ) { |
|
206 | +function give_customer_save_note($args) { |
|
207 | 207 | |
208 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
208 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
209 | 209 | |
210 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
211 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
210 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
211 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
212 | 212 | } |
213 | 213 | |
214 | - if ( empty( $args ) ) { |
|
214 | + if (empty($args)) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
218 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
219 | 219 | $customer_id = (int) $args['customer_id']; |
220 | 220 | $nonce = $args['add_customer_note_nonce']; |
221 | 221 | |
222 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
223 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
222 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
223 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( empty( $customer_note ) ) { |
|
227 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
226 | + if (empty($customer_note)) { |
|
227 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( give_get_errors() ) { |
|
230 | + if (give_get_errors()) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - $customer = new Give_Customer( $customer_id ); |
|
235 | - $new_note = $customer->add_note( $customer_note ); |
|
234 | + $customer = new Give_Customer($customer_id); |
|
235 | + $new_note = $customer->add_note($customer_note); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires before inserting customer note. |
@@ -242,22 +242,22 @@ discard block |
||
242 | 242 | * @param int $customer_id The ID of the customer. |
243 | 243 | * @param string $new_note Note content. |
244 | 244 | */ |
245 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
245 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
246 | 246 | |
247 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
247 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
248 | 248 | |
249 | 249 | ob_start(); |
250 | 250 | ?> |
251 | 251 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
252 | 252 | <span class="note-content-wrap"> |
253 | - <?php echo stripslashes( $new_note ); ?> |
|
253 | + <?php echo stripslashes($new_note); ?> |
|
254 | 254 | </span> |
255 | 255 | </div> |
256 | 256 | <?php |
257 | 257 | $output = ob_get_contents(); |
258 | 258 | ob_end_clean(); |
259 | 259 | |
260 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
260 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
261 | 261 | echo $output; |
262 | 262 | exit; |
263 | 263 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | } |
272 | 272 | |
273 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
273 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Delete a customer |
@@ -281,37 +281,37 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return int Whether it was a successful deletion |
283 | 283 | */ |
284 | -function give_customer_delete( $args ) { |
|
284 | +function give_customer_delete($args) { |
|
285 | 285 | |
286 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
286 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
287 | 287 | |
288 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
289 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
288 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
289 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
290 | 290 | } |
291 | 291 | |
292 | - if ( empty( $args ) ) { |
|
292 | + if (empty($args)) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | $customer_id = (int) $args['customer_id']; |
297 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
298 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
297 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
298 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
299 | 299 | $nonce = $args['_wpnonce']; |
300 | 300 | |
301 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
302 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
301 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
302 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
303 | 303 | } |
304 | 304 | |
305 | - if ( ! $confirm ) { |
|
306 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
305 | + if ( ! $confirm) { |
|
306 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( give_get_errors() ) { |
|
310 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
309 | + if (give_get_errors()) { |
|
310 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
311 | 311 | exit; |
312 | 312 | } |
313 | 313 | |
314 | - $customer = new Give_Customer( $customer_id ); |
|
314 | + $customer = new Give_Customer($customer_id); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Fires before deleting customer. |
@@ -322,55 +322,55 @@ discard block |
||
322 | 322 | * @param bool $confirm Delete confirmation. |
323 | 323 | * @param bool $remove_data Records delete confirmation. |
324 | 324 | */ |
325 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
325 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
326 | 326 | |
327 | 327 | $success = false; |
328 | 328 | |
329 | - if ( $customer->id > 0 ) { |
|
329 | + if ($customer->id > 0) { |
|
330 | 330 | |
331 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
332 | - $success = Give()->customers->delete( $customer->id ); |
|
331 | + $payments_array = explode(',', $customer->payment_ids); |
|
332 | + $success = Give()->customers->delete($customer->id); |
|
333 | 333 | |
334 | - if ( $success ) { |
|
334 | + if ($success) { |
|
335 | 335 | |
336 | - if ( $remove_data ) { |
|
336 | + if ($remove_data) { |
|
337 | 337 | |
338 | 338 | // Remove all payments, logs, etc |
339 | - foreach ( $payments_array as $payment_id ) { |
|
340 | - give_delete_purchase( $payment_id ); |
|
339 | + foreach ($payments_array as $payment_id) { |
|
340 | + give_delete_purchase($payment_id); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | } else { |
344 | 344 | |
345 | 345 | // Just set the payments to customer_id of 0 |
346 | - foreach ( $payments_array as $payment_id ) { |
|
347 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
346 | + foreach ($payments_array as $payment_id) { |
|
347 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
352 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
353 | 353 | |
354 | 354 | } else { |
355 | 355 | |
356 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
357 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
356 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
357 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
363 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
364 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
363 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
364 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | - wp_redirect( $redirect ); |
|
368 | + wp_redirect($redirect); |
|
369 | 369 | exit; |
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
373 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * Disconnect a user ID from a donor |
@@ -381,27 +381,27 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return bool If the disconnect was successful |
383 | 383 | */ |
384 | -function give_disconnect_customer_user_id( $args ) { |
|
384 | +function give_disconnect_customer_user_id($args) { |
|
385 | 385 | |
386 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
386 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
387 | 387 | |
388 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
389 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
388 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
389 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( empty( $args ) ) { |
|
392 | + if (empty($args)) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $customer_id = (int) $args['customer_id']; |
397 | 397 | $nonce = $args['_wpnonce']; |
398 | 398 | |
399 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
400 | - wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
399 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
400 | + wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
401 | 401 | } |
402 | 402 | |
403 | - $customer = new Give_Customer( $customer_id ); |
|
404 | - if ( empty( $customer->id ) ) { |
|
403 | + $customer = new Give_Customer($customer_id); |
|
404 | + if (empty($customer->id)) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | |
@@ -415,15 +415,15 @@ discard block |
||
415 | 415 | * @param int $customer_id The ID of the customer. |
416 | 416 | * @param int $user_id The ID of the user. |
417 | 417 | */ |
418 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id ); |
|
418 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id); |
|
419 | 419 | |
420 | - $customer_args = array( 'user_id' => 0 ); |
|
420 | + $customer_args = array('user_id' => 0); |
|
421 | 421 | |
422 | - if ( $customer->update( $customer_args ) ) { |
|
422 | + if ($customer->update($customer_args)) { |
|
423 | 423 | global $wpdb; |
424 | 424 | |
425 | - if ( ! empty( $customer->payment_ids ) ) { |
|
426 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
425 | + if ( ! empty($customer->payment_ids)) { |
|
426 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | $output['success'] = true; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } else { |
432 | 432 | |
433 | 433 | $output['success'] = false; |
434 | - give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) ); |
|
434 | + give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param int $customer_id The ID of the customer. |
443 | 443 | */ |
444 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
444 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
445 | 445 | |
446 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
447 | - header( 'Content-Type: application/json' ); |
|
448 | - echo json_encode( $output ); |
|
446 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
447 | + header('Content-Type: application/json'); |
|
448 | + echo json_encode($output); |
|
449 | 449 | wp_die(); |
450 | 450 | } |
451 | 451 | |
@@ -453,4 +453,4 @@ discard block |
||
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
456 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date( 'F j, Y' ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date('F j, Y'); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - esc_html__( 'Happy %s!', 'give' ), |
|
55 | - date( 'l', current_time( 'timestamp' ) ) |
|
54 | + esc_html__('Happy %s!', 'give'), |
|
55 | + date('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | - <?php $earnings_today = $stats->get_earnings( 0, 'today', false ); ?> |
|
59 | + <?php $earnings_today = $stats->get_earnings(0, 'today', false); ?> |
|
60 | 60 | |
61 | - <p class="give-dashboard-today-earnings"><?php echo give_currency_filter( give_format_amount( $earnings_today ) ); ?></p> |
|
61 | + <p class="give-dashboard-today-earnings"><?php echo give_currency_filter(give_format_amount($earnings_today)); ?></p> |
|
62 | 62 | |
63 | 63 | <p class="give-orders-today"> |
64 | - <?php $donations_today = $stats->get_sales( 0, 'today', false ); ?> |
|
65 | - <?php echo give_format_amount( $donations_today, false ); ?> |
|
66 | - <span><?php echo _x( 'donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give' ); ?></span> |
|
64 | + <?php $donations_today = $stats->get_sales(0, 'today', false); ?> |
|
65 | + <?php echo give_format_amount($donations_today, false); ?> |
|
66 | + <span><?php echo _x('donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give'); ?></span> |
|
67 | 67 | </p> |
68 | 68 | |
69 | 69 | |
@@ -73,34 +73,34 @@ discard block |
||
73 | 73 | <table class="give-table-stats"> |
74 | 74 | <thead style="display: none;"> |
75 | 75 | <tr> |
76 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
77 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
78 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
76 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
77 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
78 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
79 | 79 | </tr> |
80 | 80 | </thead> |
81 | 81 | <tbody> |
82 | 82 | <tr id="give-table-stats-tr-1"> |
83 | 83 | <td> |
84 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
84 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
85 | 85 | |
86 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'this week', 'give' ); ?></p> |
|
86 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('this week', 'give'); ?></p> |
|
87 | 87 | </td> |
88 | 88 | <td> |
89 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
90 | 90 | |
91 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'this month', 'give' ); ?></p> |
|
91 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('this month', 'give'); ?></p> |
|
92 | 92 | </td> |
93 | 93 | </tr> |
94 | 94 | <tr id="give-table-stats-tr-2"> |
95 | 95 | <td> |
96 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
96 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
97 | 97 | |
98 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'last month', 'give' ); ?></p> |
|
98 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('last month', 'give'); ?></p> |
|
99 | 99 | </td> |
100 | 100 | <td> |
101 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
101 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
102 | 102 | |
103 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'this year', 'give' ); ?></p> |
|
103 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('this year', 'give'); ?></p> |
|
104 | 104 | </td> |
105 | 105 | </tr> |
106 | 106 | </tbody> |
@@ -120,25 +120,25 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return array |
122 | 122 | */ |
123 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
124 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
123 | +function give_dashboard_at_a_glance_widget($items) { |
|
124 | + $num_posts = wp_count_posts('give_forms'); |
|
125 | 125 | |
126 | - if ( $num_posts && $num_posts->publish ) { |
|
126 | + if ($num_posts && $num_posts->publish) { |
|
127 | 127 | |
128 | 128 | $text = sprintf( |
129 | 129 | /* translators: 1: number of posts published 2: forms singular label 3: forms plural label */ |
130 | - _n( '%1$s Give %2$s', '%1$s Give %3$s', $num_posts->publish, 'give' ), |
|
130 | + _n('%1$s Give %2$s', '%1$s Give %3$s', $num_posts->publish, 'give'), |
|
131 | 131 | $num_posts->publish, |
132 | 132 | give_get_forms_label_singular(), |
133 | 133 | give_get_forms_label_plural() |
134 | 134 | ); |
135 | 135 | |
136 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
136 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
137 | 137 | |
138 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
139 | - $text = sprintf( '<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text ); |
|
138 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
139 | + $text = sprintf('<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text); |
|
140 | 140 | } else { |
141 | - $text = sprintf( '<span class="give-forms-count">%1$s</span>', $text ); |
|
141 | + $text = sprintf('<span class="give-forms-count">%1$s</span>', $text); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $items[] = $text; |
@@ -147,4 +147,4 @@ discard block |
||
147 | 147 | return $items; |
148 | 148 | } |
149 | 149 | |
150 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
150 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,56 +40,56 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | |
45 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
46 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
47 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
45 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
46 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
47 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
48 | 48 | $offline_instructions = $global_offline_instruction; |
49 | 49 | |
50 | - if ( $post_offline_customization_option == 'yes' ) { |
|
50 | + if ($post_offline_customization_option == 'yes') { |
|
51 | 51 | $offline_instructions = $post_offline_instructions; |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | ob_start(); ?> |
56 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
56 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
57 | 57 | <fieldset id="give_offline_payment_info"> |
58 | 58 | <?php |
59 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
59 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
60 | 60 | /* translators: %s: form settings url */ |
61 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( esc_attr__( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
62 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
61 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(esc_attr__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
62 | + echo wpautop(stripslashes($offline_instructions)); |
|
63 | 63 | ?> |
64 | 64 | </fieldset> |
65 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
65 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
66 | 66 | <?php |
67 | 67 | echo ob_get_clean(); |
68 | 68 | } |
69 | 69 | |
70 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
70 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Give Offline Billing Field |
74 | 74 | * |
75 | 75 | * @param $form_id |
76 | 76 | */ |
77 | -function give_offline_billing_fields( $form_id ) { |
|
77 | +function give_offline_billing_fields($form_id) { |
|
78 | 78 | //Enable Default CC fields (billing info) |
79 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
80 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
79 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
80 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
81 | 81 | |
82 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
82 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
83 | 83 | |
84 | 84 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
85 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
86 | - give_default_cc_address_fields( $form_id ); |
|
87 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | - give_default_cc_address_fields( $form_id ); |
|
85 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
86 | + give_default_cc_address_fields($form_id); |
|
87 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | + give_default_cc_address_fields($form_id); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
92 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Process the payment |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return void |
102 | 102 | */ |
103 | -function give_offline_process_payment( $purchase_data ) { |
|
103 | +function give_offline_process_payment($purchase_data) { |
|
104 | 104 | |
105 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
105 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
106 | 106 | |
107 | 107 | // setup the payment details |
108 | 108 | $payment_data = array( |
109 | 109 | 'price' => $purchase_data['price'], |
110 | 110 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
111 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
112 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
111 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
112 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
113 | 113 | 'date' => $purchase_data['date'], |
114 | 114 | 'user_email' => $purchase_data['user_email'], |
115 | 115 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | // record the pending payment |
124 | - $payment = give_insert_payment( $payment_data ); |
|
124 | + $payment = give_insert_payment($payment_data); |
|
125 | 125 | |
126 | - if ( $payment ) { |
|
127 | - give_offline_send_admin_notice( $payment ); |
|
128 | - give_offline_send_donor_instructions( $payment ); |
|
126 | + if ($payment) { |
|
127 | + give_offline_send_admin_notice($payment); |
|
128 | + give_offline_send_donor_instructions($payment); |
|
129 | 129 | give_send_to_success_page(); |
130 | 130 | } else { |
131 | 131 | // if errors are present, send the user back to the donation form so they can be corrected |
132 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
132 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
137 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -147,47 +147,47 @@ discard block |
||
147 | 147 | * @since 1.0 |
148 | 148 | * @return void |
149 | 149 | */ |
150 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
150 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
151 | 151 | |
152 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
153 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
152 | + $payment_data = give_get_payment_meta($payment_id); |
|
153 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
154 | 154 | |
155 | 155 | //Customize email content depending on whether the single form has been customized |
156 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
156 | + $email_content = give_get_option('global_offline_donation_email'); |
|
157 | 157 | |
158 | - if ( $post_offline_customization_option === 'yes' ) { |
|
159 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
158 | + if ($post_offline_customization_option === 'yes') { |
|
159 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
160 | 160 | } |
161 | 161 | |
162 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
163 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
162 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
163 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
164 | 164 | |
165 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
166 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
165 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
166 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
167 | 167 | |
168 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
168 | + $to_email = give_get_payment_user_email($payment_id); |
|
169 | 169 | |
170 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
171 | - if ( $post_offline_customization_option === 'yes' ) { |
|
172 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
170 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
171 | + if ($post_offline_customization_option === 'yes') { |
|
172 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
176 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
175 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
176 | + $subject = give_do_email_tags($subject, $payment_id); |
|
177 | 177 | |
178 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
179 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
178 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
179 | + $message = give_do_email_tags($email_content, $payment_id); |
|
180 | 180 | |
181 | 181 | $emails = Give()->emails; |
182 | 182 | |
183 | - $emails->__set( 'from_name', $from_name ); |
|
184 | - $emails->__set( 'from_email', $from_email ); |
|
185 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
183 | + $emails->__set('from_name', $from_name); |
|
184 | + $emails->__set('from_email', $from_email); |
|
185 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
186 | 186 | |
187 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
188 | - $emails->__set( 'headers', $headers ); |
|
187 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
188 | + $emails->__set('headers', $headers); |
|
189 | 189 | |
190 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
190 | + $emails->send($to_email, $subject, $message, $attachments); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
@@ -204,52 +204,52 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * |
206 | 206 | */ |
207 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
207 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
208 | 208 | |
209 | 209 | /* Send an email notification to the admin */ |
210 | 210 | $admin_email = give_get_admin_notice_emails(); |
211 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
211 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
212 | 212 | |
213 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
214 | - $user_data = get_userdata( $user_info['id'] ); |
|
213 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
214 | + $user_data = get_userdata($user_info['id']); |
|
215 | 215 | $name = $user_data->display_name; |
216 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
217 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
216 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
217 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
218 | 218 | } else { |
219 | 219 | $name = $user_info['email']; |
220 | 220 | } |
221 | 221 | |
222 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
222 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
223 | 223 | |
224 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id ); |
|
224 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id); |
|
225 | 225 | |
226 | - $admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
227 | - $admin_message .= esc_attr__( 'An offline donation has been made on your website: ', 'give' ) . get_bloginfo( 'name' ) . ' '; |
|
228 | - $admin_message .= esc_attr__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
226 | + $admin_message = esc_attr__('Dear Admin,', 'give')."\n\n"; |
|
227 | + $admin_message .= esc_attr__('An offline donation has been made on your website: ', 'give').get_bloginfo('name').' '; |
|
228 | + $admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
229 | 229 | |
230 | 230 | |
231 | - $admin_message .= '<strong>' . esc_attr__( 'Donor: ', 'give' ) . '</strong>' . '{fullname}' . "\n"; |
|
232 | - $admin_message .= '<strong>' . esc_attr__( 'Amount: ', 'give' ) . '</strong>' . '{price}' . "\n\n"; |
|
231 | + $admin_message .= '<strong>'.esc_attr__('Donor: ', 'give').'</strong>'.'{fullname}'."\n"; |
|
232 | + $admin_message .= '<strong>'.esc_attr__('Amount: ', 'give').'</strong>'.'{price}'."\n\n"; |
|
233 | 233 | |
234 | 234 | $admin_message .= sprintf( |
235 | 235 | '<a href="%1$s">%2$s</a>', |
236 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
237 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
238 | - ) . "\n\n"; |
|
236 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
237 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
238 | + )."\n\n"; |
|
239 | 239 | |
240 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
241 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
240 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
241 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
242 | 242 | |
243 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
244 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
243 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
244 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
245 | 245 | |
246 | 246 | //Send Email |
247 | 247 | $emails = Give()->emails; |
248 | - if ( ! empty( $admin_headers ) ) { |
|
249 | - $emails->__set( 'headers', $admin_headers ); |
|
248 | + if ( ! empty($admin_headers)) { |
|
249 | + $emails->__set('headers', $admin_headers); |
|
250 | 250 | } |
251 | 251 | |
252 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
252 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | * @since 1.0 |
261 | 261 | * @return array |
262 | 262 | */ |
263 | -function give_offline_add_settings( $settings ) { |
|
263 | +function give_offline_add_settings($settings) { |
|
264 | 264 | |
265 | 265 | //Vars |
266 | 266 | $prefix = '_give_'; |
267 | 267 | |
268 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
268 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
269 | 269 | |
270 | 270 | //this gateway isn't active |
271 | - if ( ! $is_gateway_active ) { |
|
271 | + if ( ! $is_gateway_active) { |
|
272 | 272 | //return settings and bounce |
273 | 273 | return $settings; |
274 | 274 | } |
@@ -277,27 +277,27 @@ discard block |
||
277 | 277 | $check_settings = array( |
278 | 278 | |
279 | 279 | array( |
280 | - 'name' => esc_attr__( 'Customize Offline Donations', 'give' ), |
|
281 | - 'desc' => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
282 | - 'id' => $prefix . 'customize_offline_donations', |
|
280 | + 'name' => esc_attr__('Customize Offline Donations', 'give'), |
|
281 | + 'desc' => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
282 | + 'id' => $prefix.'customize_offline_donations', |
|
283 | 283 | 'type' => 'radio_inline', |
284 | 284 | 'default' => 'no', |
285 | 285 | 'options' => array( |
286 | - 'yes' => esc_attr__( 'Yes', 'give' ), |
|
287 | - 'no' => esc_attr__( 'No', 'give' ), |
|
286 | + 'yes' => esc_attr__('Yes', 'give'), |
|
287 | + 'no' => esc_attr__('No', 'give'), |
|
288 | 288 | ), |
289 | 289 | ), |
290 | 290 | array( |
291 | - 'name' => esc_attr__( 'Request Billing Information', 'give' ), |
|
292 | - 'desc' => esc_attr__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
293 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
291 | + 'name' => esc_attr__('Request Billing Information', 'give'), |
|
292 | + 'desc' => esc_attr__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
293 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
294 | 294 | 'row_classes' => 'give-subfield', |
295 | 295 | 'type' => 'checkbox' |
296 | 296 | ), |
297 | 297 | array( |
298 | - 'id' => $prefix . 'offline_checkout_notes', |
|
299 | - 'name' => esc_attr__( 'Offline Donation Instructions', 'give' ), |
|
300 | - 'desc' => esc_attr__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
298 | + 'id' => $prefix.'offline_checkout_notes', |
|
299 | + 'name' => esc_attr__('Offline Donation Instructions', 'give'), |
|
300 | + 'desc' => esc_attr__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
301 | 301 | 'default' => give_get_default_offline_donation_content(), |
302 | 302 | 'type' => 'wysiwyg', |
303 | 303 | 'row_classes' => 'give-subfield', |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | ) |
307 | 307 | ), |
308 | 308 | array( |
309 | - 'id' => $prefix . 'offline_donation_subject', |
|
310 | - 'name' => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
311 | - 'desc' => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
312 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
309 | + 'id' => $prefix.'offline_donation_subject', |
|
310 | + 'name' => esc_attr__('Offline Donation Email Instructions Subject', 'give'), |
|
311 | + 'desc' => esc_attr__('Enter the subject line for the donation receipt email.', 'give'), |
|
312 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
313 | 313 | 'row_classes' => 'give-subfield', |
314 | 314 | 'type' => 'text' |
315 | 315 | ), |
316 | 316 | array( |
317 | - 'id' => $prefix . 'offline_donation_email', |
|
318 | - 'name' => esc_attr__( 'Offline Donation Email Instructions', 'give' ), |
|
319 | - 'desc' => esc_attr__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
317 | + 'id' => $prefix.'offline_donation_email', |
|
318 | + 'name' => esc_attr__('Offline Donation Email Instructions', 'give'), |
|
319 | + 'desc' => esc_attr__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
320 | 320 | 'default' => give_get_default_offline_donation_email_content(), |
321 | 321 | 'type' => 'wysiwyg', |
322 | 322 | 'row_classes' => 'give-subfield', |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | ) |
327 | 327 | ); |
328 | 328 | |
329 | - return array_merge( $settings, $check_settings ); |
|
329 | + return array_merge($settings, $check_settings); |
|
330 | 330 | } |
331 | 331 | |
332 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
332 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -341,32 +341,32 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function give_get_default_offline_donation_content() { |
343 | 343 | |
344 | - $sitename = get_bloginfo( 'sitename' ); |
|
344 | + $sitename = get_bloginfo('sitename'); |
|
345 | 345 | |
346 | - $default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
346 | + $default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
347 | 347 | $default_text .= '<ol>'; |
348 | 348 | $default_text .= '<li>'; |
349 | 349 | $default_text .= sprintf( |
350 | 350 | /* translators: %s: site name */ |
351 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
351 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
352 | 352 | $sitename |
353 | 353 | ); |
354 | 354 | $default_text .= '</li>'; |
355 | 355 | $default_text .= '<li>'; |
356 | 356 | $default_text .= sprintf( |
357 | 357 | /* translators: %s: site name */ |
358 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
358 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
359 | 359 | $sitename |
360 | 360 | ); |
361 | 361 | $default_text .= '</li>'; |
362 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
362 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
363 | 363 | $default_text .= '</ol>'; |
364 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
364 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
365 | 365 | $default_text .= ' <em>123 G Street </em><br>'; |
366 | 366 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
367 | - $default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
367 | + $default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
368 | 368 | |
369 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
369 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | |
@@ -379,33 +379,33 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function give_get_default_offline_donation_email_content() { |
381 | 381 | |
382 | - $sitename = get_bloginfo( 'sitename' ); |
|
383 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
384 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
382 | + $sitename = get_bloginfo('sitename'); |
|
383 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
384 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
385 | 385 | $default_text .= '<ol>'; |
386 | 386 | $default_text .= '<li>'; |
387 | 387 | $default_text .= sprintf( |
388 | 388 | /* translators: %s: site name */ |
389 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
389 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
390 | 390 | $sitename |
391 | 391 | ); |
392 | 392 | $default_text .= '</li>'; |
393 | 393 | $default_text .= '<li>'; |
394 | 394 | $default_text .= sprintf( |
395 | 395 | /* translators: %s: site name */ |
396 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
396 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
397 | 397 | $sitename |
398 | 398 | ); |
399 | 399 | $default_text .= '</li>'; |
400 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
400 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
401 | 401 | $default_text .= '</ol>'; |
402 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
402 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
403 | 403 | $default_text .= ' <em>123 G Street </em><br>'; |
404 | 404 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
405 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
406 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
407 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
405 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
406 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
407 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
408 | 408 | |
409 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
409 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
410 | 410 | |
411 | 411 | } |
@@ -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 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
42 | - do_action( 'give_purchase_form', $_POST['give_form_id'] ); |
|
41 | + if (isset($_POST['give_payment_mode'])) { |
|
42 | + do_action('give_purchase_form', $_POST['give_form_id']); |
|
43 | 43 | exit(); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
48 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
47 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
48 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Sets an error on checkout if no gateways are enabled |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | function give_no_gateway_error() { |
58 | 58 | $gateways = give_get_enabled_payment_gateways(); |
59 | 59 | |
60 | - if ( empty( $gateways ) ) { |
|
61 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
60 | + if (empty($gateways)) { |
|
61 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
62 | 62 | } else { |
63 | - give_unset_error( 'no_gateways' ); |
|
63 | + give_unset_error('no_gateways'); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | -add_action( 'init', 'give_no_gateway_error' ); |
|
67 | +add_action('init', 'give_no_gateway_error'); |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * @since 1.0 |
112 | 112 | * @access public |
113 | 113 | * |
114 | - * @param int $column Column ID. |
|
115 | - * @param int $row_id Row ID. |
|
116 | - * |
|
117 | - * @return object |
|
114 | + * @param int $column Column ID. |
|
115 | + * @param int $row_id Row ID. |
|
116 | + * |
|
117 | + * @return object |
|
118 | 118 | */ |
119 | 119 | public function get_by( $column, $row_id ) { |
120 | - /* @var WPDB $wpdb */ |
|
121 | - global $wpdb; |
|
120 | + /* @var WPDB $wpdb */ |
|
121 | + global $wpdb; |
|
122 | 122 | |
123 | 123 | $column = esc_sql( $column ); |
124 | 124 | return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @since 1.0 |
131 | 131 | * @access public |
132 | - * |
|
133 | - * @param int $column Column ID. |
|
134 | - * @param int $row_id Row ID. |
|
135 | - * |
|
132 | + * |
|
133 | + * @param int $column Column ID. |
|
134 | + * @param int $row_id Row ID. |
|
135 | + * |
|
136 | 136 | * @return string Column value. |
137 | 137 | */ |
138 | 138 | public function get_column( $column, $row_id ) { |
139 | - /* @var WPDB $wpdb */ |
|
140 | - global $wpdb; |
|
139 | + /* @var WPDB $wpdb */ |
|
140 | + global $wpdb; |
|
141 | 141 | |
142 | 142 | $column = esc_sql( $column ); |
143 | 143 | return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @since 1.0 |
150 | 150 | * @access public |
151 | - * |
|
152 | - * @param int $column Column ID. |
|
153 | - * @param string $column_where Column name. |
|
154 | - * @param string $column_value Column value. |
|
155 | - * |
|
151 | + * |
|
152 | + * @param int $column Column ID. |
|
153 | + * @param string $column_where Column name. |
|
154 | + * @param string $column_value Column value. |
|
155 | + * |
|
156 | 156 | * @return string |
157 | 157 | */ |
158 | 158 | public function get_column_by( $column, $column_where, $column_value ) { |
159 | - /* @var WPDB $wpdb */ |
|
160 | - global $wpdb; |
|
159 | + /* @var WPDB $wpdb */ |
|
160 | + global $wpdb; |
|
161 | 161 | |
162 | 162 | $column_where = esc_sql( $column_where ); |
163 | 163 | $column = esc_sql( $column ); |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @since 1.0 |
171 | 171 | * @access public |
172 | - * |
|
173 | - * @param array $data |
|
174 | - * @param string $type |
|
175 | - * |
|
172 | + * |
|
173 | + * @param array $data |
|
174 | + * @param string $type |
|
175 | + * |
|
176 | 176 | * @return int |
177 | 177 | */ |
178 | 178 | public function insert( $data, $type = '' ) { |
179 | - /* @var WPDB $wpdb */ |
|
180 | - global $wpdb; |
|
179 | + /* @var WPDB $wpdb */ |
|
180 | + global $wpdb; |
|
181 | 181 | |
182 | 182 | // Set default values |
183 | 183 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @since 1.0 |
211 | 211 | * @access public |
212 | - * |
|
213 | - * @param int $row_id Column ID |
|
214 | - * @param array $data |
|
215 | - * @param string $where Column value |
|
216 | - * |
|
212 | + * |
|
213 | + * @param int $row_id Column ID |
|
214 | + * @param array $data |
|
215 | + * @param string $where Column value |
|
216 | + * |
|
217 | 217 | * @return bool |
218 | 218 | */ |
219 | 219 | public function update( $row_id, $data = array(), $where = '' ) { |
220 | - /* @var WPDB $wpdb */ |
|
221 | - global $wpdb; |
|
220 | + /* @var WPDB $wpdb */ |
|
221 | + global $wpdb; |
|
222 | 222 | |
223 | 223 | // Row ID must be positive integer |
224 | 224 | $row_id = absint( $row_id ); |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @since 1.0 |
258 | 258 | * @access public |
259 | - * |
|
260 | - * @param int $row_id Column ID. |
|
261 | - * |
|
259 | + * |
|
260 | + * @param int $row_id Column ID. |
|
261 | + * |
|
262 | 262 | * @return bool |
263 | 263 | */ |
264 | 264 | public function delete( $row_id = 0 ) { |
265 | - /* @var WPDB $wpdb */ |
|
266 | - global $wpdb; |
|
265 | + /* @var WPDB $wpdb */ |
|
266 | + global $wpdb; |
|
267 | 267 | |
268 | 268 | // Row ID must be positive integer |
269 | 269 | $row_id = absint( $row_id ); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 1.3.2 |
286 | 286 | * @access public |
287 | - * |
|
287 | + * |
|
288 | 288 | * @param string $table The table name. |
289 | - * |
|
289 | + * |
|
290 | 290 | * @return bool If the table name exists. |
291 | 291 | */ |
292 | 292 | public function table_exists( $table ) { |
293 | - /* @var WPDB $wpdb */ |
|
293 | + /* @var WPDB $wpdb */ |
|
294 | 294 | global $wpdb; |
295 | 295 | |
296 | 296 | $table = sanitize_text_field( $table ); |
@@ -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 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return object |
100 | 100 | */ |
101 | - public function get( $row_id ) { |
|
101 | + public function get($row_id) { |
|
102 | 102 | /* @var WPDB $wpdb */ |
103 | 103 | global $wpdb; |
104 | 104 | |
105 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
105 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return object |
118 | 118 | */ |
119 | - public function get_by( $column, $row_id ) { |
|
119 | + public function get_by($column, $row_id) { |
|
120 | 120 | /* @var WPDB $wpdb */ |
121 | 121 | global $wpdb; |
122 | 122 | |
123 | - $column = esc_sql( $column ); |
|
124 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
123 | + $column = esc_sql($column); |
|
124 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string Column value. |
137 | 137 | */ |
138 | - public function get_column( $column, $row_id ) { |
|
138 | + public function get_column($column, $row_id) { |
|
139 | 139 | /* @var WPDB $wpdb */ |
140 | 140 | global $wpdb; |
141 | 141 | |
142 | - $column = esc_sql( $column ); |
|
143 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
142 | + $column = esc_sql($column); |
|
143 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
158 | + public function get_column_by($column, $column_where, $column_value) { |
|
159 | 159 | /* @var WPDB $wpdb */ |
160 | 160 | global $wpdb; |
161 | 161 | |
162 | - $column_where = esc_sql( $column_where ); |
|
163 | - $column = esc_sql( $column ); |
|
164 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
162 | + $column_where = esc_sql($column_where); |
|
163 | + $column = esc_sql($column); |
|
164 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,31 +175,31 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return int |
177 | 177 | */ |
178 | - public function insert( $data, $type = '' ) { |
|
178 | + public function insert($data, $type = '') { |
|
179 | 179 | /* @var WPDB $wpdb */ |
180 | 180 | global $wpdb; |
181 | 181 | |
182 | 182 | // Set default values |
183 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
183 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
184 | 184 | |
185 | - do_action( 'give_pre_insert_' . $type, $data ); |
|
185 | + do_action('give_pre_insert_'.$type, $data); |
|
186 | 186 | |
187 | 187 | // Initialise column format array |
188 | 188 | $column_formats = $this->get_columns(); |
189 | 189 | |
190 | 190 | // Force fields to lower case |
191 | - $data = array_change_key_case( $data ); |
|
191 | + $data = array_change_key_case($data); |
|
192 | 192 | |
193 | 193 | // White list columns |
194 | - $data = array_intersect_key( $data, $column_formats ); |
|
194 | + $data = array_intersect_key($data, $column_formats); |
|
195 | 195 | |
196 | 196 | // Reorder $column_formats to match the order of columns given in $data |
197 | - $data_keys = array_keys( $data ); |
|
198 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
197 | + $data_keys = array_keys($data); |
|
198 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
199 | 199 | |
200 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
200 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
201 | 201 | |
202 | - do_action( 'give_post_insert_' . $type, $wpdb->insert_id, $data ); |
|
202 | + do_action('give_post_insert_'.$type, $wpdb->insert_id, $data); |
|
203 | 203 | |
204 | 204 | return $wpdb->insert_id; |
205 | 205 | } |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool |
218 | 218 | */ |
219 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
219 | + public function update($row_id, $data = array(), $where = '') { |
|
220 | 220 | /* @var WPDB $wpdb */ |
221 | 221 | global $wpdb; |
222 | 222 | |
223 | 223 | // Row ID must be positive integer |
224 | - $row_id = absint( $row_id ); |
|
224 | + $row_id = absint($row_id); |
|
225 | 225 | |
226 | - if ( empty( $row_id ) ) { |
|
226 | + if (empty($row_id)) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | - if ( empty( $where ) ) { |
|
230 | + if (empty($where)) { |
|
231 | 231 | $where = $this->primary_key; |
232 | 232 | } |
233 | 233 | |
@@ -235,16 +235,16 @@ discard block |
||
235 | 235 | $column_formats = $this->get_columns(); |
236 | 236 | |
237 | 237 | // Force fields to lower case |
238 | - $data = array_change_key_case( $data ); |
|
238 | + $data = array_change_key_case($data); |
|
239 | 239 | |
240 | 240 | // White list columns |
241 | - $data = array_intersect_key( $data, $column_formats ); |
|
241 | + $data = array_intersect_key($data, $column_formats); |
|
242 | 242 | |
243 | 243 | // Reorder $column_formats to match the order of columns given in $data |
244 | - $data_keys = array_keys( $data ); |
|
245 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
244 | + $data_keys = array_keys($data); |
|
245 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
246 | 246 | |
247 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
247 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | - public function delete( $row_id = 0 ) { |
|
264 | + public function delete($row_id = 0) { |
|
265 | 265 | /* @var WPDB $wpdb */ |
266 | 266 | global $wpdb; |
267 | 267 | |
268 | 268 | // Row ID must be positive integer |
269 | - $row_id = absint( $row_id ); |
|
269 | + $row_id = absint($row_id); |
|
270 | 270 | |
271 | - if ( empty( $row_id ) ) { |
|
271 | + if (empty($row_id)) { |
|
272 | 272 | return false; |
273 | 273 | } |
274 | 274 | |
275 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
275 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
276 | 276 | return false; |
277 | 277 | } |
278 | 278 | |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return bool If the table name exists. |
291 | 291 | */ |
292 | - public function table_exists( $table ) { |
|
292 | + public function table_exists($table) { |
|
293 | 293 | /* @var WPDB $wpdb */ |
294 | 294 | global $wpdb; |
295 | 295 | |
296 | - $table = sanitize_text_field( $table ); |
|
296 | + $table = sanitize_text_field($table); |
|
297 | 297 | |
298 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
298 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @return bool Returns if the customers table was installed and upgrade routine run. |
308 | 308 | */ |
309 | 309 | public function installed() { |
310 | - return $this->table_exists( $this->table_name ); |
|
310 | + return $this->table_exists($this->table_name); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | } |
@@ -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,12 +24,12 @@ discard block |
||
24 | 24 | * @return void |
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | - if ( isset( $_GET['give_action'] ) ) { |
|
28 | - do_action( 'give_' . $_GET['give_action'], $_GET ); |
|
27 | + if (isset($_GET['give_action'])) { |
|
28 | + do_action('give_'.$_GET['give_action'], $_GET); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_action( 'init', 'give_get_actions' ); |
|
32 | +add_action('init', 'give_get_actions'); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Hooks Give actions, when present in the $_POST superglobal. Every give_action |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * @return void |
42 | 42 | */ |
43 | 43 | function give_post_actions() { |
44 | - if ( isset( $_POST['give_action'] ) ) { |
|
45 | - do_action( 'give_' . $_POST['give_action'], $_POST ); |
|
44 | + if (isset($_POST['give_action'])) { |
|
45 | + do_action('give_'.$_POST['give_action'], $_POST); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -add_action( 'init', 'give_post_actions' ); |
|
49 | +add_action('init', 'give_post_actions'); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 1.3.0 |
12 | 12 | */ |
13 | 13 | |
14 | -defined( 'ABSPATH' ) or exit; |
|
14 | +defined('ABSPATH') or exit; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Class Give_Shortcode_Button |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | 32 | |
33 | - if ( is_admin() ) { |
|
34 | - add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 ); |
|
33 | + if (is_admin()) { |
|
34 | + add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15); |
|
35 | 35 | |
36 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) ); |
|
37 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 ); |
|
38 | - add_action( 'media_buttons', array( $this, 'shortcode_button' ) ); |
|
36 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets')); |
|
37 | + add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13); |
|
38 | + add_action('media_buttons', array($this, 'shortcode_button')); |
|
39 | 39 | } |
40 | 40 | |
41 | - add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
42 | - add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
41 | + add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax')); |
|
42 | + add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @since 1.0 |
53 | 53 | */ |
54 | - public function mce_external_plugins( $plugin_array ) { |
|
54 | + public function mce_external_plugins($plugin_array) { |
|
55 | 55 | |
56 | - if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { |
|
56 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) { |
|
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
60 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
61 | 61 | |
62 | - $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js'; |
|
62 | + $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js'; |
|
63 | 63 | |
64 | 64 | return $plugin_array; |
65 | 65 | } |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function admin_enqueue_assets() { |
75 | 75 | |
76 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
76 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
77 | 77 | |
78 | 78 | wp_enqueue_script( |
79 | 79 | 'give_shortcode', |
80 | - GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js', |
|
81 | - array( 'jquery' ), |
|
80 | + GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js', |
|
81 | + array('jquery'), |
|
82 | 82 | GIVE_VERSION, |
83 | 83 | true |
84 | 84 | ); |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function admin_localize_scripts() { |
95 | 95 | |
96 | - if ( ! empty( self::$shortcodes ) ) { |
|
96 | + if ( ! empty(self::$shortcodes)) { |
|
97 | 97 | |
98 | 98 | $variables = array(); |
99 | 99 | |
100 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
101 | - if ( ! empty( $values['required'] ) ) { |
|
102 | - $variables[ $shortcode ] = $values['required']; |
|
100 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
101 | + if ( ! empty($values['required'])) { |
|
102 | + $variables[$shortcode] = $values['required']; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - wp_localize_script( 'give_shortcode', 'scShortcodes', $variables ); |
|
106 | + wp_localize_script('give_shortcode', 'scShortcodes', $variables); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -118,31 +118,31 @@ discard block |
||
118 | 118 | |
119 | 119 | global $pagenow, $wp_version; |
120 | 120 | |
121 | - $shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array( |
|
121 | + $shortcode_button_pages = apply_filters('give_shortcode_button_pages', array( |
|
122 | 122 | 'post.php', |
123 | 123 | 'page.php', |
124 | 124 | 'post-new.php', |
125 | 125 | 'post-edit.php' |
126 | - ) ); |
|
126 | + )); |
|
127 | 127 | |
128 | 128 | // Only run in admin post/page creation and edit screens |
129 | - if ( in_array( $pagenow, $shortcode_button_pages ) |
|
130 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
131 | - && ! empty( self::$shortcodes ) |
|
129 | + if (in_array($pagenow, $shortcode_button_pages) |
|
130 | + && apply_filters('give_shortcode_button_condition', true) |
|
131 | + && ! empty(self::$shortcodes) |
|
132 | 132 | ) { |
133 | 133 | |
134 | 134 | $shortcodes = array(); |
135 | 135 | |
136 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
136 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
137 | 137 | |
138 | 138 | /** |
139 | 139 | * Filters the condition for including the current shortcode |
140 | 140 | * |
141 | 141 | * @since 1.0 |
142 | 142 | */ |
143 | - if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) { |
|
143 | + if (apply_filters(sanitize_title($shortcode).'_condition', true)) { |
|
144 | 144 | |
145 | - $shortcodes[ $shortcode ] = sprintf( |
|
145 | + $shortcodes[$shortcode] = sprintf( |
|
146 | 146 | '<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>', |
147 | 147 | $shortcode, |
148 | 148 | $values['label'], |
@@ -151,37 +151,37 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - if ( ! empty( $shortcodes ) ) { |
|
154 | + if ( ! empty($shortcodes)) { |
|
155 | 155 | |
156 | 156 | // check current WP version |
157 | - $img = ( version_compare( $wp_version, '3.5', '<' ) ) |
|
158 | - ? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />' |
|
159 | - : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>'; |
|
157 | + $img = (version_compare($wp_version, '3.5', '<')) |
|
158 | + ? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />' |
|
159 | + : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>'; |
|
160 | 160 | |
161 | - reset( $shortcodes ); |
|
161 | + reset($shortcodes); |
|
162 | 162 | |
163 | - if ( count( $shortcodes ) == 1 ) { |
|
163 | + if (count($shortcodes) == 1) { |
|
164 | 164 | |
165 | - $shortcode = key( $shortcodes ); |
|
165 | + $shortcode = key($shortcodes); |
|
166 | 166 | |
167 | 167 | printf( |
168 | 168 | '<button class="button sc-shortcode" data-shortcode="%s">%s</button>', |
169 | 169 | $shortcode, |
170 | - sprintf( '%s %s %s', |
|
170 | + sprintf('%s %s %s', |
|
171 | 171 | $img, |
172 | - esc_html__( 'Insert', 'give' ), |
|
173 | - self::$shortcodes[ $shortcode ]['label'] |
|
172 | + esc_html__('Insert', 'give'), |
|
173 | + self::$shortcodes[$shortcode]['label'] |
|
174 | 174 | ) |
175 | 175 | ); |
176 | 176 | } else { |
177 | 177 | printf( |
178 | - '<div class="sc-wrap">' . |
|
179 | - '<button class="button sc-button">%s %s</button>' . |
|
180 | - '<div class="sc-menu mce-menu">%s</div>' . |
|
178 | + '<div class="sc-wrap">'. |
|
179 | + '<button class="button sc-button">%s %s</button>'. |
|
180 | + '<div class="sc-menu mce-menu">%s</div>'. |
|
181 | 181 | '</div>', |
182 | 182 | $img, |
183 | - esc_html__( 'Give Shortcodes', 'give' ), |
|
184 | - implode( '', array_values( $shortcodes ) ) |
|
183 | + esc_html__('Give Shortcodes', 'give'), |
|
184 | + implode('', array_values($shortcodes)) |
|
185 | 185 | ); |
186 | 186 | } |
187 | 187 | } |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function shortcode_ajax() { |
199 | 199 | |
200 | - $shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false; |
|
200 | + $shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false; |
|
201 | 201 | $response = false; |
202 | 202 | |
203 | - if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) { |
|
203 | + if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) { |
|
204 | 204 | |
205 | - $data = self::$shortcodes[ $shortcode ]; |
|
205 | + $data = self::$shortcodes[$shortcode]; |
|
206 | 206 | |
207 | - if ( ! empty( $data['errors'] ) ) { |
|
208 | - $data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) ); |
|
207 | + if ( ! empty($data['errors'])) { |
|
208 | + $data['btn_okay'] = array(esc_html__('Okay', 'give')); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $response = array( |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | ); |
218 | 218 | } else { |
219 | 219 | // todo: handle error |
220 | - error_log( print_r( 'AJAX error!', 1 ) ); |
|
220 | + error_log(print_r('AJAX error!', 1)); |
|
221 | 221 | } |
222 | 222 | |
223 | - wp_send_json( $response ); |
|
223 | + wp_send_json($response); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 |