@@ -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 | |
@@ -64,50 +64,50 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool If the gravatar exists or not |
66 | 66 | */ |
67 | - public function validate_gravatar( $id_or_email ) { |
|
67 | + public function validate_gravatar($id_or_email) { |
|
68 | 68 | //id or email code borrowed from wp-includes/pluggable.php |
69 | 69 | $email = ''; |
70 | - if ( is_numeric( $id_or_email ) ) { |
|
70 | + if (is_numeric($id_or_email)) { |
|
71 | 71 | $id = (int) $id_or_email; |
72 | - $user = get_userdata( $id ); |
|
73 | - if ( $user ) { |
|
72 | + $user = get_userdata($id); |
|
73 | + if ($user) { |
|
74 | 74 | $email = $user->user_email; |
75 | 75 | } |
76 | - } elseif ( is_object( $id_or_email ) ) { |
|
76 | + } elseif (is_object($id_or_email)) { |
|
77 | 77 | // No avatar for pingbacks or trackbacks |
78 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
79 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
78 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
79 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
83 | + if ( ! empty($id_or_email->user_id)) { |
|
84 | 84 | $id = (int) $id_or_email->user_id; |
85 | - $user = get_userdata( $id ); |
|
86 | - if ( $user ) { |
|
85 | + $user = get_userdata($id); |
|
86 | + if ($user) { |
|
87 | 87 | $email = $user->user_email; |
88 | 88 | } |
89 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
89 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
90 | 90 | $email = $id_or_email->comment_author_email; |
91 | 91 | } |
92 | 92 | } else { |
93 | 93 | $email = $id_or_email; |
94 | 94 | } |
95 | 95 | |
96 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
97 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
96 | + $hashkey = md5(strtolower(trim($email))); |
|
97 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
98 | 98 | |
99 | - $data = wp_cache_get( $hashkey ); |
|
100 | - if ( false === $data ) { |
|
101 | - $response = wp_remote_head( $uri ); |
|
102 | - if ( is_wp_error( $response ) ) { |
|
99 | + $data = wp_cache_get($hashkey); |
|
100 | + if (false === $data) { |
|
101 | + $response = wp_remote_head($uri); |
|
102 | + if (is_wp_error($response)) { |
|
103 | 103 | $data = 'not200'; |
104 | 104 | } else { |
105 | 105 | $data = $response['response']['code']; |
106 | 106 | } |
107 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
107 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
108 | 108 | |
109 | 109 | } |
110 | - if ( $data == '200' ) { |
|
110 | + if ($data == '200') { |
|
111 | 111 | return true; |
112 | 112 | } else { |
113 | 113 | return false; |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return array IDs if logs, false otherwise |
126 | 126 | */ |
127 | - public function get_log_ids( $form_id = '' ) { |
|
127 | + public function get_log_ids($form_id = '') { |
|
128 | 128 | |
129 | 129 | // get Give_Logging class |
130 | 130 | global $give_logs; |
131 | 131 | |
132 | 132 | // get log for this form |
133 | - $logs = $give_logs->get_logs( $form_id ); |
|
133 | + $logs = $give_logs->get_logs($form_id); |
|
134 | 134 | |
135 | - if ( $logs ) { |
|
135 | + if ($logs) { |
|
136 | 136 | // make an array with all the donor IDs |
137 | - foreach ( $logs as $log ) { |
|
137 | + foreach ($logs as $log) { |
|
138 | 138 | $log_ids[] = $log->ID; |
139 | 139 | } |
140 | 140 | |
@@ -155,49 +155,49 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | - public function get_payment_ids( $form_id = '' ) { |
|
158 | + public function get_payment_ids($form_id = '') { |
|
159 | 159 | |
160 | 160 | global $give_options; |
161 | 161 | |
162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
162 | + $log_ids = $this->get_log_ids($form_id); |
|
163 | 163 | |
164 | - if ( $log_ids ) { |
|
164 | + if ($log_ids) { |
|
165 | 165 | |
166 | 166 | $payment_ids = array(); |
167 | 167 | |
168 | - foreach ( $log_ids as $id ) { |
|
168 | + foreach ($log_ids as $id) { |
|
169 | 169 | // get the payment ID for each corresponding log ID |
170 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
170 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // remove donors who have purchased more than once so we can have unique avatars |
174 | 174 | $unique_emails = array(); |
175 | 175 | |
176 | - foreach ( $payment_ids as $key => $id ) { |
|
176 | + foreach ($payment_ids as $key => $id) { |
|
177 | 177 | |
178 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
178 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
179 | 179 | |
180 | - if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { |
|
181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
180 | + if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) { |
|
181 | + if ( ! $this->validate_gravatar($email)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
186 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | // strip duplicate emails |
191 | - $unique_emails = array_unique( $unique_emails ); |
|
191 | + $unique_emails = array_unique($unique_emails); |
|
192 | 192 | |
193 | 193 | // convert the unique IDs back into simple array |
194 | - foreach ( $unique_emails as $id => $email ) { |
|
194 | + foreach ($unique_emails as $id => $email) { |
|
195 | 195 | $unique_ids[] = $id; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // randomize the payment IDs if enabled |
199 | - if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { |
|
200 | - shuffle( $unique_ids ); |
|
199 | + if (isset($give_options['give_donators_gravatars_random_gravatars'])) { |
|
200 | + shuffle($unique_ids); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // return our unique IDs |
@@ -218,22 +218,22 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public function gravatars( $form_id = false, $title = '' ) { |
|
221 | + public function gravatars($form_id = false, $title = '') { |
|
222 | 222 | |
223 | 223 | // unique $payment_ids |
224 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
224 | + $payment_ids = $this->get_payment_ids($form_id); |
|
225 | 225 | |
226 | 226 | global $give_options; |
227 | 227 | |
228 | 228 | // return if no ID |
229 | - if ( ! $form_id ) { |
|
229 | + if ( ! $form_id) { |
|
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // minimum amount of purchases before showing gravatars |
234 | 234 | // if the number of items in array is not greater or equal to the number specified, then exit |
235 | - if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { |
|
236 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { |
|
235 | + if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) { |
|
236 | + if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | } |
@@ -244,51 +244,51 @@ discard block |
||
244 | 244 | echo '<div id="give-purchase-gravatars">'; |
245 | 245 | |
246 | 246 | |
247 | - if ( isset ( $title ) ) { |
|
247 | + if (isset ($title)) { |
|
248 | 248 | |
249 | - if ( $title ) { |
|
250 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
251 | - } elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { |
|
252 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); |
|
249 | + if ($title) { |
|
250 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
251 | + } elseif (isset($give_options['give_donators_gravatars_heading'])) { |
|
252 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | echo '<ul class="give-purchase-gravatars-list">'; |
257 | 257 | $i = 0; |
258 | 258 | |
259 | - if ( $payment_ids ) { |
|
260 | - foreach ( $payment_ids as $id ) { |
|
259 | + if ($payment_ids) { |
|
260 | + foreach ($payment_ids as $id) { |
|
261 | 261 | |
262 | 262 | // Give saves a blank option even when the control is turned off, hence the extra check |
263 | - if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { |
|
263 | + if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // get the payment meta |
268 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
268 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
269 | 269 | |
270 | 270 | // unserialize the payment meta |
271 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
271 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
272 | 272 | |
273 | 273 | // get donor's first name |
274 | 274 | $name = $user_info['first_name']; |
275 | 275 | |
276 | 276 | // get donor's email |
277 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
277 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
278 | 278 | |
279 | 279 | // set gravatar size and provide filter |
280 | - $size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; |
|
280 | + $size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : ''; |
|
281 | 281 | |
282 | 282 | // default image |
283 | - $default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); |
|
283 | + $default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false); |
|
284 | 284 | |
285 | 285 | // assemble output |
286 | 286 | $output .= '<li>'; |
287 | 287 | |
288 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
288 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
289 | 289 | $output .= '</li>'; |
290 | 290 | |
291 | - $i ++; |
|
291 | + $i++; |
|
292 | 292 | |
293 | 293 | } // end foreach |
294 | 294 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | echo '</ul>'; |
298 | 298 | echo '</div>'; |
299 | 299 | |
300 | - return apply_filters( 'give_donators_gravatars', ob_get_clean() ); |
|
300 | + return apply_filters('give_donators_gravatars', ob_get_clean()); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return void |
310 | 310 | */ |
311 | 311 | public function register_widget() { |
312 | - register_widget( 'Give_Donators_Gravatars_Widget' ); |
|
312 | + register_widget('Give_Donators_Gravatars_Widget'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -325,19 +325,19 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @todo Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
327 | 327 | */ |
328 | - public function shortcode( $atts, $content = null ) { |
|
328 | + public function shortcode($atts, $content = null) { |
|
329 | 329 | |
330 | - $atts = shortcode_atts( array( |
|
330 | + $atts = shortcode_atts(array( |
|
331 | 331 | 'id' => '', |
332 | 332 | 'title' => '' |
333 | - ), $atts, 'give_donators_gravatars' ); |
|
333 | + ), $atts, 'give_donators_gravatars'); |
|
334 | 334 | |
335 | 335 | // if no ID is passed on single give_forms pages, get the correct ID |
336 | - if ( is_singular( 'give_forms' ) ) { |
|
336 | + if (is_singular('give_forms')) { |
|
337 | 337 | $id = get_the_ID(); |
338 | 338 | } |
339 | 339 | |
340 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
340 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
341 | 341 | |
342 | 342 | return $content; |
343 | 343 | |
@@ -353,57 +353,57 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return array Gravatar settings. |
355 | 355 | */ |
356 | - public function settings( $settings ) { |
|
356 | + public function settings($settings) { |
|
357 | 357 | |
358 | 358 | $give_gravatar_settings = array( |
359 | 359 | array( |
360 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
360 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
361 | 361 | 'desc' => '<hr>', |
362 | 362 | 'id' => 'give_title', |
363 | 363 | 'type' => 'give_title' |
364 | 364 | ), |
365 | 365 | array( |
366 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
367 | - 'desc' => esc_html__( 'The heading to display above the Gravatars', 'give' ), |
|
366 | + 'name' => esc_html__('Heading', 'give'), |
|
367 | + 'desc' => esc_html__('The heading to display above the Gravatars', 'give'), |
|
368 | 368 | 'type' => 'text', |
369 | 369 | 'id' => 'give_donators_gravatars_heading' |
370 | 370 | ), |
371 | 371 | array( |
372 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
373 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), |
|
372 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
373 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum)', 'give'), |
|
374 | 374 | 'type' => 'text_small', |
375 | 375 | 'id' => 'give_donators_gravatars_gravatar_size', |
376 | 376 | 'default' => '64' |
377 | 377 | ), |
378 | 378 | array( |
379 | - 'name' => esc_html__( 'Minimum Unique Purchases Required', 'give' ), |
|
379 | + 'name' => esc_html__('Minimum Unique Purchases Required', 'give'), |
|
380 | 380 | /* translators: %s: form singular label */ |
381 | - 'desc' => sprintf( esc_html__( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), |
|
381 | + 'desc' => sprintf(esc_html__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())), |
|
382 | 382 | 'type' => 'text_small', |
383 | 383 | 'id' => 'give_donators_gravatars_min_purchases_required', |
384 | 384 | ), |
385 | 385 | array( |
386 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
387 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
386 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
387 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
388 | 388 | 'type' => 'text', |
389 | 389 | 'id' => 'give_donators_gravatars_maximum_number', |
390 | 390 | 'default' => '20', |
391 | 391 | ), |
392 | 392 | array( |
393 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
394 | - 'desc' => esc_html__( 'Only show donators with a Gravatar account', 'give' ), |
|
393 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
394 | + 'desc' => esc_html__('Only show donators with a Gravatar account', 'give'), |
|
395 | 395 | 'id' => 'give_donators_gravatars_has_gravatar_account', |
396 | 396 | 'type' => 'checkbox', |
397 | 397 | ), |
398 | 398 | array( |
399 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
400 | - 'desc' => esc_html__( 'Randomize the Gravatars', 'give' ), |
|
399 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
400 | + 'desc' => esc_html__('Randomize the Gravatars', 'give'), |
|
401 | 401 | 'id' => 'give_donators_gravatars_random_gravatars', |
402 | 402 | 'type' => 'checkbox', |
403 | 403 | ), |
404 | 404 | ); |
405 | 405 | |
406 | - return array_merge( $settings, $give_gravatar_settings ); |
|
406 | + return array_merge($settings, $give_gravatar_settings); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | } |
@@ -428,13 +428,13 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function __construct() { |
430 | 430 | |
431 | - $give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; |
|
431 | + $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; |
|
432 | 432 | |
433 | 433 | // widget settings |
434 | 434 | $widget_ops = array( |
435 | 435 | 'classname' => 'give-donators-gravatars', |
436 | 436 | /* translators: 1: form singular label 2: form singular label */ |
437 | - 'description' => sprintf( esc_html__( 'Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give' ), $give_label_singular, $give_label_singular ) |
|
437 | + 'description' => sprintf(esc_html__('Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give'), $give_label_singular, $give_label_singular) |
|
438 | 438 | ); |
439 | 439 | |
440 | 440 | // widget control settings |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | // create the widget |
448 | 448 | parent::__construct( |
449 | 449 | 'give_donators_gravatars_widget', |
450 | - esc_html__( 'Give Donators Gravatars', 'give' ), |
|
450 | + esc_html__('Give Donators Gravatars', 'give'), |
|
451 | 451 | $widget_ops, |
452 | 452 | $control_ops |
453 | 453 | ); |
@@ -467,30 +467,30 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @return void |
469 | 469 | */ |
470 | - public function widget( $args, $instance ) { |
|
470 | + public function widget($args, $instance) { |
|
471 | 471 | global $give_options; |
472 | 472 | |
473 | 473 | //@TODO: Don't extract it!!! |
474 | - extract( $args ); |
|
474 | + extract($args); |
|
475 | 475 | |
476 | - if ( ! is_singular( 'give_forms' ) ) { |
|
476 | + if ( ! is_singular('give_forms')) { |
|
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Variables from widget settings |
481 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
481 | + $title = apply_filters('widget_title', $instance['title']); |
|
482 | 482 | |
483 | 483 | // Used by themes. Opens the widget |
484 | 484 | echo $before_widget; |
485 | 485 | |
486 | 486 | // Display the widget title |
487 | - if ( $title ) { |
|
488 | - echo $before_title . $title . $after_title; |
|
487 | + if ($title) { |
|
488 | + echo $before_title.$title.$after_title; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | $gravatars = new Give_Donators_Gravatars(); |
492 | 492 | |
493 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
493 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
494 | 494 | |
495 | 495 | // Used by themes. Closes the widget |
496 | 496 | echo $after_widget; |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return array Updated settings to save. |
512 | 512 | */ |
513 | - public function update( $new_instance, $old_instance ) { |
|
513 | + public function update($new_instance, $old_instance) { |
|
514 | 514 | |
515 | 515 | $instance = $old_instance; |
516 | 516 | |
517 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
517 | + $instance['title'] = strip_tags($new_instance['title']); |
|
518 | 518 | |
519 | 519 | return $instance; |
520 | 520 | |
@@ -532,19 +532,19 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return void |
534 | 534 | */ |
535 | - public function form( $instance ) { |
|
535 | + public function form($instance) { |
|
536 | 536 | |
537 | 537 | // Set up some default widget settings. |
538 | 538 | $defaults = array( |
539 | 539 | 'title' => '', |
540 | 540 | ); |
541 | 541 | |
542 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
542 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
543 | 543 | |
544 | 544 | <!-- Title --> |
545 | 545 | <p> |
546 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
547 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
546 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
547 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
548 | 548 | </p> |
549 | 549 | |
550 | 550 | <?php |
@@ -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,40 +23,40 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | /** Give Forms Post Type */ |
26 | - $give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false; |
|
26 | + $give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false; |
|
27 | 27 | |
28 | - $give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false; |
|
28 | + $give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false; |
|
29 | 29 | |
30 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
30 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
31 | 31 | //support for old 'GIVE_FORMS_SLUG' constant |
32 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
32 | + if (defined('GIVE_FORMS_SLUG')) { |
|
33 | 33 | $give_forms_slug = GIVE_FORMS_SLUG; |
34 | 34 | } |
35 | 35 | |
36 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
37 | 37 | 'slug' => $give_forms_slug, |
38 | 38 | 'with_front' => false |
39 | 39 | ); |
40 | 40 | |
41 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
42 | - 'name' => esc_html__( 'Donation %2$s', 'give' ), |
|
41 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
42 | + 'name' => esc_html__('Donation %2$s', 'give'), |
|
43 | 43 | 'singular_name' => '%1$s', |
44 | - 'add_new' => esc_html__( 'Add %1$s', 'give' ), |
|
45 | - 'add_new_item' => esc_html__( 'Add New Donation %1$s', 'give' ), |
|
46 | - 'edit_item' => esc_html__( 'Edit Donation %1$s', 'give' ), |
|
47 | - 'new_item' => esc_html__( 'New %1$s', 'give' ), |
|
48 | - 'all_items' => esc_html__( 'All %2$s', 'give' ), |
|
49 | - 'view_item' => esc_html__( 'View %1$s', 'give' ), |
|
50 | - 'search_items' => esc_html__( 'Search %2$s', 'give' ), |
|
51 | - 'not_found' => esc_html__( 'No %2$s found', 'give' ), |
|
52 | - 'not_found_in_trash' => esc_html__( 'No %2$s found in Trash', 'give' ), |
|
44 | + 'add_new' => esc_html__('Add %1$s', 'give'), |
|
45 | + 'add_new_item' => esc_html__('Add New Donation %1$s', 'give'), |
|
46 | + 'edit_item' => esc_html__('Edit Donation %1$s', 'give'), |
|
47 | + 'new_item' => esc_html__('New %1$s', 'give'), |
|
48 | + 'all_items' => esc_html__('All %2$s', 'give'), |
|
49 | + 'view_item' => esc_html__('View %1$s', 'give'), |
|
50 | + 'search_items' => esc_html__('Search %2$s', 'give'), |
|
51 | + 'not_found' => esc_html__('No %2$s found', 'give'), |
|
52 | + 'not_found_in_trash' => esc_html__('No %2$s found in Trash', 'give'), |
|
53 | 53 | 'parent_item_colon' => '', |
54 | - 'menu_name' => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ), |
|
55 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ) |
|
56 | - ) ); |
|
54 | + 'menu_name' => apply_filters('give_menu_name', esc_html__('Donations', 'give')), |
|
55 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')) |
|
56 | + )); |
|
57 | 57 | |
58 | - foreach ( $give_forms_labels as $key => $value ) { |
|
59 | - $give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() ); |
|
58 | + foreach ($give_forms_labels as $key => $value) { |
|
59 | + $give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | //Default give_forms supports |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | ); |
70 | 70 | |
71 | 71 | //Has the user disabled the excerpt |
72 | - if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) { |
|
73 | - unset( $give_form_supports[2] ); |
|
72 | + if (give_get_option('disable_forms_excerpt') === 'on') { |
|
73 | + unset($give_form_supports[2]); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | //Has user disabled the featured image? |
77 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
78 | - unset( $give_form_supports[1] ); |
|
79 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
77 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
78 | + unset($give_form_supports[1]); |
|
79 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $give_forms_args = array( |
@@ -92,42 +92,42 @@ discard block |
||
92 | 92 | 'has_archive' => $give_forms_archives, |
93 | 93 | 'menu_icon' => 'dashicons-give', |
94 | 94 | 'hierarchical' => false, |
95 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
95 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
96 | 96 | ); |
97 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
97 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
98 | 98 | |
99 | 99 | /** Payment Post Type */ |
100 | 100 | $payment_labels = array( |
101 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
102 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
103 | - 'add_new' => esc_html__( 'Add New', 'give' ), |
|
104 | - 'add_new_item' => esc_html__( 'Add New Donation', 'give' ), |
|
105 | - 'edit_item' => esc_html__( 'Edit Donation', 'give' ), |
|
106 | - 'new_item' => esc_html__( 'New Donation', 'give' ), |
|
107 | - 'all_items' => esc_html__( 'All Donations', 'give' ), |
|
108 | - 'view_item' => esc_html__( 'View Donation', 'give' ), |
|
109 | - 'search_items' => esc_html__( 'Search Donations', 'give' ), |
|
110 | - 'not_found' => esc_html__( 'No Donations found', 'give' ), |
|
111 | - 'not_found_in_trash' => esc_html__( 'No Donations found in Trash', 'give' ), |
|
101 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
102 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
103 | + 'add_new' => esc_html__('Add New', 'give'), |
|
104 | + 'add_new_item' => esc_html__('Add New Donation', 'give'), |
|
105 | + 'edit_item' => esc_html__('Edit Donation', 'give'), |
|
106 | + 'new_item' => esc_html__('New Donation', 'give'), |
|
107 | + 'all_items' => esc_html__('All Donations', 'give'), |
|
108 | + 'view_item' => esc_html__('View Donation', 'give'), |
|
109 | + 'search_items' => esc_html__('Search Donations', 'give'), |
|
110 | + 'not_found' => esc_html__('No Donations found', 'give'), |
|
111 | + 'not_found_in_trash' => esc_html__('No Donations found in Trash', 'give'), |
|
112 | 112 | 'parent_item_colon' => '', |
113 | - 'menu_name' => esc_html__( 'Transactions', 'give' ) |
|
113 | + 'menu_name' => esc_html__('Transactions', 'give') |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 | $payment_args = array( |
117 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
117 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
118 | 118 | 'public' => false, |
119 | 119 | 'query_var' => false, |
120 | 120 | 'rewrite' => false, |
121 | 121 | 'map_meta_cap' => true, |
122 | 122 | 'capability_type' => 'give_payment', |
123 | - 'supports' => array( 'title' ), |
|
123 | + 'supports' => array('title'), |
|
124 | 124 | 'can_export' => true |
125 | 125 | ); |
126 | - register_post_type( 'give_payment', $payment_args ); |
|
126 | + register_post_type('give_payment', $payment_args); |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
130 | +add_action('init', 'give_setup_post_types', 1); |
|
131 | 131 | |
132 | 132 | |
133 | 133 | /** |
@@ -140,32 +140,32 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function give_setup_taxonomies() { |
142 | 142 | |
143 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
143 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
144 | 144 | |
145 | 145 | /** Categories */ |
146 | 146 | $category_labels = array( |
147 | 147 | /* translators: %s: form singular label */ |
148 | - 'name' => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ), |
|
149 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
150 | - 'search_items' => esc_html__( 'Search Categories', 'give' ), |
|
151 | - 'all_items' => esc_html__( 'All Categories', 'give' ), |
|
152 | - 'parent_item' => esc_html__( 'Parent Category', 'give' ), |
|
153 | - 'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ), |
|
154 | - 'edit_item' => esc_html__( 'Edit Category', 'give' ), |
|
155 | - 'update_item' => esc_html__( 'Update Category', 'give' ), |
|
148 | + 'name' => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()), |
|
149 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
150 | + 'search_items' => esc_html__('Search Categories', 'give'), |
|
151 | + 'all_items' => esc_html__('All Categories', 'give'), |
|
152 | + 'parent_item' => esc_html__('Parent Category', 'give'), |
|
153 | + 'parent_item_colon' => esc_html__('Parent Category:', 'give'), |
|
154 | + 'edit_item' => esc_html__('Edit Category', 'give'), |
|
155 | + 'update_item' => esc_html__('Update Category', 'give'), |
|
156 | 156 | /* translators: %s: form singular label */ |
157 | - 'add_new_item' => sprintf( esc_html__( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ), |
|
158 | - 'new_item_name' => esc_html__( 'New Category Name', 'give' ), |
|
159 | - 'menu_name' => esc_html__( 'Categories', 'give' ), |
|
157 | + 'add_new_item' => sprintf(esc_html__('Add New %s Category', 'give'), give_get_forms_label_singular()), |
|
158 | + 'new_item_name' => esc_html__('New Category Name', 'give'), |
|
159 | + 'menu_name' => esc_html__('Categories', 'give'), |
|
160 | 160 | ); |
161 | 161 | |
162 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
162 | + $category_args = apply_filters('give_forms_category_args', array( |
|
163 | 163 | 'hierarchical' => true, |
164 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
164 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
165 | 165 | 'show_ui' => true, |
166 | 166 | 'query_var' => 'give_forms_category', |
167 | 167 | 'rewrite' => array( |
168 | - 'slug' => $slug . '/category', |
|
168 | + 'slug' => $slug.'/category', |
|
169 | 169 | 'with_front' => false, |
170 | 170 | 'hierarchical' => true |
171 | 171 | ), |
@@ -179,36 +179,36 @@ discard block |
||
179 | 179 | ); |
180 | 180 | |
181 | 181 | //Does the user want categories? |
182 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
183 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
184 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
182 | + if (give_get_option('enable_categories') == 'on') { |
|
183 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
184 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
188 | 188 | /** Tags */ |
189 | 189 | $tag_labels = array( |
190 | 190 | /* translators: %s: form singular label */ |
191 | - 'name' => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ), |
|
192 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
193 | - 'search_items' => esc_html__( 'Search Tags', 'give' ), |
|
194 | - 'all_items' => esc_html__( 'All Tags', 'give' ), |
|
195 | - 'parent_item' => esc_html__( 'Parent Tag', 'give' ), |
|
196 | - 'parent_item_colon' => esc_html__( 'Parent Tag:', 'give' ), |
|
197 | - 'edit_item' => esc_html__( 'Edit Tag', 'give' ), |
|
198 | - 'update_item' => esc_html__( 'Update Tag', 'give' ), |
|
199 | - 'add_new_item' => esc_html__( 'Add New Tag', 'give' ), |
|
200 | - 'new_item_name' => esc_html__( 'New Tag Name', 'give' ), |
|
201 | - 'menu_name' => esc_html__( 'Tags', 'give' ), |
|
191 | + 'name' => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()), |
|
192 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
193 | + 'search_items' => esc_html__('Search Tags', 'give'), |
|
194 | + 'all_items' => esc_html__('All Tags', 'give'), |
|
195 | + 'parent_item' => esc_html__('Parent Tag', 'give'), |
|
196 | + 'parent_item_colon' => esc_html__('Parent Tag:', 'give'), |
|
197 | + 'edit_item' => esc_html__('Edit Tag', 'give'), |
|
198 | + 'update_item' => esc_html__('Update Tag', 'give'), |
|
199 | + 'add_new_item' => esc_html__('Add New Tag', 'give'), |
|
200 | + 'new_item_name' => esc_html__('New Tag Name', 'give'), |
|
201 | + 'menu_name' => esc_html__('Tags', 'give'), |
|
202 | 202 | /* translators: %s: form singular label */ |
203 | - 'choose_from_most_used' => sprintf( esc_html__( 'Choose from most used %s tags.', 'give' ), give_get_forms_label_singular() ), |
|
203 | + 'choose_from_most_used' => sprintf(esc_html__('Choose from most used %s tags.', 'give'), give_get_forms_label_singular()), |
|
204 | 204 | ); |
205 | 205 | |
206 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
206 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
207 | 207 | 'hierarchical' => false, |
208 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
208 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
209 | 209 | 'show_ui' => true, |
210 | 210 | 'query_var' => 'give_forms_tag', |
211 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
211 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
212 | 212 | 'capabilities' => array( |
213 | 213 | 'manage_terms' => 'manage_give_form_terms', |
214 | 214 | 'edit_terms' => 'edit_give_form_terms', |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | ) |
219 | 219 | ); |
220 | 220 | |
221 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
222 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
223 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
221 | + if (give_get_option('enable_tags') == 'on') { |
|
222 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
223 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
229 | +add_action('init', 'give_setup_taxonomies', 0); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function give_get_default_form_labels() { |
239 | 239 | $defaults = array( |
240 | - 'singular' => esc_html__( 'Form', 'give' ), |
|
241 | - 'plural' => esc_html__( 'Forms', 'give' ) |
|
240 | + 'singular' => esc_html__('Form', 'give'), |
|
241 | + 'plural' => esc_html__('Forms', 'give') |
|
242 | 242 | ); |
243 | 243 | |
244 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
244 | + return apply_filters('give_default_form_name', $defaults); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string $defaults['singular'] Singular label |
255 | 255 | */ |
256 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
256 | +function give_get_forms_label_singular($lowercase = false) { |
|
257 | 257 | $defaults = give_get_default_form_labels(); |
258 | 258 | |
259 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
259 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @since 1.0 |
266 | 266 | * @return string $defaults['plural'] Plural label |
267 | 267 | */ |
268 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
268 | +function give_get_forms_label_plural($lowercase = false) { |
|
269 | 269 | $defaults = give_get_default_form_labels(); |
270 | 270 | |
271 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
271 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return string $title New placeholder text |
282 | 282 | */ |
283 | -function give_change_default_title( $title ) { |
|
283 | +function give_change_default_title($title) { |
|
284 | 284 | // If a frontend plugin uses this filter (check extensions before changing this function) |
285 | - if ( ! is_admin() ) { |
|
285 | + if ( ! is_admin()) { |
|
286 | 286 | $title = sprintf( |
287 | 287 | /* translators: %s: form singular label */ |
288 | - esc_html__( 'Enter %s title here', 'give' ), |
|
288 | + esc_html__('Enter %s title here', 'give'), |
|
289 | 289 | give_get_forms_label_singular() |
290 | 290 | ); |
291 | 291 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | |
295 | 295 | $screen = get_current_screen(); |
296 | 296 | |
297 | - if ( 'give_forms' == $screen->post_type ) { |
|
297 | + if ('give_forms' == $screen->post_type) { |
|
298 | 298 | $title = sprintf( |
299 | 299 | /* translators: %s: form singular label */ |
300 | - esc_html__( 'Enter %s title here', 'give' ), |
|
300 | + esc_html__('Enter %s title here', 'give'), |
|
301 | 301 | give_get_forms_label_singular() |
302 | 302 | ); |
303 | 303 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | return $title; |
306 | 306 | } |
307 | 307 | |
308 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
308 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
309 | 309 | |
310 | 310 | /** |
311 | 311 | * Registers Custom Post Statuses which are used by the Payments |
@@ -315,50 +315,50 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function give_register_post_type_statuses() { |
317 | 317 | // Payment Statuses |
318 | - register_post_status( 'refunded', array( |
|
319 | - 'label' => _x( 'Refunded', 'payment status', 'give' ), |
|
318 | + register_post_status('refunded', array( |
|
319 | + 'label' => _x('Refunded', 'payment status', 'give'), |
|
320 | 320 | 'public' => true, |
321 | 321 | 'exclude_from_search' => false, |
322 | 322 | 'show_in_admin_all_list' => true, |
323 | 323 | 'show_in_admin_status_list' => true, |
324 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ) |
|
325 | - ) ); |
|
326 | - register_post_status( 'failed', array( |
|
327 | - 'label' => _x( 'Failed', 'payment status', 'give' ), |
|
324 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give') |
|
325 | + )); |
|
326 | + register_post_status('failed', array( |
|
327 | + 'label' => _x('Failed', 'payment status', 'give'), |
|
328 | 328 | 'public' => true, |
329 | 329 | 'exclude_from_search' => false, |
330 | 330 | 'show_in_admin_all_list' => true, |
331 | 331 | 'show_in_admin_status_list' => true, |
332 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ) |
|
333 | - ) ); |
|
334 | - register_post_status( 'revoked', array( |
|
335 | - 'label' => _x( 'Revoked', 'payment status', 'give' ), |
|
332 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give') |
|
333 | + )); |
|
334 | + register_post_status('revoked', array( |
|
335 | + 'label' => _x('Revoked', 'payment status', 'give'), |
|
336 | 336 | 'public' => true, |
337 | 337 | 'exclude_from_search' => false, |
338 | 338 | 'show_in_admin_all_list' => true, |
339 | 339 | 'show_in_admin_status_list' => true, |
340 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ) |
|
341 | - ) ); |
|
342 | - register_post_status( 'cancelled', array( |
|
343 | - 'label' => _x( 'Cancelled', 'payment status', 'give' ), |
|
340 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give') |
|
341 | + )); |
|
342 | + register_post_status('cancelled', array( |
|
343 | + 'label' => _x('Cancelled', 'payment status', 'give'), |
|
344 | 344 | 'public' => true, |
345 | 345 | 'exclude_from_search' => false, |
346 | 346 | 'show_in_admin_all_list' => true, |
347 | 347 | 'show_in_admin_status_list' => true, |
348 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ) |
|
349 | - ) ); |
|
350 | - register_post_status( 'abandoned', array( |
|
351 | - 'label' => _x( 'Abandoned', 'payment status', 'give' ), |
|
348 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give') |
|
349 | + )); |
|
350 | + register_post_status('abandoned', array( |
|
351 | + 'label' => _x('Abandoned', 'payment status', 'give'), |
|
352 | 352 | 'public' => true, |
353 | 353 | 'exclude_from_search' => false, |
354 | 354 | 'show_in_admin_all_list' => true, |
355 | 355 | 'show_in_admin_status_list' => true, |
356 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ) |
|
357 | - ) ); |
|
356 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give') |
|
357 | + )); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
361 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
361 | +add_action('init', 'give_register_post_type_statuses'); |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Updated Messages |
@@ -371,43 +371,43 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return array $messages New post updated messages |
373 | 373 | */ |
374 | -function give_updated_messages( $messages ) { |
|
374 | +function give_updated_messages($messages) { |
|
375 | 375 | global $post, $post_ID; |
376 | 376 | |
377 | - $url1 = '<a href="' . get_permalink( $post_ID ) . '">'; |
|
377 | + $url1 = '<a href="'.get_permalink($post_ID).'">'; |
|
378 | 378 | $url2 = give_get_forms_label_singular(); |
379 | 379 | $url3 = '</a>'; |
380 | 380 | |
381 | 381 | $messages['give_forms'] = array( |
382 | - 1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
383 | - 4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
384 | - 6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
385 | - 7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
386 | - 8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ) |
|
382 | + 1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
383 | + 4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
384 | + 6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
385 | + 7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
386 | + 8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3) |
|
387 | 387 | ); |
388 | 388 | |
389 | 389 | return $messages; |
390 | 390 | } |
391 | 391 | |
392 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
392 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
393 | 393 | |
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Setup Post Type Images |
397 | 397 | */ |
398 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
398 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Ensure post thumbnail support is turned on |
402 | 402 | */ |
403 | 403 | function give_add_thumbnail_support() { |
404 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
404 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
405 | 405 | return; |
406 | 406 | } |
407 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
408 | - add_theme_support( 'post-thumbnails' ); |
|
407 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
408 | + add_theme_support('post-thumbnails'); |
|
409 | 409 | } |
410 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
410 | + add_post_type_support('give_forms', 'thumbnail'); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -419,19 +419,19 @@ discard block |
||
419 | 419 | function give_widgets_init() { |
420 | 420 | |
421 | 421 | //Single Give Forms (disabled if single turned off in settings) |
422 | - if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) { |
|
422 | + if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') { |
|
423 | 423 | |
424 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
425 | - 'name' => esc_html__( 'Give Single Form Sidebar', 'give' ), |
|
424 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
425 | + 'name' => esc_html__('Give Single Form Sidebar', 'give'), |
|
426 | 426 | 'id' => 'give-forms-sidebar', |
427 | - 'description' => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
427 | + 'description' => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
428 | 428 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
429 | 429 | 'after_widget' => '</div>', |
430 | 430 | 'before_title' => '<h3 class="widgettitle widget-title">', |
431 | 431 | 'after_title' => '</h3>', |
432 | - ) ) ); |
|
432 | + ))); |
|
433 | 433 | |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
437 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -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 | |
@@ -26,94 +26,94 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_load_scripts() { |
28 | 28 | |
29 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
30 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
31 | - $scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false; |
|
29 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
30 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
31 | + $scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false; |
|
32 | 32 | |
33 | 33 | // Use minified libraries if SCRIPT_DEBUG is turned off |
34 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
34 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
35 | 35 | |
36 | 36 | //Localize / PHP to AJAX vars |
37 | - $localize_give_checkout = apply_filters( 'give_global_script_vars', array( |
|
37 | + $localize_give_checkout = apply_filters('give_global_script_vars', array( |
|
38 | 38 | 'ajaxurl' => give_get_ajax_url(), |
39 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
40 | - 'currency_sign' => give_currency_filter( '' ), |
|
39 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
40 | + 'currency_sign' => give_currency_filter(''), |
|
41 | 41 | 'currency_pos' => give_get_currency_position(), |
42 | 42 | 'thousands_separator' => give_get_price_thousand_separator(), |
43 | 43 | 'decimal_separator' => give_get_price_decimal_separator(), |
44 | - 'no_gateway' => esc_html__( 'Please select a payment method.', 'give' ), |
|
45 | - 'bad_minimum' => esc_html__( 'The minimum donation amount for this form is', 'give' ), |
|
46 | - 'general_loading' => esc_html__( 'Loading...', 'give' ), |
|
47 | - 'purchase_loading' => esc_html__( 'Please Wait...', 'give' ), |
|
44 | + 'no_gateway' => esc_html__('Please select a payment method.', 'give'), |
|
45 | + 'bad_minimum' => esc_html__('The minimum donation amount for this form is', 'give'), |
|
46 | + 'general_loading' => esc_html__('Loading...', 'give'), |
|
47 | + 'purchase_loading' => esc_html__('Please Wait...', 'give'), |
|
48 | 48 | 'number_decimals' => give_get_price_decimals(), |
49 | 49 | 'give_version' => GIVE_VERSION |
50 | - ) ); |
|
51 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
50 | + )); |
|
51 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
52 | 52 | 'ajaxurl' => give_get_ajax_url(), |
53 | - 'loading' => esc_html__( 'Loading', 'give' ), |
|
53 | + 'loading' => esc_html__('Loading', 'give'), |
|
54 | 54 | // General loading message |
55 | - 'select_option' => esc_html__( 'Please select an option', 'give' ), |
|
55 | + 'select_option' => esc_html__('Please select an option', 'give'), |
|
56 | 56 | // Variable pricing error with multi-purchase option enabled |
57 | - 'default_gateway' => give_get_default_gateway( null ), |
|
58 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
57 | + 'default_gateway' => give_get_default_gateway(null), |
|
58 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
59 | 59 | 'number_decimals' => give_get_price_decimals() |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | //DEBUG is On |
63 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
63 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
64 | 64 | |
65 | - if ( give_is_cc_verify_enabled() ) { |
|
66 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
67 | - wp_enqueue_script( 'give-cc-validator' ); |
|
65 | + if (give_is_cc_verify_enabled()) { |
|
66 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
67 | + wp_enqueue_script('give-cc-validator'); |
|
68 | 68 | } |
69 | 69 | |
70 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
71 | - wp_enqueue_script( 'give-float-labels' ); |
|
70 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
71 | + wp_enqueue_script('give-float-labels'); |
|
72 | 72 | |
73 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
74 | - wp_enqueue_script( 'give-blockui' ); |
|
73 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
74 | + wp_enqueue_script('give-blockui'); |
|
75 | 75 | |
76 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
77 | - wp_enqueue_script( 'give-qtip' ); |
|
76 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
77 | + wp_enqueue_script('give-qtip'); |
|
78 | 78 | |
79 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
80 | - wp_enqueue_script( 'give-accounting' ); |
|
79 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
80 | + wp_enqueue_script('give-accounting'); |
|
81 | 81 | |
82 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
83 | - wp_enqueue_script( 'give-magnific' ); |
|
82 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
83 | + wp_enqueue_script('give-magnific'); |
|
84 | 84 | |
85 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
86 | - wp_enqueue_script( 'give-checkout-global' ); |
|
85 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
86 | + wp_enqueue_script('give-checkout-global'); |
|
87 | 87 | |
88 | 88 | //General scripts |
89 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
90 | - wp_enqueue_script( 'give-scripts' ); |
|
89 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
90 | + wp_enqueue_script('give-scripts'); |
|
91 | 91 | |
92 | 92 | // Load AJAX scripts, if enabled |
93 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-ajax' ); |
|
93 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-ajax'); |
|
95 | 95 | |
96 | 96 | //Localize / Pass AJAX vars from PHP |
97 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout ); |
|
98 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
97 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout); |
|
98 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
99 | 99 | |
100 | 100 | |
101 | 101 | } else { |
102 | 102 | |
103 | 103 | //DEBUG is OFF (one JS file to rule them all!) |
104 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
105 | - wp_enqueue_script( 'give' ); |
|
104 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
105 | + wp_enqueue_script('give'); |
|
106 | 106 | |
107 | 107 | //Localize / Pass AJAX vars from PHP |
108 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout ); |
|
109 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
108 | + wp_localize_script('give', 'give_global_vars', $localize_give_checkout); |
|
109 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
116 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Register styles. |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function give_register_styles() { |
127 | 127 | |
128 | - if ( give_get_option( 'disable_css', false ) ) { |
|
128 | + if (give_get_option('disable_css', false)) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
133 | - wp_enqueue_style( 'give-styles' ); |
|
132 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
133 | + wp_enqueue_style('give-styles'); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
137 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -146,39 +146,39 @@ discard block |
||
146 | 146 | function give_get_stylesheet_uri() { |
147 | 147 | |
148 | 148 | // Use minified libraries if SCRIPT_DEBUG is turned off |
149 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
149 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
150 | 150 | |
151 | - $file = 'give' . $suffix . '.css'; |
|
151 | + $file = 'give'.$suffix.'.css'; |
|
152 | 152 | $templates_dir = give_get_theme_template_dir_name(); |
153 | 153 | |
154 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
155 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css'; |
|
156 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
157 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css'; |
|
158 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
154 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
155 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css'; |
|
156 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
157 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css'; |
|
158 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
159 | 159 | |
160 | 160 | $uri = false; |
161 | 161 | |
162 | 162 | // Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory |
163 | 163 | // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
164 | 164 | // This allows users to copy just give.css to their theme |
165 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
166 | - if ( ! empty( $nonmin ) ) { |
|
167 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css'; |
|
165 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
166 | + if ( ! empty($nonmin)) { |
|
167 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css'; |
|
168 | 168 | } else { |
169 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
169 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
170 | 170 | } |
171 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
172 | - if ( ! empty( $nonmin ) ) { |
|
173 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css'; |
|
171 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
172 | + if ( ! empty($nonmin)) { |
|
173 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css'; |
|
174 | 174 | } else { |
175 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
175 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
176 | 176 | } |
177 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
178 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
177 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
178 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
179 | 179 | } |
180 | 180 | |
181 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
181 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
@@ -196,65 +196,65 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return void |
198 | 198 | */ |
199 | -function give_load_admin_scripts( $hook ) { |
|
199 | +function give_load_admin_scripts($hook) { |
|
200 | 200 | |
201 | 201 | global $wp_version, $post, $post_type, $give_options; |
202 | 202 | |
203 | 203 | //Directories of assets |
204 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
205 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
206 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
204 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
205 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
206 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
207 | 207 | |
208 | 208 | // Use minified libraries if SCRIPT_DEBUG is turned off |
209 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
209 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
210 | 210 | |
211 | 211 | //Global Admin: |
212 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
213 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
212 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
213 | + wp_enqueue_style('give-admin-bar-notification'); |
|
214 | 214 | |
215 | 215 | //Give Admin Only: |
216 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
216 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | //CSS |
221 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
222 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
223 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION ); |
|
224 | - wp_enqueue_style( 'give-admin' ); |
|
225 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
226 | - wp_enqueue_style( 'jquery-chosen' ); |
|
227 | - wp_enqueue_style( 'thickbox' ); |
|
221 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
222 | + wp_enqueue_style('jquery-ui-css'); |
|
223 | + wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION); |
|
224 | + wp_enqueue_style('give-admin'); |
|
225 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
226 | + wp_enqueue_style('jquery-chosen'); |
|
227 | + wp_enqueue_style('thickbox'); |
|
228 | 228 | |
229 | 229 | //JS |
230 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
231 | - wp_enqueue_script( 'jquery-chosen' ); |
|
230 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
231 | + wp_enqueue_script('jquery-chosen'); |
|
232 | 232 | |
233 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
234 | - wp_enqueue_script( 'give-accounting' ); |
|
233 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
234 | + wp_enqueue_script('give-accounting'); |
|
235 | 235 | |
236 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
237 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
236 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
237 | + wp_enqueue_script('give-admin-scripts'); |
|
238 | 238 | |
239 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
240 | - wp_enqueue_script( 'jquery-flot' ); |
|
239 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
240 | + wp_enqueue_script('jquery-flot'); |
|
241 | 241 | |
242 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
243 | - wp_enqueue_script( 'give-qtip' ); |
|
242 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
243 | + wp_enqueue_script('give-qtip'); |
|
244 | 244 | |
245 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
246 | - wp_enqueue_script( 'thickbox' ); |
|
245 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
246 | + wp_enqueue_script('thickbox'); |
|
247 | 247 | |
248 | 248 | // Forms CPT Script. |
249 | - if ( $post_type === 'give_forms' ) { |
|
250 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
251 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
249 | + if ($post_type === 'give_forms') { |
|
250 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
251 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | //Settings Scripts |
255 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
256 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
257 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
255 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
256 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
257 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Price Separators. |
@@ -262,50 +262,50 @@ discard block |
||
262 | 262 | $decimal_separator = give_get_price_decimal_separator(); |
263 | 263 | |
264 | 264 | //Localize strings & variables for JS |
265 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
266 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
265 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
266 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
267 | 267 | 'give_version' => GIVE_VERSION, |
268 | 268 | 'thousands_separator' => $thousand_separator, |
269 | 269 | 'decimal_separator' => $decimal_separator, |
270 | - 'quick_edit_warning' => esc_html__( 'Sorry, not available for variable priced forms.', 'give' ), |
|
271 | - 'delete_payment' => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ), |
|
272 | - 'delete_payment_note' => esc_html__( 'Are you sure you wish to delete this note?', 'give' ), |
|
273 | - 'revoke_api_key' => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
274 | - 'regenerate_api_key' => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
275 | - 'resend_receipt' => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
276 | - 'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ), |
|
270 | + 'quick_edit_warning' => esc_html__('Sorry, not available for variable priced forms.', 'give'), |
|
271 | + 'delete_payment' => esc_html__('Are you sure you wish to delete this payment?', 'give'), |
|
272 | + 'delete_payment_note' => esc_html__('Are you sure you wish to delete this note?', 'give'), |
|
273 | + 'revoke_api_key' => esc_html__('Are you sure you wish to revoke this API key?', 'give'), |
|
274 | + 'regenerate_api_key' => esc_html__('Are you sure you wish to regenerate this API key?', 'give'), |
|
275 | + 'resend_receipt' => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'), |
|
276 | + 'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'), |
|
277 | 277 | /* translators: %s: form singular label */ |
278 | - 'delete_payment_download' => sprintf( esc_html__( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ), |
|
279 | - 'one_price_min' => esc_html__( 'You must have at least one price.', 'give' ), |
|
280 | - 'one_file_min' => esc_html__( 'You must have at least one file.', 'give' ), |
|
281 | - 'one_field_min' => esc_html__( 'You must have at least one field.', 'give' ), |
|
278 | + 'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), |
|
279 | + 'one_price_min' => esc_html__('You must have at least one price.', 'give'), |
|
280 | + 'one_file_min' => esc_html__('You must have at least one file.', 'give'), |
|
281 | + 'one_field_min' => esc_html__('You must have at least one field.', 'give'), |
|
282 | 282 | /* translators: %s: form singular label */ |
283 | - 'one_option' => sprintf( esc_html__( 'Choose a %s', 'give' ), give_get_forms_label_singular() ), |
|
283 | + 'one_option' => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()), |
|
284 | 284 | /* translators: %s: form plural label */ |
285 | - 'one_or_more_option' => sprintf( esc_html__( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ), |
|
286 | - 'numeric_item_price' => esc_html__( 'Item price must be numeric.', 'give' ), |
|
287 | - 'numeric_quantity' => esc_html__( 'Quantity must be numeric.', 'give' ), |
|
288 | - 'currency_sign' => give_currency_filter( '' ), |
|
289 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
290 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
291 | - 'new_media_ui' => apply_filters( 'give_use_35_media_ui', 1 ), |
|
292 | - 'remove_text' => esc_html__( 'Remove', 'give' ), |
|
285 | + 'one_or_more_option' => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()), |
|
286 | + 'numeric_item_price' => esc_html__('Item price must be numeric.', 'give'), |
|
287 | + 'numeric_quantity' => esc_html__('Quantity must be numeric.', 'give'), |
|
288 | + 'currency_sign' => give_currency_filter(''), |
|
289 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
290 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
291 | + 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), |
|
292 | + 'remove_text' => esc_html__('Remove', 'give'), |
|
293 | 293 | /* translators: %s: form plural label */ |
294 | - 'type_to_search' => sprintf( esc_html__( 'Type to search %s', 'give' ), give_get_forms_label_plural() ), |
|
295 | - 'batch_export_no_class' => esc_html__( 'You must choose a method.', 'give' ), |
|
296 | - 'batch_export_no_reqs' => esc_html__( 'Required fields not completed.', 'give' ), |
|
297 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
298 | - 'price_format_guide' => sprintf( esc_html__( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ) |
|
299 | - ) ); |
|
300 | - |
|
301 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) { |
|
294 | + 'type_to_search' => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()), |
|
295 | + 'batch_export_no_class' => esc_html__('You must choose a method.', 'give'), |
|
296 | + 'batch_export_no_reqs' => esc_html__('Required fields not completed.', 'give'), |
|
297 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
298 | + 'price_format_guide' => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator) |
|
299 | + )); |
|
300 | + |
|
301 | + if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { |
|
302 | 302 | //call for new media manager |
303 | 303 | wp_enqueue_media(); |
304 | 304 | } |
305 | 305 | |
306 | 306 | } |
307 | 307 | |
308 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
308 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
309 | 309 | |
310 | 310 | /** |
311 | 311 | * Admin Give Icon |
@@ -322,14 +322,14 @@ discard block |
||
322 | 322 | ?> |
323 | 323 | <style type="text/css" media="screen"> |
324 | 324 | |
325 | - <?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?> |
|
325 | + <?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?> |
|
326 | 326 | @font-face { |
327 | 327 | font-family: 'give-icomoon'; |
328 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
329 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
330 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
331 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
332 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
328 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
329 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
330 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
331 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
332 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
333 | 333 | font-weight: normal; |
334 | 334 | font-style: normal; |
335 | 335 | } |
@@ -348,4 +348,4 @@ discard block |
||
348 | 348 | <?php |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
351 | +add_action('admin_head', 'give_admin_icon'); |
@@ -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 | |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function get_predefined_dates() { |
87 | 87 | $predefined = array( |
88 | - 'today' => esc_html__( 'Today', 'give' ), |
|
89 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
90 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
91 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
92 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
93 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
94 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
95 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
96 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
97 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
88 | + 'today' => esc_html__('Today', 'give'), |
|
89 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
90 | + 'this_week' => esc_html__('This Week', 'give'), |
|
91 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
92 | + 'this_month' => esc_html__('This Month', 'give'), |
|
93 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
94 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
95 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
96 | + 'this_year' => esc_html__('This Year', 'give'), |
|
97 | + 'last_year' => esc_html__('Last Year', 'give') |
|
98 | 98 | ); |
99 | 99 | |
100 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
100 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
116 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
117 | 117 | |
118 | - if ( empty( $_start_date ) ) { |
|
118 | + if (empty($_start_date)) { |
|
119 | 119 | $_start_date = 'this_month'; |
120 | 120 | } |
121 | 121 | |
122 | - if ( empty( $_end_date ) ) { |
|
122 | + if (empty($_end_date)) { |
|
123 | 123 | $_end_date = $_start_date; |
124 | 124 | } |
125 | 125 | |
126 | - $this->start_date = $this->convert_date( $_start_date ); |
|
127 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
126 | + $this->start_date = $this->convert_date($_start_date); |
|
127 | + $this->end_date = $this->convert_date($_end_date, true); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -140,26 +140,26 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
142 | 142 | */ |
143 | - public function convert_date( $date, $end_date = false ) { |
|
143 | + public function convert_date($date, $end_date = false) { |
|
144 | 144 | |
145 | 145 | $this->timestamp = false; |
146 | 146 | $second = $end_date ? 59 : 0; |
147 | 147 | $minute = $end_date ? 59 : 0; |
148 | 148 | $hour = $end_date ? 23 : 0; |
149 | 149 | $day = 1; |
150 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
151 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
150 | + $month = date('n', current_time('timestamp')); |
|
151 | + $year = date('Y', current_time('timestamp')); |
|
152 | 152 | |
153 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
153 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
154 | 154 | |
155 | 155 | // This is a predefined date rate, such as last_week |
156 | - switch ( $date ) { |
|
156 | + switch ($date) { |
|
157 | 157 | |
158 | 158 | case 'this_month' : |
159 | 159 | |
160 | - if ( $end_date ) { |
|
160 | + if ($end_date) { |
|
161 | 161 | |
162 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
162 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
163 | 163 | $hour = 23; |
164 | 164 | $minute = 59; |
165 | 165 | $second = 59; |
@@ -169,28 +169,28 @@ discard block |
||
169 | 169 | |
170 | 170 | case 'last_month' : |
171 | 171 | |
172 | - if ( $month == 1 ) { |
|
172 | + if ($month == 1) { |
|
173 | 173 | |
174 | 174 | $month = 12; |
175 | - $year --; |
|
175 | + $year--; |
|
176 | 176 | |
177 | 177 | } else { |
178 | 178 | |
179 | - $month --; |
|
179 | + $month--; |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( $end_date ) { |
|
184 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
183 | + if ($end_date) { |
|
184 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'today' : |
190 | 190 | |
191 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
191 | + $day = date('d', current_time('timestamp')); |
|
192 | 192 | |
193 | - if ( $end_date ) { |
|
193 | + if ($end_date) { |
|
194 | 194 | $hour = 23; |
195 | 195 | $minute = 59; |
196 | 196 | $second = 59; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | |
201 | 201 | case 'yesterday' : |
202 | 202 | |
203 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
203 | + $day = date('d', current_time('timestamp')) - 1; |
|
204 | 204 | |
205 | 205 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
206 | - if ( $day < 1 ) { |
|
206 | + if ($day < 1) { |
|
207 | 207 | |
208 | 208 | // If current month is 1 |
209 | - if ( 1 == $month ) { |
|
209 | + if (1 == $month) { |
|
210 | 210 | |
211 | 211 | $year -= 1; // Today is January 1, so skip back to last day of December |
212 | 212 | $month = 12; |
213 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
213 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
214 | 214 | |
215 | 215 | } else { |
216 | 216 | |
217 | 217 | // Go back one month and get the last day of the month |
218 | 218 | $month -= 1; |
219 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
219 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | case 'this_week' : |
227 | 227 | |
228 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
229 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
228 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
229 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
230 | 230 | |
231 | - if ( $today < $days_to_week_start ) { |
|
231 | + if ($today < $days_to_week_start) { |
|
232 | 232 | |
233 | - if ( $month > 1 ) { |
|
233 | + if ($month > 1) { |
|
234 | 234 | $month -= 1; |
235 | 235 | } else { |
236 | 236 | $month = 12; |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if ( ! $end_date ) { |
|
241 | + if ( ! $end_date) { |
|
242 | 242 | |
243 | 243 | // Getting the start day |
244 | 244 | |
245 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
246 | - $day += get_option( 'start_of_week' ); |
|
245 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
246 | + $day += get_option('start_of_week'); |
|
247 | 247 | |
248 | 248 | } else { |
249 | 249 | |
250 | 250 | // Getting the end day |
251 | 251 | |
252 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
253 | - $day += get_option( 'start_of_week' ) + 6; |
|
252 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
253 | + $day += get_option('start_of_week') + 6; |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | |
259 | 259 | case 'last_week' : |
260 | 260 | |
261 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
262 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
261 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
262 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
263 | 263 | |
264 | - if ( $today < $days_to_week_start ) { |
|
264 | + if ($today < $days_to_week_start) { |
|
265 | 265 | |
266 | - if ( $month > 1 ) { |
|
266 | + if ($month > 1) { |
|
267 | 267 | $month -= 1; |
268 | 268 | } else { |
269 | 269 | $month = 12; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - if ( ! $end_date ) { |
|
274 | + if ( ! $end_date) { |
|
275 | 275 | |
276 | 276 | // Getting the start day |
277 | 277 | |
278 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
279 | - $day += get_option( 'start_of_week' ); |
|
278 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
279 | + $day += get_option('start_of_week'); |
|
280 | 280 | |
281 | 281 | } else { |
282 | 282 | |
283 | 283 | // Getting the end day |
284 | 284 | |
285 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
286 | - $day += get_option( 'start_of_week' ) + 6; |
|
285 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
286 | + $day += get_option('start_of_week') + 6; |
|
287 | 287 | |
288 | 288 | } |
289 | 289 | |
@@ -291,39 +291,39 @@ discard block |
||
291 | 291 | |
292 | 292 | case 'this_quarter' : |
293 | 293 | |
294 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
294 | + $month_now = date('n', current_time('timestamp')); |
|
295 | 295 | |
296 | - if ( $month_now <= 3 ) { |
|
296 | + if ($month_now <= 3) { |
|
297 | 297 | |
298 | - if ( ! $end_date ) { |
|
298 | + if ( ! $end_date) { |
|
299 | 299 | $month = 1; |
300 | 300 | } else { |
301 | 301 | $month = 3; |
302 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
302 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
303 | 303 | $hour = 23; |
304 | 304 | $minute = 59; |
305 | 305 | $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - } else if ( $month_now <= 6 ) { |
|
308 | + } else if ($month_now <= 6) { |
|
309 | 309 | |
310 | - if ( ! $end_date ) { |
|
310 | + if ( ! $end_date) { |
|
311 | 311 | $month = 4; |
312 | 312 | } else { |
313 | 313 | $month = 6; |
314 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
314 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
315 | 315 | $hour = 23; |
316 | 316 | $minute = 59; |
317 | 317 | $second = 59; |
318 | 318 | } |
319 | 319 | |
320 | - } else if ( $month_now <= 9 ) { |
|
320 | + } else if ($month_now <= 9) { |
|
321 | 321 | |
322 | - if ( ! $end_date ) { |
|
322 | + if ( ! $end_date) { |
|
323 | 323 | $month = 7; |
324 | 324 | } else { |
325 | 325 | $month = 9; |
326 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
326 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
327 | 327 | $hour = 23; |
328 | 328 | $minute = 59; |
329 | 329 | $second = 59; |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | |
332 | 332 | } else { |
333 | 333 | |
334 | - if ( ! $end_date ) { |
|
334 | + if ( ! $end_date) { |
|
335 | 335 | $month = 10; |
336 | 336 | } else { |
337 | 337 | $month = 12; |
338 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
338 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
339 | 339 | $hour = 23; |
340 | 340 | $minute = 59; |
341 | 341 | $second = 59; |
@@ -347,40 +347,40 @@ discard block |
||
347 | 347 | |
348 | 348 | case 'last_quarter' : |
349 | 349 | |
350 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
350 | + $month_now = date('n', current_time('timestamp')); |
|
351 | 351 | |
352 | - if ( $month_now <= 3 ) { |
|
352 | + if ($month_now <= 3) { |
|
353 | 353 | |
354 | - if ( ! $end_date ) { |
|
354 | + if ( ! $end_date) { |
|
355 | 355 | $month = 10; |
356 | 356 | } else { |
357 | 357 | $year -= 1; |
358 | 358 | $month = 12; |
359 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
359 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
360 | 360 | $hour = 23; |
361 | 361 | $minute = 59; |
362 | 362 | $second = 59; |
363 | 363 | } |
364 | 364 | |
365 | - } else if ( $month_now <= 6 ) { |
|
365 | + } else if ($month_now <= 6) { |
|
366 | 366 | |
367 | - if ( ! $end_date ) { |
|
367 | + if ( ! $end_date) { |
|
368 | 368 | $month = 1; |
369 | 369 | } else { |
370 | 370 | $month = 3; |
371 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
371 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
372 | 372 | $hour = 23; |
373 | 373 | $minute = 59; |
374 | 374 | $second = 59; |
375 | 375 | } |
376 | 376 | |
377 | - } else if ( $month_now <= 9 ) { |
|
377 | + } else if ($month_now <= 9) { |
|
378 | 378 | |
379 | - if ( ! $end_date ) { |
|
379 | + if ( ! $end_date) { |
|
380 | 380 | $month = 4; |
381 | 381 | } else { |
382 | 382 | $month = 6; |
383 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
383 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
384 | 384 | $hour = 23; |
385 | 385 | $minute = 59; |
386 | 386 | $second = 59; |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | |
389 | 389 | } else { |
390 | 390 | |
391 | - if ( ! $end_date ) { |
|
391 | + if ( ! $end_date) { |
|
392 | 392 | $month = 7; |
393 | 393 | } else { |
394 | 394 | $month = 9; |
395 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
395 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
396 | 396 | $hour = 23; |
397 | 397 | $minute = 59; |
398 | 398 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | |
405 | 405 | case 'this_year' : |
406 | 406 | |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,11 +419,11 @@ discard block |
||
419 | 419 | case 'last_year' : |
420 | 420 | |
421 | 421 | $year -= 1; |
422 | - if ( ! $end_date ) { |
|
422 | + if ( ! $end_date) { |
|
423 | 423 | $month = 1; |
424 | 424 | } else { |
425 | 425 | $month = 12; |
426 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
426 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
427 | 427 | $hour = 23; |
428 | 428 | $minute = 59; |
429 | 429 | $second = 59; |
@@ -434,30 +434,30 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | |
437 | - } else if ( is_numeric( $date ) ) { |
|
437 | + } else if (is_numeric($date)) { |
|
438 | 438 | |
439 | 439 | // return $date unchanged since it is a timestamp |
440 | 440 | $this->timestamp = true; |
441 | 441 | |
442 | - } else if ( false !== strtotime( $date ) ) { |
|
442 | + } else if (false !== strtotime($date)) { |
|
443 | 443 | |
444 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
445 | - $year = date( 'Y', $date ); |
|
446 | - $month = date( 'm', $date ); |
|
447 | - $day = date( 'd', $date ); |
|
444 | + $date = strtotime($date, current_time('timestamp')); |
|
445 | + $year = date('Y', $date); |
|
446 | + $month = date('m', $date); |
|
447 | + $day = date('d', $date); |
|
448 | 448 | |
449 | 449 | } else { |
450 | 450 | |
451 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
451 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | |
455 | - if ( false === $this->timestamp ) { |
|
455 | + if (false === $this->timestamp) { |
|
456 | 456 | // Create an exact timestamp |
457 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
457 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
458 | 458 | } |
459 | 459 | |
460 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
460 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
461 | 461 | |
462 | 462 | } |
463 | 463 | |
@@ -473,33 +473,33 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function count_where( $where = '' ) { |
|
476 | + public function count_where($where = '') { |
|
477 | 477 | // Only get payments in our date range |
478 | 478 | |
479 | 479 | $start_where = ''; |
480 | 480 | $end_where = ''; |
481 | 481 | |
482 | - if ( $this->start_date ) { |
|
482 | + if ($this->start_date) { |
|
483 | 483 | |
484 | - if ( $this->timestamp ) { |
|
484 | + if ($this->timestamp) { |
|
485 | 485 | $format = 'Y-m-d H:i:s'; |
486 | 486 | } else { |
487 | 487 | $format = 'Y-m-d 00:00:00'; |
488 | 488 | } |
489 | 489 | |
490 | - $start_date = date( $format, $this->start_date ); |
|
490 | + $start_date = date($format, $this->start_date); |
|
491 | 491 | $start_where = " AND p.post_date >= '{$start_date}'"; |
492 | 492 | } |
493 | 493 | |
494 | - if ( $this->end_date ) { |
|
494 | + if ($this->end_date) { |
|
495 | 495 | |
496 | - if ( $this->timestamp ) { |
|
496 | + if ($this->timestamp) { |
|
497 | 497 | $format = 'Y-m-d H:i:s'; |
498 | 498 | } else { |
499 | 499 | $format = 'Y-m-d 23:59:59'; |
500 | 500 | } |
501 | 501 | |
502 | - $end_date = date( $format, $this->end_date ); |
|
502 | + $end_date = date($format, $this->end_date); |
|
503 | 503 | |
504 | 504 | $end_where = " AND p.post_date <= '{$end_date}'"; |
505 | 505 | } |
@@ -521,34 +521,34 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string |
523 | 523 | */ |
524 | - public function payments_where( $where = '' ) { |
|
524 | + public function payments_where($where = '') { |
|
525 | 525 | |
526 | 526 | global $wpdb; |
527 | 527 | |
528 | 528 | $start_where = ''; |
529 | 529 | $end_where = ''; |
530 | 530 | |
531 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
531 | + if ( ! is_wp_error($this->start_date)) { |
|
532 | 532 | |
533 | - if ( $this->timestamp ) { |
|
533 | + if ($this->timestamp) { |
|
534 | 534 | $format = 'Y-m-d H:i:s'; |
535 | 535 | } else { |
536 | 536 | $format = 'Y-m-d 00:00:00'; |
537 | 537 | } |
538 | 538 | |
539 | - $start_date = date( $format, $this->start_date ); |
|
539 | + $start_date = date($format, $this->start_date); |
|
540 | 540 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
543 | + if ( ! is_wp_error($this->end_date)) { |
|
544 | 544 | |
545 | - if ( $this->timestamp ) { |
|
545 | + if ($this->timestamp) { |
|
546 | 546 | $format = 'Y-m-d 00:00:00'; |
547 | 547 | } else { |
548 | 548 | $format = 'Y-m-d 23:59:59'; |
549 | 549 | } |
550 | 550 | |
551 | - $end_date = date( $format, $this->end_date ); |
|
551 | + $end_date = date($format, $this->end_date); |
|
552 | 552 | |
553 | 553 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
554 | 554 | } |
@@ -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 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string $message Fully formatted message |
43 | 43 | */ |
44 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
45 | - return give_do_email_tags( $message, $payment_id ); |
|
44 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
45 | + return give_do_email_tags($message, $payment_id); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,38 +56,38 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string $message Fully formatted message |
58 | 58 | */ |
59 | -function give_email_preview_template_tags( $message ) { |
|
59 | +function give_email_preview_template_tags($message) { |
|
60 | 60 | |
61 | - $price = give_currency_filter( give_format_amount( 10.50 ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50)); |
|
62 | 62 | |
63 | 63 | $gateway = 'PayPal'; |
64 | 64 | |
65 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
65 | + $receipt_id = strtolower(md5(uniqid())); |
|
66 | 66 | |
67 | - $payment_id = rand( 1, 100 ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | 68 | |
69 | 69 | $receipt_link = sprintf( |
70 | 70 | '<a href="%1$s">%2$s</a>', |
71 | - esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ), |
|
72 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
71 | + esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())), |
|
72 | + esc_html__('View the receipt in your browser »', 'give') |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | $user = wp_get_current_user(); |
76 | 76 | |
77 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
78 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
79 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
80 | - $message = str_replace( '{date}', date( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message ); |
|
81 | - $message = str_replace( '{price}', $price, $message ); |
|
82 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
83 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
84 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
85 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
86 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
87 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
88 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
89 | - |
|
90 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
77 | + $message = str_replace('{name}', $user->display_name, $message); |
|
78 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
79 | + $message = str_replace('{username}', $user->user_login, $message); |
|
80 | + $message = str_replace('{date}', date(get_option('date_format'), current_time('timestamp')), $message); |
|
81 | + $message = str_replace('{price}', $price, $message); |
|
82 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
83 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
84 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
85 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
86 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
87 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
88 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
89 | + |
|
90 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | * @since 1.0 |
100 | 100 | * @return array|bool |
101 | 101 | */ |
102 | -function give_email_template_preview( $array ) { |
|
102 | +function give_email_template_preview($array) { |
|
103 | 103 | |
104 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
104 | + if ( ! current_user_can('manage_give_settings')) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | $custom_field = array( |
108 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
109 | - 'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ), |
|
108 | + 'name' => esc_html__('Preview Email', 'give'), |
|
109 | + 'desc' => esc_html__('Click the buttons to preview emails.', 'give'), |
|
110 | 110 | 'id' => 'give_email_preview_buttons', |
111 | 111 | 'type' => 'email_preview_buttons' |
112 | 112 | ); |
113 | 113 | |
114 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
114 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
118 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Output Email Template Preview Buttons. |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | function give_email_preview_buttons_callback() { |
128 | 128 | ob_start(); |
129 | 129 | ?> |
130 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e( 'Donation Receipt Preview', 'give' ); ?> "><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
131 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
130 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e('Donation Receipt Preview', 'give'); ?> "><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
131 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
132 | 132 | 'give_action' => 'send_test_email', |
133 | 133 | 'give-message' => 'sent-test-email', |
134 | 134 | 'tag' => 'emails' |
135 | - ) ), 'give-test-email' ); ?>" title="<?php esc_attr_e( 'This will send a demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
135 | + )), 'give-test-email'); ?>" title="<?php esc_attr_e('This will send a demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
136 | 136 | <?php |
137 | 137 | echo ob_get_clean(); |
138 | 138 | } |
@@ -145,46 +145,46 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function give_display_email_template_preview() { |
147 | 147 | |
148 | - if ( empty( $_GET['give_action'] ) ) { |
|
148 | + if (empty($_GET['give_action'])) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
152 | + if ('preview_email' !== $_GET['give_action']) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
156 | + if ( ! current_user_can('manage_give_settings')) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
161 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
162 | 162 | |
163 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
163 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
164 | 164 | |
165 | 165 | echo give_get_preview_email_header(); |
166 | 166 | |
167 | 167 | //Are we previewing an actual payment? |
168 | - if ( ! empty( $payment_id ) ) { |
|
168 | + if ( ! empty($payment_id)) { |
|
169 | 169 | |
170 | - $content = give_get_email_body_content( $payment_id ); |
|
170 | + $content = give_get_email_body_content($payment_id); |
|
171 | 171 | |
172 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
172 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
173 | 173 | |
174 | 174 | } else { |
175 | 175 | |
176 | 176 | //No payment ID, use sample preview content |
177 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
177 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | - echo Give()->emails->build_email( $preview_content ); |
|
181 | + echo Give()->emails->build_email($preview_content); |
|
182 | 182 | |
183 | 183 | exit; |
184 | 184 | |
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
187 | +add_action('init', 'give_display_email_template_preview'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Email Template Body. |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return string $email_body Body of the email |
198 | 198 | */ |
199 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
199 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
200 | 200 | |
201 | 201 | $default_email_body = give_get_default_donation_receipt_email(); |
202 | 202 | |
203 | - $email_content = give_get_option( 'donation_receipt' ); |
|
204 | - $email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
203 | + $email_content = give_get_option('donation_receipt'); |
|
204 | + $email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body; |
|
205 | 205 | |
206 | - $email_body = wpautop( $email_content ); |
|
206 | + $email_body = wpautop($email_content); |
|
207 | 207 | |
208 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
208 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
209 | 209 | |
210 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
210 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -220,37 +220,37 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string $email_body Body of the email |
222 | 222 | */ |
223 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
223 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
224 | 224 | |
225 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
226 | - $email = give_get_payment_user_email( $payment_id ); |
|
225 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
226 | + $email = give_get_payment_user_email($payment_id); |
|
227 | 227 | |
228 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
229 | - $user_data = get_userdata( $user_info['id'] ); |
|
228 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
229 | + $user_data = get_userdata($user_info['id']); |
|
230 | 230 | $name = $user_data->display_name; |
231 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
232 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
231 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
232 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
233 | 233 | } else { |
234 | 234 | $name = $email; |
235 | 235 | } |
236 | 236 | |
237 | - $gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
237 | + $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true)); |
|
238 | 238 | |
239 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
240 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
239 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
240 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
241 | 241 | /* translators: %s: form plural label */ |
242 | - $default_email_body .= sprintf( esc_html__( '%s sold:', 'give' ), give_get_forms_label_plural() ) . "\n\n"; |
|
243 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
244 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
245 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
246 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
242 | + $default_email_body .= sprintf(esc_html__('%s sold:', 'give'), give_get_forms_label_plural())."\n\n"; |
|
243 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
244 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n"; |
|
245 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
246 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
247 | 247 | |
248 | - $email = give_get_option( 'donation_notification' ); |
|
249 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
248 | + $email = give_get_option('donation_notification'); |
|
249 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
250 | 250 | |
251 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
251 | + $email_body = give_do_email_tags($email, $payment_id); |
|
252 | 252 | |
253 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
253 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -263,34 +263,34 @@ discard block |
||
263 | 263 | * @since 1.0 |
264 | 264 | */ |
265 | 265 | function give_render_receipt_in_browser() { |
266 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
267 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
266 | + if ( ! isset($_GET['payment_key'])) { |
|
267 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
268 | 268 | } |
269 | 269 | |
270 | - $key = urlencode( $_GET['payment_key'] ); |
|
270 | + $key = urlencode($_GET['payment_key']); |
|
271 | 271 | |
272 | 272 | ob_start(); |
273 | 273 | //Disallows caching of the page |
274 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
275 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
276 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
277 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
278 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
274 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
275 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
276 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
277 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
278 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
279 | 279 | ?> |
280 | 280 | <!DOCTYPE html> |
281 | 281 | <html lang="en"> |
282 | 282 | <head> |
283 | - <?php do_action( 'give_receipt_head' ); ?> |
|
283 | + <?php do_action('give_receipt_head'); ?> |
|
284 | 284 | </head> |
285 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
285 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
286 | 286 | |
287 | 287 | <div id="give_receipt_wrapper"> |
288 | - <?php do_action( 'give_render_receipt_in_browser_before' ); ?> |
|
289 | - <?php echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); ?> |
|
290 | - <?php do_action( 'give_render_receipt_in_browser_after' ); ?> |
|
288 | + <?php do_action('give_render_receipt_in_browser_before'); ?> |
|
289 | + <?php echo do_shortcode('[give_receipt payment_key='.$key.']'); ?> |
|
290 | + <?php do_action('give_render_receipt_in_browser_after'); ?> |
|
291 | 291 | </div> |
292 | 292 | |
293 | - <?php do_action( 'give_receipt_footer' ); ?> |
|
293 | + <?php do_action('give_receipt_footer'); ?> |
|
294 | 294 | </body> |
295 | 295 | </html> |
296 | 296 | <?php |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | die(); |
299 | 299 | } |
300 | 300 | |
301 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
301 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
302 | 302 | |
303 | 303 | |
304 | 304 | /** |
@@ -313,31 +313,31 @@ discard block |
||
313 | 313 | |
314 | 314 | //Payment receipt switcher |
315 | 315 | $payment_count = give_count_payments()->publish; |
316 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
316 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
317 | 317 | |
318 | - if ( $payment_count <= 0 ) { |
|
318 | + if ($payment_count <= 0) { |
|
319 | 319 | return false; |
320 | 320 | } |
321 | 321 | |
322 | 322 | //Get payments. |
323 | - $payments = new Give_Payments_Query( array( |
|
323 | + $payments = new Give_Payments_Query(array( |
|
324 | 324 | 'number' => 100 |
325 | - ) ); |
|
325 | + )); |
|
326 | 326 | $payments = $payments->get_payments(); |
327 | 327 | $options = array(); |
328 | 328 | |
329 | 329 | //Provide nice human readable options. |
330 | - if ( $payments ) { |
|
330 | + if ($payments) { |
|
331 | 331 | $options[0] = |
332 | 332 | /* translators: %s: transaction singular label */ |
333 | - esc_html__( '- Select a transaction -', 'give' ); |
|
334 | - foreach ( $payments as $payment ) { |
|
333 | + esc_html__('- Select a transaction -', 'give'); |
|
334 | + foreach ($payments as $payment) { |
|
335 | 335 | |
336 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
336 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
337 | 337 | |
338 | 338 | } |
339 | 339 | } else { |
340 | - $options[0] = esc_html__( 'No Transactions Found', 'give' ); |
|
340 | + $options[0] = esc_html__('No Transactions Found', 'give'); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | //Start constructing HTML output. |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | var selected_trans = transactions.options[transactions.selectedIndex]; |
351 | 351 | console.log(selected_trans); |
352 | 352 | if (selected_trans){ |
353 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
353 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
354 | 354 | window.location = url_string; |
355 | 355 | } |
356 | 356 | } |
357 | 357 | </script>'; |
358 | 358 | |
359 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a transaction:', 'give' ) . '</label>'; |
|
359 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a transaction:', 'give').'</label>'; |
|
360 | 360 | |
361 | 361 | //The select field with 100 latest transactions |
362 | - $transaction_header .= Give()->html->select( array( |
|
362 | + $transaction_header .= Give()->html->select(array( |
|
363 | 363 | 'name' => 'preview_email_payment_id', |
364 | 364 | 'selected' => $payment_id, |
365 | 365 | 'id' => 'give_preview_email_payment_id', |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | 'select_atts' => 'onchange="change_preview()">', |
370 | 370 | 'show_option_all' => false, |
371 | 371 | 'show_option_none' => false |
372 | - ) ); |
|
372 | + )); |
|
373 | 373 | |
374 | 374 | //Closing tag |
375 | 375 | $transaction_header .= '</div>'; |
376 | 376 | |
377 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
377 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
378 | 378 | |
379 | 379 | } |
380 | 380 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | function give_receipt_head_content() { |
389 | 389 | |
390 | 390 | //Title. |
391 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
391 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
392 | 392 | |
393 | 393 | //Meta. |
394 | 394 | $output .= '<meta charset="utf-8"/> |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | <meta name="robots" content="noindex, nofollow"/>'; |
403 | 403 | |
404 | 404 | //CSS |
405 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
405 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
406 | 406 | |
407 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
407 | + echo apply_filters('give_receipt_head_content', $output); |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
411 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
412 | 411 | \ No newline at end of file |
412 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
413 | 413 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Templates |
40 | 40 | */ |
41 | - add_filter( 'template_include', array( __CLASS__, 'template_loader' ) ); |
|
41 | + add_filter('template_include', array(__CLASS__, 'template_loader')); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Content Wrappers |
45 | 45 | */ |
46 | - add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 ); |
|
47 | - add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 ); |
|
46 | + add_action('give_before_main_content', 'give_output_content_wrapper', 10); |
|
47 | + add_action('give_after_main_content', 'give_output_content_wrapper_end', 10); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Entry Summary Classes |
51 | 51 | */ |
52 | - add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) ); |
|
52 | + add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes')); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Sidebar |
56 | 56 | */ |
57 | - add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 ); |
|
57 | + add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Single Forms Summary Box |
61 | 61 | */ |
62 | - add_action( 'give_single_form_summary', 'give_template_single_title', 5 ); |
|
63 | - add_action( 'give_single_form_summary', 'give_get_donation_form', 10 ); |
|
62 | + add_action('give_single_form_summary', 'give_template_single_title', 5); |
|
63 | + add_action('give_single_form_summary', 'give_get_donation_form', 10); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return string $classes List of space separated class names. |
77 | 77 | */ |
78 | - public function give_set_single_summary_classes( $classes ) { |
|
78 | + public function give_set_single_summary_classes($classes) { |
|
79 | 79 | |
80 | - $sidebar_option = give_get_option( 'disable_form_sidebar' ); |
|
80 | + $sidebar_option = give_get_option('disable_form_sidebar'); |
|
81 | 81 | |
82 | 82 | //Add full width class when feature image is disabled AND no widgets are present |
83 | - if ( $sidebar_option == 'on' ) { |
|
83 | + if ($sidebar_option == 'on') { |
|
84 | 84 | $classes .= ' give-full-width'; |
85 | 85 | } |
86 | 86 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function give_output_sidebar_option() { |
102 | 102 | |
103 | - $sidebar_option = give_get_option( 'disable_form_sidebar' ); |
|
103 | + $sidebar_option = give_get_option('disable_form_sidebar'); |
|
104 | 104 | |
105 | 105 | //Add full width class when feature image is disabled AND no widgets are present |
106 | - if ( $sidebar_option !== 'on' ) { |
|
107 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 ); |
|
108 | - add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 ); |
|
109 | - add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 ); |
|
110 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 ); |
|
106 | + if ($sidebar_option !== 'on') { |
|
107 | + add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5); |
|
108 | + add_action('give_before_single_form_summary', 'give_show_form_images', 10); |
|
109 | + add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20); |
|
110 | + add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return string $template |
131 | 131 | */ |
132 | - public static function template_loader( $template ) { |
|
133 | - $find = array( 'give.php' ); |
|
132 | + public static function template_loader($template) { |
|
133 | + $find = array('give.php'); |
|
134 | 134 | $file = ''; |
135 | 135 | |
136 | - if ( is_single() && get_post_type() == 'give_forms' ) { |
|
136 | + if (is_single() && get_post_type() == 'give_forms') { |
|
137 | 137 | $file = 'single-give-form.php'; |
138 | 138 | $find[] = $file; |
139 | - $find[] = apply_filters( 'give_template_path', 'give/' ) . $file; |
|
139 | + $find[] = apply_filters('give_template_path', 'give/').$file; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( $file ) { |
|
143 | - $template = locate_template( array_unique( $find ) ); |
|
144 | - if ( ! $template ) { |
|
145 | - $template = GIVE_PLUGIN_DIR . '/templates/' . $file; |
|
142 | + if ($file) { |
|
143 | + $template = locate_template(array_unique($find)); |
|
144 | + if ( ! $template) { |
|
145 | + $template = GIVE_PLUGIN_DIR.'/templates/'.$file; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // Retrieve the payment ID |
38 | 38 | $payment_id = absint( $data['give_payment_id'] ); |
39 | 39 | |
40 | - /* @var Give_Payment $payment */ |
|
40 | + /* @var Give_Payment $payment */ |
|
41 | 41 | $payment = new Give_Payment( $payment_id ); |
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
@@ -160,23 +160,23 @@ discard block |
||
160 | 160 | |
161 | 161 | if ( 'publish' == $status ) { |
162 | 162 | |
163 | - // Reduce previous user donation count and amount. |
|
164 | - $previous_customer->decrease_purchase_count(); |
|
165 | - $previous_customer->decrease_value( $curr_total ); |
|
163 | + // Reduce previous user donation count and amount. |
|
164 | + $previous_customer->decrease_purchase_count(); |
|
165 | + $previous_customer->decrease_value( $curr_total ); |
|
166 | 166 | |
167 | - // If purchase was completed adjust stats of new customers. |
|
168 | - $customer->increase_purchase_count(); |
|
167 | + // If purchase was completed adjust stats of new customers. |
|
168 | + $customer->increase_purchase_count(); |
|
169 | 169 | $customer->increase_value( $new_total ); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | 173 | } else{ |
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
176 | - // Update user donation stat. |
|
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | - } |
|
179 | - } |
|
175 | + if( 'publish' === $status ){ |
|
176 | + // Update user donation stat. |
|
177 | + $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | 181 | // Set new meta values |
182 | 182 | $payment->user_id = $customer->user_id; |
@@ -217,76 +217,76 @@ discard block |
||
217 | 217 | |
218 | 218 | $payment->save(); |
219 | 219 | |
220 | - // Get new give form ID. |
|
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
220 | + // Get new give form ID. |
|
221 | + $new_form_id = absint( $data['forms'] ); |
|
222 | + $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
223 | 223 | |
224 | - // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | - // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | - /* Check if user want to transfer current payment to new give form id. */ |
|
227 | - if( $new_form_id != $current_form_id ) { |
|
224 | + // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | + // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | + /* Check if user want to transfer current payment to new give form id. */ |
|
227 | + if( $new_form_id != $current_form_id ) { |
|
228 | 228 | |
229 | - // Get new give form title. |
|
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
229 | + // Get new give form title. |
|
230 | + $new_form_title = get_the_title( $new_form_id ); |
|
231 | 231 | |
232 | - // Update new give form data in payment data. |
|
233 | - $payment_meta = $payment->get_meta(); |
|
234 | - $payment_meta['form_title'] = $new_form_title; |
|
235 | - $payment_meta['form_id'] = $new_form_id; |
|
232 | + // Update new give form data in payment data. |
|
233 | + $payment_meta = $payment->get_meta(); |
|
234 | + $payment_meta['form_title'] = $new_form_title; |
|
235 | + $payment_meta['form_id'] = $new_form_id; |
|
236 | 236 | |
237 | - // Update price id post meta data for set donation form. |
|
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | - $payment_meta['price_id'] = ''; |
|
240 | - } |
|
237 | + // Update price id post meta data for set donation form. |
|
238 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | + $payment_meta['price_id'] = ''; |
|
240 | + } |
|
241 | 241 | |
242 | - // Update payment give form meta data. |
|
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
242 | + // Update payment give form meta data. |
|
243 | + $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | + $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
246 | 246 | |
247 | - // Update price id payment metadata. |
|
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | - } |
|
247 | + // Update price id payment metadata. |
|
248 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | + $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - // If purchase was completed, adjust stats of forms |
|
254 | - if ( 'publish' == $status ) { |
|
253 | + // If purchase was completed, adjust stats of forms |
|
254 | + if ( 'publish' == $status ) { |
|
255 | 255 | |
256 | - // Decrease sale of old give form. For other payment status |
|
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | - $current_form->decrease_sales(); |
|
259 | - $current_form->decrease_earnings( $curr_total ); |
|
256 | + // Decrease sale of old give form. For other payment status |
|
257 | + $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | + $current_form->decrease_sales(); |
|
259 | + $current_form->decrease_earnings( $curr_total ); |
|
260 | 260 | |
261 | - // Increase sale of new give form. |
|
262 | - $new_form = new Give_Donate_Form($new_form_id); |
|
263 | - $new_form->increase_sales(); |
|
264 | - $new_form->increase_earnings($new_total); |
|
265 | - } |
|
261 | + // Increase sale of new give form. |
|
262 | + $new_form = new Give_Donate_Form($new_form_id); |
|
263 | + $new_form->increase_sales(); |
|
264 | + $new_form->increase_earnings($new_total); |
|
265 | + } |
|
266 | 266 | |
267 | - // Re setup payment to update new meta value in object. |
|
268 | - $payment->update_payment_setup( $payment->ID ); |
|
269 | - } |
|
267 | + // Re setup payment to update new meta value in object. |
|
268 | + $payment->update_payment_setup( $payment->ID ); |
|
269 | + } |
|
270 | 270 | |
271 | - // Update price id if current form is variable form. |
|
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
271 | + // Update price id if current form is variable form. |
|
272 | + if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
273 | 273 | |
274 | - // Get payment meta data. |
|
275 | - $payment_meta = $payment->get_meta(); |
|
274 | + // Get payment meta data. |
|
275 | + $payment_meta = $payment->get_meta(); |
|
276 | 276 | |
277 | - // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
277 | + // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | + $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | - // Update payment meta data. |
|
281 | - $payment_meta['price_id'] = $data['give-variable-price']; |
|
280 | + // Update payment meta data. |
|
281 | + $payment_meta['price_id'] = $data['give-variable-price']; |
|
282 | 282 | |
283 | - // Update payment give form meta data. |
|
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
283 | + // Update payment give form meta data. |
|
284 | + $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
286 | 286 | |
287 | - // Re setup payment to update new meta value in object. |
|
288 | - $payment->update_payment_setup( $payment->ID ); |
|
289 | - } |
|
287 | + // Re setup payment to update new meta value in object. |
|
288 | + $payment->update_payment_setup( $payment->ID ); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Fires after updating edited purchase. |
@@ -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 | |
@@ -26,52 +26,52 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | * |
28 | 28 | */ |
29 | -function give_update_payment_details( $data ) { |
|
29 | +function give_update_payment_details($data) { |
|
30 | 30 | |
31 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
32 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
31 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
32 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
33 | 33 | } |
34 | 34 | |
35 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
35 | + check_admin_referer('give_update_payment_details_nonce'); |
|
36 | 36 | |
37 | 37 | // Retrieve the payment ID |
38 | - $payment_id = absint( $data['give_payment_id'] ); |
|
38 | + $payment_id = absint($data['give_payment_id']); |
|
39 | 39 | |
40 | 40 | /* @var Give_Payment $payment */ |
41 | - $payment = new Give_Payment( $payment_id ); |
|
41 | + $payment = new Give_Payment($payment_id); |
|
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
44 | 44 | $meta = $payment->get_meta(); |
45 | 45 | $user_info = $payment->user_info; |
46 | 46 | |
47 | 47 | $status = $data['give-payment-status']; |
48 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
49 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
48 | + $date = sanitize_text_field($data['give-payment-date']); |
|
49 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
50 | 50 | |
51 | 51 | // Restrict to our high and low |
52 | - if ( $hour > 23 ) { |
|
52 | + if ($hour > 23) { |
|
53 | 53 | $hour = 23; |
54 | - } elseif ( $hour < 0 ) { |
|
54 | + } elseif ($hour < 0) { |
|
55 | 55 | $hour = 00; |
56 | 56 | } |
57 | 57 | |
58 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
58 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
59 | 59 | |
60 | 60 | // Restrict to our high and low |
61 | - if ( $minute > 59 ) { |
|
61 | + if ($minute > 59) { |
|
62 | 62 | $minute = 59; |
63 | - } elseif ( $minute < 0 ) { |
|
63 | + } elseif ($minute < 0) { |
|
64 | 64 | $minute = 00; |
65 | 65 | } |
66 | 66 | |
67 | - $address = array_map( 'trim', $data['give-payment-address'][0] ); |
|
67 | + $address = array_map('trim', $data['give-payment-address'][0]); |
|
68 | 68 | |
69 | - $curr_total = give_sanitize_amount( $payment->total ); |
|
70 | - $new_total = give_sanitize_amount( $data['give-payment-total'] ); |
|
71 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $curr_total = give_sanitize_amount($payment->total); |
|
70 | + $new_total = give_sanitize_amount($data['give-payment-total']); |
|
71 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
72 | 72 | |
73 | - $curr_customer_id = sanitize_text_field( $data['give-current-customer'] ); |
|
74 | - $new_customer_id = sanitize_text_field( $data['customer-id'] ); |
|
73 | + $curr_customer_id = sanitize_text_field($data['give-current-customer']); |
|
74 | + $new_customer_id = sanitize_text_field($data['customer-id']); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Fires before updating edited purchase. |
@@ -80,62 +80,62 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $payment_id The ID of the payment. |
82 | 82 | */ |
83 | - do_action( 'give_update_edited_purchase', $payment_id ); |
|
83 | + do_action('give_update_edited_purchase', $payment_id); |
|
84 | 84 | |
85 | 85 | $payment->date = $date; |
86 | 86 | $updated = $payment->save(); |
87 | 87 | |
88 | - if ( 0 === $updated ) { |
|
89 | - wp_die( esc_html__( 'Error Updating Payment.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
88 | + if (0 === $updated) { |
|
89 | + wp_die(esc_html__('Error Updating Payment.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | $customer_changed = false; |
94 | 94 | |
95 | - if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) { |
|
95 | + if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') { |
|
96 | 96 | |
97 | - $email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : ''; |
|
98 | - $names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : ''; |
|
97 | + $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : ''; |
|
98 | + $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : ''; |
|
99 | 99 | |
100 | - if ( empty( $email ) || empty( $names ) ) { |
|
101 | - wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
100 | + if (empty($email) || empty($names)) { |
|
101 | + wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
102 | 102 | } |
103 | 103 | |
104 | - $customer = new Give_Customer( $email ); |
|
105 | - if ( empty( $customer->id ) ) { |
|
106 | - $customer_data = array( 'name' => $names, 'email' => $email ); |
|
107 | - $user_id = email_exists( $email ); |
|
108 | - if ( false !== $user_id ) { |
|
104 | + $customer = new Give_Customer($email); |
|
105 | + if (empty($customer->id)) { |
|
106 | + $customer_data = array('name' => $names, 'email' => $email); |
|
107 | + $user_id = email_exists($email); |
|
108 | + if (false !== $user_id) { |
|
109 | 109 | $customer_data['user_id'] = $user_id; |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! $customer->create( $customer_data ) ) { |
|
112 | + if ( ! $customer->create($customer_data)) { |
|
113 | 113 | // Failed to crete the new donor, assume the previous donor |
114 | 114 | $customer_changed = false; |
115 | - $customer = new Give_Customer( $curr_customer_id ); |
|
116 | - give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) ); |
|
115 | + $customer = new Give_Customer($curr_customer_id); |
|
116 | + give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | $new_customer_id = $customer->id; |
121 | 121 | |
122 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
122 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
123 | 123 | |
124 | 124 | $customer_changed = true; |
125 | 125 | |
126 | - } elseif ( $curr_customer_id !== $new_customer_id ) { |
|
126 | + } elseif ($curr_customer_id !== $new_customer_id) { |
|
127 | 127 | |
128 | - $customer = new Give_Customer( $new_customer_id ); |
|
128 | + $customer = new Give_Customer($new_customer_id); |
|
129 | 129 | $email = $customer->email; |
130 | 130 | $names = $customer->name; |
131 | 131 | |
132 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
132 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
133 | 133 | |
134 | 134 | $customer_changed = true; |
135 | 135 | |
136 | 136 | } else { |
137 | 137 | |
138 | - $customer = new Give_Customer( $curr_customer_id ); |
|
138 | + $customer = new Give_Customer($curr_customer_id); |
|
139 | 139 | $email = $customer->email; |
140 | 140 | $names = $customer->name; |
141 | 141 | |
@@ -143,38 +143,38 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // Setup first and last name from input values |
146 | - $names = explode( ' ', $names ); |
|
147 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
146 | + $names = explode(' ', $names); |
|
147 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
148 | 148 | $last_name = ''; |
149 | - if ( ! empty( $names[1] ) ) { |
|
150 | - unset( $names[0] ); |
|
151 | - $last_name = implode( ' ', $names ); |
|
149 | + if ( ! empty($names[1])) { |
|
150 | + unset($names[0]); |
|
151 | + $last_name = implode(' ', $names); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - if ( $customer_changed ) { |
|
155 | + if ($customer_changed) { |
|
156 | 156 | |
157 | 157 | // Remove the stats and payment from the previous customer and attach it to the new customer |
158 | - $previous_customer->remove_payment( $payment_id, false ); |
|
159 | - $customer->attach_payment( $payment_id, false ); |
|
158 | + $previous_customer->remove_payment($payment_id, false); |
|
159 | + $customer->attach_payment($payment_id, false); |
|
160 | 160 | |
161 | - if ( 'publish' == $status ) { |
|
161 | + if ('publish' == $status) { |
|
162 | 162 | |
163 | 163 | // Reduce previous user donation count and amount. |
164 | 164 | $previous_customer->decrease_purchase_count(); |
165 | - $previous_customer->decrease_value( $curr_total ); |
|
165 | + $previous_customer->decrease_value($curr_total); |
|
166 | 166 | |
167 | 167 | // If purchase was completed adjust stats of new customers. |
168 | 168 | $customer->increase_purchase_count(); |
169 | - $customer->increase_value( $new_total ); |
|
169 | + $customer->increase_value($new_total); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | - } else{ |
|
173 | + } else { |
|
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
175 | + if ('publish' === $status) { |
|
176 | 176 | // Update user donation stat. |
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
177 | + $customer->update_donation_value($curr_total, $new_total); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | // Check for payment notes |
191 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
191 | + if ( ! empty($data['give-payment-note'])) { |
|
192 | 192 | |
193 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
194 | - give_insert_payment_note( $payment_id, $note ); |
|
193 | + $note = wp_kses($data['give-payment-note'], array()); |
|
194 | + give_insert_payment_note($payment_id, $note); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $payment->status = $status; |
200 | 200 | |
201 | 201 | // Adjust total store earnings if the payment total has been changed |
202 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
202 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
203 | 203 | |
204 | - if ( $new_total > $curr_total ) { |
|
204 | + if ($new_total > $curr_total) { |
|
205 | 205 | // Increase if our new total is higher |
206 | 206 | $difference = $new_total - $curr_total; |
207 | - give_increase_total_earnings( $difference ); |
|
207 | + give_increase_total_earnings($difference); |
|
208 | 208 | |
209 | - } elseif ( $curr_total > $new_total ) { |
|
209 | + } elseif ($curr_total > $new_total) { |
|
210 | 210 | // Decrease if our new total is lower |
211 | 211 | $difference = $curr_total - $new_total; |
212 | - give_decrease_total_earnings( $difference ); |
|
212 | + give_decrease_total_earnings($difference); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $payment->save(); |
219 | 219 | |
220 | 220 | // Get new give form ID. |
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
221 | + $new_form_id = absint($data['forms']); |
|
222 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
223 | 223 | |
224 | 224 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
225 | 225 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
226 | 226 | /* Check if user want to transfer current payment to new give form id. */ |
227 | - if( $new_form_id != $current_form_id ) { |
|
227 | + if ($new_form_id != $current_form_id) { |
|
228 | 228 | |
229 | 229 | // Get new give form title. |
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
230 | + $new_form_title = get_the_title($new_form_id); |
|
231 | 231 | |
232 | 232 | // Update new give form data in payment data. |
233 | 233 | $payment_meta = $payment->get_meta(); |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | $payment_meta['form_id'] = $new_form_id; |
236 | 236 | |
237 | 237 | // Update price id post meta data for set donation form. |
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
239 | 239 | $payment_meta['price_id'] = ''; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Update payment give form meta data. |
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
243 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
244 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
245 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
246 | 246 | |
247 | 247 | // Update price id payment metadata. |
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
248 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
249 | + $payment->update_meta('_give_payment_price_id', ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | // If purchase was completed, adjust stats of forms |
254 | - if ( 'publish' == $status ) { |
|
254 | + if ('publish' == $status) { |
|
255 | 255 | |
256 | 256 | // Decrease sale of old give form. For other payment status |
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
257 | + $current_form = new Give_Donate_Form($current_form_id); |
|
258 | 258 | $current_form->decrease_sales(); |
259 | - $current_form->decrease_earnings( $curr_total ); |
|
259 | + $current_form->decrease_earnings($curr_total); |
|
260 | 260 | |
261 | 261 | // Increase sale of new give form. |
262 | 262 | $new_form = new Give_Donate_Form($new_form_id); |
@@ -265,27 +265,27 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Re setup payment to update new meta value in object. |
268 | - $payment->update_payment_setup( $payment->ID ); |
|
268 | + $payment->update_payment_setup($payment->ID); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Update price id if current form is variable form. |
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
272 | + if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) { |
|
273 | 273 | |
274 | 274 | // Get payment meta data. |
275 | 275 | $payment_meta = $payment->get_meta(); |
276 | 276 | |
277 | 277 | // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
278 | + $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | 280 | // Update payment meta data. |
281 | 281 | $payment_meta['price_id'] = $data['give-variable-price']; |
282 | 282 | |
283 | 283 | // Update payment give form meta data. |
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
284 | + $payment->update_meta('_give_payment_price_id', $data['give-variable-price']); |
|
285 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
286 | 286 | |
287 | 287 | // Re setup payment to update new meta value in object. |
288 | - $payment->update_payment_setup( $payment->ID ); |
|
288 | + $payment->update_payment_setup($payment->ID); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param int $payment_id The ID of the payment. |
297 | 297 | */ |
298 | - do_action( 'give_updated_edited_purchase', $payment_id ); |
|
298 | + do_action('give_updated_edited_purchase', $payment_id); |
|
299 | 299 | |
300 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
300 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id)); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
304 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Trigger a Purchase Deletion |
@@ -312,48 +312,48 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return void |
314 | 314 | */ |
315 | -function give_trigger_purchase_delete( $data ) { |
|
316 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) { |
|
315 | +function give_trigger_purchase_delete($data) { |
|
316 | + if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) { |
|
317 | 317 | |
318 | - $payment_id = absint( $data['purchase_id'] ); |
|
318 | + $payment_id = absint($data['purchase_id']); |
|
319 | 319 | |
320 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
321 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
320 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
321 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
322 | 322 | } |
323 | 323 | |
324 | - give_delete_purchase( $payment_id ); |
|
325 | - wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) ); |
|
324 | + give_delete_purchase($payment_id); |
|
325 | + wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted')); |
|
326 | 326 | give_die(); |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | -add_action( 'give_delete_payment', 'give_trigger_purchase_delete' ); |
|
330 | +add_action('give_delete_payment', 'give_trigger_purchase_delete'); |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * AJAX Store Payment Note |
334 | 334 | */ |
335 | 335 | function give_ajax_store_payment_note() { |
336 | 336 | |
337 | - $payment_id = absint( $_POST['payment_id'] ); |
|
338 | - $note = wp_kses( $_POST['note'], array() ); |
|
337 | + $payment_id = absint($_POST['payment_id']); |
|
338 | + $note = wp_kses($_POST['note'], array()); |
|
339 | 339 | |
340 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
341 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
340 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
341 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
345 | - die( '-1' ); |
|
344 | + if (empty($payment_id)) { |
|
345 | + die('-1'); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( empty( $note ) ) { |
|
349 | - die( '-1' ); |
|
348 | + if (empty($note)) { |
|
349 | + die('-1'); |
|
350 | 350 | } |
351 | 351 | |
352 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
353 | - die( give_get_payment_note_html( $note_id ) ); |
|
352 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
353 | + die(give_get_payment_note_html($note_id)); |
|
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
356 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Triggers a payment note deletion without ajax |
@@ -364,24 +364,24 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @return void |
366 | 366 | */ |
367 | -function give_trigger_payment_note_deletion( $data ) { |
|
367 | +function give_trigger_payment_note_deletion($data) { |
|
368 | 368 | |
369 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
369 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
374 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
373 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
374 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
375 | 375 | } |
376 | 376 | |
377 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
377 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id'])); |
|
378 | 378 | |
379 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
379 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
380 | 380 | |
381 | - wp_redirect( $edit_order_url ); |
|
381 | + wp_redirect($edit_order_url); |
|
382 | 382 | } |
383 | 383 | |
384 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
384 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Delete a payment note deletion with ajax |
@@ -392,16 +392,16 @@ discard block |
||
392 | 392 | */ |
393 | 393 | function give_ajax_delete_payment_note() { |
394 | 394 | |
395 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
396 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
395 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
396 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
400 | - die( '1' ); |
|
399 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
400 | + die('1'); |
|
401 | 401 | } else { |
402 | - die( '-1' ); |
|
402 | + die('-1'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
408 | 407 | \ No newline at end of file |
408 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |
|
409 | 409 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | public function headers() { |
41 | - ignore_user_abort( true ); |
|
41 | + ignore_user_abort(true); |
|
42 | 42 | |
43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
44 | - set_time_limit( 0 ); |
|
43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
44 | + set_time_limit(0); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | nocache_headers(); |
48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
50 | - header( "Expires: 0" ); |
|
48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
50 | + header("Expires: 0"); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | public function csv_cols() { |
62 | 62 | |
63 | 63 | $cols = array( |
64 | - 'date' => esc_html__( 'Date', 'give' ), |
|
65 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
64 | + 'date' => esc_html__('Date', 'give'), |
|
65 | + 'donations' => esc_html__('Donations', 'give'), |
|
66 | 66 | /* translators: %s: currency */ |
67 | - 'earnings' => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) ) |
|
67 | + 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function get_data() { |
81 | 81 | |
82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
86 | 86 | |
87 | 87 | $data = array(); |
88 | 88 | $year = $start_year; |
89 | 89 | $stats = new Give_Payment_Stats; |
90 | 90 | |
91 | - while ( $year <= $end_year ) { |
|
91 | + while ($year <= $end_year) { |
|
92 | 92 | |
93 | - if ( $year == $start_year && $year == $end_year ) { |
|
93 | + if ($year == $start_year && $year == $end_year) { |
|
94 | 94 | |
95 | 95 | $m1 = $start_month; |
96 | 96 | $m2 = $end_month; |
97 | 97 | |
98 | - } elseif ( $year == $start_year ) { |
|
98 | + } elseif ($year == $start_year) { |
|
99 | 99 | |
100 | 100 | $m1 = $start_month; |
101 | 101 | $m2 = 12; |
102 | 102 | |
103 | - } elseif ( $year == $end_year ) { |
|
103 | + } elseif ($year == $end_year) { |
|
104 | 104 | |
105 | 105 | $m1 = 1; |
106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | - while ( $m1 <= $m2 ) { |
|
115 | + while ($m1 <= $m2) { |
|
116 | 116 | |
117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
119 | 119 | |
120 | 120 | $data[] = array( |
121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ), |
|
121 | + 'date' => date_i18n('F Y', $date1), |
|
122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)), |
|
124 | 124 | ); |
125 | 125 | |
126 | - $m1 ++; |
|
126 | + $m1++; |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $year ++; |
|
131 | + $year++; |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
136 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
135 | + $data = apply_filters('give_export_get_data', $data); |
|
136 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
137 | 137 | |
138 | 138 | return $data; |
139 | 139 | } |
@@ -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); |