@@ -12,13 +12,13 @@ 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 | |
19 | 19 | // Load WP_List_Table if not loaded. |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults. |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | 67 | 'ajax' => false, // Does this table support ajax?. |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo sprintf( '<input type="hidden" name="orderby" value="%1$s" />', esc_attr( $_REQUEST['orderby'] ) ); |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo sprintf('<input type="hidden" name="orderby" value="%1$s" />', esc_attr($_REQUEST['orderby'])); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
91 | - echo sprintf( '<input type="hidden" name="order" value="%1$s" />', esc_attr( $_REQUEST['order'] ) ); |
|
90 | + if ( ! empty($_REQUEST['order'])) { |
|
91 | + echo sprintf('<input type="hidden" name="order" value="%1$s" />', esc_attr($_REQUEST['order'])); |
|
92 | 92 | } |
93 | 93 | ?> |
94 | 94 | <p class="search-box" role="search"> |
95 | 95 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
96 | 96 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
97 | - <?php submit_button( $text, 'button', false, false, array( |
|
97 | + <?php submit_button($text, 'button', false, false, array( |
|
98 | 98 | 'ID' => 'search-submit', |
99 | - ) ); ?> |
|
99 | + )); ?> |
|
100 | 100 | </p> |
101 | 101 | <?php |
102 | 102 | } |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return string Column Name. |
114 | 114 | */ |
115 | - public function column_default( $donor, $column_name ) { |
|
115 | + public function column_default($donor, $column_name) { |
|
116 | 116 | |
117 | - switch ( $column_name ) { |
|
117 | + switch ($column_name) { |
|
118 | 118 | |
119 | 119 | case 'num_donations' : |
120 | 120 | $value = sprintf( |
121 | 121 | '<a href="%s">%s</a>', |
122 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
123 | - esc_html( $donor['num_donations'] ) |
|
122 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
123 | + esc_html($donor['num_donations']) |
|
124 | 124 | ); |
125 | 125 | break; |
126 | 126 | |
127 | 127 | case 'amount_spent' : |
128 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
128 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case 'date_created' : |
132 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
132 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | default: |
136 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
136 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
137 | 137 | break; |
138 | 138 | } |
139 | 139 | |
140 | - return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] ); |
|
140 | + return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function column_cb( $donor ){ |
|
154 | + public function column_cb($donor) { |
|
155 | 155 | return sprintf( |
156 | 156 | '<input class="donor-selector" type="checkbox" name="%1$s[]" value="%2$d" data-name="%3$s" />', |
157 | 157 | $this->_args['singular'], |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string |
172 | 172 | */ |
173 | - public function column_name( $donor ) { |
|
174 | - $name = '#' . $donor['id'] . ' '; |
|
175 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>'; |
|
176 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
177 | - $actions = $this->get_row_actions( $donor ); |
|
173 | + public function column_name($donor) { |
|
174 | + $name = '#'.$donor['id'].' '; |
|
175 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>'; |
|
176 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
177 | + $actions = $this->get_row_actions($donor); |
|
178 | 178 | |
179 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
179 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | 192 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
193 | - 'name' => __( 'Name', 'give' ), |
|
194 | - 'email' => __( 'Email', 'give' ), |
|
195 | - 'num_donations' => __( 'Donations', 'give' ), |
|
196 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
197 | - 'date_created' => __( 'Date Created', 'give' ), |
|
193 | + 'name' => __('Name', 'give'), |
|
194 | + 'email' => __('Email', 'give'), |
|
195 | + 'num_donations' => __('Donations', 'give'), |
|
196 | + 'amount_spent' => __('Total Donated', 'give'), |
|
197 | + 'date_created' => __('Date Created', 'give'), |
|
198 | 198 | ); |
199 | 199 | |
200 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
200 | + return apply_filters('give_list_donors_columns', $columns); |
|
201 | 201 | |
202 | 202 | } |
203 | 203 | |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | public function get_sortable_columns() { |
212 | 212 | |
213 | 213 | $columns = array( |
214 | - 'date_created' => array( 'date_created', true ), |
|
215 | - 'name' => array( 'name', true ), |
|
216 | - 'num_donations' => array( 'purchase_count', false ), |
|
217 | - 'amount_spent' => array( 'purchase_value', false ), |
|
214 | + 'date_created' => array('date_created', true), |
|
215 | + 'name' => array('name', true), |
|
216 | + 'num_donations' => array('purchase_count', false), |
|
217 | + 'amount_spent' => array('purchase_value', false), |
|
218 | 218 | ); |
219 | 219 | |
220 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
220 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return array An array of action links. |
232 | 232 | */ |
233 | - public function get_row_actions( $donor ) { |
|
233 | + public function get_row_actions($donor) { |
|
234 | 234 | |
235 | 235 | $actions = array( |
236 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
237 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
238 | - 'delete' => sprintf( '<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'],sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
236 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
237 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
238 | + 'delete' => sprintf('<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'], sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
239 | 239 | ); |
240 | 240 | |
241 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
241 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return int Current page number. |
252 | 252 | */ |
253 | 253 | public function get_paged() { |
254 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
254 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @return mixed string If search is present, false otherwise. |
264 | 264 | */ |
265 | 265 | public function get_search() { |
266 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
266 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function get_bulk_actions() { |
278 | 278 | $actions = array( |
279 | - 'delete' => __( 'Delete', 'give' ), |
|
279 | + 'delete' => __('Delete', 'give'), |
|
280 | 280 | ); |
281 | 281 | return $actions; |
282 | 282 | } |
@@ -289,19 +289,19 @@ discard block |
||
289 | 289 | * @access protected |
290 | 290 | * @since 1.8.16 |
291 | 291 | */ |
292 | - protected function display_tablenav( $which ) { |
|
293 | - if ( 'top' === $which ) { |
|
294 | - wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false ); |
|
292 | + protected function display_tablenav($which) { |
|
293 | + if ('top' === $which) { |
|
294 | + wp_nonce_field('bulk-'.$this->_args['plural'], '_wpnonce', false); |
|
295 | 295 | } |
296 | 296 | ?> |
297 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
298 | - <?php if ( $this->has_items() ): ?> |
|
297 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
298 | + <?php if ($this->has_items()): ?> |
|
299 | 299 | <div class="alignleft actions bulkactions"> |
300 | - <?php $this->bulk_actions( $which ); ?> |
|
300 | + <?php $this->bulk_actions($which); ?> |
|
301 | 301 | </div> |
302 | 302 | <?php endif; |
303 | - $this->extra_tablenav( $which ); |
|
304 | - $this->pagination( $which ); |
|
303 | + $this->extra_tablenav($which); |
|
304 | + $this->pagination($which); |
|
305 | 305 | ?> |
306 | 306 | <br class="clear" /> |
307 | 307 | </div> |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | |
323 | 323 | // Get donor query. |
324 | 324 | $args = $this->get_donor_query(); |
325 | - $donors = Give()->donors->get_donors( $args ); |
|
325 | + $donors = Give()->donors->get_donors($args); |
|
326 | 326 | |
327 | - if ( $donors ) { |
|
327 | + if ($donors) { |
|
328 | 328 | |
329 | - foreach ( $donors as $donor ) { |
|
329 | + foreach ($donors as $donor) { |
|
330 | 330 | |
331 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
331 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
332 | 332 | |
333 | 333 | $data[] = array( |
334 | 334 | 'id' => $donor->id, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
345 | + return apply_filters('give_donors_column_query_data', $data); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $_donor_query['number'] = - 1; |
359 | 359 | $_donor_query['offset'] = 0; |
360 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
360 | + $donors = Give()->donors->get_donors($_donor_query); |
|
361 | 361 | |
362 | - return count( $donors ); |
|
362 | + return count($donors); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function get_donor_query() { |
374 | 374 | $paged = $this->get_paged(); |
375 | - $offset = $this->per_page * ( $paged - 1 ); |
|
375 | + $offset = $this->per_page * ($paged - 1); |
|
376 | 376 | $search = $this->get_search(); |
377 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
378 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
377 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
378 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
379 | 379 | |
380 | 380 | $args = array( |
381 | 381 | 'number' => $this->per_page, |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | 'orderby' => $orderby, |
385 | 385 | ); |
386 | 386 | |
387 | - if ( $search ) { |
|
388 | - if ( is_email( $search ) ) { |
|
387 | + if ($search) { |
|
388 | + if (is_email($search)) { |
|
389 | 389 | $args['email'] = $search; |
390 | - } elseif ( is_numeric( $search ) ) { |
|
390 | + } elseif (is_numeric($search)) { |
|
391 | 391 | $args['id'] = $search; |
392 | 392 | } else { |
393 | 393 | $args['name'] = $search; |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | * @since 1.8.17 |
406 | 406 | * @access public |
407 | 407 | */ |
408 | - public function single_row( $item ) { |
|
409 | - echo sprintf( '<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name'] ); |
|
410 | - $this->single_row_columns( $item ); |
|
408 | + public function single_row($item) { |
|
409 | + echo sprintf('<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name']); |
|
410 | + $this->single_row_columns($item); |
|
411 | 411 | echo '</tr>'; |
412 | 412 | } |
413 | 413 | |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | public function display() { |
421 | 421 | $singular = $this->_args['singular']; |
422 | 422 | |
423 | - $this->display_tablenav( 'top' ); |
|
423 | + $this->display_tablenav('top'); |
|
424 | 424 | |
425 | - $this->screen->render_screen_reader_content( 'heading_list' ); |
|
425 | + $this->screen->render_screen_reader_content('heading_list'); |
|
426 | 426 | ?> |
427 | - <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
427 | + <table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
428 | 428 | <thead> |
429 | 429 | <tr> |
430 | 430 | <?php $this->print_column_headers(); ?> |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | </thead> |
433 | 433 | |
434 | 434 | <tbody id="the-list"<?php |
435 | - if ( $singular ) { |
|
435 | + if ($singular) { |
|
436 | 436 | echo " data-wp-lists='list:$singular'"; |
437 | 437 | } ?>> |
438 | 438 | <tr class="hidden"></tr> |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | <td colspan="6" class="colspanchange"> |
441 | 441 | |
442 | 442 | <fieldset class="inline-edit-col-left"> |
443 | - <legend class="inline-edit-legend"><?php _e( 'BULK DELETE', 'give' ); ?></legend> |
|
443 | + <legend class="inline-edit-legend"><?php _e('BULK DELETE', 'give'); ?></legend> |
|
444 | 444 | <div class="inline-edit-col"> |
445 | 445 | <div id="bulk-titles"> |
446 | 446 | <div id="give-bulk-donors" class="give-bulk-donors"> |
@@ -453,22 +453,22 @@ discard block |
||
453 | 453 | <div class="inline-edit-col"> |
454 | 454 | <label> |
455 | 455 | <input id="give-delete-donor-confirm" type="checkbox" name="give-delete-donor-confirm"/> |
456 | - <?php _e( 'Are you sure you want to delete the selected donor(s)?', 'give' ); ?> |
|
456 | + <?php _e('Are you sure you want to delete the selected donor(s)?', 'give'); ?> |
|
457 | 457 | </label> |
458 | 458 | <label> |
459 | 459 | <input id="give-delete-donor-records" type="checkbox" name="give-delete-donor-records"/> |
460 | - <?php _e( 'Delete all associated donations and records?', 'give' ); ?> |
|
460 | + <?php _e('Delete all associated donations and records?', 'give'); ?> |
|
461 | 461 | </label> |
462 | 462 | </div> |
463 | 463 | </fieldset> |
464 | 464 | |
465 | 465 | <p class="submit inline-edit-save"> |
466 | 466 | <input type="hidden" name="give_action" value="delete_donor"/> |
467 | - <input type="hidden" name="s" value="<?php echo ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; ?>"/> |
|
468 | - <input type="hidden" name="orderby" value="<?php echo ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id'; ?>"/> |
|
469 | - <input type="hidden" name="order" value="<?php echo ( ! empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc'; ?>"/> |
|
470 | - <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e( 'Cancel', 'give' ); ?></button> |
|
471 | - <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e( 'Delete', 'give' ); ?>"> |
|
467 | + <input type="hidden" name="s" value="<?php echo ( ! empty($_GET['s'])) ? $_GET['s'] : ''; ?>"/> |
|
468 | + <input type="hidden" name="orderby" value="<?php echo ( ! empty($_GET['orderby'])) ? $_GET['orderby'] : 'id'; ?>"/> |
|
469 | + <input type="hidden" name="order" value="<?php echo ( ! empty($_GET['order'])) ? $_GET['order'] : 'desc'; ?>"/> |
|
470 | + <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e('Cancel', 'give'); ?></button> |
|
471 | + <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e('Delete', 'give'); ?>"> |
|
472 | 472 | <br class="clear"> |
473 | 473 | </p> |
474 | 474 | </td> |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | |
479 | 479 | <tfoot> |
480 | 480 | <tr> |
481 | - <?php $this->print_column_headers( false ); ?> |
|
481 | + <?php $this->print_column_headers(false); ?> |
|
482 | 482 | </tr> |
483 | 483 | </tfoot> |
484 | 484 | |
485 | 485 | </table> |
486 | 486 | <?php |
487 | - $this->display_tablenav( 'bottom' ); |
|
487 | + $this->display_tablenav('bottom'); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -501,16 +501,16 @@ discard block |
||
501 | 501 | $hidden = array(); // No hidden columns. |
502 | 502 | $sortable = $this->get_sortable_columns(); |
503 | 503 | |
504 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
504 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
505 | 505 | |
506 | 506 | $this->items = $this->donor_data(); |
507 | 507 | |
508 | 508 | $this->total = $this->get_donor_count(); |
509 | 509 | |
510 | - $this->set_pagination_args( array( |
|
510 | + $this->set_pagination_args(array( |
|
511 | 511 | 'total_items' => $this->total, |
512 | 512 | 'per_page' => $this->per_page, |
513 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
514 | - ) ); |
|
513 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
514 | + )); |
|
515 | 515 | } |
516 | 516 | } |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.8.13 |
21 | 21 | */ |
22 | 22 | function give_import_donation_report() { |
23 | - return get_option( 'give_import_donation_report', array() ); |
|
23 | + return get_option('give_import_donation_report', array()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8.13 |
31 | 31 | */ |
32 | -function give_import_donation_report_update( $value = array() ) { |
|
33 | - update_option( 'give_import_donation_report', $value ); |
|
32 | +function give_import_donation_report_update($value = array()) { |
|
33 | + update_option('give_import_donation_report', $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @since 1.8.13 |
41 | 41 | */ |
42 | 42 | function give_import_donation_report_reset() { |
43 | - update_option( 'give_import_donation_report', array() ); |
|
43 | + update_option('give_import_donation_report', array()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
54 | 54 | */ |
55 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
55 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
56 | 56 | $new_form = false; |
57 | 57 | |
58 | 58 | // Get the import report |
@@ -61,62 +61,62 @@ discard block |
||
61 | 61 | $form = false; |
62 | 62 | $meta = array(); |
63 | 63 | |
64 | - if ( ! empty( $data['form_id'] ) ) { |
|
65 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
64 | + if ( ! empty($data['form_id'])) { |
|
65 | + $form = new Give_Donate_Form($data['form_id']); |
|
66 | 66 | // Add support to older php version. |
67 | 67 | $form_id = $form->get_ID(); |
68 | - if ( empty( $form_id ) ) { |
|
69 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
68 | + if (empty($form_id)) { |
|
69 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
70 | 70 | $form = false; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
75 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
74 | + if (false === $form && ! empty($data['form_title'])) { |
|
75 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
76 | 76 | |
77 | - if ( ! empty( $form->ID ) ) { |
|
77 | + if ( ! empty($form->ID)) { |
|
78 | 78 | |
79 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
79 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
80 | 80 | |
81 | - $form = new Give_Donate_Form( $form->ID ); |
|
81 | + $form = new Give_Donate_Form($form->ID); |
|
82 | 82 | } else { |
83 | 83 | $form = new Give_Donate_Form(); |
84 | 84 | $args = array( |
85 | 85 | 'post_title' => $data['form_title'], |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | ); |
88 | - $form = $form->create( $args ); |
|
89 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
88 | + $form = $form->create($args); |
|
89 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
90 | 90 | $new_form = true; |
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
95 | - $form = new Give_Donate_Form( $form->ID ); |
|
94 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
95 | + $form = new Give_Donate_Form($form->ID); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $form ) && $form->get_ID() ) { |
|
98 | + if ( ! empty($form) && $form->get_ID()) { |
|
99 | 99 | |
100 | 100 | $price_option = 'set'; |
101 | - $form_level = strtolower( preg_replace('/\s+/', '', $data['form_level'] ) ); |
|
101 | + $form_level = strtolower(preg_replace('/\s+/', '', $data['form_level'])); |
|
102 | 102 | |
103 | - if ( ! empty( $data['form_level'] ) && 'custom' != $form_level ) { |
|
103 | + if ( ! empty($data['form_level']) && 'custom' != $form_level) { |
|
104 | 104 | $prices = (array) $form->get_prices(); |
105 | 105 | $price_text = array(); |
106 | - foreach ( $prices as $key => $price ) { |
|
107 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
108 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? strtolower( preg_replace('/\s+/', '', $price['_give_text'] ) ) : '' ); |
|
106 | + foreach ($prices as $key => $price) { |
|
107 | + if (isset($price['_give_id']['level_id'])) { |
|
108 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? strtolower(preg_replace('/\s+/', '', $price['_give_text'])) : ''); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! in_array( $form_level, $price_text ) ) { |
|
112 | + if ( ! in_array($form_level, $price_text)) { |
|
113 | 113 | |
114 | 114 | // For generating unquiet level id. |
115 | 115 | $count = 1; |
116 | - $new_level = count( $prices ) + $count; |
|
117 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
118 | - $count ++; |
|
119 | - $new_level = count( $prices ) + $count; |
|
116 | + $new_level = count($prices) + $count; |
|
117 | + while (array_key_exists($new_level, $price_text)) { |
|
118 | + $count++; |
|
119 | + $new_level = count($prices) + $count; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $multi_level_donations = array( |
@@ -124,42 +124,42 @@ discard block |
||
124 | 124 | '_give_id' => array( |
125 | 125 | 'level_id' => $new_level, |
126 | 126 | ), |
127 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
127 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
128 | 128 | '_give_text' => $data['form_level'], |
129 | 129 | ), |
130 | 130 | ); |
131 | 131 | |
132 | - $price_text[ $new_level ] = strtolower( preg_replace('/\s+/', '', $data['form_level'] ) ); |
|
132 | + $price_text[$new_level] = strtolower(preg_replace('/\s+/', '', $data['form_level'])); |
|
133 | 133 | |
134 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
135 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
134 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
135 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
136 | 136 | |
137 | 137 | // Sort $prices by amount in ascending order. |
138 | - $prices = wp_list_sort( $prices, '_give_amount', 'ASC' ); |
|
138 | + $prices = wp_list_sort($prices, '_give_amount', 'ASC'); |
|
139 | 139 | } else { |
140 | 140 | $prices = $multi_level_donations; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Unset _give_default key from $prices. |
144 | - foreach ( $prices as $key => $price ) { |
|
145 | - if ( isset( $prices[ $key ]['_give_default'] ) ) { |
|
146 | - unset( $prices[ $key ]['_give_default'] ); |
|
144 | + foreach ($prices as $key => $price) { |
|
145 | + if (isset($prices[$key]['_give_default'])) { |
|
146 | + unset($prices[$key]['_give_default']); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Set the first $price of the $prices as defalut. |
151 | 151 | $prices[0]['_give_default'] = 'default'; |
152 | 152 | } |
153 | - $form->price_id = array_search( $form_level, $price_text ); |
|
153 | + $form->price_id = array_search($form_level, $price_text); |
|
154 | 154 | |
155 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
156 | - $min_amount = min( $donation_levels_amounts ); |
|
157 | - $max_amount = max( $donation_levels_amounts ); |
|
155 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
156 | + $min_amount = min($donation_levels_amounts); |
|
157 | + $max_amount = max($donation_levels_amounts); |
|
158 | 158 | |
159 | 159 | $meta = array( |
160 | 160 | '_give_levels_minimum_amount' => $min_amount, |
161 | 161 | '_give_levels_maximum_amount' => $max_amount, |
162 | - '_give_donation_levels' => array_values( $prices ), |
|
162 | + '_give_donation_levels' => array_values($prices), |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | $price_option = 'multi'; |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | $defaults = array( |
171 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
171 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
172 | 172 | ); |
173 | 173 | |
174 | 174 | // If new form is created. |
175 | - if ( ! empty( $new_form ) ) { |
|
175 | + if ( ! empty($new_form)) { |
|
176 | 176 | $new_form = array( |
177 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
177 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
178 | 178 | '_give_logged_in_only' => 'enabled', |
179 | 179 | '_give_custom_amount' => 'enabled', |
180 | 180 | '_give_payment_import' => true, |
@@ -186,18 +186,18 @@ discard block |
||
186 | 186 | '_give_show_register_form' => 'both', |
187 | 187 | '_give_price_option' => $price_option, |
188 | 188 | ); |
189 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
189 | + $defaults = wp_parse_args($defaults, $new_form); |
|
190 | 190 | } |
191 | 191 | |
192 | - $meta = wp_parse_args( $meta, $defaults ); |
|
192 | + $meta = wp_parse_args($meta, $defaults); |
|
193 | 193 | |
194 | - foreach ( $meta as $key => $value ) { |
|
195 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
194 | + foreach ($meta as $key => $value) { |
|
195 | + give_update_meta($form->get_ID(), $key, $value); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | // update the report |
200 | - give_import_donation_report_update( $report ); |
|
200 | + give_import_donation_report_update($report); |
|
201 | 201 | |
202 | 202 | return $form; |
203 | 203 | } |
@@ -211,30 +211,30 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return bool|false|WP_User |
213 | 213 | */ |
214 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
214 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
215 | 215 | $report = give_import_donation_report(); |
216 | 216 | $donor_data = false; |
217 | 217 | $donor_id = false; |
218 | 218 | |
219 | 219 | // check if donor id is not empty |
220 | - if ( ! empty( $data['donor_id'] ) ) { |
|
221 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
222 | - if ( ! empty( $donor_data->id ) ) { |
|
223 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
220 | + if ( ! empty($data['donor_id'])) { |
|
221 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
222 | + if ( ! empty($donor_data->id)) { |
|
223 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
227 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
228 | 228 | $user_id = (int) $data['user_id']; |
229 | - $donor_data = new Give_Donor( $user_id, true ); |
|
229 | + $donor_data = new Give_Donor($user_id, true); |
|
230 | 230 | |
231 | 231 | |
232 | - if ( empty( $donor_data->id ) ) { |
|
233 | - $donor_data = get_user_by( 'id', $user_id ); |
|
234 | - if ( ! empty( $donor_data->ID ) ) { |
|
235 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
236 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
237 | - $name = $first_name . ' ' . $last_name; |
|
232 | + if (empty($donor_data->id)) { |
|
233 | + $donor_data = get_user_by('id', $user_id); |
|
234 | + if ( ! empty($donor_data->ID)) { |
|
235 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
236 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
237 | + $name = $first_name.' '.$last_name; |
|
238 | 238 | $user_email = $donor_data->user_email; |
239 | 239 | $donor_args = array( |
240 | 240 | 'name' => $name, |
@@ -243,45 +243,45 @@ discard block |
||
243 | 243 | ); |
244 | 244 | |
245 | 245 | $donor_data = new Give_Donor(); |
246 | - $donor_data->create( $donor_args ); |
|
246 | + $donor_data->create($donor_args); |
|
247 | 247 | |
248 | 248 | // Adding notes that donor is being imported from CSV. |
249 | 249 | $current_user = wp_get_current_user(); |
250 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
250 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
251 | 251 | |
252 | 252 | // Add is used to ensure duplicate emails are not added |
253 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
254 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
253 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
254 | + $donor_data->add_meta('additional_email', $data['email']); |
|
255 | 255 | } |
256 | 256 | |
257 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
257 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
258 | 258 | } |
259 | 259 | } else { |
260 | 260 | // Add is used to ensure duplicate emails are not added |
261 | - if ( $donor_data->email != $data['email'] ) { |
|
262 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
261 | + if ($donor_data->email != $data['email']) { |
|
262 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
263 | 263 | } |
264 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
264 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
268 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
269 | 269 | |
270 | - $donor_data = new Give_Donor( $data['email'] ); |
|
271 | - if ( empty( $donor_data->id ) ) { |
|
272 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
270 | + $donor_data = new Give_Donor($data['email']); |
|
271 | + if (empty($donor_data->id)) { |
|
272 | + $donor_data = get_user_by('email', $data['email']); |
|
273 | 273 | |
274 | - if ( empty( $donor_data->ID ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
275 | - $data['first_name'] = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $data['email'] ); |
|
276 | - $data['last_name'] = ( ! empty( $data['last_name'] ) ? $data['last_name'] : '' ); |
|
277 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
274 | + if (empty($donor_data->ID) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
275 | + $data['first_name'] = ( ! empty($data['first_name']) ? $data['first_name'] : $data['email']); |
|
276 | + $data['last_name'] = ( ! empty($data['last_name']) ? $data['last_name'] : ''); |
|
277 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
278 | 278 | $donor_args = array( |
279 | 279 | 'user_login' => $data['email'], |
280 | 280 | 'user_email' => $data['email'], |
281 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
281 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
282 | 282 | 'user_first' => $data['first_name'], |
283 | 283 | 'user_last' => $data['last_name'], |
284 | - 'user_pass' => wp_generate_password( 8, true ), |
|
284 | + 'user_pass' => wp_generate_password(8, true), |
|
285 | 285 | 'role' => $give_role, |
286 | 286 | ); |
287 | 287 | |
@@ -290,55 +290,55 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @since 1.8.13 |
292 | 292 | */ |
293 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
293 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
294 | 294 | |
295 | 295 | // This action was added to remove the login when using the give register function. |
296 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
297 | - $donor_id = give_register_and_login_new_user( $donor_args ); |
|
298 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
296 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
297 | + $donor_id = give_register_and_login_new_user($donor_args); |
|
298 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
299 | 299 | |
300 | - update_user_meta( $donor_id, '_give_payment_import', true ); |
|
301 | - $donor_data = new Give_Donor( $donor_id, true ); |
|
300 | + update_user_meta($donor_id, '_give_payment_import', true); |
|
301 | + $donor_data = new Give_Donor($donor_id, true); |
|
302 | 302 | } else { |
303 | - $donor_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
303 | + $donor_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
304 | 304 | } |
305 | 305 | |
306 | - if ( ! empty( $donor_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
307 | - $donor_data = new Give_Donor( $donor_id, true ); |
|
306 | + if ( ! empty($donor_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
307 | + $donor_data = new Give_Donor($donor_id, true); |
|
308 | 308 | |
309 | - if ( empty( $donor_data->id ) ) { |
|
309 | + if (empty($donor_data->id)) { |
|
310 | 310 | |
311 | - if ( ! empty( $data['form_id'] ) ) { |
|
312 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
311 | + if ( ! empty($data['form_id'])) { |
|
312 | + $form = new Give_Donate_Form($data['form_id']); |
|
313 | 313 | } |
314 | 314 | |
315 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
315 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
316 | 316 | $donor_args = array( |
317 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
317 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
318 | 318 | 'email' => $data['email'], |
319 | 319 | ); |
320 | 320 | |
321 | - if ( ! empty( $donor_id ) ) { |
|
321 | + if ( ! empty($donor_id)) { |
|
322 | 322 | $donor_args['user_id'] = $donor_id; |
323 | 323 | } |
324 | 324 | |
325 | - $donor_data->create( $donor_args ); |
|
325 | + $donor_data->create($donor_args); |
|
326 | 326 | |
327 | 327 | // Adding notes that donor is being imported from CSV. |
328 | 328 | $current_user = wp_get_current_user(); |
329 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
329 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
330 | 330 | |
331 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
331 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
332 | 332 | } else { |
333 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
333 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } else { |
337 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
337 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | // update the report |
341 | - give_import_donation_report_update( $report ); |
|
341 | + give_import_donation_report_update($report); |
|
342 | 342 | |
343 | 343 | return $donor_data; |
344 | 344 | } |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return array |
358 | 358 | */ |
359 | - return (array) apply_filters( 'give_import_default_options', array( |
|
360 | - '' => __( 'Do not import', 'give' ), |
|
361 | - ) ); |
|
359 | + return (array) apply_filters('give_import_default_options', array( |
|
360 | + '' => __('Do not import', 'give'), |
|
361 | + )); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -374,62 +374,62 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @return array |
376 | 376 | */ |
377 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
378 | - 'id' => __( 'Donation ID', 'give' ), |
|
377 | + return (array) apply_filters('give_import_donations_options', array( |
|
378 | + 'id' => __('Donation ID', 'give'), |
|
379 | 379 | 'amount' => array( |
380 | - __( 'Donation Amount', 'give' ), |
|
381 | - __( 'Amount', 'give' ) |
|
380 | + __('Donation Amount', 'give'), |
|
381 | + __('Amount', 'give') |
|
382 | 382 | ), |
383 | 383 | 'post_date' => array( |
384 | - __( 'Donation Date', 'give' ), |
|
385 | - __( 'Date', 'give' ), |
|
384 | + __('Donation Date', 'give'), |
|
385 | + __('Date', 'give'), |
|
386 | 386 | ), |
387 | 387 | 'first_name' => array( |
388 | - __( 'Donor First Name', 'give' ), |
|
389 | - __( 'First Name', 'give' ), |
|
390 | - __( 'Name', 'give' ), |
|
388 | + __('Donor First Name', 'give'), |
|
389 | + __('First Name', 'give'), |
|
390 | + __('Name', 'give'), |
|
391 | 391 | ), |
392 | 392 | 'last_name' => array( |
393 | - __( 'Donor Last Name', 'give' ), |
|
394 | - __( 'Last Name', 'give' ), |
|
393 | + __('Donor Last Name', 'give'), |
|
394 | + __('Last Name', 'give'), |
|
395 | 395 | ), |
396 | 396 | 'line1' => array( |
397 | - __( 'Address 1', 'give' ), |
|
398 | - __( 'Address', 'give' ), |
|
397 | + __('Address 1', 'give'), |
|
398 | + __('Address', 'give'), |
|
399 | 399 | ), |
400 | - 'line2' => __( 'Address 2', 'give' ), |
|
401 | - 'city' => __( 'City', 'give' ), |
|
400 | + 'line2' => __('Address 2', 'give'), |
|
401 | + 'city' => __('City', 'give'), |
|
402 | 402 | 'state' => array( |
403 | - __( 'State', 'give' ), |
|
404 | - __( 'Province', 'give' ), |
|
405 | - __( 'County', 'give' ), |
|
406 | - __( 'Region', 'give' ), |
|
403 | + __('State', 'give'), |
|
404 | + __('Province', 'give'), |
|
405 | + __('County', 'give'), |
|
406 | + __('Region', 'give'), |
|
407 | 407 | ), |
408 | - 'country' => __( 'Country', 'give' ), |
|
408 | + 'country' => __('Country', 'give'), |
|
409 | 409 | 'zip' => array( |
410 | - __( 'Zip', 'give' ), |
|
411 | - __( 'Zip Code', 'give' ), |
|
412 | - __( 'Postal Code', 'give' ), |
|
410 | + __('Zip', 'give'), |
|
411 | + __('Zip Code', 'give'), |
|
412 | + __('Postal Code', 'give'), |
|
413 | 413 | ), |
414 | 414 | 'email' => array( |
415 | - __( 'Donor Email', 'give' ), |
|
416 | - __( 'Email', 'give' ) |
|
415 | + __('Donor Email', 'give'), |
|
416 | + __('Email', 'give') |
|
417 | 417 | ), |
418 | 418 | 'post_status' => array( |
419 | - __( 'Donation Status', 'give' ), |
|
420 | - __( 'Status', 'give' ), |
|
419 | + __('Donation Status', 'give'), |
|
420 | + __('Status', 'give'), |
|
421 | 421 | ), |
422 | 422 | 'gateway' => array( |
423 | - __( 'Payment Method', 'give' ), |
|
424 | - __( 'Method', 'give' ), |
|
423 | + __('Payment Method', 'give'), |
|
424 | + __('Method', 'give'), |
|
425 | 425 | ), |
426 | - 'notes' => __( 'Notes', 'give' ), |
|
426 | + 'notes' => __('Notes', 'give'), |
|
427 | 427 | 'mode' => array( |
428 | - __( 'Test Mode', 'give' ), |
|
429 | - __( 'Mode', 'give' ), |
|
428 | + __('Test Mode', 'give'), |
|
429 | + __('Mode', 'give'), |
|
430 | 430 | ), |
431 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
432 | - ) ); |
|
431 | + 'post_meta' => __('Import as Meta', 'give'), |
|
432 | + )); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -445,10 +445,10 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return array |
447 | 447 | */ |
448 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
449 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
450 | - 'user_id' => __( 'User ID', 'give' ), |
|
451 | - ) ); |
|
448 | + return (array) apply_filters('give_import_donor_options', array( |
|
449 | + 'donor_id' => __('Donor ID', 'give'), |
|
450 | + 'user_id' => __('User ID', 'give'), |
|
451 | + )); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -464,23 +464,23 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return array |
466 | 466 | */ |
467 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
467 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
468 | 468 | 'form_title' => array( |
469 | - __( 'Donation Form Title', 'give' ), |
|
470 | - __( 'Donation Form', 'give' ), |
|
471 | - __( 'Form Name', 'give' ), |
|
472 | - __( 'Title', 'give' ), |
|
469 | + __('Donation Form Title', 'give'), |
|
470 | + __('Donation Form', 'give'), |
|
471 | + __('Form Name', 'give'), |
|
472 | + __('Title', 'give'), |
|
473 | 473 | ), |
474 | 474 | 'form_id' => array( |
475 | - __( 'Donation Form ID', 'give' ), |
|
476 | - __( 'Form ID', 'give' ) |
|
475 | + __('Donation Form ID', 'give'), |
|
476 | + __('Form ID', 'give') |
|
477 | 477 | ), |
478 | 478 | 'form_level' => array( |
479 | - __( 'Donation Level', 'give' ), |
|
480 | - __( 'Level', 'give' ), |
|
479 | + __('Donation Level', 'give'), |
|
480 | + __('Level', 'give'), |
|
481 | 481 | ), |
482 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
483 | - ) ); |
|
482 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
483 | + )); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return array |
495 | 495 | */ |
496 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
496 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
497 | 497 | /** |
498 | 498 | * Filter to modify delimiter of Import. |
499 | 499 | * |
@@ -502,19 +502,19 @@ discard block |
||
502 | 502 | * |
503 | 503 | * Return string $delimiter. |
504 | 504 | */ |
505 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
505 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
506 | 506 | |
507 | 507 | $raw_data = array(); |
508 | - $file_dir = get_attached_file( $file_id ); |
|
508 | + $file_dir = get_attached_file($file_id); |
|
509 | 509 | $count = 0; |
510 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
511 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
512 | - if ( $count >= $start && $count <= $end ) { |
|
510 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
511 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
512 | + if ($count >= $start && $count <= $end) { |
|
513 | 513 | $raw_data[] = $row; |
514 | 514 | } |
515 | - $count ++; |
|
515 | + $count++; |
|
516 | 516 | } |
517 | - fclose( $handle ); |
|
517 | + fclose($handle); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | return $raw_data; |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return bool |
532 | 532 | */ |
533 | -function give_log_user_in_on_register_callback( $value ) { |
|
533 | +function give_log_user_in_on_register_callback($value) { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | 536 | |
@@ -546,22 +546,22 @@ discard block |
||
546 | 546 | * |
547 | 547 | * @return bool |
548 | 548 | */ |
549 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
550 | - $data = array_combine( $raw_key, $row_data ); |
|
549 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
550 | + $data = array_combine($raw_key, $row_data); |
|
551 | 551 | $price_id = false; |
552 | 552 | $donor_id = 0; |
553 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
553 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
554 | 554 | |
555 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
555 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
556 | 556 | |
557 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
557 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
558 | 558 | |
559 | 559 | // Here come the login function. |
560 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
561 | - if ( ! empty( $donor_data->id ) ) { |
|
562 | - if ( ! empty( $donor_data->user_id ) ) { |
|
560 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
561 | + if ( ! empty($donor_data->id)) { |
|
562 | + if ( ! empty($donor_data->user_id)) { |
|
563 | 563 | $donor_id = $donor_data->user_id; |
564 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
564 | + } elseif ( ! empty($data['user_id'])) { |
|
565 | 565 | $donor_id = $data['user_id']; |
566 | 566 | } |
567 | 567 | } else { |
@@ -569,24 +569,24 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | // get form data or register a form data. |
572 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
573 | - if ( false == $form ) { |
|
572 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
573 | + if (false == $form) { |
|
574 | 574 | return false; |
575 | 575 | } else { |
576 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
576 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | - $status = give_import_donation_get_status( $data ); |
|
580 | + $status = give_import_donation_get_status($data); |
|
581 | 581 | |
582 | 582 | |
583 | 583 | $address = array( |
584 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
585 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
586 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
587 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
588 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
589 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
584 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
585 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
586 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
587 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
588 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
589 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
590 | 590 | ); |
591 | 591 | |
592 | 592 | //Create payment_data array |
@@ -597,72 +597,72 @@ discard block |
||
597 | 597 | 'currency' => give_get_currency(), |
598 | 598 | 'user_info' => array( |
599 | 599 | 'id' => $donor_id, |
600 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
601 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $donor_id ) && ( $first_name = get_user_meta( $donor_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
602 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $donor_id ) && ( $last_name = get_user_meta( $donor_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
600 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
601 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($donor_id) && ($first_name = get_user_meta($donor_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
602 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($donor_id) && ($last_name = get_user_meta($donor_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
603 | 603 | 'address' => $address, |
604 | 604 | ), |
605 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
606 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
605 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
606 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
607 | 607 | 'give_form_id' => (string) $form->get_ID(), |
608 | 608 | 'give_price_id' => $price_id, |
609 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
609 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
610 | 610 | 'user_email' => $data['email'], |
611 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
612 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
611 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
612 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
613 | 613 | ); |
614 | 614 | |
615 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
615 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
616 | 616 | |
617 | 617 | // Get the report |
618 | 618 | $report = give_import_donation_report(); |
619 | 619 | |
620 | 620 | // Check for duplicate code. |
621 | - $donation_duplicate = give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ); |
|
622 | - if ( false !== $donation_duplicate ) { |
|
623 | - $report['donation_details'][ $import_setting['donation_key'] ]['duplicate'] = $donation_duplicate; |
|
624 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
621 | + $donation_duplicate = give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data); |
|
622 | + if (false !== $donation_duplicate) { |
|
623 | + $report['donation_details'][$import_setting['donation_key']]['duplicate'] = $donation_duplicate; |
|
624 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
625 | 625 | } else { |
626 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
627 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
628 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
629 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
630 | - $payment = give_insert_payment( $payment_data ); |
|
631 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
632 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
633 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
634 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
626 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
627 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
628 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
629 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
630 | + $payment = give_insert_payment($payment_data); |
|
631 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
632 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
633 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
634 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
635 | 635 | |
636 | - if ( $payment ) { |
|
636 | + if ($payment) { |
|
637 | 637 | |
638 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
638 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
639 | 639 | |
640 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
640 | + update_post_meta($payment, '_give_payment_import', true); |
|
641 | 641 | |
642 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
643 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
642 | + if ( ! empty($import_setting['csv'])) { |
|
643 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | // Insert Notes. |
647 | - if ( ! empty( $data['notes'] ) ) { |
|
648 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
647 | + if ( ! empty($data['notes'])) { |
|
648 | + give_insert_payment_note($payment, $data['notes']); |
|
649 | 649 | } |
650 | 650 | |
651 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
652 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
653 | - foreach ( $meta_exists as $meta_exist ) { |
|
654 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
655 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
651 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
652 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
653 | + foreach ($meta_exists as $meta_exist) { |
|
654 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
655 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | } |
659 | 659 | } else { |
660 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
660 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | |
664 | 664 | // update the report |
665 | - give_import_donation_report_update( $report ); |
|
665 | + give_import_donation_report_update($report); |
|
666 | 666 | |
667 | 667 | return true; |
668 | 668 | } |
@@ -676,25 +676,25 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return string $status Donation status. |
678 | 678 | */ |
679 | -function give_import_donation_get_status( $data ) { |
|
680 | - if ( empty( $data['post_status'] ) ) { |
|
679 | +function give_import_donation_get_status($data) { |
|
680 | + if (empty($data['post_status'])) { |
|
681 | 681 | return 'publish'; |
682 | 682 | } |
683 | 683 | |
684 | 684 | $status = 'publish'; |
685 | 685 | |
686 | - $donation_status = trim( $data['post_status'] ); |
|
687 | - $donation_status_key = strtolower( preg_replace( '/\s+/', '', $donation_status ) ); |
|
686 | + $donation_status = trim($data['post_status']); |
|
687 | + $donation_status_key = strtolower(preg_replace('/\s+/', '', $donation_status)); |
|
688 | 688 | |
689 | - foreach ( give_get_payment_statuses() as $key => $value ) { |
|
689 | + foreach (give_get_payment_statuses() as $key => $value) { |
|
690 | 690 | $match = false; |
691 | - if ( $key === $donation_status_key ) { |
|
691 | + if ($key === $donation_status_key) { |
|
692 | 692 | $match = true; |
693 | - } else if ( stristr( $donation_status, $value ) ) { |
|
693 | + } else if (stristr($donation_status, $value)) { |
|
694 | 694 | $match = true; |
695 | 695 | } |
696 | 696 | |
697 | - if ( ! empty( $match ) ) { |
|
697 | + if ( ! empty($match)) { |
|
698 | 698 | $status = $key; |
699 | 699 | break; |
700 | 700 | } |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @return Give_Donor |
716 | 716 | */ |
717 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
717 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
718 | 718 | $old_donor = $donor; |
719 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
720 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
721 | - $donor = new Give_Donor( $donor_id ); |
|
722 | - if ( ! empty( $donor->id ) ) { |
|
719 | + if ( ! empty($payment_data['donor_id'])) { |
|
720 | + $donor_id = absint($payment_data['donor_id']); |
|
721 | + $donor = new Give_Donor($donor_id); |
|
722 | + if ( ! empty($donor->id)) { |
|
723 | 723 | return $donor; |
724 | 724 | } |
725 | 725 | } |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @since 1.8.13 |
734 | 734 | */ |
735 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
735 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
736 | 736 | // Update Give Customers purchase_count |
737 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
738 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
739 | - if ( ! empty( $donor_id ) ) { |
|
740 | - $donor = new Give_Donor( $donor_id ); |
|
737 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
738 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
739 | + if ( ! empty($donor_id)) { |
|
740 | + $donor = new Give_Donor($donor_id); |
|
741 | 741 | $donor->increase_purchase_count(); |
742 | 742 | } |
743 | 743 | } |
@@ -748,8 +748,8 @@ discard block |
||
748 | 748 | * |
749 | 749 | * @since 1.8.13 |
750 | 750 | */ |
751 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
752 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
751 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
752 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
753 | 753 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
754 | 754 | } |
755 | 755 | |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @since 1.8.13 |
763 | 763 | */ |
764 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
764 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
765 | 765 | $return = false; |
766 | - if ( ! empty( $data['post_date'] ) ) { |
|
767 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
768 | - $post_date = explode( '-', $post_date ); |
|
766 | + if ( ! empty($data['post_date'])) { |
|
767 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
768 | + $post_date = explode('-', $post_date); |
|
769 | 769 | $args = array( |
770 | 770 | 'output' => 'post', |
771 | 771 | 'cache_results' => false, |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | 'meta_query' => array( |
787 | 787 | array( |
788 | 788 | 'key' => '_give_payment_total', |
789 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
789 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
790 | 790 | 'compare' => 'LIKE', |
791 | 791 | ), |
792 | 792 | array( |
@@ -808,9 +808,9 @@ discard block |
||
808 | 808 | ), |
809 | 809 | ); |
810 | 810 | |
811 | - $payments = new Give_Payments_Query( $args ); |
|
811 | + $payments = new Give_Payments_Query($args); |
|
812 | 812 | $donations = $payments->get_payments(); |
813 | - if ( ! empty( $donations ) ) { |
|
813 | + if ( ! empty($donations)) { |
|
814 | 814 | $return = $donations; |
815 | 815 | } |
816 | 816 | } |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @since 1.8.18 |
822 | 822 | */ |
823 | - return apply_filters( 'give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data ); |
|
823 | + return apply_filters('give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
@@ -832,9 +832,9 @@ discard block |
||
832 | 832 | * |
833 | 833 | * @return void |
834 | 834 | */ |
835 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
835 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
836 | 836 | $current_user = wp_get_current_user(); |
837 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
837 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return string URL |
848 | 848 | */ |
849 | -function give_import_page_url( $parameter = array() ) { |
|
849 | +function give_import_page_url($parameter = array()) { |
|
850 | 850 | $defalut_query_arg = array( |
851 | 851 | 'post_type' => 'give_forms', |
852 | 852 | 'page' => 'give-tools', |
853 | 853 | 'tab' => 'import', |
854 | 854 | 'importer-type' => 'import_donations', |
855 | 855 | ); |
856 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
856 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
857 | 857 | |
858 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
858 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
859 | 859 | } |
860 | 860 | \ No newline at end of file |
@@ -928,10 +928,10 @@ discard block |
||
928 | 928 | <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
929 | 929 | > |
930 | 930 | <?php |
931 | - foreach ( $countries as $country_code => $country ) { |
|
932 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
933 | - } |
|
934 | - ?> |
|
931 | + foreach ( $countries as $country_code => $country ) { |
|
932 | + echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
933 | + } |
|
934 | + ?> |
|
935 | 935 | </select> |
936 | 936 | </p> |
937 | 937 | |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | <label for="card_state" class="give-label"> |
1001 | 1001 | <span class="state-label-text"><?php echo $label; ?></span> |
1002 | 1002 | <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
1003 | - ?> |
|
1003 | + ?> |
|
1004 | 1004 | <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
1005 | 1005 | <?php endif; ?> |
1006 | 1006 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1008,17 +1008,17 @@ discard block |
||
1008 | 1008 | </label> |
1009 | 1009 | <?php |
1010 | 1010 | |
1011 | - if ( ! empty( $states ) ) : ?> |
|
1011 | + if ( ! empty( $states ) ) : ?> |
|
1012 | 1012 | <select |
1013 | 1013 | name="card_state" |
1014 | 1014 | id="card_state" |
1015 | 1015 | class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
1016 | 1016 | <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
1017 | 1017 | <?php |
1018 | - foreach ( $states as $state_code => $state ) { |
|
1019 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1020 | - } |
|
1021 | - ?> |
|
1018 | + foreach ( $states as $state_code => $state ) { |
|
1019 | + echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1020 | + } |
|
1021 | + ?> |
|
1022 | 1022 | </select> |
1023 | 1023 | <?php else : ?> |
1024 | 1024 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
@@ -1218,8 +1218,8 @@ discard block |
||
1218 | 1218 | <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
1219 | 1219 | data-action="give_checkout_register"> |
1220 | 1220 | <?php if ( give_logged_in_only( $form_id ) ) { |
1221 | - _e( 'Register as a part of your donation »', 'give' ); |
|
1222 | - } else { |
|
1221 | + _e( 'Register as a part of your donation »', 'give' ); |
|
1222 | + } else { |
|
1223 | 1223 | _e( 'Register or donate as a guest »', 'give' ); |
1224 | 1224 | } ?> |
1225 | 1225 | </a> |
@@ -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,50 +23,50 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | |
30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
31 | 31 | |
32 | - if ( isset( $args['id'] ) ) { |
|
32 | + if (isset($args['id'])) { |
|
33 | 33 | $form_id = $args['id']; |
34 | 34 | } |
35 | 35 | |
36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
37 | 37 | 'form_id' => $form_id, |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | |
40 | - $args = wp_parse_args( $args, $defaults ); |
|
40 | + $args = wp_parse_args($args, $defaults); |
|
41 | 41 | |
42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
42 | + $form = new Give_Donate_Form($args['form_id']); |
|
43 | 43 | |
44 | 44 | //bail if no form ID. |
45 | - if ( empty( $form->ID ) ) { |
|
45 | + if (empty($form->ID)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
50 | 50 | |
51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
52 | 52 | 'payment-mode' => $payment_mode, |
53 | - ) ), |
|
53 | + )), |
|
54 | 54 | give_get_current_page_url() |
55 | 55 | ); |
56 | 56 | |
57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
58 | 58 | if ( |
59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
60 | - || ( 'trash' === $form->post_status ) |
|
59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
60 | + || ('trash' === $form->post_status) |
|
61 | 61 | ) { |
62 | 62 | return false; |
63 | 63 | } |
64 | 64 | |
65 | 65 | //Get the form wrap CSS classes. |
66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
67 | 67 | |
68 | 68 | //Get the <form> tag wrap CSS classes. |
69 | - $form_classes = $form->get_form_classes( $args ); |
|
69 | + $form_classes = $form->get_form_classes($args); |
|
70 | 70 | |
71 | 71 | ob_start(); |
72 | 72 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | * @param int $form_id The form ID. |
79 | 79 | * @param array $args An array of form arguments. |
80 | 80 | */ |
81 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
81 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
82 | 82 | |
83 | 83 | ?> |
84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
85 | 85 | |
86 | - <?php if ( $form->is_close_donation_form() ) { |
|
86 | + <?php if ($form->is_close_donation_form()) { |
|
87 | 87 | |
88 | 88 | // Get Goal thank you message. |
89 | - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
90 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
89 | + $goal_achieved_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
90 | + $goal_achieved_message = ! empty($goal_achieved_message) ? apply_filters('the_content', $goal_achieved_message) : ''; |
|
91 | 91 | |
92 | 92 | // Print thank you message. |
93 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
93 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
94 | 94 | |
95 | 95 | } else { |
96 | 96 | /** |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | * 1. if show_title params set to true |
99 | 99 | * 2. if admin set form display_style to button |
100 | 100 | */ |
101 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
101 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
102 | 102 | if ( |
103 | 103 | ( |
104 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
105 | - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
|
104 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
105 | + || ('button' === get_post_meta($form_id, '_give_payment_display', true)) |
|
106 | 106 | ) |
107 | - && ! doing_action( 'give_single_form_summary' ) |
|
107 | + && ! doing_action('give_single_form_summary') |
|
108 | 108 | ) { |
109 | 109 | echo $form_title; |
110 | 110 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param array $args An array of form arguments. |
119 | 119 | * @param Give_Donate_Form $form Form object. |
120 | 120 | */ |
121 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
121 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
122 | 122 | |
123 | 123 | // Set form html tags. |
124 | 124 | $form_html_tags = array( |
125 | 125 | 'id' => "give-form-{$form_id}", |
126 | 126 | 'class' => $form_classes, |
127 | - 'action' => esc_url_raw( $form_action ), |
|
127 | + 'action' => esc_url_raw($form_action), |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | /** |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * @param array $form_html_tags Array of form html tags. |
136 | 136 | * @param Give_Donate_Form $form Form object. |
137 | 137 | */ |
138 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
138 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
139 | 139 | ?> |
140 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
140 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
141 | 141 | |
142 | 142 | <!-- The following field is for robots only, invisible to humans: --> |
143 | 143 | <span class="give-hidden" style="display: none !important;"> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param array $args An array of form arguments. |
157 | 157 | * @param Give_Donate_Form $form Form object. |
158 | 158 | */ |
159 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
159 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Fires while outputting donation form, for payment gateway fields. |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param array $args An array of form arguments. |
168 | 168 | * @param Give_Donate_Form $form Form object. |
169 | 169 | */ |
170 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
170 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Fires while outputting donation form, after all other fields. |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param array $args An array of form arguments. |
179 | 179 | * @param Give_Donate_Form $form Form object. |
180 | 180 | */ |
181 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
181 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
182 | 182 | |
183 | 183 | ?> |
184 | 184 | </form> |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * @param array $args An array of form arguments. |
194 | 194 | * @param Give_Donate_Form $form Form object. |
195 | 195 | */ |
196 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
196 | + do_action('give_post_form', $form->ID, $args, $form); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | ?> |
200 | 200 | |
201 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
201 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
202 | 202 | <?php |
203 | 203 | |
204 | 204 | /** |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param int $form_id The form ID. |
210 | 210 | * @param array $args An array of form arguments. |
211 | 211 | */ |
212 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
212 | + do_action('give_post_form_output', $form->ID, $args); |
|
213 | 213 | |
214 | 214 | $final_output = ob_get_clean(); |
215 | 215 | |
216 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
216 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return string |
232 | 232 | */ |
233 | -function give_show_purchase_form( $form_id ) { |
|
233 | +function give_show_purchase_form($form_id) { |
|
234 | 234 | |
235 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
235 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
236 | 236 | |
237 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
237 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
238 | 238 | $form_id = $_POST['give_form_id']; |
239 | 239 | } |
240 | 240 | |
@@ -243,33 +243,33 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @since 1.7 |
245 | 245 | */ |
246 | - do_action( 'give_payment_fields_top', $form_id ); |
|
246 | + do_action('give_payment_fields_top', $form_id); |
|
247 | 247 | |
248 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
248 | + if (give_can_checkout() && isset($form_id)) { |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Fires while displaying donation form, before registration login. |
252 | 252 | * |
253 | 253 | * @since 1.7 |
254 | 254 | */ |
255 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
255 | + do_action('give_donation_form_before_register_login', $form_id); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Fire when register/login form fields render. |
259 | 259 | * |
260 | 260 | * @since 1.7 |
261 | 261 | */ |
262 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
262 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Fire when credit card form fields render. |
266 | 266 | * |
267 | 267 | * @since 1.7 |
268 | 268 | */ |
269 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
269 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
270 | 270 | |
271 | 271 | // Load the credit card form and allow gateways to load their own if they wish. |
272 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
272 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
273 | 273 | /** |
274 | 274 | * Fires while displaying donation form, credit card form fields for a given gateway. |
275 | 275 | * |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @param int $form_id The form ID. |
279 | 279 | */ |
280 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
280 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
281 | 281 | } else { |
282 | 282 | /** |
283 | 283 | * Fires while displaying donation form, credit card form fields. |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param int $form_id The form ID. |
288 | 288 | */ |
289 | - do_action( 'give_cc_form', $form_id ); |
|
289 | + do_action('give_cc_form', $form_id); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @since 1.7 |
296 | 296 | */ |
297 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
297 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
298 | 298 | |
299 | 299 | } else { |
300 | 300 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @since 1.7 |
304 | 304 | */ |
305 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
305 | + do_action('give_donation_form_no_access', $form_id); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @since 1.7 |
313 | 313 | */ |
314 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
314 | + do_action('give_payment_fields_bottom', $form_id); |
|
315 | 315 | } |
316 | 316 | |
317 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
317 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
318 | 318 | |
319 | 319 | /** |
320 | 320 | * Give Show Login/Register Form Fields. |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @return void |
327 | 327 | */ |
328 | -function give_show_register_login_fields( $form_id ) { |
|
328 | +function give_show_register_login_fields($form_id) { |
|
329 | 329 | |
330 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
330 | + $show_register_form = give_show_login_register_option($form_id); |
|
331 | 331 | |
332 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
332 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
333 | 333 | ?> |
334 | 334 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
335 | 335 | <?php |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @since 1.7 |
340 | 340 | */ |
341 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
341 | + do_action('give_donation_form_register_fields', $form_id); |
|
342 | 342 | ?> |
343 | 343 | </div> |
344 | 344 | <?php |
345 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
345 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
346 | 346 | ?> |
347 | 347 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
348 | 348 | <?php |
@@ -351,23 +351,23 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @since 1.7 |
353 | 353 | */ |
354 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
354 | + do_action('give_donation_form_login_fields', $form_id); |
|
355 | 355 | ?> |
356 | 356 | </div> |
357 | 357 | <?php |
358 | 358 | endif; |
359 | 359 | |
360 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
360 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
361 | 361 | /** |
362 | 362 | * Fire when user info render. |
363 | 363 | * |
364 | 364 | * @since 1.7 |
365 | 365 | */ |
366 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
366 | + do_action('give_donation_form_after_user_info', $form_id); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
370 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
371 | 371 | |
372 | 372 | /** |
373 | 373 | * Donation Amount Field. |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return void |
384 | 384 | */ |
385 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
385 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
386 | 386 | |
387 | 387 | $give_options = give_get_settings(); |
388 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
389 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
390 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
391 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
392 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
393 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
394 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
388 | + $variable_pricing = give_has_variable_prices($form_id); |
|
389 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
390 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
391 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
392 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
393 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
394 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Fires while displaying donation form, before donation level fields. |
@@ -401,20 +401,20 @@ discard block |
||
401 | 401 | * @param int $form_id The form ID. |
402 | 402 | * @param array $args An array of form arguments. |
403 | 403 | */ |
404 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
404 | + do_action('give_before_donation_levels', $form_id, $args); |
|
405 | 405 | |
406 | 406 | //Set Price, No Custom Amount Allowed means hidden price field |
407 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
407 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
408 | 408 | ?> |
409 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
409 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
410 | 410 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
411 | 411 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
412 | 412 | <div class="set-price give-donation-amount form-row-wide"> |
413 | - <?php if ( $currency_position == 'before' ) { |
|
413 | + <?php if ($currency_position == 'before') { |
|
414 | 414 | echo $currency_output; |
415 | 415 | } ?> |
416 | 416 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
417 | - <?php if ( $currency_position == 'after' ) { |
|
417 | + <?php if ($currency_position == 'after') { |
|
418 | 418 | echo $currency_output; |
419 | 419 | } ?> |
420 | 420 | </div> |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | ?> |
425 | 425 | <div class="give-total-wrap"> |
426 | 426 | <div class="give-donation-amount form-row-wide"> |
427 | - <?php if ( $currency_position == 'before' ) { |
|
427 | + <?php if ($currency_position == 'before') { |
|
428 | 428 | echo $currency_output; |
429 | 429 | } ?> |
430 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
430 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
431 | 431 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
432 | 432 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
433 | - <?php if ( $currency_position == 'after' ) { |
|
433 | + <?php if ($currency_position == 'after') { |
|
434 | 434 | echo $currency_output; |
435 | 435 | } ?> |
436 | 436 | </div> |
@@ -445,16 +445,16 @@ discard block |
||
445 | 445 | * @param int $form_id The form ID. |
446 | 446 | * @param array $args An array of form arguments. |
447 | 447 | */ |
448 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
448 | + do_action('give_after_donation_amount', $form_id, $args); |
|
449 | 449 | |
450 | 450 | //Custom Amount Text |
451 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
451 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
452 | 452 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
453 | 453 | <?php } |
454 | 454 | |
455 | 455 | //Output Variable Pricing Levels. |
456 | - if ( $variable_pricing ) { |
|
457 | - give_output_levels( $form_id ); |
|
456 | + if ($variable_pricing) { |
|
457 | + give_output_levels($form_id); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | * @param int $form_id The form ID. |
466 | 466 | * @param array $args An array of form arguments. |
467 | 467 | */ |
468 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
468 | + do_action('give_after_donation_levels', $form_id, $args); |
|
469 | 469 | } |
470 | 470 | |
471 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
471 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
472 | 472 | |
473 | 473 | /** |
474 | 474 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -479,30 +479,30 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string Donation levels. |
481 | 481 | */ |
482 | -function give_output_levels( $form_id ) { |
|
482 | +function give_output_levels($form_id) { |
|
483 | 483 | |
484 | 484 | //Get variable pricing. |
485 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
486 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
487 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
488 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
489 | - if ( empty( $custom_amount_text ) ) { |
|
490 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
485 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
486 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
487 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
488 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
489 | + if (empty($custom_amount_text)) { |
|
490 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | $output = ''; |
494 | 494 | |
495 | - switch ( $display_style ) { |
|
495 | + switch ($display_style) { |
|
496 | 496 | case 'buttons': |
497 | 497 | |
498 | 498 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
499 | 499 | |
500 | - foreach ( $prices as $price ) { |
|
501 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
502 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
500 | + foreach ($prices as $price) { |
|
501 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
502 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
503 | 503 | |
504 | 504 | $output .= '<li>'; |
505 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
505 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
506 | 506 | $output .= $level_text; |
507 | 507 | $output .= '</button>'; |
508 | 508 | $output .= '</li>'; |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | } |
511 | 511 | |
512 | 512 | //Custom Amount. |
513 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
513 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
514 | 514 | $output .= '<li>'; |
515 | 515 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
516 | 516 | $output .= $custom_amount_text; |
@@ -526,22 +526,22 @@ discard block |
||
526 | 526 | |
527 | 527 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
528 | 528 | |
529 | - foreach ( $prices as $price ) { |
|
530 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
531 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
529 | + foreach ($prices as $price) { |
|
530 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
531 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
532 | 532 | |
533 | 533 | $output .= '<li>'; |
534 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $price['_give_id']['level_id'] . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
535 | - $output .= '<label for="give-radio-level-' . $price['_give_id']['level_id'] . '">' . $level_text . '</label>'; |
|
534 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$price['_give_id']['level_id'].'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
535 | + $output .= '<label for="give-radio-level-'.$price['_give_id']['level_id'].'">'.$level_text.'</label>'; |
|
536 | 536 | $output .= '</li>'; |
537 | 537 | |
538 | 538 | } |
539 | 539 | |
540 | 540 | //Custom Amount. |
541 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
541 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
542 | 542 | $output .= '<li>'; |
543 | 543 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
544 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
544 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
545 | 545 | $output .= '</li>'; |
546 | 546 | } |
547 | 547 | |
@@ -551,23 +551,23 @@ discard block |
||
551 | 551 | |
552 | 552 | case 'dropdown': |
553 | 553 | |
554 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
555 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
554 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
555 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
556 | 556 | |
557 | 557 | //first loop through prices. |
558 | - foreach ( $prices as $price ) { |
|
559 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
560 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
558 | + foreach ($prices as $price) { |
|
559 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
560 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
561 | 561 | |
562 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
562 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
563 | 563 | $output .= $level_text; |
564 | 564 | $output .= '</option>'; |
565 | 565 | |
566 | 566 | } |
567 | 567 | |
568 | 568 | //Custom Amount. |
569 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
570 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
569 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
570 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | $output .= '</select>'; |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | break; |
576 | 576 | } |
577 | 577 | |
578 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
578 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -590,27 +590,27 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return string Checkout button. |
592 | 592 | */ |
593 | -function give_display_checkout_button( $form_id, $args ) { |
|
593 | +function give_display_checkout_button($form_id, $args) { |
|
594 | 594 | |
595 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
595 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
596 | 596 | ? $args['display_style'] |
597 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
597 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
598 | 598 | |
599 | - if ( 'button' === $display_option ) { |
|
599 | + if ('button' === $display_option) { |
|
600 | 600 | $display_option = 'modal'; |
601 | - } elseif ( $display_option === 'onpage' ) { |
|
601 | + } elseif ($display_option === 'onpage') { |
|
602 | 602 | return ''; |
603 | 603 | } |
604 | 604 | |
605 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
606 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
605 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
606 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
607 | 607 | |
608 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
608 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
609 | 609 | |
610 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
610 | + echo apply_filters('give_display_checkout_button', $output); |
|
611 | 611 | } |
612 | 612 | |
613 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
613 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
614 | 614 | |
615 | 615 | /** |
616 | 616 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -623,55 +623,55 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @return void |
625 | 625 | */ |
626 | -function give_user_info_fields( $form_id ) { |
|
626 | +function give_user_info_fields($form_id) { |
|
627 | 627 | // Get user info. |
628 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
628 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
629 | 629 | |
630 | 630 | /** |
631 | 631 | * Fire before user personal information fields |
632 | 632 | * |
633 | 633 | * @since 1.7 |
634 | 634 | */ |
635 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
635 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
636 | 636 | ?> |
637 | 637 | <fieldset id="give_checkout_user_info"> |
638 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
638 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
639 | 639 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
640 | 640 | <label class="give-label" for="give-first"> |
641 | - <?php _e( 'First Name', 'give' ); ?> |
|
642 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
641 | + <?php _e('First Name', 'give'); ?> |
|
642 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
643 | 643 | <span class="give-required-indicator">*</span> |
644 | 644 | <?php endif ?> |
645 | - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
645 | + <?php echo Give()->tooltips->render_help(__('We will use this to personalize your account experience.', 'give')); ?> |
|
646 | 646 | </label> |
647 | 647 | <input |
648 | 648 | class="give-input required" |
649 | 649 | type="text" |
650 | 650 | name="give_first" |
651 | - placeholder="<?php _e( 'First Name', 'give' ); ?>" |
|
651 | + placeholder="<?php _e('First Name', 'give'); ?>" |
|
652 | 652 | id="give-first" |
653 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
654 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
653 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
654 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
655 | 655 | /> |
656 | 656 | </p> |
657 | 657 | |
658 | 658 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
659 | 659 | <label class="give-label" for="give-last"> |
660 | - <?php _e( 'Last Name', 'give' ); ?> |
|
661 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
660 | + <?php _e('Last Name', 'give'); ?> |
|
661 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
662 | 662 | <span class="give-required-indicator">*</span> |
663 | 663 | <?php endif ?> |
664 | - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
664 | + <?php echo Give()->tooltips->render_help(__('We will use this as well to personalize your account experience.', 'give')); ?> |
|
665 | 665 | </label> |
666 | 666 | |
667 | 667 | <input |
668 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
668 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
669 | 669 | type="text" |
670 | 670 | name="give_last" |
671 | 671 | id="give-last" |
672 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
|
673 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
674 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
672 | + placeholder="<?php _e('Last Name', 'give'); ?>" |
|
673 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
674 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
675 | 675 | /> |
676 | 676 | </p> |
677 | 677 | |
@@ -681,25 +681,25 @@ discard block |
||
681 | 681 | * |
682 | 682 | * @since 1.7 |
683 | 683 | */ |
684 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
684 | + do_action('give_donation_form_before_email', $form_id); |
|
685 | 685 | ?> |
686 | 686 | <p id="give-email-wrap" class="form-row form-row-wide"> |
687 | 687 | <label class="give-label" for="give-email"> |
688 | - <?php _e( 'Email Address', 'give' ); ?> |
|
689 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
688 | + <?php _e('Email Address', 'give'); ?> |
|
689 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
690 | 690 | <span class="give-required-indicator">*</span> |
691 | 691 | <?php } ?> |
692 | - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
692 | + <?php echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?> |
|
693 | 693 | </label> |
694 | 694 | |
695 | 695 | <input |
696 | 696 | class="give-input required" |
697 | 697 | type="email" |
698 | 698 | name="give_email" |
699 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
|
699 | + placeholder="<?php _e('Email Address', 'give'); ?>" |
|
700 | 700 | id="give-email" |
701 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
702 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
701 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
702 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
703 | 703 | /> |
704 | 704 | |
705 | 705 | </p> |
@@ -709,14 +709,14 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @since 1.7 |
711 | 711 | */ |
712 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
712 | + do_action('give_donation_form_after_email', $form_id); |
|
713 | 713 | |
714 | 714 | /** |
715 | 715 | * Fire after personal email field |
716 | 716 | * |
717 | 717 | * @since 1.7 |
718 | 718 | */ |
719 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
719 | + do_action('give_donation_form_user_info', $form_id); |
|
720 | 720 | ?> |
721 | 721 | </fieldset> |
722 | 722 | <?php |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @since 1.7 |
727 | 727 | */ |
728 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
728 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
729 | 729 | } |
730 | 730 | |
731 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
732 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
731 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
732 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
733 | 733 | |
734 | 734 | /** |
735 | 735 | * Renders the credit card info form. |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | * |
741 | 741 | * @return void |
742 | 742 | */ |
743 | -function give_get_cc_form( $form_id ) { |
|
743 | +function give_get_cc_form($form_id) { |
|
744 | 744 | |
745 | 745 | ob_start(); |
746 | 746 | |
@@ -751,50 +751,50 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @param int $form_id The form ID. |
753 | 753 | */ |
754 | - do_action( 'give_before_cc_fields', $form_id ); |
|
754 | + do_action('give_before_cc_fields', $form_id); |
|
755 | 755 | ?> |
756 | 756 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
757 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
758 | - <?php if ( is_ssl() ) : ?> |
|
757 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
758 | + <?php if (is_ssl()) : ?> |
|
759 | 759 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
760 | 760 | <span class="give-icon padlock"></span> |
761 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
761 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
762 | 762 | </div> |
763 | 763 | <?php endif; ?> |
764 | 764 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
765 | 765 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
766 | - <?php _e( 'Card Number', 'give' ); ?> |
|
766 | + <?php _e('Card Number', 'give'); ?> |
|
767 | 767 | <span class="give-required-indicator">*</span> |
768 | - <?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
768 | + <?php echo Give()->tooltips->render_help(__('The (typically) 16 digits on the front of your credit card.', 'give')); ?> |
|
769 | 769 | <span class="card-type"></span> |
770 | 770 | </label> |
771 | 771 | |
772 | 772 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
773 | - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
|
773 | + class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" |
|
774 | 774 | required aria-required="true"/> |
775 | 775 | </p> |
776 | 776 | |
777 | 777 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
778 | 778 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
779 | - <?php _e( 'CVC', 'give' ); ?> |
|
779 | + <?php _e('CVC', 'give'); ?> |
|
780 | 780 | <span class="give-required-indicator">*</span> |
781 | - <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
781 | + <?php echo Give()->tooltips->render_help(__('The 3 digit (back) or 4 digit (front) value on your card.', 'give')); ?> |
|
782 | 782 | </label> |
783 | 783 | |
784 | 784 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
785 | - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
|
785 | + class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" |
|
786 | 786 | required aria-required="true"/> |
787 | 787 | </p> |
788 | 788 | |
789 | 789 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
790 | 790 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
791 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
791 | + <?php _e('Name on the Card', 'give'); ?> |
|
792 | 792 | <span class="give-required-indicator">*</span> |
793 | - <?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
793 | + <?php echo Give()->tooltips->render_help(__('The name printed on the front of your credit card.', 'give')); ?> |
|
794 | 794 | </label> |
795 | 795 | |
796 | 796 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
797 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
797 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
798 | 798 | required aria-required="true"/> |
799 | 799 | </p> |
800 | 800 | <?php |
@@ -805,19 +805,19 @@ discard block |
||
805 | 805 | * |
806 | 806 | * @param int $form_id The form ID. |
807 | 807 | */ |
808 | - do_action( 'give_before_cc_expiration' ); |
|
808 | + do_action('give_before_cc_expiration'); |
|
809 | 809 | ?> |
810 | 810 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
811 | 811 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
812 | - <?php _e( 'Expiration', 'give' ); ?> |
|
812 | + <?php _e('Expiration', 'give'); ?> |
|
813 | 813 | <span class="give-required-indicator">*</span> |
814 | - <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
814 | + <?php echo Give()->tooltips->render_help(__('The date your credit card expires, typically on the front of the card.', 'give')); ?> |
|
815 | 815 | </label> |
816 | 816 | |
817 | 817 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
818 | 818 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
819 | 819 | |
820 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
820 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true"/> |
|
821 | 821 | </p> |
822 | 822 | <?php |
823 | 823 | /** |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @param int $form_id The form ID. |
829 | 829 | */ |
830 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
830 | + do_action('give_after_cc_expiration', $form_id); |
|
831 | 831 | ?> |
832 | 832 | </fieldset> |
833 | 833 | <?php |
@@ -838,12 +838,12 @@ discard block |
||
838 | 838 | * |
839 | 839 | * @param int $form_id The form ID. |
840 | 840 | */ |
841 | - do_action( 'give_after_cc_fields', $form_id ); |
|
841 | + do_action('give_after_cc_fields', $form_id); |
|
842 | 842 | |
843 | 843 | echo ob_get_clean(); |
844 | 844 | } |
845 | 845 | |
846 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
846 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
847 | 847 | |
848 | 848 | /** |
849 | 849 | * Outputs the default credit card address fields. |
@@ -854,20 +854,20 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @return void |
856 | 856 | */ |
857 | -function give_default_cc_address_fields( $form_id ) { |
|
857 | +function give_default_cc_address_fields($form_id) { |
|
858 | 858 | // Get user info. |
859 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
859 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
860 | 860 | |
861 | 861 | $logged_in = is_user_logged_in(); |
862 | 862 | |
863 | - if ( $logged_in ) { |
|
864 | - $user_address = give_get_donor_address( get_current_user_id() ); |
|
863 | + if ($logged_in) { |
|
864 | + $user_address = give_get_donor_address(get_current_user_id()); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | ob_start(); |
868 | 868 | ?> |
869 | 869 | <fieldset id="give_cc_address" class="cc-address"> |
870 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
870 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
871 | 871 | <?php |
872 | 872 | /** |
873 | 873 | * Fires while rendering credit card billing form, before address fields. |
@@ -876,36 +876,36 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @param int $form_id The form ID. |
878 | 878 | */ |
879 | - do_action( 'give_cc_billing_top' ); |
|
879 | + do_action('give_cc_billing_top'); |
|
880 | 880 | |
881 | 881 | // For Country. |
882 | 882 | $selected_country = give_get_country(); |
883 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
883 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
884 | 884 | $selected_country = $give_user_info['billing_country']; |
885 | 885 | } |
886 | 886 | $countries = give_get_country_list(); |
887 | 887 | |
888 | 888 | // For state |
889 | 889 | $selected_state = ''; |
890 | - if ( $selected_country === give_get_country() ) { |
|
890 | + if ($selected_country === give_get_country()) { |
|
891 | 891 | // Get defalut selected state by admin. |
892 | 892 | $selected_state = give_get_state(); |
893 | 893 | } |
894 | 894 | // Get the last payment made by user states. |
895 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
895 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
896 | 896 | $selected_state = $give_user_info['card_state']; |
897 | 897 | } |
898 | 898 | // Get the country code |
899 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
899 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
900 | 900 | $selected_country = $give_user_info['billing_country']; |
901 | 901 | } |
902 | - $label = __( 'State', 'give' ); |
|
902 | + $label = __('State', 'give'); |
|
903 | 903 | $states_label = give_get_states_label(); |
904 | 904 | // Check if $country code exists in the array key for states label. |
905 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
906 | - $label = $states_label[ $selected_country ]; |
|
905 | + if (array_key_exists($selected_country, $states_label)) { |
|
906 | + $label = $states_label[$selected_country]; |
|
907 | 907 | } |
908 | - $states = give_get_states( $selected_country ); |
|
908 | + $states = give_get_states($selected_country); |
|
909 | 909 | // Get the country list that do not have any states init. |
910 | 910 | $no_states_country = give_no_states_country_list(); |
911 | 911 | // Get the country list that does not require states. |
@@ -913,23 +913,23 @@ discard block |
||
913 | 913 | ?> |
914 | 914 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
915 | 915 | <label for="billing_country" class="give-label"> |
916 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
917 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
916 | + <?php esc_html_e('Country', 'give'); ?> |
|
917 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
918 | 918 | <span class="give-required-indicator">*</span> |
919 | 919 | <?php endif; ?> |
920 | 920 | <span class="give-tooltip give-icon give-icon-question" |
921 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
921 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
922 | 922 | </label> |
923 | 923 | |
924 | 924 | <select |
925 | 925 | name="billing_country" |
926 | 926 | id="billing_country" |
927 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
928 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
927 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
928 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
929 | 929 | > |
930 | 930 | <?php |
931 | - foreach ( $countries as $country_code => $country ) { |
|
932 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
931 | + foreach ($countries as $country_code => $country) { |
|
932 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
933 | 933 | } |
934 | 934 | ?> |
935 | 935 | </select> |
@@ -937,86 +937,86 @@ discard block |
||
937 | 937 | |
938 | 938 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
939 | 939 | <label for="card_address" class="give-label"> |
940 | - <?php _e( 'Address 1', 'give' ); ?> |
|
940 | + <?php _e('Address 1', 'give'); ?> |
|
941 | 941 | <?php |
942 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
942 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
943 | 943 | <span class="give-required-indicator">*</span> |
944 | 944 | <?php endif; ?> |
945 | - <?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
945 | + <?php echo Give()->tooltips->render_help(__('The primary billing address for your credit card.', 'give')); ?> |
|
946 | 946 | </label> |
947 | 947 | |
948 | 948 | <input |
949 | 949 | type="text" |
950 | 950 | id="card_address" |
951 | 951 | name="card_address" |
952 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
953 | - placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
|
954 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
955 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
952 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
953 | + placeholder="<?php _e('Address line 1', 'give'); ?>" |
|
954 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
955 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
956 | 956 | /> |
957 | 957 | </p> |
958 | 958 | |
959 | 959 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
960 | 960 | <label for="card_address_2" class="give-label"> |
961 | - <?php _e( 'Address 2', 'give' ); ?> |
|
962 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
961 | + <?php _e('Address 2', 'give'); ?> |
|
962 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
963 | 963 | <span class="give-required-indicator">*</span> |
964 | 964 | <?php endif; ?> |
965 | - <?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
965 | + <?php echo Give()->tooltips->render_help(__('(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give')); ?> |
|
966 | 966 | </label> |
967 | 967 | |
968 | 968 | <input |
969 | 969 | type="text" |
970 | 970 | id="card_address_2" |
971 | 971 | name="card_address_2" |
972 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
973 | - placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
|
974 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
975 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
972 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
973 | + placeholder="<?php _e('Address line 2', 'give'); ?>" |
|
974 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
975 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
976 | 976 | /> |
977 | 977 | </p> |
978 | 978 | |
979 | 979 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
980 | 980 | <label for="card_city" class="give-label"> |
981 | - <?php _e( 'City', 'give' ); ?> |
|
982 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
981 | + <?php _e('City', 'give'); ?> |
|
982 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
983 | 983 | <span class="give-required-indicator">*</span> |
984 | 984 | <?php endif; ?> |
985 | - <?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
985 | + <?php echo Give()->tooltips->render_help(__('The city for your billing address.', 'give')); ?> |
|
986 | 986 | </label> |
987 | 987 | <input |
988 | 988 | type="text" |
989 | 989 | id="card_city" |
990 | 990 | name="card_city" |
991 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
992 | - placeholder="<?php _e( 'City', 'give' ); ?>" |
|
993 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
994 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
991 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
992 | + placeholder="<?php _e('City', 'give'); ?>" |
|
993 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
994 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
995 | 995 | /> |
996 | 996 | </p> |
997 | 997 | |
998 | 998 | <p id="give-card-state-wrap" |
999 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
999 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
1000 | 1000 | <label for="card_state" class="give-label"> |
1001 | 1001 | <span class="state-label-text"><?php echo $label; ?></span> |
1002 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
1002 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
1003 | 1003 | ?> |
1004 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
1004 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
1005 | 1005 | <?php endif; ?> |
1006 | 1006 | <span class="give-tooltip give-icon give-icon-question" |
1007 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
1007 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
1008 | 1008 | </label> |
1009 | 1009 | <?php |
1010 | 1010 | |
1011 | - if ( ! empty( $states ) ) : ?> |
|
1011 | + if ( ! empty($states)) : ?> |
|
1012 | 1012 | <select |
1013 | 1013 | name="card_state" |
1014 | 1014 | id="card_state" |
1015 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
1016 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
1015 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
1016 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
1017 | 1017 | <?php |
1018 | - foreach ( $states as $state_code => $state ) { |
|
1019 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1018 | + foreach ($states as $state_code => $state) { |
|
1019 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
1020 | 1020 | } |
1021 | 1021 | ?> |
1022 | 1022 | </select> |
@@ -1028,11 +1028,11 @@ discard block |
||
1028 | 1028 | |
1029 | 1029 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
1030 | 1030 | <label for="card_zip" class="give-label"> |
1031 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
1032 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
1031 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
1032 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
1033 | 1033 | <span class="give-required-indicator">*</span> |
1034 | 1034 | <?php endif; ?> |
1035 | - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
1035 | + <?php echo Give()->tooltips->render_help(__('The ZIP Code or postal code for your billing address.', 'give')); ?> |
|
1036 | 1036 | </label> |
1037 | 1037 | |
1038 | 1038 | <input |
@@ -1040,10 +1040,10 @@ discard block |
||
1040 | 1040 | size="4" |
1041 | 1041 | id="card_zip" |
1042 | 1042 | name="card_zip" |
1043 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
1044 | - placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
|
1045 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
1046 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1043 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
1044 | + placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" |
|
1045 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
1046 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1047 | 1047 | /> |
1048 | 1048 | </p> |
1049 | 1049 | <?php |
@@ -1054,14 +1054,14 @@ discard block |
||
1054 | 1054 | * |
1055 | 1055 | * @param int $form_id The form ID. |
1056 | 1056 | */ |
1057 | - do_action( 'give_cc_billing_bottom' ); |
|
1057 | + do_action('give_cc_billing_bottom'); |
|
1058 | 1058 | ?> |
1059 | 1059 | </fieldset> |
1060 | 1060 | <?php |
1061 | 1061 | echo ob_get_clean(); |
1062 | 1062 | } |
1063 | 1063 | |
1064 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1064 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1065 | 1065 | |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1074,15 +1074,15 @@ discard block |
||
1074 | 1074 | * |
1075 | 1075 | * @return string |
1076 | 1076 | */ |
1077 | -function give_get_register_fields( $form_id ) { |
|
1077 | +function give_get_register_fields($form_id) { |
|
1078 | 1078 | |
1079 | 1079 | global $user_ID; |
1080 | 1080 | |
1081 | - if ( is_user_logged_in() ) { |
|
1082 | - $user_data = get_userdata( $user_ID ); |
|
1081 | + if (is_user_logged_in()) { |
|
1082 | + $user_data = get_userdata($user_ID); |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1085 | + $show_register_form = give_show_login_register_option($form_id); |
|
1086 | 1086 | |
1087 | 1087 | ob_start(); ?> |
1088 | 1088 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @param int $form_id The form ID. |
1097 | 1097 | */ |
1098 | - do_action( 'give_register_fields_before', $form_id ); |
|
1098 | + do_action('give_register_fields_before', $form_id); |
|
1099 | 1099 | ?> |
1100 | 1100 | |
1101 | 1101 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
@@ -1107,22 +1107,22 @@ discard block |
||
1107 | 1107 | * |
1108 | 1108 | * @param int $form_id The form ID. |
1109 | 1109 | */ |
1110 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1110 | + do_action('give_register_account_fields_before', $form_id); |
|
1111 | 1111 | ?> |
1112 | 1112 | <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1113 | 1113 | <label for="give-create-account-<?php echo $form_id; ?>"> |
1114 | 1114 | <?php |
1115 | 1115 | // Add attributes to checkbox, if Guest Checkout is disabled. |
1116 | - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
1117 | - $id = 'give-create-account-' . $form_id; |
|
1118 | - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
|
1116 | + $is_guest_checkout = give_get_meta($form_id, '_give_logged_in_only', true); |
|
1117 | + $id = 'give-create-account-'.$form_id; |
|
1118 | + if ( ! give_is_setting_enabled($is_guest_checkout)) { |
|
1119 | 1119 | echo Give()->tooltips->render( |
1120 | 1120 | array( |
1121 | 1121 | 'tag_content' => sprintf( |
1122 | 1122 | '<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />', |
1123 | 1123 | $id |
1124 | 1124 | ), |
1125 | - 'label' => __( 'Registration is required to donate.', 'give' ), |
|
1125 | + 'label' => __('Registration is required to donate.', 'give'), |
|
1126 | 1126 | ) ); |
1127 | 1127 | } else { |
1128 | 1128 | ?> |
@@ -1130,16 +1130,16 @@ discard block |
||
1130 | 1130 | <?php |
1131 | 1131 | } |
1132 | 1132 | ?> |
1133 | - <?php _e( 'Create an account', 'give' ); ?> |
|
1134 | - <?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
1133 | + <?php _e('Create an account', 'give'); ?> |
|
1134 | + <?php echo Give()->tooltips->render_help(__('Create an account on the site to see and manage donation history.', 'give')); ?> |
|
1135 | 1135 | </label> |
1136 | 1136 | </div> |
1137 | 1137 | |
1138 | - <?php if ( 'both' === $show_register_form ) { ?> |
|
1138 | + <?php if ('both' === $show_register_form) { ?> |
|
1139 | 1139 | <div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
1140 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1141 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
1142 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1140 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1141 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
1142 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1143 | 1143 | </p> |
1144 | 1144 | <p class="give-loading-text"> |
1145 | 1145 | <span class="give-loading-animation"></span> |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | * |
1156 | 1156 | * @param int $form_id The form ID. |
1157 | 1157 | */ |
1158 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1158 | + do_action('give_register_account_fields_after', $form_id); |
|
1159 | 1159 | ?> |
1160 | 1160 | </fieldset> |
1161 | 1161 | |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | * |
1168 | 1168 | * @param int $form_id The form ID. |
1169 | 1169 | */ |
1170 | - do_action( 'give_register_fields_after', $form_id ); |
|
1170 | + do_action('give_register_fields_after', $form_id); |
|
1171 | 1171 | ?> |
1172 | 1172 | |
1173 | 1173 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | * |
1179 | 1179 | * @since 1.7 |
1180 | 1180 | */ |
1181 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1181 | + do_action('give_donation_form_user_info', $form_id); |
|
1182 | 1182 | ?> |
1183 | 1183 | |
1184 | 1184 | </fieldset> |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | echo ob_get_clean(); |
1187 | 1187 | } |
1188 | 1188 | |
1189 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1189 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1190 | 1190 | |
1191 | 1191 | /** |
1192 | 1192 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1199,28 +1199,28 @@ discard block |
||
1199 | 1199 | * |
1200 | 1200 | * @return string |
1201 | 1201 | */ |
1202 | -function give_get_login_fields( $form_id ) { |
|
1202 | +function give_get_login_fields($form_id) { |
|
1203 | 1203 | |
1204 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1205 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1204 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1205 | + $show_register_form = give_show_login_register_option($form_id); |
|
1206 | 1206 | |
1207 | 1207 | ob_start(); |
1208 | 1208 | ?> |
1209 | 1209 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1210 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
1211 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1212 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
1210 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
1211 | + if ( ! give_logged_in_only($form_id)) { |
|
1212 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
1213 | 1213 | } ?> |
1214 | 1214 | </legend> |
1215 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1215 | + <?php if ($show_register_form == 'both') { ?> |
|
1216 | 1216 | <p class="give-new-account-link"> |
1217 | - <?php _e( 'Don\'t have an account?', 'give' ); ?> |
|
1218 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
1217 | + <?php _e('Don\'t have an account?', 'give'); ?> |
|
1218 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
1219 | 1219 | data-action="give_checkout_register"> |
1220 | - <?php if ( give_logged_in_only( $form_id ) ) { |
|
1221 | - _e( 'Register as a part of your donation »', 'give' ); |
|
1220 | + <?php if (give_logged_in_only($form_id)) { |
|
1221 | + _e('Register as a part of your donation »', 'give'); |
|
1222 | 1222 | } else { |
1223 | - _e( 'Register or donate as a guest »', 'give' ); |
|
1223 | + _e('Register or donate as a guest »', 'give'); |
|
1224 | 1224 | } ?> |
1225 | 1225 | </a> |
1226 | 1226 | </p> |
@@ -1236,49 +1236,49 @@ discard block |
||
1236 | 1236 | * |
1237 | 1237 | * @param int $form_id The form ID. |
1238 | 1238 | */ |
1239 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1239 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1240 | 1240 | ?> |
1241 | 1241 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1242 | 1242 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1243 | - <?php _e( 'Username', 'give' ); ?> |
|
1244 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1243 | + <?php _e('Username', 'give'); ?> |
|
1244 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1245 | 1245 | <span class="give-required-indicator">*</span> |
1246 | 1246 | <?php } ?> |
1247 | 1247 | </label> |
1248 | 1248 | |
1249 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
1249 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
1250 | 1250 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
1251 | - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1251 | + placeholder="<?php _e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1252 | 1252 | </div> |
1253 | 1253 | |
1254 | 1254 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1255 | 1255 | class="give_login_password form-row form-row-last form-row-responsive"> |
1256 | 1256 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1257 | - <?php _e( 'Password', 'give' ); ?> |
|
1258 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1257 | + <?php _e('Password', 'give'); ?> |
|
1258 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1259 | 1259 | <span class="give-required-indicator">*</span> |
1260 | 1260 | <?php } ?> |
1261 | 1261 | </label> |
1262 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
1262 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
1263 | 1263 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
1264 | - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1264 | + placeholder="<?php _e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1265 | 1265 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1266 | 1266 | </div> |
1267 | 1267 | |
1268 | 1268 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1269 | 1269 | <span class="give-forgot-password "> |
1270 | 1270 | <a href="<?php echo wp_lostpassword_url() ?>" |
1271 | - target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
|
1271 | + target="_blank"><?php _e('Reset Password', 'give') ?></a> |
|
1272 | 1272 | </span> |
1273 | 1273 | </div> |
1274 | 1274 | |
1275 | 1275 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1276 | 1276 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1277 | - value="<?php _e( 'Login', 'give' ); ?>"/> |
|
1278 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1277 | + value="<?php _e('Login', 'give'); ?>"/> |
|
1278 | + <?php if ($show_register_form !== 'login') { ?> |
|
1279 | 1279 | <input type="button" data-action="give_cancel_login" |
1280 | 1280 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1281 | - value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
1281 | + value="<?php _e('Cancel', 'give'); ?>"/> |
|
1282 | 1282 | <?php } ?> |
1283 | 1283 | <span class="give-loading-animation"></span> |
1284 | 1284 | </div> |
@@ -1290,14 +1290,14 @@ discard block |
||
1290 | 1290 | * |
1291 | 1291 | * @param int $form_id The form ID. |
1292 | 1292 | */ |
1293 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1293 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1294 | 1294 | ?> |
1295 | 1295 | </fieldset><!--end #give-login-fields--> |
1296 | 1296 | <?php |
1297 | 1297 | echo ob_get_clean(); |
1298 | 1298 | } |
1299 | 1299 | |
1300 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1300 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1301 | 1301 | |
1302 | 1302 | /** |
1303 | 1303 | * Payment Mode Select. |
@@ -1313,9 +1313,9 @@ discard block |
||
1313 | 1313 | * |
1314 | 1314 | * @return void |
1315 | 1315 | */ |
1316 | -function give_payment_mode_select( $form_id ) { |
|
1316 | +function give_payment_mode_select($form_id) { |
|
1317 | 1317 | |
1318 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1318 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1319 | 1319 | |
1320 | 1320 | /** |
1321 | 1321 | * Fires while selecting payment gateways, before the fields. |
@@ -1324,10 +1324,10 @@ discard block |
||
1324 | 1324 | * |
1325 | 1325 | * @param int $form_id The form ID. |
1326 | 1326 | */ |
1327 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1327 | + do_action('give_payment_mode_top', $form_id); |
|
1328 | 1328 | ?> |
1329 | 1329 | |
1330 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
1330 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
1331 | 1331 | echo 'style="display: none;"'; |
1332 | 1332 | } ?>> |
1333 | 1333 | <?php |
@@ -1338,10 +1338,10 @@ discard block |
||
1338 | 1338 | * |
1339 | 1339 | * @param int $form_id The form ID. |
1340 | 1340 | */ |
1341 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1341 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1342 | 1342 | ?> |
1343 | 1343 | <legend |
1344 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1344 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1345 | 1345 | <span class="give-loading-text"><span |
1346 | 1346 | class="give-loading-animation"></span> |
1347 | 1347 | </span> |
@@ -1354,26 +1354,26 @@ discard block |
||
1354 | 1354 | * |
1355 | 1355 | * @since 1.7 |
1356 | 1356 | */ |
1357 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1357 | + do_action('give_payment_mode_before_gateways') |
|
1358 | 1358 | ?> |
1359 | 1359 | <ul id="give-gateway-radio-list"> |
1360 | 1360 | <?php |
1361 | 1361 | /** |
1362 | 1362 | * Loop through the active payment gateways. |
1363 | 1363 | */ |
1364 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
1364 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
1365 | 1365 | |
1366 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1366 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1367 | 1367 | //Determine the default gateway. |
1368 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1368 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1369 | 1369 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1370 | 1370 | <li<?php echo $checked_class ?>> |
1371 | 1371 | <input type="radio" name="payment-mode" class="give-gateway" |
1372 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
1373 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1374 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
1372 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
1373 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1374 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
1375 | 1375 | class="give-gateway-option" |
1376 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1376 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1377 | 1377 | </li> |
1378 | 1378 | <?php |
1379 | 1379 | endforeach; |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | * |
1386 | 1386 | * @since 1.7 |
1387 | 1387 | */ |
1388 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1388 | + do_action('give_payment_mode_after_gateways'); |
|
1389 | 1389 | ?> |
1390 | 1390 | </div> |
1391 | 1391 | <?php |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | * |
1397 | 1397 | * @param int $form_id The form ID. |
1398 | 1398 | */ |
1399 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1399 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1400 | 1400 | ?> |
1401 | 1401 | </fieldset> |
1402 | 1402 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | * |
1409 | 1409 | * @param int $form_id The form ID. |
1410 | 1410 | */ |
1411 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1411 | + do_action('give_payment_mode_bottom', $form_id); |
|
1412 | 1412 | ?> |
1413 | 1413 | |
1414 | 1414 | <div id="give_purchase_form_wrap"> |
@@ -1419,7 +1419,7 @@ discard block |
||
1419 | 1419 | * |
1420 | 1420 | * @since 1.7 |
1421 | 1421 | */ |
1422 | - do_action( 'give_donation_form', $form_id ); |
|
1422 | + do_action('give_donation_form', $form_id); |
|
1423 | 1423 | ?> |
1424 | 1424 | |
1425 | 1425 | </div> |
@@ -1430,10 +1430,10 @@ discard block |
||
1430 | 1430 | * |
1431 | 1431 | * @since 1.7 |
1432 | 1432 | */ |
1433 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1433 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1434 | 1434 | } |
1435 | 1435 | |
1436 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1436 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1437 | 1437 | |
1438 | 1438 | /** |
1439 | 1439 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1446,31 +1446,31 @@ discard block |
||
1446 | 1446 | * |
1447 | 1447 | * @return bool |
1448 | 1448 | */ |
1449 | -function give_terms_agreement( $form_id ) { |
|
1450 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1449 | +function give_terms_agreement($form_id) { |
|
1450 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1451 | 1451 | |
1452 | 1452 | // Bailout if per form and global term and conditions is not setup. |
1453 | 1453 | if ( |
1454 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1455 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1454 | + give_is_setting_enabled($form_option, 'global') |
|
1455 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1456 | 1456 | ) { |
1457 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
1458 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
1459 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
1457 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
1458 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
1459 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
1460 | 1460 | |
1461 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1462 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
1463 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
1464 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
1461 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1462 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
1463 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
1464 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
1465 | 1465 | |
1466 | 1466 | } else { |
1467 | 1467 | return false; |
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | // Bailout: Check if term and conditions text is empty or not. |
1471 | - if ( empty( $terms ) ) { |
|
1472 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
1473 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
1471 | + if (empty($terms)) { |
|
1472 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
1473 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | return false; |
@@ -1478,7 +1478,7 @@ discard block |
||
1478 | 1478 | |
1479 | 1479 | ?> |
1480 | 1480 | <fieldset id="give_terms_agreement"> |
1481 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1481 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1482 | 1482 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1483 | 1483 | <?php |
1484 | 1484 | /** |
@@ -1486,22 +1486,22 @@ discard block |
||
1486 | 1486 | * |
1487 | 1487 | * @since 1.0 |
1488 | 1488 | */ |
1489 | - do_action( 'give_before_terms' ); |
|
1489 | + do_action('give_before_terms'); |
|
1490 | 1490 | |
1491 | - echo wpautop( stripslashes( $terms ) ); |
|
1491 | + echo wpautop(stripslashes($terms)); |
|
1492 | 1492 | /** |
1493 | 1493 | * Fires while rendering terms of agreement, after the fields. |
1494 | 1494 | * |
1495 | 1495 | * @since 1.0 |
1496 | 1496 | */ |
1497 | - do_action( 'give_after_terms' ); |
|
1497 | + do_action('give_after_terms'); |
|
1498 | 1498 | ?> |
1499 | 1499 | </div> |
1500 | 1500 | <div id="give_show_terms"> |
1501 | 1501 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1502 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1502 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1503 | 1503 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1504 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1504 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1505 | 1505 | </div> |
1506 | 1506 | |
1507 | 1507 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | <?php |
1513 | 1513 | } |
1514 | 1514 | |
1515 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1515 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1516 | 1516 | |
1517 | 1517 | /** |
1518 | 1518 | * Checkout Final Total. |
@@ -1525,31 +1525,30 @@ discard block |
||
1525 | 1525 | * |
1526 | 1526 | * @return void |
1527 | 1527 | */ |
1528 | -function give_checkout_final_total( $form_id ) { |
|
1528 | +function give_checkout_final_total($form_id) { |
|
1529 | 1529 | |
1530 | - $total = isset( $_POST['give_total'] ) ? |
|
1531 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
1532 | - give_get_default_form_amount( $form_id ); |
|
1530 | + $total = isset($_POST['give_total']) ? |
|
1531 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
1533 | 1532 | |
1534 | 1533 | |
1535 | 1534 | // Only proceed if give_total available. |
1536 | - if ( empty( $total ) ) { |
|
1535 | + if (empty($total)) { |
|
1537 | 1536 | return; |
1538 | 1537 | } |
1539 | 1538 | ?> |
1540 | 1539 | <p id="give-final-total-wrap" class="form-wrap "> |
1541 | 1540 | <span class="give-donation-total-label"> |
1542 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
1541 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
1543 | 1542 | </span> |
1544 | 1543 | <span class="give-final-total-amount" |
1545 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
1546 | - <?php echo give_currency_filter( give_format_amount( $total, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
|
1544 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
1545 | + <?php echo give_currency_filter(give_format_amount($total, array('sanitize' => false)), array('currency_code' => give_get_currency($form_id))); ?> |
|
1547 | 1546 | </span> |
1548 | 1547 | </p> |
1549 | 1548 | <?php |
1550 | 1549 | } |
1551 | 1550 | |
1552 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1551 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1553 | 1552 | |
1554 | 1553 | /** |
1555 | 1554 | * Renders the Checkout Submit section. |
@@ -1560,7 +1559,7 @@ discard block |
||
1560 | 1559 | * |
1561 | 1560 | * @return void |
1562 | 1561 | */ |
1563 | -function give_checkout_submit( $form_id ) { |
|
1562 | +function give_checkout_submit($form_id) { |
|
1564 | 1563 | ?> |
1565 | 1564 | <fieldset id="give_purchase_submit"> |
1566 | 1565 | <?php |
@@ -1569,24 +1568,24 @@ discard block |
||
1569 | 1568 | * |
1570 | 1569 | * @since 1.7 |
1571 | 1570 | */ |
1572 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
1571 | + do_action('give_donation_form_before_submit', $form_id); |
|
1573 | 1572 | |
1574 | - give_checkout_hidden_fields( $form_id ); |
|
1573 | + give_checkout_hidden_fields($form_id); |
|
1575 | 1574 | |
1576 | - echo give_get_donation_form_submit_button( $form_id ); |
|
1575 | + echo give_get_donation_form_submit_button($form_id); |
|
1577 | 1576 | |
1578 | 1577 | /** |
1579 | 1578 | * Fire after donation form submit. |
1580 | 1579 | * |
1581 | 1580 | * @since 1.7 |
1582 | 1581 | */ |
1583 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
1582 | + do_action('give_donation_form_after_submit', $form_id); |
|
1584 | 1583 | ?> |
1585 | 1584 | </fieldset> |
1586 | 1585 | <?php |
1587 | 1586 | } |
1588 | 1587 | |
1589 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1588 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1590 | 1589 | |
1591 | 1590 | /** |
1592 | 1591 | * Give Donation form submit button. |
@@ -1597,10 +1596,10 @@ discard block |
||
1597 | 1596 | * |
1598 | 1597 | * @return string |
1599 | 1598 | */ |
1600 | -function give_get_donation_form_submit_button( $form_id ) { |
|
1599 | +function give_get_donation_form_submit_button($form_id) { |
|
1601 | 1600 | |
1602 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
1603 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1601 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
1602 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1604 | 1603 | ob_start(); |
1605 | 1604 | ?> |
1606 | 1605 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1609,7 +1608,7 @@ discard block |
||
1609 | 1608 | <span class="give-loading-animation"></span> |
1610 | 1609 | </div> |
1611 | 1610 | <?php |
1612 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
1611 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
1613 | 1612 | } |
1614 | 1613 | |
1615 | 1614 | /** |
@@ -1624,22 +1623,22 @@ discard block |
||
1624 | 1623 | * |
1625 | 1624 | * @return mixed |
1626 | 1625 | */ |
1627 | -function give_show_goal_progress( $form_id, $args ) { |
|
1626 | +function give_show_goal_progress($form_id, $args) { |
|
1628 | 1627 | |
1629 | 1628 | ob_start(); |
1630 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1629 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1631 | 1630 | |
1632 | 1631 | /** |
1633 | 1632 | * Filter progress bar output |
1634 | 1633 | * |
1635 | 1634 | * @since 2.0 |
1636 | 1635 | */ |
1637 | - echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
1636 | + echo apply_filters('give_goal_output', ob_get_clean(), $form_id, $args); |
|
1638 | 1637 | |
1639 | 1638 | return true; |
1640 | 1639 | } |
1641 | 1640 | |
1642 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1641 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1643 | 1642 | |
1644 | 1643 | |
1645 | 1644 | /** |
@@ -1652,10 +1651,10 @@ discard block |
||
1652 | 1651 | * |
1653 | 1652 | * @return mixed|string |
1654 | 1653 | */ |
1655 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1654 | +function give_get_form_content_placement($form_id, $args) { |
|
1656 | 1655 | $show_content = ''; |
1657 | 1656 | |
1658 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1657 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1659 | 1658 | // Content positions. |
1660 | 1659 | $content_placement = array( |
1661 | 1660 | 'above' => 'give_pre_form', |
@@ -1663,18 +1662,18 @@ discard block |
||
1663 | 1662 | ); |
1664 | 1663 | |
1665 | 1664 | // Check if content position already decoded. |
1666 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
1665 | + if (in_array($args['show_content'], $content_placement)) { |
|
1667 | 1666 | return $args['show_content']; |
1668 | 1667 | } |
1669 | 1668 | |
1670 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
1669 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
1671 | 1670 | |
1672 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1673 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
1671 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
1672 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
1674 | 1673 | |
1675 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
1674 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
1676 | 1675 | // Backward compatibility for _give_content_option for v18. |
1677 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
1676 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
1678 | 1677 | } |
1679 | 1678 | |
1680 | 1679 | return $show_content; |
@@ -1690,20 +1689,20 @@ discard block |
||
1690 | 1689 | * |
1691 | 1690 | * @return void|bool |
1692 | 1691 | */ |
1693 | -function give_form_content( $form_id, $args ) { |
|
1692 | +function give_form_content($form_id, $args) { |
|
1694 | 1693 | |
1695 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1694 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1696 | 1695 | |
1697 | 1696 | // Bailout. |
1698 | - if ( empty( $show_content ) ) { |
|
1697 | + if (empty($show_content)) { |
|
1699 | 1698 | return false; |
1700 | 1699 | } |
1701 | 1700 | |
1702 | 1701 | // Add action according to value. |
1703 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1702 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1704 | 1703 | } |
1705 | 1704 | |
1706 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1705 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1707 | 1706 | |
1708 | 1707 | /** |
1709 | 1708 | * Renders Post Form Content. |
@@ -1717,22 +1716,22 @@ discard block |
||
1717 | 1716 | * |
1718 | 1717 | * @return void |
1719 | 1718 | */ |
1720 | -function give_form_display_content( $form_id, $args ) { |
|
1719 | +function give_form_display_content($form_id, $args) { |
|
1721 | 1720 | |
1722 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
1723 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1721 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
1722 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1724 | 1723 | |
1725 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1726 | - $content = apply_filters( 'the_content', $content ); |
|
1724 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1725 | + $content = apply_filters('the_content', $content); |
|
1727 | 1726 | } |
1728 | 1727 | |
1729 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
1728 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
1730 | 1729 | |
1731 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1730 | + echo apply_filters('give_form_content_output', $output); |
|
1732 | 1731 | |
1733 | 1732 | // remove action to prevent content output on addition forms on page. |
1734 | 1733 | // @see: https://github.com/WordImpress/Give/issues/634. |
1735 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1734 | + remove_action($show_content, 'give_form_display_content'); |
|
1736 | 1735 | } |
1737 | 1736 | |
1738 | 1737 | /** |
@@ -1744,7 +1743,7 @@ discard block |
||
1744 | 1743 | * |
1745 | 1744 | * @return void |
1746 | 1745 | */ |
1747 | -function give_checkout_hidden_fields( $form_id ) { |
|
1746 | +function give_checkout_hidden_fields($form_id) { |
|
1748 | 1747 | |
1749 | 1748 | /** |
1750 | 1749 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1753,13 +1752,13 @@ discard block |
||
1753 | 1752 | * |
1754 | 1753 | * @param int $form_id The form ID. |
1755 | 1754 | */ |
1756 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1755 | + do_action('give_hidden_fields_before', $form_id); |
|
1757 | 1756 | |
1758 | - if ( is_user_logged_in() ) { ?> |
|
1757 | + if (is_user_logged_in()) { ?> |
|
1759 | 1758 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1760 | 1759 | <?php } ?> |
1761 | 1760 | <input type="hidden" name="give_action" value="purchase"/> |
1762 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1761 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1763 | 1762 | <?php |
1764 | 1763 | /** |
1765 | 1764 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1768,7 +1767,7 @@ discard block |
||
1768 | 1767 | * |
1769 | 1768 | * @param int $form_id The form ID. |
1770 | 1769 | */ |
1771 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1770 | + do_action('give_hidden_fields_after', $form_id); |
|
1772 | 1771 | |
1773 | 1772 | } |
1774 | 1773 | |
@@ -1783,20 +1782,20 @@ discard block |
||
1783 | 1782 | * |
1784 | 1783 | * @return string $content Filtered content. |
1785 | 1784 | */ |
1786 | -function give_filter_success_page_content( $content ) { |
|
1785 | +function give_filter_success_page_content($content) { |
|
1787 | 1786 | |
1788 | 1787 | $give_options = give_get_settings(); |
1789 | 1788 | |
1790 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1791 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1792 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1789 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1790 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1791 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1793 | 1792 | } |
1794 | 1793 | } |
1795 | 1794 | |
1796 | 1795 | return $content; |
1797 | 1796 | } |
1798 | 1797 | |
1799 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1798 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1800 | 1799 | |
1801 | 1800 | /** |
1802 | 1801 | * Test Mode Frontend Warning. |
@@ -1807,12 +1806,12 @@ discard block |
||
1807 | 1806 | */ |
1808 | 1807 | function give_test_mode_frontend_warning() { |
1809 | 1808 | |
1810 | - if ( give_is_test_mode() ) { |
|
1811 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1809 | + if (give_is_test_mode()) { |
|
1810 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1812 | 1811 | } |
1813 | 1812 | } |
1814 | 1813 | |
1815 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1814 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1816 | 1815 | |
1817 | 1816 | /** |
1818 | 1817 | * Members-only Form. |
@@ -1826,21 +1825,21 @@ discard block |
||
1826 | 1825 | * |
1827 | 1826 | * @return string |
1828 | 1827 | */ |
1829 | -function give_members_only_form( $final_output, $args ) { |
|
1828 | +function give_members_only_form($final_output, $args) { |
|
1830 | 1829 | |
1831 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1830 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1832 | 1831 | |
1833 | 1832 | //Sanity Check: Must have form_id & not be logged in. |
1834 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1833 | + if (empty($form_id) || is_user_logged_in()) { |
|
1835 | 1834 | return $final_output; |
1836 | 1835 | } |
1837 | 1836 | |
1838 | 1837 | //Logged in only and Register / Login set to none. |
1839 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1838 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1840 | 1839 | |
1841 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1840 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1842 | 1841 | |
1843 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1842 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1844 | 1843 | |
1845 | 1844 | } |
1846 | 1845 | |
@@ -1848,7 +1847,7 @@ discard block |
||
1848 | 1847 | |
1849 | 1848 | } |
1850 | 1849 | |
1851 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1850 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
1852 | 1851 | |
1853 | 1852 | |
1854 | 1853 | /** |
@@ -1860,28 +1859,28 @@ discard block |
||
1860 | 1859 | * @param array $args |
1861 | 1860 | * @param Give_Donate_Form $form |
1862 | 1861 | */ |
1863 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
1862 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
1864 | 1863 | ?> |
1865 | 1864 | <input type="hidden" name="give-form-id" value="<?php echo $form_id; ?>"/> |
1866 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
1865 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
1867 | 1866 | <input type="hidden" name="give-current-url" |
1868 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
1869 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
1867 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
1868 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
1870 | 1869 | <input type="hidden" name="give-form-minimum" |
1871 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ); ?>"/> |
|
1870 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)); ?>"/> |
|
1872 | 1871 | <?php |
1873 | 1872 | |
1874 | 1873 | // WP nonce field. |
1875 | - wp_nonce_field( "donation_form_nonce_{$form_id}", '_wpnonce', false ); |
|
1874 | + wp_nonce_field("donation_form_nonce_{$form_id}", '_wpnonce', false); |
|
1876 | 1875 | |
1877 | 1876 | // Price ID hidden field for variable (multi-level) donation forms. |
1878 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1877 | + if (give_has_variable_prices($form_id)) { |
|
1879 | 1878 | // Get default selected price ID. |
1880 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
1879 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
1881 | 1880 | $price_id = 0; |
1882 | 1881 | //loop through prices. |
1883 | - foreach ( $prices as $price ) { |
|
1884 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
1882 | + foreach ($prices as $price) { |
|
1883 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
1885 | 1884 | $price_id = $price['_give_id']['level_id']; |
1886 | 1885 | }; |
1887 | 1886 | } |
@@ -1894,7 +1893,7 @@ discard block |
||
1894 | 1893 | } |
1895 | 1894 | } |
1896 | 1895 | |
1897 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
1896 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
1898 | 1897 | |
1899 | 1898 | /** |
1900 | 1899 | * Add currency settings on donation form. |
@@ -1906,20 +1905,20 @@ discard block |
||
1906 | 1905 | * |
1907 | 1906 | * @return array |
1908 | 1907 | */ |
1909 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
1910 | - $form_currency = give_get_currency( $form->ID ); |
|
1911 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
1908 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
1909 | + $form_currency = give_get_currency($form->ID); |
|
1910 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
1912 | 1911 | |
1913 | 1912 | // Check if currency exist. |
1914 | - if ( empty( $currency_settings ) ) { |
|
1913 | + if (empty($currency_settings)) { |
|
1915 | 1914 | return $form_html_tags; |
1916 | 1915 | } |
1917 | 1916 | |
1918 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
1917 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
1919 | 1918 | $form_html_tags['data-currency_code'] = $form_currency; |
1920 | 1919 | |
1921 | - if ( ! empty( $currency_settings ) ) { |
|
1922 | - foreach ( $currency_settings as $key => $value ) { |
|
1920 | + if ( ! empty($currency_settings)) { |
|
1921 | + foreach ($currency_settings as $key => $value) { |
|
1923 | 1922 | $form_html_tags["data-{$key}"] = $value; |
1924 | 1923 | } |
1925 | 1924 | } |
@@ -1927,4 +1926,4 @@ discard block |
||
1927 | 1926 | return $form_html_tags; |
1928 | 1927 | } |
1929 | 1928 | |
1930 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
1929 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
@@ -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 | |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_test_ajax_works() { |
28 | 28 | // Handle ajax. |
29 | - if ( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) { |
|
30 | - wp_die( 0, 200 ); |
|
29 | + if (doing_action('wp_ajax_nopriv_give_test_ajax')) { |
|
30 | + wp_die(0, 200); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Check if the Airplane Mode plugin is installed. |
34 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
34 | + if (class_exists('Airplane_Mode_Core')) { |
|
35 | 35 | |
36 | 36 | $airplane = Airplane_Mode_Core::getInstance(); |
37 | 37 | |
38 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
38 | + if (method_exists($airplane, 'enabled')) { |
|
39 | 39 | |
40 | - if ( $airplane->enabled() ) { |
|
40 | + if ($airplane->enabled()) { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } else { |
44 | 44 | |
45 | - if ( 'on' === $airplane->check_status() ) { |
|
45 | + if ('on' === $airplane->check_status()) { |
|
46 | 46 | return true; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - add_filter( 'block_local_requests', '__return_false' ); |
|
51 | + add_filter('block_local_requests', '__return_false'); |
|
52 | 52 | |
53 | - if ( Give_Cache::get( '_give_ajax_works', true ) ) { |
|
53 | + if (Give_Cache::get('_give_ajax_works', true)) { |
|
54 | 54 | return true; |
55 | 55 | } |
56 | 56 | |
@@ -62,41 +62,41 @@ discard block |
||
62 | 62 | ), |
63 | 63 | ); |
64 | 64 | |
65 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
65 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
66 | 66 | |
67 | 67 | $works = true; |
68 | 68 | |
69 | - if ( is_wp_error( $ajax ) ) { |
|
69 | + if (is_wp_error($ajax)) { |
|
70 | 70 | |
71 | 71 | $works = false; |
72 | 72 | |
73 | 73 | } else { |
74 | 74 | |
75 | - if ( empty( $ajax['response'] ) ) { |
|
75 | + if (empty($ajax['response'])) { |
|
76 | 76 | $works = false; |
77 | 77 | } |
78 | 78 | |
79 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
79 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
80 | 80 | $works = false; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
83 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
84 | 84 | $works = false; |
85 | 85 | } |
86 | 86 | |
87 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
87 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
88 | 88 | $works = false; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if ( $works ) { |
|
93 | - Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true ); |
|
92 | + if ($works) { |
|
93 | + Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true); |
|
94 | 94 | } |
95 | 95 | |
96 | - return apply_filters( 'give_test_ajax_works', $works ); |
|
96 | + return apply_filters('give_test_ajax_works', $works); |
|
97 | 97 | } |
98 | 98 | |
99 | -add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' ); |
|
99 | +add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works'); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Get AJAX URL |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function give_get_ajax_url( $query = array() ) { |
|
111 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
110 | +function give_get_ajax_url($query = array()) { |
|
111 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
112 | 112 | |
113 | 113 | $current_url = give_get_current_page_url(); |
114 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
114 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
115 | 115 | |
116 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
117 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
116 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
117 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $query ) ) { |
|
121 | - $ajax_url = add_query_arg( $query, $ajax_url ); |
|
120 | + if ( ! empty($query)) { |
|
121 | + $ajax_url = add_query_arg($query, $ajax_url); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
124 | + return apply_filters('give_ajax_url', $ajax_url); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @since 1.7 |
139 | 139 | */ |
140 | - do_action( 'give_donation_form_login_fields' ); |
|
140 | + do_action('give_donation_form_login_fields'); |
|
141 | 141 | |
142 | 142 | give_die(); |
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
145 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Load Checkout Fields |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | function give_load_checkout_fields() { |
155 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
155 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
156 | 156 | |
157 | 157 | ob_start(); |
158 | 158 | |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @since 1.7 |
163 | 163 | */ |
164 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
164 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
165 | 165 | |
166 | 166 | $fields = ob_get_clean(); |
167 | 167 | |
168 | - wp_send_json( array( |
|
169 | - 'fields' => wp_json_encode( $fields ), |
|
170 | - 'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ), |
|
171 | - ) ); |
|
168 | + wp_send_json(array( |
|
169 | + 'fields' => wp_json_encode($fields), |
|
170 | + 'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)), |
|
171 | + )); |
|
172 | 172 | } |
173 | 173 | |
174 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
175 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
174 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
175 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | function give_ajax_get_form_title() { |
185 | - if ( isset( $_POST['form_id'] ) ) { |
|
186 | - $title = get_the_title( $_POST['form_id'] ); |
|
187 | - if ( $title ) { |
|
185 | + if (isset($_POST['form_id'])) { |
|
186 | + $title = get_the_title($_POST['form_id']); |
|
187 | + if ($title) { |
|
188 | 188 | echo $title; |
189 | 189 | } else { |
190 | 190 | echo 'fail'; |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | give_die(); |
194 | 194 | } |
195 | 195 | |
196 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
197 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
196 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
197 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Retrieve a states drop down |
@@ -208,41 +208,41 @@ discard block |
||
208 | 208 | $show_field = true; |
209 | 209 | $states_require = true; |
210 | 210 | // Get the Country code from the $_POST. |
211 | - $country = sanitize_text_field( $_POST['country'] ); |
|
211 | + $country = sanitize_text_field($_POST['country']); |
|
212 | 212 | |
213 | 213 | // Get the field name from the $_POST. |
214 | - $field_name = sanitize_text_field( $_POST['field_name'] ); |
|
214 | + $field_name = sanitize_text_field($_POST['field_name']); |
|
215 | 215 | |
216 | - $label = __( 'State', 'give' ); |
|
216 | + $label = __('State', 'give'); |
|
217 | 217 | $states_label = give_get_states_label(); |
218 | 218 | |
219 | 219 | $default_state = ''; |
220 | - if ( $country === give_get_country() ) { |
|
220 | + if ($country === give_get_country()) { |
|
221 | 221 | $default_state = give_get_state(); |
222 | 222 | } |
223 | 223 | |
224 | 224 | // Check if $country code exists in the array key for states label. |
225 | - if ( array_key_exists( $country, $states_label ) ) { |
|
226 | - $label = $states_label[ $country ]; |
|
225 | + if (array_key_exists($country, $states_label)) { |
|
226 | + $label = $states_label[$country]; |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( empty( $country ) ) { |
|
229 | + if (empty($country)) { |
|
230 | 230 | $country = give_get_country(); |
231 | 231 | } |
232 | 232 | |
233 | - $states = give_get_states( $country ); |
|
234 | - if ( ! empty( $states ) ) { |
|
235 | - $args = array( |
|
233 | + $states = give_get_states($country); |
|
234 | + if ( ! empty($states)) { |
|
235 | + $args = array( |
|
236 | 236 | 'name' => $field_name, |
237 | 237 | 'id' => $field_name, |
238 | - 'class' => $field_name . ' give-select', |
|
238 | + 'class' => $field_name.' give-select', |
|
239 | 239 | 'options' => $states, |
240 | 240 | 'show_option_all' => false, |
241 | 241 | 'show_option_none' => false, |
242 | 242 | 'placeholder' => $label, |
243 | 243 | 'selected' => $default_state, |
244 | 244 | ); |
245 | - $data = Give()->html->select( $args ); |
|
245 | + $data = Give()->html->select($args); |
|
246 | 246 | $states_found = true; |
247 | 247 | } else { |
248 | 248 | $data = 'nostates'; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $no_states_country = give_no_states_country_list(); |
252 | 252 | |
253 | 253 | // Check if $country code exists in the array key. |
254 | - if ( array_key_exists( $country, $no_states_country ) ) { |
|
254 | + if (array_key_exists($country, $no_states_country)) { |
|
255 | 255 | $show_field = false; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $states_not_required_country_list = give_states_not_required_country_list(); |
260 | 260 | |
261 | 261 | // Check if $country code exists in the array key. |
262 | - if ( array_key_exists( $country, $states_not_required_country_list ) ) { |
|
262 | + if (array_key_exists($country, $states_not_required_country_list)) { |
|
263 | 263 | $states_require = false; |
264 | 264 | } |
265 | 265 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | 'data' => $data, |
273 | 273 | 'default_state' => $default_state, |
274 | 274 | ); |
275 | - wp_send_json( $response ); |
|
275 | + wp_send_json($response); |
|
276 | 276 | } |
277 | 277 | |
278 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
279 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
278 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
279 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Retrieve donation forms via AJAX for chosen dropdown search field. |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | function give_ajax_form_search() { |
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
292 | - $excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() ); |
|
291 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
292 | + $excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array()); |
|
293 | 293 | |
294 | 294 | $results = array(); |
295 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
296 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
295 | + if (current_user_can('edit_give_forms')) { |
|
296 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
297 | 297 | } else { |
298 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
298 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( $items ) { |
|
301 | + if ($items) { |
|
302 | 302 | |
303 | - foreach ( $items as $item ) { |
|
303 | + foreach ($items as $item) { |
|
304 | 304 | |
305 | 305 | $results[] = array( |
306 | 306 | 'id' => $item->ID, |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | |
312 | 312 | $items[] = array( |
313 | 313 | 'id' => 0, |
314 | - 'name' => __( 'No forms found.', 'give' ), |
|
314 | + 'name' => __('No forms found.', 'give'), |
|
315 | 315 | ); |
316 | 316 | |
317 | 317 | } |
318 | 318 | |
319 | - echo json_encode( $results ); |
|
319 | + echo json_encode($results); |
|
320 | 320 | |
321 | 321 | give_die(); |
322 | 322 | } |
323 | 323 | |
324 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
325 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
324 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
325 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Search the donors database via Ajax |
@@ -334,38 +334,38 @@ discard block |
||
334 | 334 | function give_ajax_donor_search() { |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
337 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
338 | 338 | $results = array(); |
339 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
339 | + if ( ! current_user_can('view_give_reports')) { |
|
340 | 340 | $donors = array(); |
341 | 341 | } else { |
342 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
342 | + $donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $donors ) { |
|
345 | + if ($donors) { |
|
346 | 346 | |
347 | - foreach ( $donors as $donor ) { |
|
347 | + foreach ($donors as $donor) { |
|
348 | 348 | |
349 | 349 | $results[] = array( |
350 | 350 | 'id' => $donor->id, |
351 | - 'name' => $donor->name . ' (' . $donor->email . ')', |
|
351 | + 'name' => $donor->name.' ('.$donor->email.')', |
|
352 | 352 | ); |
353 | 353 | } |
354 | 354 | } else { |
355 | 355 | |
356 | 356 | $donors[] = array( |
357 | 357 | 'id' => 0, |
358 | - 'name' => __( 'No donors found.', 'give' ), |
|
358 | + 'name' => __('No donors found.', 'give'), |
|
359 | 359 | ); |
360 | 360 | |
361 | 361 | } |
362 | 362 | |
363 | - echo json_encode( $results ); |
|
363 | + echo json_encode($results); |
|
364 | 364 | |
365 | 365 | give_die(); |
366 | 366 | } |
367 | 367 | |
368 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
368 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,39 +377,39 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_ajax_search_users() { |
379 | 379 | |
380 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
380 | + if (current_user_can('manage_give_settings')) { |
|
381 | 381 | |
382 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
382 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
383 | 383 | |
384 | 384 | $get_users_args = array( |
385 | 385 | 'number' => 9999, |
386 | - 'search' => $search . '*', |
|
386 | + 'search' => $search.'*', |
|
387 | 387 | ); |
388 | 388 | |
389 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
389 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
390 | 390 | |
391 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search ); |
|
391 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search); |
|
392 | 392 | $results = array(); |
393 | 393 | |
394 | - if ( $found_users ) { |
|
394 | + if ($found_users) { |
|
395 | 395 | |
396 | - foreach ( $found_users as $user ) { |
|
396 | + foreach ($found_users as $user) { |
|
397 | 397 | |
398 | 398 | $results[] = array( |
399 | 399 | 'id' => $user->ID, |
400 | - 'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ), |
|
400 | + 'name' => esc_html($user->user_login.' ('.$user->user_email.')'), |
|
401 | 401 | ); |
402 | 402 | } |
403 | 403 | } else { |
404 | 404 | |
405 | 405 | $results[] = array( |
406 | 406 | 'id' => 0, |
407 | - 'name' => __( 'No users found.', 'give' ), |
|
407 | + 'name' => __('No users found.', 'give'), |
|
408 | 408 | ); |
409 | 409 | |
410 | 410 | } |
411 | 411 | |
412 | - echo json_encode( $results ); |
|
412 | + echo json_encode($results); |
|
413 | 413 | |
414 | 414 | }// End if(). |
415 | 415 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | } |
419 | 419 | |
420 | -add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' ); |
|
420 | +add_action('wp_ajax_give_user_search', 'give_ajax_search_users'); |
|
421 | 421 | |
422 | 422 | |
423 | 423 | /** |
@@ -429,32 +429,32 @@ discard block |
||
429 | 429 | */ |
430 | 430 | function give_check_for_form_price_variations() { |
431 | 431 | |
432 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
433 | - die( '-1' ); |
|
432 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
433 | + die('-1'); |
|
434 | 434 | } |
435 | 435 | |
436 | - $form_id = intval( $_POST['form_id'] ); |
|
437 | - $form = get_post( $form_id ); |
|
436 | + $form_id = intval($_POST['form_id']); |
|
437 | + $form = get_post($form_id); |
|
438 | 438 | |
439 | - if ( 'give_forms' !== $form->post_type ) { |
|
440 | - die( '-2' ); |
|
439 | + if ('give_forms' !== $form->post_type) { |
|
440 | + die('-2'); |
|
441 | 441 | } |
442 | 442 | |
443 | - if ( give_has_variable_prices( $form_id ) ) { |
|
444 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
443 | + if (give_has_variable_prices($form_id)) { |
|
444 | + $variable_prices = give_get_variable_prices($form_id); |
|
445 | 445 | |
446 | - if ( $variable_prices ) { |
|
446 | + if ($variable_prices) { |
|
447 | 447 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
448 | 448 | |
449 | - if ( isset( $_POST['all_prices'] ) ) { |
|
450 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
449 | + if (isset($_POST['all_prices'])) { |
|
450 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
451 | 451 | } |
452 | 452 | |
453 | - foreach ( $variable_prices as $key => $price ) { |
|
453 | + foreach ($variable_prices as $key => $price) { |
|
454 | 454 | |
455 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
455 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))); |
|
456 | 456 | |
457 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
457 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
458 | 458 | } |
459 | 459 | $ajax_response .= '</select>'; |
460 | 460 | echo $ajax_response; |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | give_die(); |
465 | 465 | } |
466 | 466 | |
467 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
467 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
468 | 468 | |
469 | 469 | |
470 | 470 | /** |
@@ -475,28 +475,28 @@ discard block |
||
475 | 475 | * @return void |
476 | 476 | */ |
477 | 477 | function give_check_for_form_price_variations_html() { |
478 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
478 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
479 | 479 | wp_die(); |
480 | 480 | } |
481 | 481 | |
482 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false; |
|
483 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false; |
|
484 | - if ( empty( $form_id ) || empty( $payment_id ) ) { |
|
482 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false; |
|
483 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false; |
|
484 | + if (empty($form_id) || empty($payment_id)) { |
|
485 | 485 | wp_die(); |
486 | 486 | } |
487 | 487 | |
488 | - $form = get_post( $form_id ); |
|
489 | - if ( ! empty( $form->post_type ) && 'give_forms' !== $form->post_type ) { |
|
488 | + $form = get_post($form_id); |
|
489 | + if ( ! empty($form->post_type) && 'give_forms' !== $form->post_type) { |
|
490 | 490 | wp_die(); |
491 | 491 | } |
492 | 492 | |
493 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
494 | - esc_html_e( 'n/a', 'give' ); |
|
493 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
494 | + esc_html_e('n/a', 'give'); |
|
495 | 495 | } else { |
496 | 496 | $prices_atts = array(); |
497 | - if ( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
498 | - foreach ( $variable_prices as $variable_price ) { |
|
499 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
|
497 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
498 | + foreach ($variable_prices as $variable_price) { |
|
499 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false)); |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -507,12 +507,12 @@ discard block |
||
507 | 507 | 'chosen' => true, |
508 | 508 | 'show_option_all' => '', |
509 | 509 | 'show_option_none' => '', |
510 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
510 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
511 | 511 | ); |
512 | 512 | |
513 | - if ( $payment_id ) { |
|
513 | + if ($payment_id) { |
|
514 | 514 | // Payment object. |
515 | - $payment = new Give_Payment( $payment_id ); |
|
515 | + $payment = new Give_Payment($payment_id); |
|
516 | 516 | |
517 | 517 | // Payment meta. |
518 | 518 | $payment_meta = $payment->get_meta(); |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | // Render variable prices select tag html. |
523 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
523 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | give_die(); |
527 | 527 | } |
528 | 528 | |
529 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
529 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
530 | 530 | |
531 | 531 | /** |
532 | 532 | * Send Confirmation Email For Complete Donation History Access. |
@@ -538,24 +538,24 @@ discard block |
||
538 | 538 | function give_confirm_email_for_donation_access() { |
539 | 539 | |
540 | 540 | // Verify Security using Nonce. |
541 | - if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) { |
|
541 | + if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Bail Out, if email is empty. |
546 | - if ( empty( $_POST['email'] ) ) { |
|
546 | + if (empty($_POST['email'])) { |
|
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | |
550 | - $donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) ); |
|
551 | - if ( Give()->email_access->can_send_email( $donor->id ) ) { |
|
550 | + $donor = Give()->donors->get_donor_by('email', give_clean($_POST['email'])); |
|
551 | + if (Give()->email_access->can_send_email($donor->id)) { |
|
552 | 552 | $return = array(); |
553 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
553 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
554 | 554 | |
555 | - if ( ! $email_sent ) { |
|
555 | + if ( ! $email_sent) { |
|
556 | 556 | $return['status'] = 'error'; |
557 | 557 | $return['message'] = Give()->notices->print_frontend_notice( |
558 | - __( 'Unable to send email. Please try again.', 'give' ), |
|
558 | + __('Unable to send email. Please try again.', 'give'), |
|
559 | 559 | false, |
560 | 560 | 'error' |
561 | 561 | ); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | |
564 | 564 | $return['status'] = 'success'; |
565 | 565 | $return['message'] = Give()->notices->print_frontend_notice( |
566 | - __( 'Please check your email and click on the link to access your complete donation history.', 'give' ), |
|
566 | + __('Please check your email and click on the link to access your complete donation history.', 'give'), |
|
567 | 567 | false, |
568 | 568 | 'success' |
569 | 569 | ); |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | $return['status'] = 'error'; |
575 | 575 | $return['message'] = Give()->notices->print_frontend_notice( |
576 | 576 | sprintf( |
577 | - __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
|
578 | - sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
|
577 | + __('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'), |
|
578 | + sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value) |
|
579 | 579 | ), |
580 | 580 | false, |
581 | 581 | 'error' |
582 | 582 | ); |
583 | 583 | } |
584 | 584 | |
585 | - echo json_encode( $return ); |
|
585 | + echo json_encode($return); |
|
586 | 586 | give_die(); |
587 | 587 | } |
588 | 588 | |
589 | -add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' ); |
|
590 | 589 | \ No newline at end of file |
590 | +add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access'); |
|
591 | 591 | \ 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 | |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | * @return mixed |
26 | 26 | */ |
27 | 27 | function give_process_donation_form() { |
28 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
28 | + $is_ajax = isset($_POST['give_ajax']); |
|
29 | 29 | |
30 | 30 | // Verify donation form nonce. |
31 | - if( ! give_verify_donation_form_nonce() ) { |
|
32 | - if( $is_ajax ) { |
|
31 | + if ( ! give_verify_donation_form_nonce()) { |
|
32 | + if ($is_ajax) { |
|
33 | 33 | /** |
34 | 34 | * Fires when AJAX sends back errors from the donation form. |
35 | 35 | * |
36 | 36 | * @since 1.0 |
37 | 37 | */ |
38 | - do_action( 'give_ajax_donation_errors' ); |
|
38 | + do_action('give_ajax_donation_errors'); |
|
39 | 39 | |
40 | 40 | give_die(); |
41 | - } else{ |
|
41 | + } else { |
|
42 | 42 | give_send_back_to_checkout(); |
43 | 43 | } |
44 | 44 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @since 1.0 |
50 | 50 | */ |
51 | - do_action( 'give_pre_process_donation' ); |
|
51 | + do_action('give_pre_process_donation'); |
|
52 | 52 | |
53 | 53 | // Validate the form $_POST data. |
54 | 54 | $valid_data = give_donation_form_validate_fields(); |
@@ -63,24 +63,24 @@ discard block |
||
63 | 63 | * @param bool|array $valid_data Validate fields. |
64 | 64 | * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead. |
65 | 65 | */ |
66 | - do_action( 'give_checkout_error_checks', $valid_data, $deprecated = $_POST ); |
|
66 | + do_action('give_checkout_error_checks', $valid_data, $deprecated = $_POST); |
|
67 | 67 | |
68 | 68 | // Process the login form. |
69 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
69 | + if (isset($_POST['give_login_submit'])) { |
|
70 | 70 | give_process_form_login(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | // Validate the user. |
74 | - $user = give_get_donation_form_user( $valid_data ); |
|
74 | + $user = give_get_donation_form_user($valid_data); |
|
75 | 75 | |
76 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
77 | - if ( $is_ajax ) { |
|
76 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
77 | + if ($is_ajax) { |
|
78 | 78 | /** |
79 | 79 | * Fires when AJAX sends back errors from the donation form. |
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_ajax_donation_errors' ); |
|
83 | + do_action('give_ajax_donation_errors'); |
|
84 | 84 | give_die(); |
85 | 85 | } else { |
86 | 86 | return false; |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | // If AJAX send back success to proceed with form submission. |
91 | - if ( $is_ajax ) { |
|
91 | + if ($is_ajax) { |
|
92 | 92 | echo 'success'; |
93 | 93 | give_die(); |
94 | 94 | } |
95 | 95 | |
96 | 96 | // After AJAX: Setup session if not using php_sessions. |
97 | - if ( ! Give()->session->use_php_sessions() ) { |
|
97 | + if ( ! Give()->session->use_php_sessions()) { |
|
98 | 98 | // Double-check that set_cookie is publicly accessible. |
99 | 99 | // we're using a slightly modified class-wp-sessions.php. |
100 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
101 | - if ( $session_reflection->isPublic() ) { |
|
100 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
101 | + if ($session_reflection->isPublic()) { |
|
102 | 102 | // Manually set the cookie. |
103 | 103 | Give()->session->init()->set_cookie(); |
104 | 104 | } |
@@ -113,21 +113,20 @@ discard block |
||
113 | 113 | 'address' => $user['address'], |
114 | 114 | ); |
115 | 115 | |
116 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
116 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
117 | 117 | |
118 | - $price = isset( $_POST['give-amount'] ) ? |
|
119 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
120 | - '0.00'; |
|
121 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
118 | + $price = isset($_POST['give-amount']) ? |
|
119 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
120 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
122 | 121 | |
123 | 122 | // Setup donation information. |
124 | 123 | $donation_data = array( |
125 | 124 | 'price' => $price, |
126 | 125 | 'purchase_key' => $purchase_key, |
127 | 126 | 'user_email' => $user['user_email'], |
128 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
129 | - 'user_info' => stripslashes_deep( $user_info ), |
|
130 | - 'post_data' => give_clean( $_POST ), |
|
127 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
128 | + 'user_info' => stripslashes_deep($user_info), |
|
129 | + 'post_data' => give_clean($_POST), |
|
131 | 130 | 'gateway' => $valid_data['gateway'], |
132 | 131 | 'card_info' => $valid_data['cc_info'], |
133 | 132 | ); |
@@ -146,10 +145,10 @@ discard block |
||
146 | 145 | * @param array $user_info Array containing basic user information. |
147 | 146 | * @param bool|array $valid_data Validate fields. |
148 | 147 | */ |
149 | - do_action( 'give_checkout_before_gateway', give_clean( $_POST ), $user_info, $valid_data ); |
|
148 | + do_action('give_checkout_before_gateway', give_clean($_POST), $user_info, $valid_data); |
|
150 | 149 | |
151 | 150 | // Sanity check for price. |
152 | - if ( ! $donation_data['price'] ) { |
|
151 | + if ( ! $donation_data['price']) { |
|
153 | 152 | // Revert to manual. |
154 | 153 | $donation_data['gateway'] = 'manual'; |
155 | 154 | $_POST['give-gateway'] = 'manual'; |
@@ -160,26 +159,26 @@ discard block |
||
160 | 159 | * |
161 | 160 | * @since 1.7 |
162 | 161 | */ |
163 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
162 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
164 | 163 | |
165 | 164 | // Setup the data we're storing in the donation session. |
166 | 165 | $session_data = $donation_data; |
167 | 166 | |
168 | 167 | // Make sure credit card numbers are never stored in sessions. |
169 | - unset( $session_data['card_info']['card_number'] ); |
|
170 | - unset( $session_data['post_data']['card_number'] ); |
|
168 | + unset($session_data['card_info']['card_number']); |
|
169 | + unset($session_data['post_data']['card_number']); |
|
171 | 170 | |
172 | 171 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
173 | - give_set_purchase_session( $session_data ); |
|
172 | + give_set_purchase_session($session_data); |
|
174 | 173 | |
175 | 174 | // Send info to the gateway for payment processing. |
176 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
175 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
177 | 176 | give_die(); |
178 | 177 | } |
179 | 178 | |
180 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
181 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
182 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
179 | +add_action('give_purchase', 'give_process_donation_form'); |
|
180 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
181 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
183 | 182 | |
184 | 183 | /** |
185 | 184 | * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer. |
@@ -190,29 +189,29 @@ discard block |
||
190 | 189 | * |
191 | 190 | * @return void |
192 | 191 | */ |
193 | -function give_check_logged_in_user_for_existing_email( $valid_data ) { |
|
192 | +function give_check_logged_in_user_for_existing_email($valid_data) { |
|
194 | 193 | |
195 | 194 | // Verify that the email address belongs to this customer. |
196 | - if ( is_user_logged_in() ) { |
|
195 | + if (is_user_logged_in()) { |
|
197 | 196 | |
198 | 197 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
199 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
198 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
200 | 199 | |
201 | 200 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
202 | 201 | if ( |
203 | 202 | $submitted_email !== $donor->email |
204 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
203 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
205 | 204 | ) { |
206 | - $found_donor = new Give_Donor( $submitted_email ); |
|
205 | + $found_donor = new Give_Donor($submitted_email); |
|
207 | 206 | |
208 | - if ( $found_donor->id > 0 ) { |
|
209 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
207 | + if ($found_donor->id > 0) { |
|
208 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
210 | 209 | } |
211 | 210 | } |
212 | 211 | } |
213 | 212 | } |
214 | 213 | |
215 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 ); |
|
214 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1); |
|
216 | 215 | |
217 | 216 | /** |
218 | 217 | * Process the checkout login form |
@@ -222,49 +221,49 @@ discard block |
||
222 | 221 | * @return void |
223 | 222 | */ |
224 | 223 | function give_process_form_login() { |
225 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
224 | + $is_ajax = isset($_POST['give_ajax']); |
|
226 | 225 | |
227 | 226 | $user_data = give_donation_form_validate_user_login(); |
228 | 227 | |
229 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
230 | - if ( $is_ajax ) { |
|
228 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
229 | + if ($is_ajax) { |
|
231 | 230 | /** |
232 | 231 | * Fires when AJAX sends back errors from the donation form. |
233 | 232 | * |
234 | 233 | * @since 1.0 |
235 | 234 | */ |
236 | 235 | ob_start(); |
237 | - do_action( 'give_ajax_donation_errors' ); |
|
236 | + do_action('give_ajax_donation_errors'); |
|
238 | 237 | $message = ob_get_contents(); |
239 | 238 | ob_end_clean(); |
240 | - wp_send_json_error( $message ); |
|
239 | + wp_send_json_error($message); |
|
241 | 240 | } else { |
242 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
241 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
243 | 242 | exit; |
244 | 243 | } |
245 | 244 | } |
246 | 245 | |
247 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
246 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
248 | 247 | |
249 | - if ( $is_ajax ) { |
|
248 | + if ($is_ajax) { |
|
250 | 249 | $message = Give()->notices->print_frontend_notice( |
251 | 250 | sprintf( |
252 | 251 | /* translators: %s: user first name */ |
253 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
254 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
252 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
253 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
255 | 254 | ), |
256 | 255 | false, |
257 | 256 | 'success' |
258 | 257 | ); |
259 | 258 | |
260 | - wp_send_json_success( $message ); |
|
259 | + wp_send_json_success($message); |
|
261 | 260 | } else { |
262 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
261 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
263 | 262 | } |
264 | 263 | } |
265 | 264 | |
266 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
267 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
265 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
266 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
268 | 267 | |
269 | 268 | /** |
270 | 269 | * Donation Form Validate Fields. |
@@ -276,52 +275,52 @@ discard block |
||
276 | 275 | function give_donation_form_validate_fields() { |
277 | 276 | |
278 | 277 | // Check if there is $_POST. |
279 | - if ( empty( $_POST ) ) { |
|
278 | + if (empty($_POST)) { |
|
280 | 279 | return false; |
281 | 280 | } |
282 | 281 | |
283 | - $form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
282 | + $form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
284 | 283 | |
285 | 284 | // Start an array to collect valid data. |
286 | 285 | $valid_data = array( |
287 | 286 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
288 | - 'need_new_user' => false, // New user flag. |
|
289 | - 'need_user_login' => false, // Login user flag. |
|
290 | - 'logged_user_data' => array(), // Logged user collected data. |
|
291 | - 'new_user_data' => array(), // New user collected data. |
|
292 | - 'login_user_data' => array(), // Login user collected data. |
|
293 | - 'guest_user_data' => array(), // Guest user collected data. |
|
294 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info. |
|
287 | + 'need_new_user' => false, // New user flag. |
|
288 | + 'need_user_login' => false, // Login user flag. |
|
289 | + 'logged_user_data' => array(), // Logged user collected data. |
|
290 | + 'new_user_data' => array(), // New user collected data. |
|
291 | + 'login_user_data' => array(), // Login user collected data. |
|
292 | + 'guest_user_data' => array(), // Guest user collected data. |
|
293 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
|
295 | 294 | ); |
296 | 295 | |
297 | 296 | // Validate Honeypot First. |
298 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
299 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
297 | + if ( ! empty($_POST['give-honeypot'])) { |
|
298 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
300 | 299 | } |
301 | 300 | |
302 | 301 | // Check spam detect. |
303 | - if ( isset( $_POST['action'] ) |
|
304 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
302 | + if (isset($_POST['action']) |
|
303 | + && give_is_setting_enabled(give_get_option('akismet_spam_protection')) |
|
305 | 304 | && give_is_spam_donation() |
306 | 305 | ) { |
307 | - give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
306 | + give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
308 | 307 | } |
309 | 308 | |
310 | 309 | // Validate agree to terms. |
311 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
310 | + if (give_is_terms_enabled($form_id)) { |
|
312 | 311 | give_donation_form_validate_agree_to_terms(); |
313 | 312 | } |
314 | 313 | |
315 | - if ( is_user_logged_in() ) { |
|
314 | + if (is_user_logged_in()) { |
|
316 | 315 | // Collect logged in user data. |
317 | 316 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
318 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' && ! empty( $_POST['give_create_account'] ) ) { |
|
317 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register' && ! empty($_POST['give_create_account'])) { |
|
319 | 318 | // Set new user registration as required. |
320 | 319 | $valid_data['need_new_user'] = true; |
321 | 320 | // Validate new user data. |
322 | 321 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
323 | 322 | // Check if login validation is needed. |
324 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
323 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
325 | 324 | // Set user login as required. |
326 | 325 | $valid_data['need_user_login'] = true; |
327 | 326 | // Validate users login info. |
@@ -345,14 +344,14 @@ discard block |
||
345 | 344 | function give_is_spam_donation() { |
346 | 345 | $spam = false; |
347 | 346 | |
348 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
347 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
349 | 348 | |
350 | - if ( strlen( $user_agent ) < 2 ) { |
|
349 | + if (strlen($user_agent) < 2) { |
|
351 | 350 | $spam = true; |
352 | 351 | } |
353 | 352 | |
354 | 353 | // Allow developer to customized Akismet spam detect API call and it's response. |
355 | - return apply_filters( 'give_spam', $spam ); |
|
354 | + return apply_filters('give_spam', $spam); |
|
356 | 355 | } |
357 | 356 | |
358 | 357 | /** |
@@ -366,41 +365,41 @@ discard block |
||
366 | 365 | */ |
367 | 366 | function give_donation_form_validate_gateway() { |
368 | 367 | |
369 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
370 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
371 | - $gateway = give_get_default_gateway( $form_id ); |
|
368 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
369 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
370 | + $gateway = give_get_default_gateway($form_id); |
|
372 | 371 | |
373 | 372 | // Check if a gateway value is present. |
374 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
373 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
375 | 374 | |
376 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
375 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
377 | 376 | |
378 | 377 | // Is amount being donated in LIVE mode 0.00? If so, error: |
379 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
378 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
380 | 379 | |
381 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
380 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
382 | 381 | |
383 | 382 | } // End if(). |
384 | - elseif ( ! give_verify_minimum_price() ) { |
|
383 | + elseif ( ! give_verify_minimum_price()) { |
|
385 | 384 | // translators: %s: minimum donation amount. |
386 | 385 | give_set_error( |
387 | 386 | 'invalid_donation_minimum', |
388 | 387 | sprintf( |
389 | 388 | /* translators: %s: minimum donation amount */ |
390 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
391 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
389 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
390 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
392 | 391 | ) |
393 | 392 | ); |
394 | 393 | |
395 | 394 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
396 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
395 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
397 | 396 | |
398 | 397 | $gateway = 'manual'; |
399 | 398 | |
400 | 399 | } //Check if this gateway is active. |
401 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
400 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
402 | 401 | |
403 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
402 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
404 | 403 | |
405 | 404 | } |
406 | 405 | } |
@@ -418,21 +417,21 @@ discard block |
||
418 | 417 | */ |
419 | 418 | function give_verify_minimum_price() { |
420 | 419 | |
421 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
422 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
423 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
424 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
420 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
421 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
422 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
423 | + $variable_prices = give_has_variable_prices($form_id); |
|
425 | 424 | |
426 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
425 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
427 | 426 | |
428 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
427 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
429 | 428 | |
430 | - if ( $price_level_amount == $amount ) { |
|
429 | + if ($price_level_amount == $amount) { |
|
431 | 430 | return true; |
432 | 431 | } |
433 | 432 | } |
434 | 433 | |
435 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
434 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
436 | 435 | return false; |
437 | 436 | } |
438 | 437 | |
@@ -448,9 +447,9 @@ discard block |
||
448 | 447 | */ |
449 | 448 | function give_donation_form_validate_agree_to_terms() { |
450 | 449 | // Validate agree to terms. |
451 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
450 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
452 | 451 | // User did not agree. |
453 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
452 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
454 | 453 | } |
455 | 454 | } |
456 | 455 | |
@@ -464,59 +463,59 @@ discard block |
||
464 | 463 | * |
465 | 464 | * @return array |
466 | 465 | */ |
467 | -function give_get_required_fields( $form_id ) { |
|
466 | +function give_get_required_fields($form_id) { |
|
468 | 467 | |
469 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
468 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
470 | 469 | |
471 | 470 | $required_fields = array( |
472 | 471 | 'give_email' => array( |
473 | 472 | 'error_id' => 'invalid_email', |
474 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
473 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
475 | 474 | ), |
476 | 475 | 'give_first' => array( |
477 | 476 | 'error_id' => 'invalid_first_name', |
478 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
477 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
479 | 478 | ), |
480 | 479 | ); |
481 | 480 | |
482 | - $require_address = give_require_billing_address( $payment_mode ); |
|
481 | + $require_address = give_require_billing_address($payment_mode); |
|
483 | 482 | |
484 | - if ( $require_address ) { |
|
485 | - $required_fields['card_address'] = array( |
|
483 | + if ($require_address) { |
|
484 | + $required_fields['card_address'] = array( |
|
486 | 485 | 'error_id' => 'invalid_card_address', |
487 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
486 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
488 | 487 | ); |
489 | - $required_fields['card_zip'] = array( |
|
488 | + $required_fields['card_zip'] = array( |
|
490 | 489 | 'error_id' => 'invalid_zip_code', |
491 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
490 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
492 | 491 | ); |
493 | - $required_fields['card_city'] = array( |
|
492 | + $required_fields['card_city'] = array( |
|
494 | 493 | 'error_id' => 'invalid_city', |
495 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
494 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
496 | 495 | ); |
497 | 496 | $required_fields['billing_country'] = array( |
498 | 497 | 'error_id' => 'invalid_country', |
499 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
498 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
500 | 499 | ); |
501 | 500 | |
502 | 501 | |
503 | 502 | $required_fields['card_state'] = array( |
504 | 503 | 'error_id' => 'invalid_state', |
505 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
504 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
506 | 505 | ); |
507 | 506 | |
508 | 507 | // Check if billing country already exists. |
509 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
508 | + if ( ! empty($_POST['billing_country'])) { |
|
510 | 509 | // Get the value from $_POST. |
511 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
510 | + $country = sanitize_text_field($_POST['billing_country']); |
|
512 | 511 | |
513 | 512 | // Get the country list that does not required any states init. |
514 | 513 | $states_country = give_states_not_required_country_list(); |
515 | 514 | |
516 | 515 | // Check if states is empty or not. |
517 | - if ( array_key_exists( $country, $states_country ) ) { |
|
516 | + if (array_key_exists($country, $states_country)) { |
|
518 | 517 | // If states is empty remove the required feilds of state in billing cart. |
519 | - unset( $required_fields['card_state'] ); |
|
518 | + unset($required_fields['card_state']); |
|
520 | 519 | } |
521 | 520 | } |
522 | 521 | } |
@@ -526,7 +525,7 @@ discard block |
||
526 | 525 | * |
527 | 526 | * @since 1.7 |
528 | 527 | */ |
529 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
528 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
530 | 529 | |
531 | 530 | return $required_fields; |
532 | 531 | |
@@ -541,16 +540,16 @@ discard block |
||
541 | 540 | * |
542 | 541 | * @return bool |
543 | 542 | */ |
544 | -function give_require_billing_address( $payment_mode ) { |
|
543 | +function give_require_billing_address($payment_mode) { |
|
545 | 544 | |
546 | 545 | $return = false; |
547 | 546 | |
548 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
547 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
549 | 548 | $return = true; |
550 | 549 | } |
551 | 550 | |
552 | 551 | // Let payment gateways and other extensions determine if address fields should be required. |
553 | - return apply_filters( 'give_require_billing_address', $return ); |
|
552 | + return apply_filters('give_require_billing_address', $return); |
|
554 | 553 | |
555 | 554 | } |
556 | 555 | |
@@ -564,38 +563,38 @@ discard block |
||
564 | 563 | function give_donation_form_validate_logged_in_user() { |
565 | 564 | global $user_ID; |
566 | 565 | |
567 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
566 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
568 | 567 | |
569 | 568 | // Start empty array to collect valid user data. |
570 | 569 | $valid_user_data = array( |
571 | 570 | // Assume there will be errors. |
572 | - 'user_id' => - 1, |
|
571 | + 'user_id' => -1, |
|
573 | 572 | ); |
574 | 573 | |
575 | 574 | // Verify there is a user_ID. |
576 | - if ( $user_ID > 0 ) { |
|
575 | + if ($user_ID > 0) { |
|
577 | 576 | // Get the logged in user data. |
578 | - $user_data = get_userdata( $user_ID ); |
|
577 | + $user_data = get_userdata($user_ID); |
|
579 | 578 | |
580 | 579 | // Validate Required Form Fields. |
581 | - give_validate_required_form_fields( $form_id ); |
|
580 | + give_validate_required_form_fields($form_id); |
|
582 | 581 | |
583 | 582 | // Verify data. |
584 | - if ( $user_data ) { |
|
583 | + if ($user_data) { |
|
585 | 584 | // Collected logged in user data. |
586 | 585 | $valid_user_data = array( |
587 | 586 | 'user_id' => $user_ID, |
588 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
589 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
590 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
587 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
588 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
589 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
591 | 590 | ); |
592 | 591 | |
593 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
594 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
592 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
593 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
595 | 594 | } |
596 | 595 | } else { |
597 | 596 | // Set invalid user error. |
598 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
597 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
599 | 598 | } |
600 | 599 | } |
601 | 600 | |
@@ -617,7 +616,7 @@ discard block |
||
617 | 616 | // Default user data. |
618 | 617 | $default_user_data = array( |
619 | 618 | 'give-form-id' => '', |
620 | - 'user_id' => - 1, // Assume there will be errors. |
|
619 | + 'user_id' => -1, // Assume there will be errors. |
|
621 | 620 | 'user_first' => '', |
622 | 621 | 'user_last' => '', |
623 | 622 | 'give_user_login' => false, |
@@ -627,14 +626,14 @@ discard block |
||
627 | 626 | ); |
628 | 627 | |
629 | 628 | // Get user data. |
630 | - $user_data = wp_parse_args( give_clean( $_POST ), $default_user_data ); |
|
629 | + $user_data = wp_parse_args(give_clean($_POST), $default_user_data); |
|
631 | 630 | $registering_new_user = false; |
632 | - $form_id = absint( $user_data['give-form-id'] ); |
|
631 | + $form_id = absint($user_data['give-form-id']); |
|
633 | 632 | |
634 | 633 | // Start an empty array to collect valid user data. |
635 | 634 | $valid_user_data = array( |
636 | 635 | // Assume there will be errors. |
637 | - 'user_id' => - 1, |
|
636 | + 'user_id' => -1, |
|
638 | 637 | |
639 | 638 | // Get first name. |
640 | 639 | 'user_first' => $user_data['give_first'], |
@@ -647,13 +646,13 @@ discard block |
||
647 | 646 | ); |
648 | 647 | |
649 | 648 | // Validate Required Form Fields. |
650 | - give_validate_required_form_fields( $form_id ); |
|
649 | + give_validate_required_form_fields($form_id); |
|
651 | 650 | |
652 | 651 | // Set Email as Username. |
653 | 652 | $valid_user_data['user_login'] = $user_data['give_email']; |
654 | 653 | |
655 | 654 | // Check if we have an email to verify. |
656 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
655 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
657 | 656 | $valid_user_data['user_email'] = $user_data['give_email']; |
658 | 657 | } |
659 | 658 | |
@@ -672,36 +671,36 @@ discard block |
||
672 | 671 | // Start an array to collect valid user data. |
673 | 672 | $valid_user_data = array( |
674 | 673 | // Assume there will be errors. |
675 | - 'user_id' => - 1, |
|
674 | + 'user_id' => -1, |
|
676 | 675 | ); |
677 | 676 | |
678 | 677 | // Username. |
679 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
680 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
678 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
679 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
681 | 680 | |
682 | 681 | return $valid_user_data; |
683 | 682 | } |
684 | 683 | |
685 | 684 | // Get the user by login. |
686 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
685 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
687 | 686 | |
688 | 687 | // Check if user exists. |
689 | - if ( $user_data ) { |
|
688 | + if ($user_data) { |
|
690 | 689 | // Get password. |
691 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
690 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
692 | 691 | |
693 | 692 | // Check user_pass. |
694 | - if ( $user_pass ) { |
|
693 | + if ($user_pass) { |
|
695 | 694 | // Check if password is valid. |
696 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
695 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
697 | 696 | // Incorrect password. |
698 | 697 | give_set_error( |
699 | 698 | 'password_incorrect', |
700 | 699 | sprintf( |
701 | 700 | '%1$s <a href="%2$s">%3$s</a>', |
702 | - __( 'The password you entered is incorrect.', 'give' ), |
|
703 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
704 | - __( 'Reset Password', 'give' ) |
|
701 | + __('The password you entered is incorrect.', 'give'), |
|
702 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
703 | + __('Reset Password', 'give') |
|
705 | 704 | ) |
706 | 705 | ); |
707 | 706 | // All is correct. |
@@ -719,11 +718,11 @@ discard block |
||
719 | 718 | } |
720 | 719 | } else { |
721 | 720 | // Empty password. |
722 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
721 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
723 | 722 | } |
724 | 723 | } else { |
725 | 724 | // No username. |
726 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
725 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
727 | 726 | }// End if(). |
728 | 727 | |
729 | 728 | return $valid_user_data; |
@@ -738,7 +737,7 @@ discard block |
||
738 | 737 | */ |
739 | 738 | function give_donation_form_validate_guest_user() { |
740 | 739 | |
741 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
740 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
742 | 741 | |
743 | 742 | // Start an array to collect valid user data. |
744 | 743 | $valid_user_data = array( |
@@ -747,31 +746,31 @@ discard block |
||
747 | 746 | ); |
748 | 747 | |
749 | 748 | // Get the guest email. |
750 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
749 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
751 | 750 | |
752 | 751 | // Check email. |
753 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
752 | + if ($guest_email && strlen($guest_email) > 0) { |
|
754 | 753 | // Validate email. |
755 | - if ( ! is_email( $guest_email ) ) { |
|
754 | + if ( ! is_email($guest_email)) { |
|
756 | 755 | // Invalid email. |
757 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
756 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
758 | 757 | } else { |
759 | 758 | // All is good to go. |
760 | 759 | $valid_user_data['user_email'] = $guest_email; |
761 | 760 | |
762 | 761 | // Get user_id from donor if exist. |
763 | - $donor = new Give_Donor( $guest_email ); |
|
764 | - if ( $donor->id && $donor->user_id ) { |
|
762 | + $donor = new Give_Donor($guest_email); |
|
763 | + if ($donor->id && $donor->user_id) { |
|
765 | 764 | $valid_user_data['user_id'] = $donor->user_id; |
766 | 765 | } |
767 | 766 | } |
768 | 767 | } else { |
769 | 768 | // No email. |
770 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
769 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
771 | 770 | } |
772 | 771 | |
773 | 772 | // Validate Required Form Fields. |
774 | - give_validate_required_form_fields( $form_id ); |
|
773 | + give_validate_required_form_fields($form_id); |
|
775 | 774 | |
776 | 775 | return $valid_user_data; |
777 | 776 | } |
@@ -785,36 +784,36 @@ discard block |
||
785 | 784 | * @since 1.0 |
786 | 785 | * @return integer |
787 | 786 | */ |
788 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
787 | +function give_register_and_login_new_user($user_data = array()) { |
|
789 | 788 | // Verify the array. |
790 | - if ( empty( $user_data ) ) { |
|
791 | - return - 1; |
|
789 | + if (empty($user_data)) { |
|
790 | + return -1; |
|
792 | 791 | } |
793 | 792 | |
794 | - if ( give_get_errors() ) { |
|
795 | - return - 1; |
|
793 | + if (give_get_errors()) { |
|
794 | + return -1; |
|
796 | 795 | } |
797 | 796 | |
798 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
799 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
800 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
801 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
802 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
803 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
804 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
805 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
806 | - ), $user_data ); |
|
797 | + $user_args = apply_filters('give_insert_user_args', array( |
|
798 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
799 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
800 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
801 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
802 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
803 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
804 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
805 | + ), $user_data); |
|
807 | 806 | |
808 | 807 | // Insert new user. |
809 | - $user_id = wp_insert_user( $user_args ); |
|
808 | + $user_id = wp_insert_user($user_args); |
|
810 | 809 | |
811 | 810 | // Validate inserted user. |
812 | - if ( is_wp_error( $user_id ) ) { |
|
813 | - return - 1; |
|
811 | + if (is_wp_error($user_id)) { |
|
812 | + return -1; |
|
814 | 813 | } |
815 | 814 | |
816 | 815 | // Allow themes and plugins to filter the user data. |
817 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
816 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
818 | 817 | |
819 | 818 | /** |
820 | 819 | * Fires after inserting user. |
@@ -824,7 +823,7 @@ discard block |
||
824 | 823 | * @param int $user_id User id. |
825 | 824 | * @param array $user_data Array containing user data. |
826 | 825 | */ |
827 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
826 | + do_action('give_insert_user', $user_id, $user_data); |
|
828 | 827 | |
829 | 828 | /** |
830 | 829 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -833,9 +832,9 @@ discard block |
||
833 | 832 | * |
834 | 833 | * return bool True if login with registration and False if only want to register. |
835 | 834 | */ |
836 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
835 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
837 | 836 | // Login new user. |
838 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
837 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
839 | 838 | } |
840 | 839 | |
841 | 840 | // Return user id. |
@@ -851,27 +850,27 @@ discard block |
||
851 | 850 | * @since 1.0 |
852 | 851 | * @return array|bool |
853 | 852 | */ |
854 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
853 | +function give_get_donation_form_user($valid_data = array()) { |
|
855 | 854 | |
856 | 855 | // Initialize user. |
857 | 856 | $user = false; |
858 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
857 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
859 | 858 | |
860 | - if ( $is_ajax ) { |
|
859 | + if ($is_ajax) { |
|
861 | 860 | // Do not create or login the user during the ajax submission (check for errors only). |
862 | 861 | return true; |
863 | - } elseif ( is_user_logged_in() ) { |
|
862 | + } elseif (is_user_logged_in()) { |
|
864 | 863 | // Set the valid user as the logged in collected data. |
865 | 864 | $user = $valid_data['logged_in_user']; |
866 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
865 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
867 | 866 | // New user registration. |
868 | - if ( $valid_data['need_new_user'] === true ) { |
|
867 | + if ($valid_data['need_new_user'] === true) { |
|
869 | 868 | // Set user. |
870 | 869 | $user = $valid_data['new_user_data']; |
871 | 870 | // Register and login new user. |
872 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
871 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
873 | 872 | // User login |
874 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
873 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
875 | 874 | |
876 | 875 | /** |
877 | 876 | * The login form is now processed in the give_process_donation_login() function. |
@@ -883,42 +882,42 @@ discard block |
||
883 | 882 | // Set user. |
884 | 883 | $user = $valid_data['login_user_data']; |
885 | 884 | // Login user. |
886 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
885 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
887 | 886 | } |
888 | 887 | } |
889 | 888 | |
890 | 889 | // Check guest checkout. |
891 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
890 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
892 | 891 | // Set user |
893 | 892 | $user = $valid_data['guest_user_data']; |
894 | 893 | } |
895 | 894 | |
896 | 895 | // Verify we have an user. |
897 | - if ( false === $user || empty( $user ) ) { |
|
896 | + if (false === $user || empty($user)) { |
|
898 | 897 | // Return false. |
899 | 898 | return false; |
900 | 899 | } |
901 | 900 | |
902 | 901 | // Get user first name. |
903 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
904 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
902 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
903 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
905 | 904 | } |
906 | 905 | |
907 | 906 | // Get user last name. |
908 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
909 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
907 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
908 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
910 | 909 | } |
911 | 910 | |
912 | 911 | // Get the user's billing address details. |
913 | 912 | $user['address'] = array(); |
914 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
915 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
916 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
917 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
918 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
919 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
920 | - |
|
921 | - if ( empty( $user['address']['country'] ) ) { |
|
913 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
914 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
915 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
916 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
917 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
918 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
919 | + |
|
920 | + if (empty($user['address']['country'])) { |
|
922 | 921 | $user['address'] = false; |
923 | 922 | } // End if(). |
924 | 923 | |
@@ -938,16 +937,16 @@ discard block |
||
938 | 937 | $card_data = give_get_donation_cc_info(); |
939 | 938 | |
940 | 939 | // Validate the card zip. |
941 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
942 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
943 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
940 | + if ( ! empty($card_data['card_zip'])) { |
|
941 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
942 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
944 | 943 | } |
945 | 944 | } |
946 | 945 | |
947 | 946 | // Ensure no spaces. |
948 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
949 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
950 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
947 | + if ( ! empty($card_data['card_number'])) { |
|
948 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
949 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
951 | 950 | } |
952 | 951 | |
953 | 952 | // This should validate card numbers at some point too. |
@@ -964,17 +963,17 @@ discard block |
||
964 | 963 | function give_get_donation_cc_info() { |
965 | 964 | |
966 | 965 | $cc_info = array(); |
967 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
968 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
969 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
970 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
971 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
972 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
973 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
974 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
975 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
976 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
977 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
966 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
967 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
968 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
969 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
970 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
971 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
972 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
973 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
974 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
975 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
976 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
978 | 977 | |
979 | 978 | // Return cc info. |
980 | 979 | return $cc_info; |
@@ -990,14 +989,14 @@ discard block |
||
990 | 989 | * |
991 | 990 | * @return bool|mixed |
992 | 991 | */ |
993 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
992 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
994 | 993 | $ret = false; |
995 | 994 | |
996 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
995 | + if (empty($zip) || empty($country_code)) { |
|
997 | 996 | return $ret; |
998 | 997 | } |
999 | 998 | |
1000 | - $country_code = strtoupper( $country_code ); |
|
999 | + $country_code = strtoupper($country_code); |
|
1001 | 1000 | |
1002 | 1001 | $zip_regex = array( |
1003 | 1002 | 'AD' => 'AD\d{3}', |
@@ -1157,11 +1156,11 @@ discard block |
||
1157 | 1156 | 'ZM' => '\d{5}', |
1158 | 1157 | ); |
1159 | 1158 | |
1160 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1159 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1161 | 1160 | $ret = true; |
1162 | 1161 | } |
1163 | 1162 | |
1164 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1163 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1165 | 1164 | } |
1166 | 1165 | |
1167 | 1166 | /** |
@@ -1173,49 +1172,49 @@ discard block |
||
1173 | 1172 | * |
1174 | 1173 | * @return bool |
1175 | 1174 | */ |
1176 | -function give_validate_donation_amount( $valid_data ) { |
|
1175 | +function give_validate_donation_amount($valid_data) { |
|
1177 | 1176 | $data = $_POST; |
1178 | 1177 | |
1179 | 1178 | /* @var Give_Donate_Form $form */ |
1180 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1179 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1181 | 1180 | |
1182 | 1181 | $donation_level_matched = false; |
1183 | 1182 | |
1184 | - if ( $form->is_set_type_donation_form() ) { |
|
1183 | + if ($form->is_set_type_donation_form()) { |
|
1185 | 1184 | // Sanitize donation amount. |
1186 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1185 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1187 | 1186 | |
1188 | 1187 | // Backward compatibility. |
1189 | - if ( $form->is_custom_price( $data['give-amount'] ) ) { |
|
1188 | + if ($form->is_custom_price($data['give-amount'])) { |
|
1190 | 1189 | $_POST['give-price-id'] = 'custom'; |
1191 | 1190 | } |
1192 | 1191 | |
1193 | 1192 | $donation_level_matched = true; |
1194 | 1193 | |
1195 | - } elseif ( $form->is_multi_type_donation_form() ) { |
|
1194 | + } elseif ($form->is_multi_type_donation_form()) { |
|
1196 | 1195 | |
1197 | 1196 | // Bailout. |
1198 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1197 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1199 | 1198 | return false; |
1200 | 1199 | } |
1201 | 1200 | |
1202 | 1201 | // Sanitize donation amount. |
1203 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1202 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1204 | 1203 | |
1205 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1204 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1206 | 1205 | return true; |
1207 | 1206 | } |
1208 | 1207 | |
1209 | - if ( $form->is_custom_price( $data['give-amount'] ) ) { |
|
1208 | + if ($form->is_custom_price($data['give-amount'])) { |
|
1210 | 1209 | $_POST['give-price-id'] = 'custom'; |
1211 | 1210 | } else { |
1212 | 1211 | // Find correct donation level from all donation levels. |
1213 | - foreach ( $variable_prices as $variable_price ) { |
|
1212 | + foreach ($variable_prices as $variable_price) { |
|
1214 | 1213 | // Sanitize level amount. |
1215 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1214 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1216 | 1215 | |
1217 | 1216 | // Set first match donation level ID. |
1218 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1217 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1219 | 1218 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1220 | 1219 | break; |
1221 | 1220 | } |
@@ -1224,15 +1223,15 @@ discard block |
||
1224 | 1223 | |
1225 | 1224 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
1226 | 1225 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1227 | - if ( ! empty( $_POST['give-price-id'] ) ) { |
|
1226 | + if ( ! empty($_POST['give-price-id'])) { |
|
1228 | 1227 | $donation_level_matched = true; |
1229 | 1228 | } |
1230 | 1229 | }// End if(). |
1231 | 1230 | |
1232 | - return ( $donation_level_matched ? true : false ); |
|
1231 | + return ($donation_level_matched ? true : false); |
|
1233 | 1232 | } |
1234 | 1233 | |
1235 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 ); |
|
1234 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1); |
|
1236 | 1235 | |
1237 | 1236 | /** |
1238 | 1237 | * Validate Required Form Fields. |
@@ -1241,17 +1240,17 @@ discard block |
||
1241 | 1240 | * |
1242 | 1241 | * @since 2.0 |
1243 | 1242 | */ |
1244 | -function give_validate_required_form_fields( $form_id ) { |
|
1243 | +function give_validate_required_form_fields($form_id) { |
|
1245 | 1244 | |
1246 | 1245 | // Loop through required fields and show error messages. |
1247 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
1246 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
1248 | 1247 | |
1249 | 1248 | // Clean Up Data of the input fields. |
1250 | - $field_value = give_clean( $_POST[ $field_name ] ); |
|
1249 | + $field_value = give_clean($_POST[$field_name]); |
|
1251 | 1250 | |
1252 | 1251 | // Check whether the required field is empty, then show the error message. |
1253 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $field_value ) ) { |
|
1254 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
1252 | + if (in_array($value, give_get_required_fields($form_id)) && empty($field_value)) { |
|
1253 | + give_set_error($value['error_id'], $value['error_message']); |
|
1255 | 1254 | } |
1256 | 1255 | } |
1257 | 1256 | } |
@@ -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,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | |
40 | 40 | global $wp; |
41 | 41 | |
42 | - if ( get_option( 'permalink_structure' ) ) { |
|
43 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
42 | + if (get_option('permalink_structure')) { |
|
43 | + $base = trailingslashit(home_url($wp->request)); |
|
44 | 44 | } else { |
45 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
46 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
45 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
46 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $scheme = is_ssl() ? 'https' : 'http'; |
50 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
50 | + $current_uri = set_url_scheme($base, $scheme); |
|
51 | 51 | |
52 | - if ( is_front_page() ) { |
|
53 | - $current_uri = home_url( '/' ); |
|
52 | + if (is_front_page()) { |
|
53 | + $current_uri = home_url('/'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $current_uri |
62 | 62 | */ |
63 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
63 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | */ |
83 | 83 | $gateways = give_get_enabled_payment_gateways(); |
84 | 84 | |
85 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
85 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
86 | 86 | $ret = true; |
87 | - } elseif ( count( $gateways ) == 1 ) { |
|
87 | + } elseif (count($gateways) == 1) { |
|
88 | 88 | $ret = false; |
89 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
89 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
90 | 90 | $ret = false; |
91 | 91 | } |
92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param bool $ret |
99 | 99 | */ |
100 | - return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret ); |
|
100 | + return (bool) apply_filters('give_is_cc_verify_enabled', $ret); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -109,26 +109,26 @@ discard block |
||
109 | 109 | function give_get_timezone_id() { |
110 | 110 | |
111 | 111 | // if site timezone string exists, return it. |
112 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
112 | + if ($timezone = get_option('timezone_string')) { |
|
113 | 113 | return $timezone; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // get UTC offset, if it isn't set return UTC. |
117 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
117 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
118 | 118 | return 'UTC'; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // attempt to guess the timezone string from the UTC offset. |
122 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
122 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
123 | 123 | |
124 | 124 | // last try, guess timezone string manually. |
125 | - if ( $timezone === false ) { |
|
125 | + if ($timezone === false) { |
|
126 | 126 | |
127 | - $is_dst = date( 'I' ); |
|
127 | + $is_dst = date('I'); |
|
128 | 128 | |
129 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
130 | - foreach ( $abbr as $city ) { |
|
131 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
129 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
130 | + foreach ($abbr as $city) { |
|
131 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
132 | 132 | return $city['timezone_id']; |
133 | 133 | } |
134 | 134 | } |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | |
153 | 153 | $ip = '127.0.0.1'; |
154 | 154 | |
155 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
155 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
156 | 156 | // check ip from share internet |
157 | 157 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
158 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
158 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
159 | 159 | // to check ip is pass from proxy |
160 | 160 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
161 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
161 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
162 | 162 | $ip = $_SERVER['REMOTE_ADDR']; |
163 | 163 | } |
164 | 164 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - $ip = apply_filters( 'give_get_ip', $ip ); |
|
170 | + $ip = apply_filters('give_get_ip', $ip); |
|
171 | 171 | |
172 | 172 | // Filter empty values. |
173 | - if( false !== strpos( $ip, ',' ) ) { |
|
174 | - $ip = give_clean( explode( ',', $ip ) ); |
|
175 | - $ip = array_filter( $ip ); |
|
176 | - $ip = implode( ',', $ip ); |
|
177 | - } else{ |
|
178 | - $ip = give_clean( $ip ); |
|
173 | + if (false !== strpos($ip, ',')) { |
|
174 | + $ip = give_clean(explode(',', $ip)); |
|
175 | + $ip = array_filter($ip); |
|
176 | + $ip = implode(',', $ip); |
|
177 | + } else { |
|
178 | + $ip = give_clean($ip); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $ip; |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @uses Give()->session->set() |
195 | 195 | */ |
196 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
197 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
198 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
196 | +function give_set_purchase_session($purchase_data = array()) { |
|
197 | + Give()->session->set('give_purchase', $purchase_data); |
|
198 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return mixed array | false |
210 | 210 | */ |
211 | 211 | function give_get_purchase_session() { |
212 | - return Give()->session->get( 'give_purchase' ); |
|
212 | + return Give()->session->get('give_purchase'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return array|string |
221 | 221 | */ |
222 | 222 | function give_get_receipt_session() { |
223 | - return Give()->session->get( 'receipt_access' ); |
|
223 | + return Give()->session->get('receipt_access'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return array|string |
232 | 232 | */ |
233 | 233 | function give_get_history_session() { |
234 | - return (bool) Give()->session->get( 'history_access' ); |
|
234 | + return (bool) Give()->session->get('history_access'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return string By default, the name of the form. Then the price level text if any is found. |
245 | 245 | */ |
246 | -function give_payment_gateway_item_title( $payment_data ) { |
|
246 | +function give_payment_gateway_item_title($payment_data) { |
|
247 | 247 | |
248 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
249 | - $item_name = isset( $payment_data['post_data']['give-form-title'] ) ? $payment_data['post_data']['give-form-title'] : ''; |
|
250 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
248 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
249 | + $item_name = isset($payment_data['post_data']['give-form-title']) ? $payment_data['post_data']['give-form-title'] : ''; |
|
250 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
251 | 251 | |
252 | 252 | |
253 | 253 | // Verify has variable prices. |
254 | - if ( give_has_variable_prices( $form_id ) && ! empty( $price_id ) ) { |
|
254 | + if (give_has_variable_prices($form_id) && ! empty($price_id)) { |
|
255 | 255 | |
256 | - $item_price_level_text = give_get_price_option_name( $form_id, $price_id, 0, false ); |
|
256 | + $item_price_level_text = give_get_price_option_name($form_id, $price_id, 0, false); |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Output donation level text if: |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | */ |
264 | 264 | if ( |
265 | 265 | 'custom' !== $price_id |
266 | - && ! empty( $item_price_level_text ) |
|
266 | + && ! empty($item_price_level_text) |
|
267 | 267 | ) { |
268 | 268 | // Matches a donation level - append level text. |
269 | - $item_name .= ' - ' . $item_price_level_text; |
|
269 | + $item_name .= ' - '.$item_price_level_text; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data ); |
|
284 | + return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -297,38 +297,38 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return string |
299 | 299 | */ |
300 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
300 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
301 | 301 | |
302 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
303 | - $price_id = isset( $donation_data['post_data']['give-price-id'] ) ? $donation_data['post_data']['give-price-id'] : ''; |
|
302 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
303 | + $price_id = isset($donation_data['post_data']['give-price-id']) ? $donation_data['post_data']['give-price-id'] : ''; |
|
304 | 304 | |
305 | 305 | // Form title. |
306 | - $summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) ); |
|
306 | + $summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give'))); |
|
307 | 307 | |
308 | 308 | // Form multilevel if applicable. |
309 | - if ( ! empty( $price_id ) && 'custom' !== $price_id ) { |
|
310 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
309 | + if ( ! empty($price_id) && 'custom' !== $price_id) { |
|
310 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | // Add Donor's name + email if requested. |
314 | - if ( $name_and_email ) { |
|
314 | + if ($name_and_email) { |
|
315 | 315 | |
316 | 316 | // First name |
317 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
318 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
317 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
318 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
319 | 319 | } |
320 | 320 | |
321 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
322 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
321 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
322 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
323 | 323 | } |
324 | 324 | |
325 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
325 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | // Cut the length |
329 | - $summary = substr( $summary, 0, $length ); |
|
329 | + $summary = substr($summary, 0, $length); |
|
330 | 330 | |
331 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
331 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -343,31 +343,31 @@ discard block |
||
343 | 343 | function give_get_host() { |
344 | 344 | $host = false; |
345 | 345 | |
346 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
346 | + if (defined('WPE_APIKEY')) { |
|
347 | 347 | $host = 'WP Engine'; |
348 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
348 | + } elseif (defined('PAGELYBIN')) { |
|
349 | 349 | $host = 'Pagely'; |
350 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
350 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
351 | 351 | $host = 'ICDSoft'; |
352 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
352 | + } elseif (DB_HOST == 'mysqlv5') { |
|
353 | 353 | $host = 'NetworkSolutions'; |
354 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
354 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
355 | 355 | $host = 'iPage'; |
356 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
356 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
357 | 357 | $host = 'IPower'; |
358 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
358 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
359 | 359 | $host = 'MediaTemple Grid'; |
360 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
360 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
361 | 361 | $host = 'pair Networks'; |
362 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
362 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
363 | 363 | $host = 'Rackspace Cloud'; |
364 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
364 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
365 | 365 | $host = 'SysFix.eu Power Hosting'; |
366 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
366 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
367 | 367 | $host = 'Flywheel'; |
368 | 368 | } else { |
369 | 369 | // Adding a general fallback for data gathering |
370 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
370 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return $host; |
@@ -383,67 +383,67 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @return bool true if host matches, false if not |
385 | 385 | */ |
386 | -function give_is_host( $host = false ) { |
|
386 | +function give_is_host($host = false) { |
|
387 | 387 | |
388 | 388 | $return = false; |
389 | 389 | |
390 | - if ( $host ) { |
|
391 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
390 | + if ($host) { |
|
391 | + $host = str_replace(' ', '', strtolower($host)); |
|
392 | 392 | |
393 | - switch ( $host ) { |
|
393 | + switch ($host) { |
|
394 | 394 | case 'wpengine': |
395 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
395 | + if (defined('WPE_APIKEY')) { |
|
396 | 396 | $return = true; |
397 | 397 | } |
398 | 398 | break; |
399 | 399 | case 'pagely': |
400 | - if ( defined( 'PAGELYBIN' ) ) { |
|
400 | + if (defined('PAGELYBIN')) { |
|
401 | 401 | $return = true; |
402 | 402 | } |
403 | 403 | break; |
404 | 404 | case 'icdsoft': |
405 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
405 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
406 | 406 | $return = true; |
407 | 407 | } |
408 | 408 | break; |
409 | 409 | case 'networksolutions': |
410 | - if ( DB_HOST == 'mysqlv5' ) { |
|
410 | + if (DB_HOST == 'mysqlv5') { |
|
411 | 411 | $return = true; |
412 | 412 | } |
413 | 413 | break; |
414 | 414 | case 'ipage': |
415 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
415 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
416 | 416 | $return = true; |
417 | 417 | } |
418 | 418 | break; |
419 | 419 | case 'ipower': |
420 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
420 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
421 | 421 | $return = true; |
422 | 422 | } |
423 | 423 | break; |
424 | 424 | case 'mediatemplegrid': |
425 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
425 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
426 | 426 | $return = true; |
427 | 427 | } |
428 | 428 | break; |
429 | 429 | case 'pairnetworks': |
430 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
430 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
431 | 431 | $return = true; |
432 | 432 | } |
433 | 433 | break; |
434 | 434 | case 'rackspacecloud': |
435 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
435 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
436 | 436 | $return = true; |
437 | 437 | } |
438 | 438 | break; |
439 | 439 | case 'sysfix.eu': |
440 | 440 | case 'sysfix.eupowerhosting': |
441 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
441 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
442 | 442 | $return = true; |
443 | 443 | } |
444 | 444 | break; |
445 | 445 | case 'flywheel': |
446 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
446 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
447 | 447 | $return = true; |
448 | 448 | } |
449 | 449 | break; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param string $replacement Optional. The function that should have been called. |
477 | 477 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
478 | 478 | */ |
479 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
479 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
480 | 480 | |
481 | 481 | /** |
482 | 482 | * Fires while give deprecated function call occurs. |
@@ -489,19 +489,19 @@ discard block |
||
489 | 489 | * @param string $replacement Optional. The function that should have been called. |
490 | 490 | * @param string $version The plugin version that deprecated the function. |
491 | 491 | */ |
492 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
492 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
493 | 493 | |
494 | - $show_errors = current_user_can( 'manage_options' ); |
|
494 | + $show_errors = current_user_can('manage_options'); |
|
495 | 495 | |
496 | 496 | // Allow plugin to filter the output error trigger. |
497 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
498 | - if ( ! is_null( $replacement ) ) { |
|
499 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
500 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
497 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
498 | + if ( ! is_null($replacement)) { |
|
499 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
500 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
501 | 501 | // Alternatively we could dump this to a file. |
502 | 502 | } else { |
503 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
504 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
503 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
504 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
505 | 505 | // Alternatively we could dump this to a file. |
506 | 506 | } |
507 | 507 | } |
@@ -515,17 +515,17 @@ discard block |
||
515 | 515 | * @return string $post_id |
516 | 516 | */ |
517 | 517 | function give_get_admin_post_id() { |
518 | - $post_id = isset( $_REQUEST['post'] ) |
|
519 | - ? absint( $_REQUEST['post'] ) |
|
518 | + $post_id = isset($_REQUEST['post']) |
|
519 | + ? absint($_REQUEST['post']) |
|
520 | 520 | : null; |
521 | 521 | |
522 | - $post_id = ! empty( $post_id ) |
|
522 | + $post_id = ! empty($post_id) |
|
523 | 523 | ? $post_id |
524 | - : ( isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : null ); |
|
524 | + : (isset($_REQUEST['post_id']) ? absint($_REQUEST['post_id']) : null); |
|
525 | 525 | |
526 | - $post_id = ! empty( $post_id ) |
|
526 | + $post_id = ! empty($post_id) |
|
527 | 527 | ? $post_id |
528 | - : ( isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : null ); |
|
528 | + : (isset($_REQUEST['post_ID']) ? absint($_REQUEST['post_ID']) : null); |
|
529 | 529 | |
530 | 530 | return $post_id; |
531 | 531 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @return string Arg separator output |
538 | 538 | */ |
539 | 539 | function give_get_php_arg_separator_output() { |
540 | - return ini_get( 'arg_separator.output' ); |
|
540 | + return ini_get('arg_separator.output'); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
@@ -552,10 +552,10 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return string Short month name |
554 | 554 | */ |
555 | -function give_month_num_to_name( $n ) { |
|
556 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
555 | +function give_month_num_to_name($n) { |
|
556 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
557 | 557 | |
558 | - return date_i18n( 'M', $timestamp ); |
|
558 | + return date_i18n('M', $timestamp); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return bool Whether or not function is disabled. |
570 | 570 | */ |
571 | -function give_is_func_disabled( $function ) { |
|
572 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
571 | +function give_is_func_disabled($function) { |
|
572 | + $disabled = explode(',', ini_get('disable_functions')); |
|
573 | 573 | |
574 | - return in_array( $function, $disabled ); |
|
574 | + return in_array($function, $disabled); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | function give_get_newsletter() { |
584 | 584 | ?> |
585 | 585 | |
586 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
586 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
587 | 587 | |
588 | 588 | <div class="give-newsletter-form-wrap"> |
589 | 589 | |
@@ -591,33 +591,33 @@ discard block |
||
591 | 591 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
592 | 592 | target="_blank" novalidate> |
593 | 593 | <div class="give-newsletter-confirmation"> |
594 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
594 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
595 | 595 | </div> |
596 | 596 | |
597 | 597 | <table class="form-table give-newsletter-form"> |
598 | 598 | <tr valign="middle"> |
599 | 599 | <td> |
600 | 600 | <label for="mce-EMAIL" |
601 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
601 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
602 | 602 | <input type="email" name="EMAIL" id="mce-EMAIL" |
603 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
603 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
604 | 604 | class="required email" value=""> |
605 | 605 | </td> |
606 | 606 | <td> |
607 | 607 | <label for="mce-FNAME" |
608 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
608 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
609 | 609 | <input type="text" name="FNAME" id="mce-FNAME" |
610 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
610 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
611 | 611 | </td> |
612 | 612 | <td> |
613 | 613 | <label for="mce-LNAME" |
614 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
614 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
615 | 615 | <input type="text" name="LNAME" id="mce-LNAME" |
616 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
616 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
617 | 617 | </td> |
618 | 618 | <td> |
619 | 619 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
620 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
620 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
621 | 621 | </td> |
622 | 622 | </tr> |
623 | 623 | </table> |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return string |
672 | 672 | */ |
673 | -function give_svg_icons( $icon ) { |
|
673 | +function give_svg_icons($icon) { |
|
674 | 674 | |
675 | 675 | // Store your SVGs in an associative array |
676 | 676 | $svgs = array( |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | ); |
683 | 683 | |
684 | 684 | // Return the chosen icon's SVG string |
685 | - return $svgs[ $icon ]; |
|
685 | + return $svgs[$icon]; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -694,15 +694,15 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @return mixed |
696 | 696 | */ |
697 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
698 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
699 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
697 | +function modify_nav_menu_meta_box_object($post_type) { |
|
698 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
699 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | return $post_type; |
703 | 703 | } |
704 | 704 | |
705 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
705 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
706 | 706 | |
707 | 707 | /** |
708 | 708 | * Show Donation Forms Post Type in Appearance > Menus by default on fresh install. |
@@ -721,35 +721,35 @@ discard block |
||
721 | 721 | // Proceed, if current screen is navigation menus. |
722 | 722 | if ( |
723 | 723 | 'nav-menus' === $screen->id && |
724 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && |
|
725 | - ! get_user_option( 'give_is_donation_forms_menu_updated' ) |
|
724 | + give_is_setting_enabled(give_get_option('forms_singular')) && |
|
725 | + ! get_user_option('give_is_donation_forms_menu_updated') |
|
726 | 726 | ) { |
727 | 727 | |
728 | 728 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
729 | 729 | if ( |
730 | 730 | ! is_admin() || |
731 | - ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) |
|
731 | + ( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) |
|
732 | 732 | ) { |
733 | 733 | return false; |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
737 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
737 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
738 | 738 | return false; |
739 | 739 | } |
740 | 740 | |
741 | 741 | // Exclude 'Donation Form' value from hidden meta box's list. |
742 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
742 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
743 | 743 | |
744 | 744 | // Get current user ID. |
745 | 745 | $user = wp_get_current_user(); |
746 | 746 | |
747 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
748 | - update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true ); |
|
747 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
748 | + update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | -add_action( 'current_screen', 'give_donation_metabox_menu' ); |
|
752 | +add_action('current_screen', 'give_donation_metabox_menu'); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Array_column backup usage |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * @license https://opensource.org/licenses/MIT MIT |
763 | 763 | */ |
764 | 764 | |
765 | -if ( ! function_exists( 'array_column' ) ) { |
|
765 | +if ( ! function_exists('array_column')) { |
|
766 | 766 | /** |
767 | 767 | * Returns the values from a single column of the input array, identified by |
768 | 768 | * the $columnKey. |
@@ -781,53 +781,53 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return array |
783 | 783 | */ |
784 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
784 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
785 | 785 | // Using func_get_args() in order to check for proper number of |
786 | 786 | // parameters and trigger errors exactly as the built-in array_column() |
787 | 787 | // does in PHP 5.5. |
788 | 788 | $argc = func_num_args(); |
789 | 789 | $params = func_get_args(); |
790 | 790 | |
791 | - if ( $argc < 2 ) { |
|
792 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
791 | + if ($argc < 2) { |
|
792 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
793 | 793 | |
794 | 794 | return null; |
795 | 795 | } |
796 | 796 | |
797 | - if ( ! is_array( $params[0] ) ) { |
|
798 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
797 | + if ( ! is_array($params[0])) { |
|
798 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
799 | 799 | |
800 | 800 | return null; |
801 | 801 | } |
802 | 802 | |
803 | - if ( ! is_int( $params[1] ) |
|
804 | - && ! is_float( $params[1] ) |
|
805 | - && ! is_string( $params[1] ) |
|
803 | + if ( ! is_int($params[1]) |
|
804 | + && ! is_float($params[1]) |
|
805 | + && ! is_string($params[1]) |
|
806 | 806 | && $params[1] !== null |
807 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
807 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
808 | 808 | ) { |
809 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
809 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
810 | 810 | |
811 | 811 | return false; |
812 | 812 | } |
813 | 813 | |
814 | - if ( isset( $params[2] ) |
|
815 | - && ! is_int( $params[2] ) |
|
816 | - && ! is_float( $params[2] ) |
|
817 | - && ! is_string( $params[2] ) |
|
818 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
814 | + if (isset($params[2]) |
|
815 | + && ! is_int($params[2]) |
|
816 | + && ! is_float($params[2]) |
|
817 | + && ! is_string($params[2]) |
|
818 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
819 | 819 | ) { |
820 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
820 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
821 | 821 | |
822 | 822 | return false; |
823 | 823 | } |
824 | 824 | |
825 | 825 | $paramsInput = $params[0]; |
826 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
826 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
827 | 827 | |
828 | 828 | $paramsIndexKey = null; |
829 | - if ( isset( $params[2] ) ) { |
|
830 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
829 | + if (isset($params[2])) { |
|
830 | + if (is_float($params[2]) || is_int($params[2])) { |
|
831 | 831 | $paramsIndexKey = (int) $params[2]; |
832 | 832 | } else { |
833 | 833 | $paramsIndexKey = (string) $params[2]; |
@@ -836,26 +836,26 @@ discard block |
||
836 | 836 | |
837 | 837 | $resultArray = array(); |
838 | 838 | |
839 | - foreach ( $paramsInput as $row ) { |
|
839 | + foreach ($paramsInput as $row) { |
|
840 | 840 | $key = $value = null; |
841 | 841 | $keySet = $valueSet = false; |
842 | 842 | |
843 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
843 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
844 | 844 | $keySet = true; |
845 | - $key = (string) $row[ $paramsIndexKey ]; |
|
845 | + $key = (string) $row[$paramsIndexKey]; |
|
846 | 846 | } |
847 | 847 | |
848 | - if ( $paramsColumnKey === null ) { |
|
848 | + if ($paramsColumnKey === null) { |
|
849 | 849 | $valueSet = true; |
850 | 850 | $value = $row; |
851 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
851 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
852 | 852 | $valueSet = true; |
853 | - $value = $row[ $paramsColumnKey ]; |
|
853 | + $value = $row[$paramsColumnKey]; |
|
854 | 854 | } |
855 | 855 | |
856 | - if ( $valueSet ) { |
|
857 | - if ( $keySet ) { |
|
858 | - $resultArray[ $key ] = $value; |
|
856 | + if ($valueSet) { |
|
857 | + if ($keySet) { |
|
858 | + $resultArray[$key] = $value; |
|
859 | 859 | } else { |
860 | 860 | $resultArray[] = $value; |
861 | 861 | } |
@@ -875,54 +875,54 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return bool Whether the receipt is visible or not. |
877 | 877 | */ |
878 | -function give_can_view_receipt( $payment_key = '' ) { |
|
878 | +function give_can_view_receipt($payment_key = '') { |
|
879 | 879 | |
880 | 880 | $return = false; |
881 | 881 | |
882 | - if ( empty( $payment_key ) ) { |
|
882 | + if (empty($payment_key)) { |
|
883 | 883 | return $return; |
884 | 884 | } |
885 | 885 | |
886 | 886 | global $give_receipt_args; |
887 | 887 | |
888 | - $give_receipt_args['id'] = give_get_donation_id_by_key( $payment_key ); |
|
888 | + $give_receipt_args['id'] = give_get_donation_id_by_key($payment_key); |
|
889 | 889 | |
890 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
890 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
891 | 891 | |
892 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
892 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
893 | 893 | |
894 | - if ( is_user_logged_in() ) { |
|
895 | - if ( $user_id === (int) get_current_user_id() ) { |
|
894 | + if (is_user_logged_in()) { |
|
895 | + if ($user_id === (int) get_current_user_id()) { |
|
896 | 896 | $return = true; |
897 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
897 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
898 | 898 | $return = true; |
899 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
899 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
900 | 900 | $return = true; |
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
904 | 904 | // Check whether it is purchase session? |
905 | 905 | $purchase_session = give_get_purchase_session(); |
906 | - if ( ! empty( $purchase_session ) && ! is_user_logged_in() ) { |
|
907 | - if ( $purchase_session['purchase_key'] === $payment_meta['key'] ) { |
|
906 | + if ( ! empty($purchase_session) && ! is_user_logged_in()) { |
|
907 | + if ($purchase_session['purchase_key'] === $payment_meta['key']) { |
|
908 | 908 | $return = true; |
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
912 | 912 | // Check whether it is receipt access session? |
913 | 913 | $receipt_session = give_get_receipt_session(); |
914 | - if ( ! empty( $receipt_session ) && ! is_user_logged_in() ) { |
|
915 | - if ( $receipt_session === $payment_meta['key'] ) { |
|
914 | + if ( ! empty($receipt_session) && ! is_user_logged_in()) { |
|
915 | + if ($receipt_session === $payment_meta['key']) { |
|
916 | 916 | $return = true; |
917 | 917 | } |
918 | 918 | } |
919 | 919 | |
920 | 920 | // Check whether it is history access session? |
921 | - if ( true === give_get_history_session() ) { |
|
921 | + if (true === give_get_history_session()) { |
|
922 | 922 | $return = true; |
923 | 923 | } |
924 | 924 | |
925 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
925 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
926 | 926 | |
927 | 927 | } |
928 | 928 | |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | * |
932 | 932 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
933 | 933 | */ |
934 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
934 | +if ( ! function_exists('cal_days_in_month')) { |
|
935 | 935 | /** |
936 | 936 | * cal_days_in_month |
937 | 937 | * |
@@ -941,8 +941,8 @@ discard block |
||
941 | 941 | * |
942 | 942 | * @return bool|string |
943 | 943 | */ |
944 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
945 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
944 | + function cal_days_in_month($calendar, $month, $year) { |
|
945 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | |
@@ -961,42 +961,42 @@ discard block |
||
961 | 961 | */ |
962 | 962 | function give_get_plugins() { |
963 | 963 | $plugins = get_plugins(); |
964 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
964 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
965 | 965 | |
966 | - if ( is_multisite() ) { |
|
967 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
968 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
966 | + if (is_multisite()) { |
|
967 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
968 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
969 | 969 | } |
970 | 970 | |
971 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
971 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
972 | 972 | // Is plugin active? |
973 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
974 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
973 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
974 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
975 | 975 | } else { |
976 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
976 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
977 | 977 | } |
978 | 978 | |
979 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
979 | + $dirname = strtolower(dirname($plugin_path)); |
|
980 | 980 | |
981 | 981 | // Is plugin a Give add-on by WordImpress? |
982 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
982 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
983 | 983 | // Plugin is a Give-addon. |
984 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
984 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
985 | 985 | |
986 | 986 | // Get license info from database. |
987 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
988 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
989 | - $license_active = get_option( $db_option ); |
|
987 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
988 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
989 | + $license_active = get_option($db_option); |
|
990 | 990 | |
991 | 991 | // Does a valid license exist? |
992 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
993 | - $plugins[ $plugin_path ]['License'] = true; |
|
992 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
993 | + $plugins[$plugin_path]['License'] = true; |
|
994 | 994 | } else { |
995 | - $plugins[ $plugin_path ]['License'] = false; |
|
995 | + $plugins[$plugin_path]['License'] = false; |
|
996 | 996 | } |
997 | 997 | } else { |
998 | 998 | // Plugin is not a Give add-on. |
999 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
999 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1013,16 +1013,16 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @return bool |
1015 | 1015 | */ |
1016 | -function give_is_terms_enabled( $form_id ) { |
|
1017 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1016 | +function give_is_terms_enabled($form_id) { |
|
1017 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1018 | 1018 | |
1019 | 1019 | if ( |
1020 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1021 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1020 | + give_is_setting_enabled($form_option, 'global') |
|
1021 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1022 | 1022 | ) { |
1023 | 1023 | return true; |
1024 | 1024 | |
1025 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1025 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1026 | 1026 | return true; |
1027 | 1027 | |
1028 | 1028 | } else { |
@@ -1047,10 +1047,10 @@ discard block |
||
1047 | 1047 | * |
1048 | 1048 | * @return WP_Error|bool |
1049 | 1049 | */ |
1050 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1050 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1051 | 1051 | |
1052 | 1052 | // Delete all cache. |
1053 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1053 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1054 | 1054 | |
1055 | 1055 | /** |
1056 | 1056 | * Fire the action when donation stats delete. |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | * @param string|array $date_range |
1061 | 1061 | * @param array $args |
1062 | 1062 | */ |
1063 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1063 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1064 | 1064 | |
1065 | 1065 | return $status; |
1066 | 1066 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | function give_is_add_new_form_page() { |
1075 | 1075 | $status = false; |
1076 | 1076 | |
1077 | - if ( false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) { |
|
1077 | + if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) { |
|
1078 | 1078 | $status = true; |
1079 | 1079 | } |
1080 | 1080 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return mixed |
1099 | 1099 | */ |
1100 | -function give_get_meta( $id, $meta_key = '', $single = false, $default = false ) { |
|
1100 | +function give_get_meta($id, $meta_key = '', $single = false, $default = false) { |
|
1101 | 1101 | /** |
1102 | 1102 | * Filter the meta value |
1103 | 1103 | * |
@@ -1105,14 +1105,14 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | $meta_value = apply_filters( |
1107 | 1107 | 'give_get_meta', |
1108 | - get_post_meta( $id, $meta_key, $single ), |
|
1108 | + get_post_meta($id, $meta_key, $single), |
|
1109 | 1109 | $id, |
1110 | 1110 | $meta_key, |
1111 | 1111 | $default |
1112 | 1112 | ); |
1113 | 1113 | |
1114 | 1114 | if ( |
1115 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
1115 | + (empty($meta_key) || empty($meta_value)) |
|
1116 | 1116 | && $default |
1117 | 1117 | ) { |
1118 | 1118 | $meta_value = $default; |
@@ -1133,15 +1133,15 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @return mixed |
1135 | 1135 | */ |
1136 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1137 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
1136 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
1137 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
1138 | 1138 | |
1139 | 1139 | /** |
1140 | 1140 | * Filter the meta value update status |
1141 | 1141 | * |
1142 | 1142 | * @since 1.8.8 |
1143 | 1143 | */ |
1144 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
1144 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1155,15 +1155,15 @@ discard block |
||
1155 | 1155 | * |
1156 | 1156 | * @return mixed |
1157 | 1157 | */ |
1158 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
1159 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
1158 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
1159 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
1160 | 1160 | |
1161 | 1161 | /** |
1162 | 1162 | * Filter the meta value delete status |
1163 | 1163 | * |
1164 | 1164 | * @since 1.8.8 |
1165 | 1165 | */ |
1166 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
1166 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1175,23 +1175,23 @@ discard block |
||
1175 | 1175 | * |
1176 | 1176 | * @return bool If the action has been added to the completed actions array |
1177 | 1177 | */ |
1178 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
1178 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
1179 | 1179 | // Bailout. |
1180 | - if ( empty( $upgrade_action ) ) { |
|
1180 | + if (empty($upgrade_action)) { |
|
1181 | 1181 | return false; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | // Fresh install? |
1185 | 1185 | // If fresh install then all upgrades will be consider as completed. |
1186 | - $is_fresh_install = ! get_option( 'give_version' ); |
|
1187 | - if ( $is_fresh_install ) { |
|
1186 | + $is_fresh_install = ! get_option('give_version'); |
|
1187 | + if ($is_fresh_install) { |
|
1188 | 1188 | return true; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | |
1192 | 1192 | $completed_upgrades = give_get_completed_upgrades(); |
1193 | 1193 | |
1194 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
1194 | + return in_array($upgrade_action, $completed_upgrades); |
|
1195 | 1195 | |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1203,8 +1203,8 @@ discard block |
||
1203 | 1203 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
1204 | 1204 | */ |
1205 | 1205 | function give_maybe_resume_upgrade() { |
1206 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
1207 | - if ( empty( $doing_upgrade ) ) { |
|
1206 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
1207 | + if (empty($doing_upgrade)) { |
|
1208 | 1208 | return false; |
1209 | 1209 | } |
1210 | 1210 | |
@@ -1220,9 +1220,9 @@ discard block |
||
1220 | 1220 | * |
1221 | 1221 | * @return bool If the function was successfully added |
1222 | 1222 | */ |
1223 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
1223 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
1224 | 1224 | |
1225 | - if ( empty( $upgrade_action ) ) { |
|
1225 | + if (empty($upgrade_action)) { |
|
1226 | 1226 | return false; |
1227 | 1227 | } |
1228 | 1228 | |
@@ -1230,16 +1230,16 @@ discard block |
||
1230 | 1230 | $completed_upgrades[] = $upgrade_action; |
1231 | 1231 | |
1232 | 1232 | // Remove any blanks, and only show uniques. |
1233 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
1233 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
1234 | 1234 | |
1235 | 1235 | /** |
1236 | 1236 | * Fire the action when any upgrade set to complete. |
1237 | 1237 | * |
1238 | 1238 | * @since 1.8.12 |
1239 | 1239 | */ |
1240 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
1240 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
1241 | 1241 | |
1242 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
1242 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | /** |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | * @return array The array of completed upgrades |
1250 | 1250 | */ |
1251 | 1251 | function give_get_completed_upgrades() { |
1252 | - return (array) get_option( 'give_completed_upgrades' ); |
|
1252 | + return (array) get_option('give_completed_upgrades'); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | /** |
@@ -1264,16 +1264,16 @@ discard block |
||
1264 | 1264 | * |
1265 | 1265 | * @return null|array |
1266 | 1266 | */ |
1267 | -function __give_v20_bc_table_details( $type ) { |
|
1267 | +function __give_v20_bc_table_details($type) { |
|
1268 | 1268 | global $wpdb; |
1269 | 1269 | $table = array(); |
1270 | 1270 | |
1271 | 1271 | // Bailout. |
1272 | - if ( empty( $type ) ) { |
|
1272 | + if (empty($type)) { |
|
1273 | 1273 | return null; |
1274 | 1274 | } |
1275 | 1275 | |
1276 | - switch ( $type ) { |
|
1276 | + switch ($type) { |
|
1277 | 1277 | case 'form': |
1278 | 1278 | $table['name'] = $wpdb->formmeta; |
1279 | 1279 | $table['column']['id'] = 'form_id'; |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | // Backward compatibility. |
1289 | - if ( ! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) ) { |
|
1289 | + if ( ! give_has_upgrade_completed('v20_move_metadata_into_new_table')) { |
|
1290 | 1290 | $table['name'] = $wpdb->postmeta; |
1291 | 1291 | $table['column']['id'] = 'post_id'; |
1292 | 1292 | } |
@@ -1302,12 +1302,12 @@ discard block |
||
1302 | 1302 | * |
1303 | 1303 | * @param WP_Query $query |
1304 | 1304 | */ |
1305 | -function give_remove_pages_from_search( $query ) { |
|
1305 | +function give_remove_pages_from_search($query) { |
|
1306 | 1306 | |
1307 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
1307 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
1308 | 1308 | |
1309 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
1310 | - $success_page = give_get_option( 'success_page', 0 ); |
|
1309 | + $transaction_failed = give_get_option('failure_page', 0); |
|
1310 | + $success_page = give_get_option('success_page', 0); |
|
1311 | 1311 | |
1312 | 1312 | $args = apply_filters( |
1313 | 1313 | 'give_remove_pages_from_search', array( |
@@ -1315,11 +1315,11 @@ discard block |
||
1315 | 1315 | $success_page, |
1316 | 1316 | ), $query |
1317 | 1317 | ); |
1318 | - $query->set( 'post__not_in', $args ); |
|
1318 | + $query->set('post__not_in', $args); |
|
1319 | 1319 | } |
1320 | 1320 | } |
1321 | 1321 | |
1322 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
1322 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
1323 | 1323 | |
1324 | 1324 | /** |
1325 | 1325 | * Inserts a new key/value before a key in the array. |
@@ -1335,14 +1335,14 @@ discard block |
||
1335 | 1335 | * |
1336 | 1336 | * @see array_insert_before() |
1337 | 1337 | */ |
1338 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
1339 | - if ( array_key_exists( $key, $array ) ) { |
|
1338 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
1339 | + if (array_key_exists($key, $array)) { |
|
1340 | 1340 | $new = array(); |
1341 | - foreach ( $array as $k => $value ) { |
|
1342 | - if ( $k === $key ) { |
|
1343 | - $new[ $new_key ] = $new_value; |
|
1341 | + foreach ($array as $k => $value) { |
|
1342 | + if ($k === $key) { |
|
1343 | + $new[$new_key] = $new_value; |
|
1344 | 1344 | } |
1345 | - $new[ $k ] = $value; |
|
1345 | + $new[$k] = $value; |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | return $new; |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | * |
1366 | 1366 | * @see array_insert_before() |
1367 | 1367 | */ |
1368 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
1369 | - if ( array_key_exists( $key, $array ) ) { |
|
1368 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
1369 | + if (array_key_exists($key, $array)) { |
|
1370 | 1370 | $new = array(); |
1371 | - foreach ( $array as $k => $value ) { |
|
1372 | - $new[ $k ] = $value; |
|
1373 | - if ( $k === $key ) { |
|
1374 | - $new[ $new_key ] = $new_value; |
|
1371 | + foreach ($array as $k => $value) { |
|
1372 | + $new[$k] = $value; |
|
1373 | + if ($k === $key) { |
|
1374 | + $new[$new_key] = $new_value; |
|
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | |
@@ -1398,21 +1398,21 @@ discard block |
||
1398 | 1398 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
1399 | 1399 | * `$list` will be preserved in the results. |
1400 | 1400 | */ |
1401 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
1401 | +function give_list_pluck($list, $field, $index_key = null) { |
|
1402 | 1402 | |
1403 | - if ( ! $index_key ) { |
|
1403 | + if ( ! $index_key) { |
|
1404 | 1404 | /** |
1405 | 1405 | * This is simple. Could at some point wrap array_column() |
1406 | 1406 | * if we knew we had an array of arrays. |
1407 | 1407 | */ |
1408 | - foreach ( $list as $key => $value ) { |
|
1409 | - if ( is_object( $value ) ) { |
|
1410 | - if ( isset( $value->$field ) ) { |
|
1411 | - $list[ $key ] = $value->$field; |
|
1408 | + foreach ($list as $key => $value) { |
|
1409 | + if (is_object($value)) { |
|
1410 | + if (isset($value->$field)) { |
|
1411 | + $list[$key] = $value->$field; |
|
1412 | 1412 | } |
1413 | 1413 | } else { |
1414 | - if ( isset( $value[ $field ] ) ) { |
|
1415 | - $list[ $key ] = $value[ $field ]; |
|
1414 | + if (isset($value[$field])) { |
|
1415 | + $list[$key] = $value[$field]; |
|
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | } |
@@ -1425,18 +1425,18 @@ discard block |
||
1425 | 1425 | * to the end of the stack. This is how array_column() behaves. |
1426 | 1426 | */ |
1427 | 1427 | $newlist = array(); |
1428 | - foreach ( $list as $value ) { |
|
1429 | - if ( is_object( $value ) ) { |
|
1430 | - if ( isset( $value->$index_key ) ) { |
|
1431 | - $newlist[ $value->$index_key ] = $value->$field; |
|
1428 | + foreach ($list as $value) { |
|
1429 | + if (is_object($value)) { |
|
1430 | + if (isset($value->$index_key)) { |
|
1431 | + $newlist[$value->$index_key] = $value->$field; |
|
1432 | 1432 | } else { |
1433 | 1433 | $newlist[] = $value->$field; |
1434 | 1434 | } |
1435 | 1435 | } else { |
1436 | - if ( isset( $value[ $index_key ] ) ) { |
|
1437 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
1436 | + if (isset($value[$index_key])) { |
|
1437 | + $newlist[$value[$index_key]] = $value[$field]; |
|
1438 | 1438 | } else { |
1439 | - $newlist[] = $value[ $field ]; |
|
1439 | + $newlist[] = $value[$field]; |
|
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | } |
@@ -1459,8 +1459,8 @@ discard block |
||
1459 | 1459 | * |
1460 | 1460 | * @return int|false Meta ID on success, false on failure. |
1461 | 1461 | */ |
1462 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
1463 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
1462 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
1463 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | /** |
@@ -1478,8 +1478,8 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @return bool True on success, false on failure. |
1480 | 1480 | */ |
1481 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
1482 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
1481 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
1482 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | /** |
@@ -1494,8 +1494,8 @@ discard block |
||
1494 | 1494 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
1495 | 1495 | * is true. |
1496 | 1496 | */ |
1497 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
1498 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
1497 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
1498 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | /** |
@@ -1512,8 +1512,8 @@ discard block |
||
1512 | 1512 | * |
1513 | 1513 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
1514 | 1514 | */ |
1515 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1516 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
1515 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
1516 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | |
@@ -1526,15 +1526,15 @@ discard block |
||
1526 | 1526 | * |
1527 | 1527 | * @return void |
1528 | 1528 | */ |
1529 | -function give_recount_form_income_donation( $form_id = 0 ) { |
|
1529 | +function give_recount_form_income_donation($form_id = 0) { |
|
1530 | 1530 | // Check if form id is not empty. |
1531 | - if ( ! empty( $form_id ) ) { |
|
1531 | + if ( ! empty($form_id)) { |
|
1532 | 1532 | /** |
1533 | 1533 | * Filter to modify payment status. |
1534 | 1534 | * |
1535 | 1535 | * @since 1.8.13 |
1536 | 1536 | */ |
1537 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
1537 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
1538 | 1538 | |
1539 | 1539 | /** |
1540 | 1540 | * Filter to modify args of payment query before recalculating the form total |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | 'give_recount_form_stats_args', array( |
1546 | 1546 | 'give_forms' => $form_id, |
1547 | 1547 | 'status' => $accepted_statuses, |
1548 | - 'posts_per_page' => - 1, |
|
1548 | + 'posts_per_page' => -1, |
|
1549 | 1549 | 'fields' => 'ids', |
1550 | 1550 | ) |
1551 | 1551 | ); |
@@ -1555,28 +1555,28 @@ discard block |
||
1555 | 1555 | 'earnings' => 0, |
1556 | 1556 | ); |
1557 | 1557 | |
1558 | - $payments = new Give_Payments_Query( $args ); |
|
1558 | + $payments = new Give_Payments_Query($args); |
|
1559 | 1559 | $payments = $payments->get_payments(); |
1560 | 1560 | |
1561 | - if ( $payments ) { |
|
1562 | - foreach ( $payments as $payment ) { |
|
1561 | + if ($payments) { |
|
1562 | + foreach ($payments as $payment) { |
|
1563 | 1563 | // Ensure acceptible status only |
1564 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
1564 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
1565 | 1565 | continue; |
1566 | 1566 | } |
1567 | 1567 | |
1568 | 1568 | // Ensure only payments for this form are counted |
1569 | - if ( $payment->form_id != $form_id ) { |
|
1569 | + if ($payment->form_id != $form_id) { |
|
1570 | 1570 | continue; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $totals['sales'] ++; |
|
1573 | + $totals['sales']++; |
|
1574 | 1574 | $totals['earnings'] += $payment->total; |
1575 | 1575 | |
1576 | 1576 | } |
1577 | 1577 | } |
1578 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
1579 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
1578 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
1579 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
1580 | 1580 | }// End if(). |
1581 | 1581 | } |
1582 | 1582 | |
@@ -1590,18 +1590,18 @@ discard block |
||
1590 | 1590 | * |
1591 | 1591 | * @return string |
1592 | 1592 | */ |
1593 | -function give_get_attribute_str( $attributes ) { |
|
1593 | +function give_get_attribute_str($attributes) { |
|
1594 | 1594 | $attribute_str = ''; |
1595 | 1595 | |
1596 | - if ( empty( $attributes ) ) { |
|
1596 | + if (empty($attributes)) { |
|
1597 | 1597 | return $attribute_str; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | - foreach ( $attributes as $tag => $value ) { |
|
1600 | + foreach ($attributes as $tag => $value) { |
|
1601 | 1601 | $attribute_str .= " {$tag}=\"{$value}\""; |
1602 | 1602 | } |
1603 | 1603 | |
1604 | - return trim( $attribute_str ); |
|
1604 | + return trim($attribute_str); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | /** |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | function give_get_wp_upload_dir() { |
1615 | 1615 | $wp_upload_dir = wp_upload_dir(); |
1616 | 1616 | |
1617 | - return ( ! empty( $wp_upload_dir['path'] ) ? $wp_upload_dir['path'] : false ); |
|
1617 | + return ( ! empty($wp_upload_dir['path']) ? $wp_upload_dir['path'] : false); |
|
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | /** |
@@ -1626,15 +1626,15 @@ discard block |
||
1626 | 1626 | * |
1627 | 1627 | * @return string|bool $file_contents File content |
1628 | 1628 | */ |
1629 | -function give_get_core_settings_json( $file_name ) { |
|
1629 | +function give_get_core_settings_json($file_name) { |
|
1630 | 1630 | $upload_dir = give_get_wp_upload_dir(); |
1631 | - $file_path = $upload_dir . '/' . $file_name; |
|
1631 | + $file_path = $upload_dir.'/'.$file_name; |
|
1632 | 1632 | |
1633 | - if ( is_wp_error( $file_path ) || empty( $file_path ) ) { |
|
1634 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) ); |
|
1633 | + if (is_wp_error($file_path) || empty($file_path)) { |
|
1634 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give')); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | - $file_contents = file_get_contents( $file_path ); |
|
1637 | + $file_contents = file_get_contents($file_path); |
|
1638 | 1638 | |
1639 | 1639 | return $file_contents; |
1640 | 1640 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | * @return int $country The two letter country code for the site's base country |
1648 | 1648 | */ |
1649 | 1649 | function give_get_limit_display_donations() { |
1650 | - return give_get_option( 'limit_display_donations', 1 ); |
|
1650 | + return give_get_option('limit_display_donations', 1); |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | /** |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | * @since 1.8.17 |
1657 | 1657 | */ |
1658 | 1658 | function give_donation_history_table_end() { |
1659 | - $email = Give()->session->get( 'give_email' ); |
|
1659 | + $email = Give()->session->get('give_email'); |
|
1660 | 1660 | ?> |
1661 | 1661 | <tfoot> |
1662 | 1662 | <tr> |
@@ -1665,16 +1665,16 @@ discard block |
||
1665 | 1665 | <div class="give-security-column give-security-description-wrap"> |
1666 | 1666 | <?php |
1667 | 1667 | echo sprintf( |
1668 | - __( 'For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give' ), |
|
1668 | + __('For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give'), |
|
1669 | 1669 | |
1670 | 1670 | ); |
1671 | 1671 | ?> |
1672 | 1672 | </div> |
1673 | 1673 | <div class="give-security-column give-security-button-wrap"> |
1674 | 1674 | <a href="#" data-email="<?php echo $email; ?>" id="give-confirm-email-btn" class="give-confirm-email-btn give-btn"> |
1675 | - <?php _e( 'Confirm Email', 'give' ); ?> |
|
1675 | + <?php _e('Confirm Email', 'give'); ?> |
|
1676 | 1676 | </a> |
1677 | - <span><?php _e( 'Email Sent!', 'give' ); ?></span> |
|
1677 | + <span><?php _e('Email Sent!', 'give'); ?></span> |
|
1678 | 1678 | </div> |
1679 | 1679 | </div> |
1680 | 1680 | </td> |
@@ -1694,10 +1694,10 @@ discard block |
||
1694 | 1694 | * |
1695 | 1695 | * @return void |
1696 | 1696 | */ |
1697 | -function give_doing_it_wrong( $function, $message, $version ) { |
|
1698 | - $message .= "\nBacktrace:" . wp_debug_backtrace_summary(); |
|
1697 | +function give_doing_it_wrong($function, $message, $version) { |
|
1698 | + $message .= "\nBacktrace:".wp_debug_backtrace_summary(); |
|
1699 | 1699 | |
1700 | - _doing_it_wrong( $function, $message , $version ); |
|
1700 | + _doing_it_wrong($function, $message, $version); |
|
1701 | 1701 | } |
1702 | 1702 | |
1703 | 1703 | |
@@ -1706,11 +1706,11 @@ discard block |
||
1706 | 1706 | * |
1707 | 1707 | * @since 1.8.18 |
1708 | 1708 | */ |
1709 | -function give_ignore_user_abort(){ |
|
1710 | - ignore_user_abort( true ); |
|
1709 | +function give_ignore_user_abort() { |
|
1710 | + ignore_user_abort(true); |
|
1711 | 1711 | |
1712 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
1713 | - set_time_limit( 0 ); |
|
1712 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
1713 | + set_time_limit(0); |
|
1714 | 1714 | } |
1715 | 1715 | } |
1716 | 1716 | |
@@ -1724,26 +1724,26 @@ discard block |
||
1724 | 1724 | * |
1725 | 1725 | * @return int |
1726 | 1726 | */ |
1727 | -function give_get_total_post_type_count( $post_type = '', $args = array() ){ |
|
1727 | +function give_get_total_post_type_count($post_type = '', $args = array()) { |
|
1728 | 1728 | global $wpdb; |
1729 | 1729 | $where = ''; |
1730 | 1730 | |
1731 | - if( ! $post_type ) { |
|
1731 | + if ( ! $post_type) { |
|
1732 | 1732 | return 0; |
1733 | 1733 | } |
1734 | 1734 | |
1735 | 1735 | // Bulit where query |
1736 | - if( ! empty( $post_type ) ) { |
|
1737 | - $where.=' WHERE'; |
|
1736 | + if ( ! empty($post_type)) { |
|
1737 | + $where .= ' WHERE'; |
|
1738 | 1738 | |
1739 | - if( is_array( $post_type ) ) { |
|
1740 | - $where .= " post_type='" . implode( "' OR post_type='", $post_type ) . "'"; |
|
1741 | - }else{ |
|
1739 | + if (is_array($post_type)) { |
|
1740 | + $where .= " post_type='".implode("' OR post_type='", $post_type)."'"; |
|
1741 | + } else { |
|
1742 | 1742 | $where .= " post_type='{$post_type}'"; |
1743 | 1743 | } |
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | $result = $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts}{$where}"); |
1747 | 1747 | |
1748 | - return absint( $result ); |
|
1748 | + return absint($result); |
|
1749 | 1749 | } |
1750 | 1750 | \ No newline at end of file |
@@ -1738,7 +1738,7 @@ |
||
1738 | 1738 | |
1739 | 1739 | if( is_array( $post_type ) ) { |
1740 | 1740 | $where .= " post_type='" . implode( "' OR post_type='", $post_type ) . "'"; |
1741 | - }else{ |
|
1741 | + } else{ |
|
1742 | 1742 | $where .= " post_type='{$post_type}'"; |
1743 | 1743 | } |
1744 | 1744 | } |
@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /* @var WPDB $wpdb */ |
54 | 54 | global $wpdb; |
55 | 55 | |
56 | - $wpdb->donormeta = $this->table_name = $wpdb->prefix . 'give_donormeta'; |
|
56 | + $wpdb->donormeta = $this->table_name = $wpdb->prefix.'give_donormeta'; |
|
57 | 57 | $this->primary_key = 'meta_id'; |
58 | 58 | $this->version = '1.0'; |
59 | 59 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return bool False for failure. True for success. |
92 | 92 | */ |
93 | - public function delete_all_meta( $donor_id = 0 ) { |
|
93 | + public function delete_all_meta($donor_id = 0) { |
|
94 | 94 | global $wpdb; |
95 | - $status = $wpdb->delete( $this->table_name, array( 'donor_id' => $donor_id ), array( '%d' ) ); |
|
95 | + $status = $wpdb->delete($this->table_name, array('donor_id' => $donor_id), array('%d')); |
|
96 | 96 | |
97 | - if( $status ) { |
|
98 | - Give_Cache::delete_group( $donor_id, 'give-donors' ); |
|
97 | + if ($status) { |
|
98 | + Give_Cache::delete_group($donor_id, 'give-donors'); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | global $wpdb; |
112 | 112 | |
113 | 113 | if ( |
114 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
115 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) ) |
|
114 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
115 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta")) |
|
116 | 116 | ) { |
117 | 117 | $wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta"; |
118 | 118 | $this->meta_type = 'customer'; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - protected function is_valid_post_type( $ID ) { |
|
134 | + protected function is_valid_post_type($ID) { |
|
135 | 135 | return $ID && true; |
136 | 136 | } |
137 | 137 |
@@ -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 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return string |
27 | 27 | */ |
28 | -function __give_get_format_address( $address, $address_args = array() ) { |
|
28 | +function __give_get_format_address($address, $address_args = array()) { |
|
29 | 29 | $address_html = ''; |
30 | 30 | $address_args = wp_parse_args( |
31 | 31 | $address_args, |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $address_id = $address_args['type']; |
41 | 41 | |
42 | 42 | // Bailout. |
43 | - if ( empty( $address ) || ! is_array( $address ) ) { |
|
43 | + if (empty($address) || ! is_array($address)) { |
|
44 | 44 | return $address_html; |
45 | 45 | } |
46 | 46 | |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | $address_html .= sprintf( |
50 | 50 | '<span data-address-type="line1">%1$s</span>%2$s', |
51 | 51 | $address['line1'], |
52 | - ( ! empty( $address['line2'] ) ? '<br>' : '' ) |
|
52 | + ( ! empty($address['line2']) ? '<br>' : '') |
|
53 | 53 | ); |
54 | 54 | $address_html .= sprintf( |
55 | 55 | '<span data-address-type="line2">%1$s</span>%2$s', |
56 | 56 | $address['line2'], |
57 | - ( ! empty( $address['city'] ) ? '<br>' : '' ) |
|
57 | + ( ! empty($address['city']) ? '<br>' : '') |
|
58 | 58 | ); |
59 | 59 | $address_html .= sprintf( |
60 | 60 | '<span data-address-type="city">%1$s</span><span data-address-type="state">%2$s</span><span data-address-type="zip">%3$s</span>%4$s', |
61 | 61 | $address['city'], |
62 | - ( ! empty( $address['state'] ) ? ", {$address['state']}" : '' ), |
|
63 | - ( ! empty( $address['zip'] ) ? " {$address['zip']}" : '' ), |
|
64 | - ( ! empty( $address['country'] ) ? '<br>' : '' ) |
|
62 | + ( ! empty($address['state']) ? ", {$address['state']}" : ''), |
|
63 | + ( ! empty($address['zip']) ? " {$address['zip']}" : ''), |
|
64 | + ( ! empty($address['country']) ? '<br>' : '') |
|
65 | 65 | ); |
66 | 66 | $address_html .= sprintf( |
67 | 67 | '<span data-address-type="country">%s</span><br>', |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | // Address action. |
72 | 72 | $address_html .= sprintf( |
73 | 73 | '<br><a href="#" class="js-edit">%1$s</a> | <a href="#" class="js-remove">%2$s</a>', |
74 | - __( 'Edit', 'give' ), |
|
75 | - __( 'Remove', 'give' ) |
|
74 | + __('Edit', 'give'), |
|
75 | + __('Remove', 'give') |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | /** |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 2.0 |
82 | 82 | */ |
83 | - $address_label = apply_filters( "give_donor_{$address_args['type']}_address_label", ucfirst( $address_args['type'] ), $address_args ); |
|
83 | + $address_label = apply_filters("give_donor_{$address_args['type']}_address_label", ucfirst($address_args['type']), $address_args); |
|
84 | 84 | |
85 | 85 | // Set unique id and index for multi type address. |
86 | - if ( isset( $address_args['index'] ) ) { |
|
86 | + if (isset($address_args['index'])) { |
|
87 | 87 | $address_label = "{$address_label} #{$address_args['index']}"; |
88 | 88 | } |
89 | 89 | |
90 | - if ( isset( $address_args['id'] ) ) { |
|
90 | + if (isset($address_args['id'])) { |
|
91 | 91 | $address_id = "{$address_id}_{$address_args['id']}"; |
92 | 92 | } |
93 | 93 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function give_donors_page() { |
114 | 114 | $default_views = give_donor_views(); |
115 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
116 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
117 | - give_render_donor_view( $requested_view, $default_views ); |
|
115 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
116 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
117 | + give_render_donor_view($requested_view, $default_views); |
|
118 | 118 | } else { |
119 | 119 | give_donors_list(); |
120 | 120 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | $views = array(); |
132 | 132 | |
133 | - return apply_filters( 'give_donor_views', $views ); |
|
133 | + return apply_filters('give_donor_views', $views); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | $tabs = array(); |
146 | 146 | |
147 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
147 | + return apply_filters('give_donor_tabs', $tabs); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function give_donors_list() { |
158 | 158 | |
159 | - include GIVE_PLUGIN_DIR . 'includes/admin/donors/class-donor-table.php'; |
|
159 | + include GIVE_PLUGIN_DIR.'includes/admin/donors/class-donor-table.php'; |
|
160 | 160 | |
161 | 161 | $donors_table = new Give_Donor_List_Table(); |
162 | 162 | $donors_table->prepare_items(); |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @since 1.0 |
171 | 171 | */ |
172 | - do_action( 'give_donors_table_top' ); |
|
172 | + do_action('give_donors_table_top'); |
|
173 | 173 | ?> |
174 | 174 | |
175 | 175 | <hr class="wp-header-end"> |
176 | - <form id="give-donors-search-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
177 | - <?php $donors_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' ); ?> |
|
176 | + <form id="give-donors-search-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
177 | + <?php $donors_table->search_box(__('Search Donors', 'give'), 'give-donors'); ?> |
|
178 | 178 | <input type="hidden" name="post_type" value="give_forms" /> |
179 | 179 | <input type="hidden" name="page" value="give-donors" /> |
180 | 180 | <input type="hidden" name="view" value="donors" /> |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @since 1.0 |
193 | 193 | */ |
194 | - do_action( 'give_donors_table_bottom' ); |
|
194 | + do_action('give_donors_table_bottom'); |
|
195 | 195 | ?> |
196 | 196 | </div> |
197 | 197 | <?php |
@@ -207,33 +207,33 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return void |
209 | 209 | */ |
210 | -function give_render_donor_view( $view, $callbacks ) { |
|
210 | +function give_render_donor_view($view, $callbacks) { |
|
211 | 211 | |
212 | 212 | $render = true; |
213 | 213 | |
214 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
214 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
215 | 215 | |
216 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
217 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
216 | + if ( ! current_user_can($donor_view_role)) { |
|
217 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
218 | 218 | $render = false; |
219 | 219 | } |
220 | 220 | |
221 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
222 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
221 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
222 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
223 | 223 | $render = false; |
224 | 224 | } |
225 | 225 | |
226 | 226 | $donor_id = (int) $_GET['id']; |
227 | - $reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : ''; |
|
228 | - $donor = new Give_Donor( $donor_id ); |
|
227 | + $reconnect_user_id = ! empty($_GET['user_id']) ? (int) $_GET['user_id'] : ''; |
|
228 | + $donor = new Give_Donor($donor_id); |
|
229 | 229 | |
230 | 230 | // Reconnect User with Donor profile. |
231 | - if ( $reconnect_user_id ) { |
|
232 | - give_connect_user_donor_profile( $donor, array( 'user_id' => $reconnect_user_id ), array() ); |
|
231 | + if ($reconnect_user_id) { |
|
232 | + give_connect_user_donor_profile($donor, array('user_id' => $reconnect_user_id), array()); |
|
233 | 233 | } |
234 | 234 | |
235 | - if ( empty( $donor->id ) ) { |
|
236 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
235 | + if (empty($donor->id)) { |
|
236 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
237 | 237 | $render = false; |
238 | 238 | } |
239 | 239 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | |
243 | 243 | <div class='wrap'> |
244 | 244 | |
245 | - <?php if ( give_get_errors() ) : ?> |
|
245 | + <?php if (give_get_errors()) : ?> |
|
246 | 246 | <div class="error settings-error"> |
247 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
247 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
248 | 248 | </div> |
249 | 249 | <?php endif; ?> |
250 | 250 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | <?php |
253 | 253 | printf( |
254 | 254 | /* translators: %s: donor first name */ |
255 | - __( 'Edit Donor #%s: %s %s', 'give' ), |
|
255 | + __('Edit Donor #%s: %s %s', 'give'), |
|
256 | 256 | $donor->id, |
257 | 257 | $donor->get_first_name(), |
258 | 258 | $donor->get_last_name() |
@@ -262,26 +262,26 @@ discard block |
||
262 | 262 | |
263 | 263 | <hr class="wp-header-end"> |
264 | 264 | |
265 | - <?php if ( $donor && $render ) : ?> |
|
265 | + <?php if ($donor && $render) : ?> |
|
266 | 266 | |
267 | 267 | <h2 class="nav-tab-wrapper"> |
268 | 268 | <?php |
269 | - foreach ( $donor_tabs as $key => $tab ) : |
|
269 | + foreach ($donor_tabs as $key => $tab) : |
|
270 | 270 | $active = $key === $view ? true : false; |
271 | 271 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
272 | 272 | printf( |
273 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
274 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
275 | - esc_attr( $class ), |
|
276 | - sanitize_html_class( $tab['dashicon'] ), |
|
277 | - esc_html( $tab['title'] ) |
|
273 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
274 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
275 | + esc_attr($class), |
|
276 | + sanitize_html_class($tab['dashicon']), |
|
277 | + esc_html($tab['title']) |
|
278 | 278 | ); |
279 | 279 | endforeach; |
280 | 280 | ?> |
281 | 281 | </h2> |
282 | 282 | |
283 | 283 | <div id="give-donor-card-wrapper"> |
284 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
284 | + <?php $callbacks[$view]($donor) ?> |
|
285 | 285 | </div> |
286 | 286 | |
287 | 287 | <?php endif; ?> |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return void |
303 | 303 | */ |
304 | -function give_donor_view( $donor ) { |
|
304 | +function give_donor_view($donor) { |
|
305 | 305 | |
306 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
306 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Fires in donor profile screen, above the donor card. |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param object $donor The donor object being displayed. |
314 | 314 | */ |
315 | - do_action( 'give_donor_card_top', $donor ); |
|
315 | + do_action('give_donor_card_top', $donor); |
|
316 | 316 | |
317 | 317 | // Set Read only to the fields which needs to be locked. |
318 | 318 | $read_only = ''; |
319 | - if ( $donor->user_id ) { |
|
319 | + if ($donor->user_id) { |
|
320 | 320 | $read_only = 'readonly="readonly"'; |
321 | 321 | } |
322 | 322 | ?> |
@@ -324,14 +324,14 @@ discard block |
||
324 | 324 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
325 | 325 | |
326 | 326 | <form id="edit-donor-info" method="post" |
327 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
327 | + action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
328 | 328 | |
329 | 329 | <div class="donor-info"> |
330 | 330 | |
331 | 331 | <div class="donor-bio-header clearfix"> |
332 | 332 | |
333 | 333 | <div class="avatar-wrap left" id="donor-avatar"> |
334 | - <?php echo get_avatar( $donor->email ); ?> |
|
334 | + <?php echo get_avatar($donor->email); ?> |
|
335 | 335 | </div> |
336 | 336 | |
337 | 337 | <div id="donor-name-wrap" class="left"> |
@@ -339,18 +339,18 @@ discard block |
||
339 | 339 | <span class="donor-name info-item edit-item"> |
340 | 340 | <input <?php echo $read_only; ?> size="15" data-key="first_name" |
341 | 341 | name="customerinfo[first_name]" type="text" |
342 | - value="<?php esc_attr_e( $donor->get_first_name() ); ?>" |
|
343 | - placeholder="<?php _e( 'First Name', 'give' ); ?>"/> |
|
344 | - <?php if ( $donor->user_id ) : ?> |
|
342 | + value="<?php esc_attr_e($donor->get_first_name()); ?>" |
|
343 | + placeholder="<?php _e('First Name', 'give'); ?>"/> |
|
344 | + <?php if ($donor->user_id) : ?> |
|
345 | 345 | <a href="#" class="give-lock-block"> |
346 | 346 | <i class="give-icon give-icon-locked"></i> |
347 | 347 | </a> |
348 | 348 | <?php endif; ?> |
349 | 349 | <input <?php echo $read_only; ?> size="15" data-key="last_name" |
350 | 350 | name="customerinfo[last_name]" type="text" |
351 | - value="<?php esc_attr_e( $donor->get_last_name() ); ?>" |
|
352 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>"/> |
|
353 | - <?php if ( $donor->user_id ) : ?> |
|
351 | + value="<?php esc_attr_e($donor->get_last_name()); ?>" |
|
352 | + placeholder="<?php _e('Last Name', 'give'); ?>"/> |
|
353 | + <?php if ($donor->user_id) : ?> |
|
354 | 354 | <a href="#" class="give-lock-block"> |
355 | 355 | <i class="give-icon give-icon-locked"></i> |
356 | 356 | </a> |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | data-key="name"><?php echo $donor->name; ?></span></span> |
361 | 361 | </div> |
362 | 362 | <p class="donor-since info-item"> |
363 | - <?php _e( 'Donor since', 'give' ); ?> |
|
364 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
363 | + <?php _e('Donor since', 'give'); ?> |
|
364 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
365 | 365 | </p> |
366 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
366 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
367 | 367 | <a href="#" id="edit-donor" |
368 | - class="button info-item editable donor-edit-link"><?php _e( 'Edit Donor', 'give' ); ?></a> |
|
368 | + class="button info-item editable donor-edit-link"><?php _e('Edit Donor', 'give'); ?></a> |
|
369 | 369 | <?php endif; ?> |
370 | 370 | </div> |
371 | 371 | <!-- /donor-bio-header --> |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | <table class="widefat"> |
376 | 376 | <tbody> |
377 | 377 | <tr class="alternate"> |
378 | - <th scope="col"><label for="tablecell"><?php _e( 'User:', 'give' ); ?></label></th> |
|
378 | + <th scope="col"><label for="tablecell"><?php _e('User:', 'give'); ?></label></th> |
|
379 | 379 | <td> |
380 | 380 | <span class="donor-user-id info-item edit-item"> |
381 | 381 | <?php |
@@ -392,22 +392,22 @@ discard block |
||
392 | 392 | 'data' => $data_atts, |
393 | 393 | ); |
394 | 394 | |
395 | - if ( ! empty( $user_id ) ) { |
|
396 | - $userdata = get_userdata( $user_id ); |
|
395 | + if ( ! empty($user_id)) { |
|
396 | + $userdata = get_userdata($user_id); |
|
397 | 397 | $user_args['selected'] = $user_id; |
398 | 398 | } |
399 | 399 | |
400 | - echo Give()->html->ajax_user_search( $user_args ); |
|
400 | + echo Give()->html->ajax_user_search($user_args); |
|
401 | 401 | ?> |
402 | 402 | </span> |
403 | 403 | |
404 | 404 | <span class="donor-user-id info-item editable"> |
405 | - <?php if ( ! empty( $userdata ) ) : ?> |
|
406 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
405 | + <?php if ( ! empty($userdata)) : ?> |
|
406 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
407 | 407 | <?php else: ?> |
408 | - <span data-key="user_id"><?php _e( 'None', 'give' ); ?></span> |
|
408 | + <span data-key="user_id"><?php _e('None', 'give'); ?></span> |
|
409 | 409 | <?php endif; ?> |
410 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ): |
|
410 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0): |
|
411 | 411 | |
412 | 412 | echo sprintf( |
413 | 413 | '- <span class="disconnect-user"> |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | | <span class="view-user-profile"> |
417 | 417 | <a id="view-user-profile" href="%3$s" aria-label="%4$s">%5$s</a> |
418 | 418 | </span>', |
419 | - __( 'Disconnects the current user ID from this donor record.', 'give' ), |
|
420 | - __( 'Disconnect User', 'give' ), |
|
421 | - 'user-edit.php?user_id=' . $donor->user_id, |
|
422 | - __( 'View User Profile of current user ID.', 'give' ), |
|
423 | - __( 'View User Profile', 'give' ) |
|
419 | + __('Disconnects the current user ID from this donor record.', 'give'), |
|
420 | + __('Disconnect User', 'give'), |
|
421 | + 'user-edit.php?user_id='.$donor->user_id, |
|
422 | + __('View User Profile of current user ID.', 'give'), |
|
423 | + __('View User Profile', 'give') |
|
424 | 424 | ); |
425 | 425 | |
426 | 426 | endif; ?> |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | |
437 | 437 | <span id="donor-edit-actions" class="edit-item"> |
438 | 438 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>"/> |
439 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
439 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
440 | 440 | <input type="hidden" name="give_action" value="edit-donor"/> |
441 | 441 | <input type="submit" id="give-edit-donor-save" class="button-secondary" |
442 | - value="<?php _e( 'Update Donor', 'give' ); ?>"/> |
|
443 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
442 | + value="<?php _e('Update Donor', 'give'); ?>"/> |
|
443 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
444 | 444 | </span> |
445 | 445 | |
446 | 446 | </form> |
@@ -455,24 +455,24 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @param Give_Donor $donor The donor object being displayed. |
457 | 457 | */ |
458 | - do_action( 'give_donor_before_stats', $donor ); |
|
458 | + do_action('give_donor_before_stats', $donor); |
|
459 | 459 | ?> |
460 | 460 | |
461 | 461 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
462 | 462 | <ul> |
463 | 463 | <li> |
464 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
|
464 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>"> |
|
465 | 465 | <span class="dashicons dashicons-heart"></span> |
466 | 466 | <?php |
467 | 467 | // Completed Donations. |
468 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
469 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
468 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
469 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
470 | 470 | ?> |
471 | 471 | </a> |
472 | 472 | </li> |
473 | 473 | <li> |
474 | 474 | <span class="dashicons dashicons-chart-area"></span> |
475 | - <?php echo give_currency_filter( give_format_amount( $donor->get_total_donation_amount(), array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?> |
|
475 | + <?php echo give_currency_filter(give_format_amount($donor->get_total_donation_amount(), array('sanitize' => false))); ?> <?php _e('Lifetime Donations', 'give'); ?> |
|
476 | 476 | </li> |
477 | 477 | <?php |
478 | 478 | /** |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @param object $donor The donor object being displayed. |
486 | 486 | */ |
487 | - do_action( 'give_donor_stats_list', $donor ); |
|
487 | + do_action('give_donor_stats_list', $donor); |
|
488 | 488 | ?> |
489 | 489 | </ul> |
490 | 490 | </div> |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @param Give_Donor $donor The donor object being displayed. |
499 | 499 | */ |
500 | - do_action( 'give_donor_before_address', $donor ); |
|
500 | + do_action('give_donor_before_address', $donor); |
|
501 | 501 | ?> |
502 | 502 | |
503 | 503 | <div id="donor-address-wrapper" class="donor-section clear"> |
504 | - <h3><?php _e( 'Addresses', 'give' ); ?></h3> |
|
504 | + <h3><?php _e('Addresses', 'give'); ?></h3> |
|
505 | 505 | |
506 | 506 | <div class="postbox"> |
507 | 507 | <div class="give-spinner-wrapper"> |
@@ -511,16 +511,16 @@ discard block |
||
511 | 511 | <div class="all-address"> |
512 | 512 | <div class="give-grid-row"> |
513 | 513 | <?php |
514 | - if ( ! empty( $donor->address ) ) : |
|
514 | + if ( ! empty($donor->address)) : |
|
515 | 515 | // Default address always will be at zero array index. |
516 | 516 | $is_set_as_default = null; |
517 | 517 | |
518 | - foreach ( $donor->address as $address_type => $addresses ) { |
|
518 | + foreach ($donor->address as $address_type => $addresses) { |
|
519 | 519 | |
520 | - switch ( true ) { |
|
521 | - case is_array( end( $addresses ) ): |
|
520 | + switch (true) { |
|
521 | + case is_array(end($addresses)): |
|
522 | 522 | $index = 1; |
523 | - foreach ( $addresses as $id => $address ) { |
|
523 | + foreach ($addresses as $id => $address) { |
|
524 | 524 | echo __give_get_format_address( |
525 | 525 | $address, |
526 | 526 | array( |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | ) |
531 | 531 | ); |
532 | 532 | |
533 | - $index ++; |
|
533 | + $index++; |
|
534 | 534 | } |
535 | 535 | break; |
536 | 536 | |
537 | - case is_string( end( $addresses ) ): |
|
537 | + case is_string(end($addresses)): |
|
538 | 538 | echo __give_get_format_address( |
539 | 539 | $addresses, |
540 | 540 | array( |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | endif; |
548 | 548 | ?> |
549 | 549 | </div> |
550 | - <span class="give-no-address-message<?php if ( ! empty( $donor->address ) ) { |
|
550 | + <span class="give-no-address-message<?php if ( ! empty($donor->address)) { |
|
551 | 551 | echo ' give-hidden'; |
552 | 552 | } ?>"> |
553 | - <?php _e( 'This donor does not have any addresses saved.', 'give' ); ?> |
|
553 | + <?php _e('This donor does not have any addresses saved.', 'give'); ?> |
|
554 | 554 | </span> |
555 | 555 | <button class="button add-new-address"> |
556 | - <?php _e( 'Add Address', 'give' ); ?> |
|
556 | + <?php _e('Add Address', 'give'); ?> |
|
557 | 557 | </button> |
558 | 558 | </div> |
559 | 559 | |
@@ -563,26 +563,26 @@ discard block |
||
563 | 563 | <tbody> |
564 | 564 | <tr> |
565 | 565 | <th class="col"> |
566 | - <label class="country"><?php esc_html_e( 'Country:', 'give' ); ?></label> |
|
566 | + <label class="country"><?php esc_html_e('Country:', 'give'); ?></label> |
|
567 | 567 | </th> |
568 | 568 | <td> |
569 | 569 | <?php |
570 | - echo Give()->html->select( array( |
|
570 | + echo Give()->html->select(array( |
|
571 | 571 | 'options' => give_get_country_list(), |
572 | 572 | 'name' => 'country', |
573 | - 'selected' => give_get_option( 'base_country' ), |
|
573 | + 'selected' => give_get_option('base_country'), |
|
574 | 574 | 'show_option_all' => false, |
575 | 575 | 'show_option_none' => false, |
576 | 576 | 'chosen' => true, |
577 | - 'placeholder' => esc_attr__( 'Select a country', 'give' ), |
|
578 | - 'data' => array( 'search-type' => 'no_ajax' ), |
|
579 | - ) ); |
|
577 | + 'placeholder' => esc_attr__('Select a country', 'give'), |
|
578 | + 'data' => array('search-type' => 'no_ajax'), |
|
579 | + )); |
|
580 | 580 | ?> |
581 | 581 | </td> |
582 | 582 | </tr> |
583 | 583 | <tr> |
584 | 584 | <th class="col"> |
585 | - <label for="line1"><?php esc_html_e( 'Address 1:', 'give' ); ?></label> |
|
585 | + <label for="line1"><?php esc_html_e('Address 1:', 'give'); ?></label> |
|
586 | 586 | </th> |
587 | 587 | <td> |
588 | 588 | <input id="line1" name="line1" type="text" class="medium-text"/> |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | </tr> |
591 | 591 | <tr> |
592 | 592 | <th class="col"> |
593 | - <label for="line2"><?php esc_html_e( 'Address 2:', 'give' ); ?></label> |
|
593 | + <label for="line2"><?php esc_html_e('Address 2:', 'give'); ?></label> |
|
594 | 594 | </th> |
595 | 595 | <td> |
596 | 596 | <input id="line2" type="text" name="line2" value="" class="medium-text"/> |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | </tr> |
600 | 600 | <tr> |
601 | 601 | <th class="col"> |
602 | - <label for="city"><?php esc_html_e( 'City:', 'give' ); ?></label> |
|
602 | + <label for="city"><?php esc_html_e('City:', 'give'); ?></label> |
|
603 | 603 | </th> |
604 | 604 | <td> |
605 | 605 | <input id="city" type="text" name="city" value="" class="medium-text"/> |
@@ -607,41 +607,41 @@ discard block |
||
607 | 607 | </tr> |
608 | 608 | <?php |
609 | 609 | $no_states_country = give_no_states_country_list(); |
610 | - $base_country = give_get_option( 'base_country' ); |
|
611 | - if ( ! array_key_exists( $base_country, $no_states_country ) ) { |
|
610 | + $base_country = give_get_option('base_country'); |
|
611 | + if ( ! array_key_exists($base_country, $no_states_country)) { |
|
612 | 612 | ?> |
613 | 613 | <tr class="give-field-wrap"> |
614 | 614 | <th class="col"> |
615 | - <label for="state"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label> |
|
615 | + <label for="state"><?php esc_html_e('State / Province / County:', 'give'); ?></label> |
|
616 | 616 | </th> |
617 | 617 | <td> |
618 | 618 | <?php |
619 | - $states = give_get_states( $base_country ); |
|
619 | + $states = give_get_states($base_country); |
|
620 | 620 | $state_args = array( |
621 | 621 | 'name' => 'state', |
622 | 622 | 'class' => 'regular-text', |
623 | 623 | ); |
624 | 624 | |
625 | - if ( empty( $states ) ) { |
|
625 | + if (empty($states)) { |
|
626 | 626 | |
627 | 627 | // Show Text field, if empty states. |
628 | - $state_args = wp_parse_args( $state_args, array( |
|
629 | - 'value' => give_get_option( 'base_state' ), |
|
630 | - ) ); |
|
631 | - echo Give()->html->text( $state_args ); |
|
628 | + $state_args = wp_parse_args($state_args, array( |
|
629 | + 'value' => give_get_option('base_state'), |
|
630 | + )); |
|
631 | + echo Give()->html->text($state_args); |
|
632 | 632 | } else { |
633 | 633 | |
634 | 634 | // Show Chosen DropDown, if states are not empty. |
635 | - $state_args = wp_parse_args( $state_args, array( |
|
635 | + $state_args = wp_parse_args($state_args, array( |
|
636 | 636 | 'options' => $states, |
637 | - 'selected' => give_get_option( 'base_state' ), |
|
637 | + 'selected' => give_get_option('base_state'), |
|
638 | 638 | 'show_option_all' => false, |
639 | 639 | 'show_option_none' => false, |
640 | 640 | 'chosen' => true, |
641 | - 'placeholder' => __( 'Select a state', 'give' ), |
|
642 | - 'data' => array( 'search-type' => 'no_ajax' ), |
|
643 | - ) ); |
|
644 | - echo Give()->html->select( $state_args ); |
|
641 | + 'placeholder' => __('Select a state', 'give'), |
|
642 | + 'data' => array('search-type' => 'no_ajax'), |
|
643 | + )); |
|
644 | + echo Give()->html->select($state_args); |
|
645 | 645 | } |
646 | 646 | ?> |
647 | 647 | </td> |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | ?> |
652 | 652 | <tr> |
653 | 653 | <th class="col"> |
654 | - <label for="zip"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label> |
|
654 | + <label for="zip"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></label> |
|
655 | 655 | </th> |
656 | 656 | <td> |
657 | 657 | <input id="zip" type="text" name="zip" value="" class="medium-text"/> |
@@ -659,12 +659,12 @@ discard block |
||
659 | 659 | </tr> |
660 | 660 | <tr> |
661 | 661 | <td colspan="2"> |
662 | - <?php wp_nonce_field( 'give-manage-donor-addresses', '_wpnonce', false ); ?> |
|
662 | + <?php wp_nonce_field('give-manage-donor-addresses', '_wpnonce', false); ?> |
|
663 | 663 | <input type="hidden" name="address-action" value="add"> |
664 | 664 | <input type="hidden" name="address-id" value=""> |
665 | 665 | <input type="submit" class="button button-primary js-save" |
666 | - value="<?php _e( 'Save', 'give' ); ?>"> <button |
|
667 | - class="button js-cancel"><?php _e( 'Cancel', 'give' ); ?></button> |
|
666 | + value="<?php _e('Save', 'give'); ?>"> <button |
|
667 | + class="button js-cancel"><?php _e('Cancel', 'give'); ?></button> |
|
668 | 668 | </td> |
669 | 669 | </tr> |
670 | 670 | </tbody> |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @param Give_Donor $donor The donor object being displayed. |
685 | 685 | */ |
686 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
686 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
687 | 687 | ?> |
688 | 688 | |
689 | 689 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -696,46 +696,46 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @param object $donor The donor object being displayed. |
698 | 698 | */ |
699 | - do_action( 'give_donor_before_tables', $donor ); |
|
699 | + do_action('give_donor_before_tables', $donor); |
|
700 | 700 | ?> |
701 | 701 | |
702 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
702 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
703 | 703 | |
704 | 704 | <table class="wp-list-table widefat striped emails"> |
705 | 705 | <thead> |
706 | 706 | <tr> |
707 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
708 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
707 | + <th><?php _e('Email', 'give'); ?></th> |
|
708 | + <th><?php _e('Actions', 'give'); ?></th> |
|
709 | 709 | </tr> |
710 | 710 | </thead> |
711 | 711 | |
712 | 712 | <tbody> |
713 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
713 | + <?php if ( ! empty($donor->emails)) { ?> |
|
714 | 714 | |
715 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
715 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
716 | 716 | <tr data-key="<?php echo $key; ?>"> |
717 | 717 | <td> |
718 | 718 | <?php echo $email; ?> |
719 | - <?php if ( 'primary' === $key ) : ?> |
|
719 | + <?php if ('primary' === $key) : ?> |
|
720 | 720 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
721 | 721 | <?php endif; ?> |
722 | 722 | </td> |
723 | 723 | <td> |
724 | - <?php if ( 'primary' !== $key ) : ?> |
|
724 | + <?php if ('primary' !== $key) : ?> |
|
725 | 725 | <?php |
726 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
727 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
728 | - 'email' => rawurlencode( $email ), |
|
726 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
727 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
728 | + 'email' => rawurlencode($email), |
|
729 | 729 | 'give_action' => 'set_donor_primary_email', |
730 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
731 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
732 | - 'email' => rawurlencode( $email ), |
|
730 | + ), $base_url), 'give-set-donor-primary-email'); |
|
731 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
732 | + 'email' => rawurlencode($email), |
|
733 | 733 | 'give_action' => 'remove_donor_email', |
734 | - ), $base_url ), 'give-remove-donor-email' ); |
|
734 | + ), $base_url), 'give-remove-donor-email'); |
|
735 | 735 | ?> |
736 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
736 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
737 | 737 | | |
738 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
738 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
739 | 739 | <?php endif; ?> |
740 | 740 | </td> |
741 | 741 | </tr> |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | <td colspan="2" class="add-donor-email-td"> |
746 | 746 | <div class="add-donor-email-wrapper"> |
747 | 747 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>"/> |
748 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
748 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
749 | 749 | <input type="email" name="additional-email" value="" |
750 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>"/> |
|
750 | + placeholder="<?php _e('Email Address', 'give'); ?>"/> |
|
751 | 751 | <input type="checkbox" name="make-additional-primary" value="1" |
752 | 752 | id="make-additional-primary"/> <label |
753 | - for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
753 | + for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
754 | 754 | <button class="button-secondary give-add-donor-email" |
755 | - id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
755 | + id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
756 | 756 | <span class="spinner"></span> |
757 | 757 | </div> |
758 | 758 | <div class="notice-wrap"></div> |
@@ -760,50 +760,50 @@ discard block |
||
760 | 760 | </tr> |
761 | 761 | <?php } else { ?> |
762 | 762 | <tr> |
763 | - <td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td> |
|
763 | + <td colspan="2"><?php _e('No Emails Found', 'give'); ?></td> |
|
764 | 764 | </tr> |
765 | 765 | <?php }// End if(). |
766 | 766 | ?> |
767 | 767 | </tbody> |
768 | 768 | </table> |
769 | 769 | |
770 | - <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
|
770 | + <h3><?php _e('Recent Donations', 'give'); ?></h3> |
|
771 | 771 | <?php |
772 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
773 | - $payments = give_get_payments( array( |
|
772 | + $payment_ids = explode(',', $donor->payment_ids); |
|
773 | + $payments = give_get_payments(array( |
|
774 | 774 | 'post__in' => $payment_ids, |
775 | - ) ); |
|
776 | - $payments = array_slice( $payments, 0, 10 ); |
|
775 | + )); |
|
776 | + $payments = array_slice($payments, 0, 10); |
|
777 | 777 | ?> |
778 | 778 | <table class="wp-list-table widefat striped payments"> |
779 | 779 | <thead> |
780 | 780 | <tr> |
781 | - <th scope="col"><?php _e( 'ID', 'give' ); ?></th> |
|
782 | - <th scope="col"><?php _e( 'Amount', 'give' ); ?></th> |
|
783 | - <th scope="col"><?php _e( 'Date', 'give' ); ?></th> |
|
784 | - <th scope="col"><?php _e( 'Status', 'give' ); ?></th> |
|
785 | - <th scope="col"><?php _e( 'Actions', 'give' ); ?></th> |
|
781 | + <th scope="col"><?php _e('ID', 'give'); ?></th> |
|
782 | + <th scope="col"><?php _e('Amount', 'give'); ?></th> |
|
783 | + <th scope="col"><?php _e('Date', 'give'); ?></th> |
|
784 | + <th scope="col"><?php _e('Status', 'give'); ?></th> |
|
785 | + <th scope="col"><?php _e('Actions', 'give'); ?></th> |
|
786 | 786 | </tr> |
787 | 787 | </thead> |
788 | 788 | <tbody> |
789 | - <?php if ( ! empty( $payments ) ) { ?> |
|
790 | - <?php foreach ( $payments as $payment ) : ?> |
|
789 | + <?php if ( ! empty($payments)) { ?> |
|
790 | + <?php foreach ($payments as $payment) : ?> |
|
791 | 791 | <tr> |
792 | 792 | <td><?php echo $payment->ID; ?></td> |
793 | - <td><?php echo give_donation_amount( $payment->ID, array( 'currency' => true, 'amount' => true, 'type' => 'donor' ) ); ?></td> |
|
794 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
795 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
793 | + <td><?php echo give_donation_amount($payment->ID, array('currency' => true, 'amount' => true, 'type' => 'donor')); ?></td> |
|
794 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
795 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
796 | 796 | <td> |
797 | 797 | <?php |
798 | 798 | printf( |
799 | 799 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
800 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
800 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
801 | 801 | sprintf( |
802 | 802 | /* translators: %s: Donation ID */ |
803 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
803 | + esc_attr__('View Donation %s.', 'give'), |
|
804 | 804 | $payment->ID |
805 | 805 | ), |
806 | - __( 'View Donation', 'give' ) |
|
806 | + __('View Donation', 'give') |
|
807 | 807 | ); |
808 | 808 | ?> |
809 | 809 | |
@@ -818,47 +818,47 @@ discard block |
||
818 | 818 | * @param object $donor The donor object being displayed. |
819 | 819 | * @param object $payment The payment object being displayed. |
820 | 820 | */ |
821 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
821 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
822 | 822 | ?> |
823 | 823 | </td> |
824 | 824 | </tr> |
825 | 825 | <?php endforeach; ?> |
826 | 826 | <?php } else { ?> |
827 | 827 | <tr> |
828 | - <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td> |
|
828 | + <td colspan="5"><?php _e('No donations found.', 'give'); ?></td> |
|
829 | 829 | </tr> |
830 | 830 | <?php }// End if(). |
831 | 831 | ?> |
832 | 832 | </tbody> |
833 | 833 | </table> |
834 | 834 | |
835 | - <h3><?php _e( 'Completed Forms', 'give' ); ?></h3> |
|
835 | + <h3><?php _e('Completed Forms', 'give'); ?></h3> |
|
836 | 836 | <?php |
837 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
837 | + $donations = give_get_users_completed_donations($donor->email); |
|
838 | 838 | ?> |
839 | 839 | <table class="wp-list-table widefat striped donations"> |
840 | 840 | <thead> |
841 | 841 | <tr> |
842 | - <th scope="col"><?php _e( 'Form', 'give' ); ?></th> |
|
843 | - <th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th> |
|
842 | + <th scope="col"><?php _e('Form', 'give'); ?></th> |
|
843 | + <th scope="col" width="120px"><?php _e('Actions', 'give'); ?></th> |
|
844 | 844 | </tr> |
845 | 845 | </thead> |
846 | 846 | <tbody> |
847 | - <?php if ( ! empty( $donations ) ) { ?> |
|
848 | - <?php foreach ( $donations as $donation ) : ?> |
|
847 | + <?php if ( ! empty($donations)) { ?> |
|
848 | + <?php foreach ($donations as $donation) : ?> |
|
849 | 849 | <tr> |
850 | 850 | <td><?php echo $donation->post_title; ?></td> |
851 | 851 | <td> |
852 | 852 | <?php |
853 | 853 | printf( |
854 | 854 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
855 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
855 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
856 | 856 | sprintf( |
857 | 857 | /* translators: %s: form name */ |
858 | - esc_attr__( 'View Form %s.', 'give' ), |
|
858 | + esc_attr__('View Form %s.', 'give'), |
|
859 | 859 | $donation->post_title |
860 | 860 | ), |
861 | - __( 'View Form', 'give' ) |
|
861 | + __('View Form', 'give') |
|
862 | 862 | ); |
863 | 863 | ?> |
864 | 864 | </td> |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | <?php endforeach; ?> |
867 | 867 | <?php } else { ?> |
868 | 868 | <tr> |
869 | - <td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td> |
|
869 | + <td colspan="2"><?php _e('No completed donations found.', 'give'); ?></td> |
|
870 | 870 | </tr> |
871 | 871 | <?php } ?> |
872 | 872 | </tbody> |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * |
881 | 881 | * @param object $donor The donor object being displayed. |
882 | 882 | */ |
883 | - do_action( 'give_donor_after_tables', $donor ); |
|
883 | + do_action('give_donor_after_tables', $donor); |
|
884 | 884 | ?> |
885 | 885 | |
886 | 886 | </div> |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * |
894 | 894 | * @param object $donor The donor object being displayed. |
895 | 895 | */ |
896 | - do_action( 'give_donor_card_bottom', $donor ); |
|
896 | + do_action('give_donor_card_bottom', $donor); |
|
897 | 897 | |
898 | 898 | } |
899 | 899 | |
@@ -906,31 +906,31 @@ discard block |
||
906 | 906 | * |
907 | 907 | * @return void |
908 | 908 | */ |
909 | -function give_donor_notes_view( $donor ) { |
|
909 | +function give_donor_notes_view($donor) { |
|
910 | 910 | |
911 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
912 | - $paged = absint( $paged ); |
|
911 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
912 | + $paged = absint($paged); |
|
913 | 913 | $note_count = $donor->get_notes_count(); |
914 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
915 | - $total_pages = ceil( $note_count / $per_page ); |
|
916 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
914 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
915 | + $total_pages = ceil($note_count / $per_page); |
|
916 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
917 | 917 | ?> |
918 | 918 | |
919 | 919 | <div id="donor-notes-wrapper"> |
920 | 920 | <div class="donor-notes-header"> |
921 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
921 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
922 | 922 | </div> |
923 | - <h3><?php _e( 'Notes', 'give' ); ?></h3> |
|
923 | + <h3><?php _e('Notes', 'give'); ?></h3> |
|
924 | 924 | |
925 | - <?php if ( 1 == $paged ) : ?> |
|
925 | + <?php if (1 == $paged) : ?> |
|
926 | 926 | <div style="display: block; margin-bottom: 55px;"> |
927 | 927 | <form id="give-add-donor-note" method="post" |
928 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
928 | + action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
929 | 929 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
930 | 930 | <br/> |
931 | 931 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>"/> |
932 | 932 | <input type="hidden" name="give_action" value="add-donor-note"/> |
933 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
933 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
934 | 934 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note"/> |
935 | 935 | </form> |
936 | 936 | </div> |
@@ -945,26 +945,26 @@ discard block |
||
945 | 945 | 'show_all' => true, |
946 | 946 | ); |
947 | 947 | |
948 | - echo paginate_links( $pagination_args ); |
|
948 | + echo paginate_links($pagination_args); |
|
949 | 949 | ?> |
950 | 950 | |
951 | 951 | <div id="give-donor-notes" class="postbox"> |
952 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
953 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
952 | + <?php if (count($donor_notes) > 0) { ?> |
|
953 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
954 | 954 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
955 | 955 | <span class="note-content-wrap"> |
956 | - <?php echo stripslashes( $note ); ?> |
|
956 | + <?php echo stripslashes($note); ?> |
|
957 | 957 | </span> |
958 | 958 | </div> |
959 | 959 | <?php endforeach; ?> |
960 | 960 | <?php } else { ?> |
961 | 961 | <div class="give-no-donor-notes"> |
962 | - <?php _e( 'No donor notes found.', 'give' ); ?> |
|
962 | + <?php _e('No donor notes found.', 'give'); ?> |
|
963 | 963 | </div> |
964 | 964 | <?php } ?> |
965 | 965 | </div> |
966 | 966 | |
967 | - <?php echo paginate_links( $pagination_args ); ?> |
|
967 | + <?php echo paginate_links($pagination_args); ?> |
|
968 | 968 | |
969 | 969 | </div> |
970 | 970 | |
@@ -980,9 +980,9 @@ discard block |
||
980 | 980 | * |
981 | 981 | * @return void |
982 | 982 | */ |
983 | -function give_donor_delete_view( $donor ) { |
|
983 | +function give_donor_delete_view($donor) { |
|
984 | 984 | |
985 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
985 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
986 | 986 | |
987 | 987 | /** |
988 | 988 | * Fires in donor delete screen, above the content. |
@@ -991,16 +991,16 @@ discard block |
||
991 | 991 | * |
992 | 992 | * @param object $donor The donor object being displayed. |
993 | 993 | */ |
994 | - do_action( 'give_donor_delete_top', $donor ); |
|
994 | + do_action('give_donor_delete_top', $donor); |
|
995 | 995 | ?> |
996 | 996 | |
997 | 997 | <div class="info-wrapper donor-section"> |
998 | 998 | |
999 | 999 | <form id="delete-donor" method="post" |
1000 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
1000 | + action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
1001 | 1001 | |
1002 | 1002 | <div class="donor-notes-header"> |
1003 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
1003 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
1004 | 1004 | </div> |
1005 | 1005 | |
1006 | 1006 | |
@@ -1008,20 +1008,20 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | <span class="delete-donor-options"> |
1010 | 1010 | <p> |
1011 | - <?php echo Give()->html->checkbox( array( |
|
1011 | + <?php echo Give()->html->checkbox(array( |
|
1012 | 1012 | 'name' => 'give-donor-delete-confirm', |
1013 | - ) ); ?> |
|
1014 | - <label for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
1013 | + )); ?> |
|
1014 | + <label for="give-donor-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
1015 | 1015 | </p> |
1016 | 1016 | |
1017 | 1017 | <p> |
1018 | - <?php echo Give()->html->checkbox( array( |
|
1018 | + <?php echo Give()->html->checkbox(array( |
|
1019 | 1019 | 'name' => 'give-donor-delete-records', |
1020 | 1020 | 'options' => array( |
1021 | 1021 | 'disabled' => true, |
1022 | 1022 | ), |
1023 | - ) ); ?> |
|
1024 | - <label for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
1023 | + )); ?> |
|
1024 | + <label for="give-donor-delete-records"><?php _e('Delete all associated donations and records?', 'give'); ?></label> |
|
1025 | 1025 | </p> |
1026 | 1026 | |
1027 | 1027 | <?php |
@@ -1034,19 +1034,19 @@ discard block |
||
1034 | 1034 | * |
1035 | 1035 | * @param object $donor The donor object being displayed. |
1036 | 1036 | */ |
1037 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
1037 | + do_action('give_donor_delete_inputs', $donor); |
|
1038 | 1038 | ?> |
1039 | 1039 | </span> |
1040 | 1040 | |
1041 | 1041 | <span id="donor-edit-actions"> |
1042 | 1042 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>"/> |
1043 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
1043 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
1044 | 1044 | <input type="hidden" name="give_action" value="delete-donor"/> |
1045 | 1045 | <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" |
1046 | - value="<?php _e( 'Delete Donor', 'give' ); ?>"/> |
|
1046 | + value="<?php _e('Delete Donor', 'give'); ?>"/> |
|
1047 | 1047 | <a id="give-delete-donor-cancel" |
1048 | - href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" |
|
1049 | - class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
1048 | + href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" |
|
1049 | + class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
1050 | 1050 | </span> |
1051 | 1051 | |
1052 | 1052 | </div> |
@@ -1062,5 +1062,5 @@ discard block |
||
1062 | 1062 | * |
1063 | 1063 | * @param object $donor The donor object being displayed. |
1064 | 1064 | */ |
1065 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
1065 | + do_action('give_donor_delete_bottom', $donor); |
|
1066 | 1066 | } |
@@ -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 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Constructor. |
50 | 50 | */ |
51 | - public function __construct( $_step = 1 ) { |
|
52 | - parent::__construct( $_step ); |
|
51 | + public function __construct($_step = 1) { |
|
52 | + parent::__construct($_step); |
|
53 | 53 | |
54 | 54 | $this->is_writable = true; |
55 | 55 | } |
@@ -66,32 +66,32 @@ discard block |
||
66 | 66 | |
67 | 67 | $args = array( |
68 | 68 | 'number' => $this->per_step, |
69 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
69 | + 'offset' => $this->per_step * ($this->step - 1), |
|
70 | 70 | 'orderby' => 'id', |
71 | 71 | 'order' => 'DESC', |
72 | 72 | ); |
73 | 73 | |
74 | - $donors = Give()->donors->get_donors( $args ); |
|
74 | + $donors = Give()->donors->get_donors($args); |
|
75 | 75 | |
76 | - if ( $donors ) { |
|
76 | + if ($donors) { |
|
77 | 77 | |
78 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
78 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
79 | 79 | |
80 | - foreach ( $donors as $donor ) { |
|
80 | + foreach ($donors as $donor) { |
|
81 | 81 | |
82 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
82 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
83 | 83 | |
84 | 84 | $attached_args = array( |
85 | 85 | 'post__in' => $attached_payment_ids, |
86 | - 'number' => - 1, |
|
86 | + 'number' => -1, |
|
87 | 87 | 'status' => $allowed_payment_status, |
88 | 88 | ); |
89 | 89 | |
90 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
90 | + $attached_payments = (array) give_get_payments($attached_args); |
|
91 | 91 | |
92 | 92 | $unattached_args = array( |
93 | 93 | 'post__not_in' => $attached_payment_ids, |
94 | - 'number' => - 1, |
|
94 | + 'number' => -1, |
|
95 | 95 | 'status' => $allowed_payment_status, |
96 | 96 | 'meta_query' => array( |
97 | 97 | array( |
@@ -102,29 +102,29 @@ discard block |
||
102 | 102 | ), |
103 | 103 | ); |
104 | 104 | |
105 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
105 | + $unattached_payments = give_get_payments($unattached_args); |
|
106 | 106 | |
107 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
107 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
108 | 108 | |
109 | 109 | $purchase_value = 0.00; |
110 | 110 | $purchase_count = 0; |
111 | 111 | $payment_ids = array(); |
112 | 112 | |
113 | - if ( $payments ) { |
|
113 | + if ($payments) { |
|
114 | 114 | |
115 | - foreach ( $payments as $payment ) { |
|
115 | + foreach ($payments as $payment) { |
|
116 | 116 | |
117 | 117 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
118 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
118 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
119 | 119 | |
120 | - if ( true === $should_process_payment ) { |
|
120 | + if (true === $should_process_payment) { |
|
121 | 121 | |
122 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
123 | - $purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
122 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
123 | + $purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
127 | - $purchase_count ++; |
|
126 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
127 | + $purchase_count++; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - $payment_ids = implode( ',', $payment_ids ); |
|
135 | + $payment_ids = implode(',', $payment_ids); |
|
136 | 136 | |
137 | 137 | $donor_update_data = array( |
138 | 138 | 'purchase_count' => $purchase_count, |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | 'payment_ids' => $payment_ids, |
141 | 141 | ); |
142 | 142 | |
143 | - $donor_instance = new Give_Donor( $donor->id ); |
|
144 | - $donor_instance->update( $donor_update_data ); |
|
143 | + $donor_instance = new Give_Donor($donor->id); |
|
144 | + $donor_instance->update($donor_update_data); |
|
145 | 145 | |
146 | 146 | }// End foreach(). |
147 | 147 | |
@@ -161,21 +161,21 @@ discard block |
||
161 | 161 | public function get_percentage_complete() { |
162 | 162 | |
163 | 163 | $args = array( |
164 | - 'number' => - 1, |
|
164 | + 'number' => -1, |
|
165 | 165 | 'orderby' => 'id', |
166 | 166 | 'order' => 'DESC', |
167 | 167 | ); |
168 | 168 | |
169 | - $donors = Give()->donors->get_donors( $args ); |
|
170 | - $total = count( $donors ); |
|
169 | + $donors = Give()->donors->get_donors($args); |
|
170 | + $total = count($donors); |
|
171 | 171 | |
172 | 172 | $percentage = 100; |
173 | 173 | |
174 | - if ( $total > 0 ) { |
|
175 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
174 | + if ($total > 0) { |
|
175 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( $percentage > 100 ) { |
|
178 | + if ($percentage > 100) { |
|
179 | 179 | $percentage = 100; |
180 | 180 | } |
181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param array $request The Form Data passed into the batch processing |
191 | 191 | */ |
192 | - public function set_properties( $request ) { |
|
192 | + public function set_properties($request) { |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function process_step() { |
202 | 202 | |
203 | - if ( ! $this->can_export() ) { |
|
204 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
203 | + if ( ! $this->can_export()) { |
|
204 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array( |
|
205 | 205 | 'response' => 403, |
206 | - ) ); |
|
206 | + )); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | $had_data = $this->get_data(); |
210 | 210 | |
211 | - if ( $had_data ) { |
|
211 | + if ($had_data) { |
|
212 | 212 | $this->done = false; |
213 | 213 | |
214 | 214 | return true; |
215 | 215 | } else { |
216 | 216 | $this->done = true; |
217 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
217 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
218 | 218 | |
219 | 219 | return false; |
220 | 220 | } |