@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | /** |
456 | 456 | * @param $option_value |
457 | - * @param $value |
|
457 | + * @param boolean $value |
|
458 | 458 | * |
459 | 459 | * @return string |
460 | 460 | */ |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @since 1.8.14 |
546 | 546 | * |
547 | - * @param $file_id |
|
547 | + * @param integer $file_id |
|
548 | 548 | * |
549 | 549 | * @return bool|int |
550 | 550 | */ |
@@ -871,8 +871,8 @@ |
||
871 | 871 | */ |
872 | 872 | private function is_donations_import_page() { |
873 | 873 | return 'import' === give_get_current_setting_tab() && |
874 | - isset( $_GET['importer-type'] ) && |
|
875 | - $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
874 | + isset( $_GET['importer-type'] ) && |
|
875 | + $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | * @since 1.8.14 |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; // Exit if accessed directly |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Give_Import_Donations' ) ) { |
|
18 | +if ( ! class_exists('Give_Import_Donations')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Give_Import_Donations. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @access private |
58 | 58 | */ |
59 | 59 | private function __construct() { |
60 | - self::$per_page = ! empty( $_GET['per_page'] ) ? absint( $_GET['per_page'] ) : self::$per_page; |
|
60 | + self::$per_page = ! empty($_GET['per_page']) ? absint($_GET['per_page']) : self::$per_page; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return static |
70 | 70 | */ |
71 | 71 | public static function get_instance() { |
72 | - if ( null === static::$instance ) { |
|
72 | + if (null === static::$instance) { |
|
73 | 73 | self::$instance = new static(); |
74 | 74 | } |
75 | 75 | |
@@ -96,27 +96,27 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | private function setup_hooks() { |
99 | - if ( ! $this->is_donations_import_page() ) { |
|
99 | + if ( ! $this->is_donations_import_page()) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Do not render main import tools page. |
104 | - remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) ); |
|
104 | + remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',)); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | // Render donation import page |
108 | - add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) ); |
|
108 | + add_action('give_admin_field_tools_import', array($this, 'render_page')); |
|
109 | 109 | |
110 | 110 | // Print the HTML. |
111 | - add_action( 'give_tools_import_donations_form_start', array( $this, 'html' ), 10 ); |
|
111 | + add_action('give_tools_import_donations_form_start', array($this, 'html'), 10); |
|
112 | 112 | |
113 | 113 | // Run when form submit. |
114 | - add_action( 'give-tools_save_import', array( $this, 'save' ) ); |
|
114 | + add_action('give-tools_save_import', array($this, 'save')); |
|
115 | 115 | |
116 | - add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 ); |
|
116 | + add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1); |
|
117 | 117 | |
118 | 118 | // Used to add submit button. |
119 | - add_action( 'give_tools_import_donations_form_end', array( $this, 'submit' ), 10 ); |
|
119 | + add_action('give_tools_import_donations_form_end', array($this, 'submit'), 10); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return mixed |
130 | 130 | */ |
131 | - public function update_notices( $messages ) { |
|
132 | - if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) { |
|
133 | - unset( $messages['give-setting-updated'] ); |
|
131 | + public function update_notices($messages) { |
|
132 | + if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) { |
|
133 | + unset($messages['give-setting-updated']); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return $messages; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @since 1.8.14 |
143 | 143 | */ |
144 | 144 | public function submit() { |
145 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
145 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
146 | 146 | ?> |
147 | 147 | <input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/> |
148 | 148 | <input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/> |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | <table class="widefat export-options-table give-table <?php echo "step-{$step}"; ?>" id="<?php echo "step-{$step}"; ?>"> |
165 | 165 | <tbody> |
166 | 166 | <?php |
167 | - switch ( $this->get_step() ) { |
|
167 | + switch ($this->get_step()) { |
|
168 | 168 | case 1: |
169 | 169 | $this->render_media_csv(); |
170 | 170 | break; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->import_success(); |
182 | 182 | } |
183 | 183 | |
184 | - if ( false === $this->check_for_dropdown_or_import() ) { |
|
184 | + if (false === $this->check_for_dropdown_or_import()) { |
|
185 | 185 | ?> |
186 | 186 | <tr valign="top"> |
187 | 187 | <th></th> |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | <input type="submit" |
190 | 190 | class="button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>" |
191 | 191 | id="recount-stats-submit" |
192 | - value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/> |
|
192 | + value="<?php esc_attr_e('Submit', 'give'); ?>"/> |
|
193 | 193 | </th> |
194 | 194 | </tr> |
195 | 195 | <?php |
@@ -208,56 +208,56 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function import_success() { |
210 | 210 | |
211 | - $delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false ); |
|
212 | - $csv = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false ); |
|
213 | - if ( ! empty( $delete_csv ) && ! empty( $csv ) ) { |
|
214 | - wp_delete_attachment( $csv, true ); |
|
211 | + $delete_csv = ( ! empty($_GET['delete_csv']) ? absint($_GET['delete_csv']) : false); |
|
212 | + $csv = ( ! empty($_GET['csv']) ? absint($_GET['csv']) : false); |
|
213 | + if ( ! empty($delete_csv) && ! empty($csv)) { |
|
214 | + wp_delete_attachment($csv, true); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | $report = give_import_donation_report(); |
218 | 218 | $report_html = array( |
219 | 219 | 'duplicate_donor' => array( |
220 | - __( '%s duplicate %s detected', 'give' ), |
|
221 | - __( 'donor', 'give' ), |
|
222 | - __( 'donors', 'give' ), |
|
220 | + __('%s duplicate %s detected', 'give'), |
|
221 | + __('donor', 'give'), |
|
222 | + __('donors', 'give'), |
|
223 | 223 | ), |
224 | 224 | 'create_donor' => array( |
225 | - __( '%s %s created', 'give' ), |
|
226 | - __( 'donor', 'give' ), |
|
227 | - __( 'donors', 'give' ), |
|
225 | + __('%s %s created', 'give'), |
|
226 | + __('donor', 'give'), |
|
227 | + __('donors', 'give'), |
|
228 | 228 | ), |
229 | 229 | 'create_form' => array( |
230 | - __( '%s donation %s created', 'give' ), |
|
231 | - __( 'form', 'give' ), |
|
232 | - __( 'forms', 'give' ), |
|
230 | + __('%s donation %s created', 'give'), |
|
231 | + __('form', 'give'), |
|
232 | + __('forms', 'give'), |
|
233 | 233 | ), |
234 | 234 | 'duplicate_donation' => array( |
235 | - __( '%s duplicate %s detected', 'give' ), |
|
236 | - __( 'donation', 'give' ), |
|
237 | - __( 'donations', 'give' ), |
|
235 | + __('%s duplicate %s detected', 'give'), |
|
236 | + __('donation', 'give'), |
|
237 | + __('donations', 'give'), |
|
238 | 238 | ), |
239 | 239 | 'create_donation' => array( |
240 | - __( '%s %s imported', 'give' ), |
|
241 | - __( 'donation', 'give' ), |
|
242 | - __( 'donations', 'give' ), |
|
240 | + __('%s %s imported', 'give'), |
|
241 | + __('donation', 'give'), |
|
242 | + __('donations', 'give'), |
|
243 | 243 | ), |
244 | 244 | ); |
245 | - $total = (int) $_GET['total']; |
|
246 | - -- $total; |
|
245 | + $total = (int) $_GET['total']; |
|
246 | + --$total; |
|
247 | 247 | $success = (bool) $_GET['success']; |
248 | 248 | ?> |
249 | 249 | <tr valign="top" class="give-import-dropdown"> |
250 | 250 | <th colspan="2"> |
251 | 251 | <h2> |
252 | 252 | <?php |
253 | - if ( $success ) { |
|
253 | + if ($success) { |
|
254 | 254 | echo sprintf( |
255 | - __( 'Import complete! %s donations processed', 'give' ), |
|
255 | + __('Import complete! %s donations processed', 'give'), |
|
256 | 256 | "<strong>{$total}</strong>" |
257 | 257 | ); |
258 | 258 | } else { |
259 | 259 | echo sprintf( |
260 | - __( 'Failed to import %s donations', 'give' ), |
|
260 | + __('Failed to import %s donations', 'give'), |
|
261 | 261 | "<strong>{$total}</strong>" |
262 | 262 | ); |
263 | 263 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | </h2> |
266 | 266 | |
267 | 267 | <?php |
268 | - $text = __( 'Import Donation', 'give' ); |
|
268 | + $text = __('Import Donation', 'give'); |
|
269 | 269 | $query_arg = array( |
270 | 270 | 'post_type' => 'give_forms', |
271 | 271 | 'page' => 'give-tools', |
272 | 272 | 'tab' => 'import', |
273 | 273 | ); |
274 | - if ( $success ) { |
|
274 | + if ($success) { |
|
275 | 275 | $query_arg = array( |
276 | 276 | 'post_type' => 'give_forms', |
277 | 277 | 'page' => 'give-payment-history', |
278 | 278 | ); |
279 | - $text = __( 'View Donations', 'give' ); |
|
279 | + $text = __('View Donations', 'give'); |
|
280 | 280 | } |
281 | 281 | |
282 | - foreach ( $report as $key => $value ) { |
|
283 | - if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) { |
|
282 | + foreach ($report as $key => $value) { |
|
283 | + if (array_key_exists($key, $report_html) && ! empty($value)) { |
|
284 | 284 | ?> |
285 | 285 | <p> |
286 | - <?php echo esc_html( wp_sprintf( $report_html[ $key ][0], $value, _n( $report_html[ $key ][1], $report_html[ $key ][2], $value, 'give' ) ) ); ?> |
|
286 | + <?php echo esc_html(wp_sprintf($report_html[$key][0], $value, _n($report_html[$key][1], $report_html[$key][2], $value, 'give'))); ?> |
|
287 | 287 | </p> |
288 | 288 | <?php |
289 | 289 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ?> |
292 | 292 | |
293 | 293 | <p> |
294 | - <a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a> |
|
294 | + <a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg, admin_url('edit.php')); ?>"><?php echo $text; ?></a> |
|
295 | 295 | </p> |
296 | 296 | </th> |
297 | 297 | </tr> |
@@ -308,26 +308,26 @@ discard block |
||
308 | 308 | give_import_donation_report_reset(); |
309 | 309 | |
310 | 310 | $csv = (int) $_REQUEST['csv']; |
311 | - $delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' ); |
|
311 | + $delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv'); |
|
312 | 312 | $index_start = 1; |
313 | 313 | $index_end = 1; |
314 | 314 | $next = true; |
315 | - $total = self::get_csv_total( $csv ); |
|
316 | - if ( self::$per_page < $total ) { |
|
317 | - $total_ajax = ceil( $total / self::$per_page ); |
|
315 | + $total = self::get_csv_total($csv); |
|
316 | + if (self::$per_page < $total) { |
|
317 | + $total_ajax = ceil($total / self::$per_page); |
|
318 | 318 | $index_end = self::$per_page; |
319 | 319 | } else { |
320 | 320 | $total_ajax = 1; |
321 | 321 | $index_end = $total; |
322 | 322 | $next = false; |
323 | 323 | } |
324 | - $current_percentage = 100 / ( $total_ajax + 1 ); |
|
324 | + $current_percentage = 100 / ($total_ajax + 1); |
|
325 | 325 | |
326 | 326 | ?> |
327 | 327 | <tr valign="top" class="give-import-dropdown"> |
328 | 328 | <th colspan="2"> |
329 | - <h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2> |
|
330 | - <p class="give-field-description"><?php esc_html_e( 'Your donations are now being imported...', 'give' ) ?></p> |
|
329 | + <h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2> |
|
330 | + <p class="give-field-description"><?php esc_html_e('Your donations are now being imported...', 'give') ?></p> |
|
331 | 331 | </th> |
332 | 332 | </tr> |
333 | 333 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | <div style="width: <?php echo $current_percentage; ?>%"></div> |
347 | 347 | </div> |
348 | 348 | <input type="hidden" value="3" name="step"> |
349 | - <input type="hidden" value='<?php echo maybe_serialize( $_REQUEST['mapto'] ); ?>' name="mapto" |
|
349 | + <input type="hidden" value='<?php echo maybe_serialize($_REQUEST['mapto']); ?>' name="mapto" |
|
350 | 350 | class="mapto"> |
351 | 351 | <input type="hidden" value="<?php echo $_REQUEST['csv']; ?>" name="csv" class="csv"> |
352 | 352 | <input type="hidden" value="<?php echo $_REQUEST['mode']; ?>" name="mode" class="mode"> |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | <input type="hidden" value="<?php echo $_REQUEST['delete_csv']; ?>" name="delete_csv" |
356 | 356 | class="delete_csv"> |
357 | 357 | <input type="hidden" value="<?php echo $delimiter; ?>" name="delimiter"> |
358 | - <input type="hidden" value='<?php echo maybe_serialize( self::get_importer( $csv, 0, $delimiter ) ); ?>' |
|
358 | + <input type="hidden" value='<?php echo maybe_serialize(self::get_importer($csv, 0, $delimiter)); ?>' |
|
359 | 359 | name="main_key" |
360 | 360 | class="main_key"> |
361 | 361 | </th> |
@@ -376,20 +376,20 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function check_for_dropdown_or_import() { |
378 | 378 | $return = true; |
379 | - if ( isset( $_REQUEST['mapto'] ) ) { |
|
379 | + if (isset($_REQUEST['mapto'])) { |
|
380 | 380 | $mapto = (array) $_REQUEST['mapto']; |
381 | - if ( false === in_array( 'form_title', $mapto ) && false === in_array( 'form_id', $mapto ) ) { |
|
382 | - Give_Admin_Settings::add_error( 'give-import-csv-form', __( 'In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give' ) ); |
|
381 | + if (false === in_array('form_title', $mapto) && false === in_array('form_id', $mapto)) { |
|
382 | + Give_Admin_Settings::add_error('give-import-csv-form', __('In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give')); |
|
383 | 383 | $return = false; |
384 | 384 | } |
385 | 385 | |
386 | - if ( false === in_array( 'amount', $mapto ) ) { |
|
387 | - Give_Admin_Settings::add_error( 'give-import-csv-amount', __( 'In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give' ) ); |
|
386 | + if (false === in_array('amount', $mapto)) { |
|
387 | + Give_Admin_Settings::add_error('give-import-csv-amount', __('In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give')); |
|
388 | 388 | $return = false; |
389 | 389 | } |
390 | 390 | |
391 | - if ( false === in_array( 'email', $mapto ) && false === in_array( 'donor_id', $mapto ) ) { |
|
392 | - Give_Admin_Settings::add_error( 'give-import-csv-donor', __( 'In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give' ) ); |
|
391 | + if (false === in_array('email', $mapto) && false === in_array('donor_id', $mapto)) { |
|
392 | + Give_Admin_Settings::add_error('give-import-csv-donor', __('In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give')); |
|
393 | 393 | $return = false; |
394 | 394 | } |
395 | 395 | } else { |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | */ |
407 | 407 | public function render_dropdown() { |
408 | 408 | $csv = (int) $_GET['csv']; |
409 | - $delimiter = ( ! empty( $_GET['delimiter'] ) ? give_clean( $_GET['delimiter'] ) : 'csv' ); |
|
409 | + $delimiter = ( ! empty($_GET['delimiter']) ? give_clean($_GET['delimiter']) : 'csv'); |
|
410 | 410 | |
411 | 411 | // TO check if the CSV files that is being add is valid or not if not then redirect to first step again |
412 | - if ( ! $this->is_valid_csv( $csv ) ) { |
|
412 | + if ( ! $this->is_valid_csv($csv)) { |
|
413 | 413 | $url = give_import_page_url(); |
414 | 414 | ?> |
415 | 415 | <script type="text/javascript"> |
@@ -420,27 +420,27 @@ discard block |
||
420 | 420 | ?> |
421 | 421 | <tr valign="top" class="give-import-dropdown"> |
422 | 422 | <th colspan="2"> |
423 | - <h2 id="give-import-title"><?php esc_html_e( 'Map CSV fields to donations', 'give' ) ?></h2> |
|
424 | - <p class="give-field-description"><?php esc_html_e( 'Select fields from your CSV file to map against donations fields or to ignore during import.', 'give' ) ?></p> |
|
423 | + <h2 id="give-import-title"><?php esc_html_e('Map CSV fields to donations', 'give') ?></h2> |
|
424 | + <p class="give-field-description"><?php esc_html_e('Select fields from your CSV file to map against donations fields or to ignore during import.', 'give') ?></p> |
|
425 | 425 | </th> |
426 | 426 | </tr> |
427 | 427 | |
428 | 428 | <tr valign="top" class="give-import-dropdown"> |
429 | - <th><b><?php esc_html_e( 'Column name', 'give' ); ?></b></th> |
|
430 | - <th><b><?php esc_html_e( 'Map to field', 'give' ); ?></b></th> |
|
429 | + <th><b><?php esc_html_e('Column name', 'give'); ?></b></th> |
|
430 | + <th><b><?php esc_html_e('Map to field', 'give'); ?></b></th> |
|
431 | 431 | </tr> |
432 | 432 | |
433 | 433 | <?php |
434 | - $raw_key = $this->get_importer( $csv, 0, $delimiter ); |
|
435 | - $mapto = (array) ( isset( $_REQUEST['mapto'] ) ? $_REQUEST['mapto'] : array() ); |
|
434 | + $raw_key = $this->get_importer($csv, 0, $delimiter); |
|
435 | + $mapto = (array) (isset($_REQUEST['mapto']) ? $_REQUEST['mapto'] : array()); |
|
436 | 436 | |
437 | - foreach ( $raw_key as $index => $value ) { |
|
437 | + foreach ($raw_key as $index => $value) { |
|
438 | 438 | ?> |
439 | 439 | <tr valign="top" class="give-import-option"> |
440 | 440 | <th><?php echo $value; ?></th> |
441 | 441 | <th> |
442 | 442 | <?php |
443 | - $this->get_columns( $index, $value, $mapto ); |
|
443 | + $this->get_columns($index, $value, $mapto); |
|
444 | 444 | ?> |
445 | 445 | </th> |
446 | 446 | </tr> |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function selected( $option_value, $value ) { |
|
459 | - $option_value = strtolower( $option_value ); |
|
460 | - $value = strtolower( $value ); |
|
458 | + public function selected($option_value, $value) { |
|
459 | + $option_value = strtolower($option_value); |
|
460 | + $value = strtolower($value); |
|
461 | 461 | |
462 | 462 | $selected = ''; |
463 | - if ( stristr( $value, $option_value ) ) { |
|
463 | + if (stristr($value, $option_value)) { |
|
464 | 464 | $selected = 'selected'; |
465 | - } elseif ( strrpos( $value, '_' ) && stristr( $option_value, __( 'Import as Meta', 'give' ) ) ) { |
|
465 | + } elseif (strrpos($value, '_') && stristr($option_value, __('Import as Meta', 'give'))) { |
|
466 | 466 | $selected = 'selected'; |
467 | 467 | } |
468 | 468 | |
@@ -481,28 +481,28 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return void |
483 | 483 | */ |
484 | - private function get_columns( $index, $value = false, $mapto = array() ) { |
|
484 | + private function get_columns($index, $value = false, $mapto = array()) { |
|
485 | 485 | $default = give_import_default_options(); |
486 | - $current_mapto = (string) ( ! empty( $mapto[ $index ] ) ? $mapto[ $index ] : '' ); |
|
486 | + $current_mapto = (string) ( ! empty($mapto[$index]) ? $mapto[$index] : ''); |
|
487 | 487 | ?> |
488 | 488 | <select name="mapto[<?php echo $index; ?>]"> |
489 | - <?php $this->get_dropdown_option_html( $default, $current_mapto, $value ); ?> |
|
489 | + <?php $this->get_dropdown_option_html($default, $current_mapto, $value); ?> |
|
490 | 490 | |
491 | - <optgroup label="<?php _e( 'Donations', 'give' ); ?>"> |
|
491 | + <optgroup label="<?php _e('Donations', 'give'); ?>"> |
|
492 | 492 | <?php |
493 | - $this->get_dropdown_option_html( give_import_donations_options(), $current_mapto, $value ); |
|
493 | + $this->get_dropdown_option_html(give_import_donations_options(), $current_mapto, $value); |
|
494 | 494 | ?> |
495 | 495 | </optgroup> |
496 | 496 | |
497 | - <optgroup label="<?php _e( 'Donors', 'give' ); ?>"> |
|
497 | + <optgroup label="<?php _e('Donors', 'give'); ?>"> |
|
498 | 498 | <?php |
499 | - $this->get_dropdown_option_html( give_import_donor_options(), $current_mapto, $value ); |
|
499 | + $this->get_dropdown_option_html(give_import_donor_options(), $current_mapto, $value); |
|
500 | 500 | ?> |
501 | 501 | </optgroup> |
502 | 502 | |
503 | - <optgroup label="<?php _e( 'Forms', 'give' ); ?>"> |
|
503 | + <optgroup label="<?php _e('Forms', 'give'); ?>"> |
|
504 | 504 | <?php |
505 | - $this->get_dropdown_option_html( give_import_donation_form_options(), $current_mapto, $value ); |
|
505 | + $this->get_dropdown_option_html(give_import_donation_form_options(), $current_mapto, $value); |
|
506 | 506 | ?> |
507 | 507 | </optgroup> |
508 | 508 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @since 1.8.15 |
515 | 515 | */ |
516 | - do_action( 'give_import_dropdown_option', $index, $value, $mapto, $current_mapto ); |
|
516 | + do_action('give_import_dropdown_option', $index, $value, $mapto, $current_mapto); |
|
517 | 517 | ?> |
518 | 518 | </select> |
519 | 519 | <?php |
@@ -531,16 +531,16 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return void |
533 | 533 | */ |
534 | - public function get_dropdown_option_html( $options, $current_mapto, $value = false ) { |
|
535 | - foreach ( $options as $option => $option_value ) { |
|
534 | + public function get_dropdown_option_html($options, $current_mapto, $value = false) { |
|
535 | + foreach ($options as $option => $option_value) { |
|
536 | 536 | $option_value_texts = (array) $option_value; |
537 | 537 | $option_text = $option_value_texts[0]; |
538 | 538 | |
539 | - $checked = ( ( $current_mapto === $option ) ? 'selected' : false ); |
|
540 | - if ( empty( $checked ) ) { |
|
541 | - foreach ( $option_value_texts as $option_value_text ) { |
|
542 | - $checked = $this->selected( $option_value_text, $value ); |
|
543 | - if ( $checked ) { |
|
539 | + $checked = (($current_mapto === $option) ? 'selected' : false); |
|
540 | + if (empty($checked)) { |
|
541 | + foreach ($option_value_texts as $option_value_text) { |
|
542 | + $checked = $this->selected($option_value_text, $value); |
|
543 | + if ($checked) { |
|
544 | 544 | break; |
545 | 545 | } |
546 | 546 | } |
@@ -564,13 +564,13 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @return bool|int |
566 | 566 | */ |
567 | - public function get_csv_total( $file_id ) { |
|
567 | + public function get_csv_total($file_id) { |
|
568 | 568 | $total = false; |
569 | - if ( $file_id ) { |
|
570 | - $file_dir = get_attached_file( $file_id ); |
|
571 | - if ( $file_dir ) { |
|
572 | - $file = new SplFileObject( $file_dir, 'r' ); |
|
573 | - $file->seek( PHP_INT_MAX ); |
|
569 | + if ($file_id) { |
|
570 | + $file_dir = get_attached_file($file_id); |
|
571 | + if ($file_dir) { |
|
572 | + $file = new SplFileObject($file_dir, 'r'); |
|
573 | + $file->seek(PHP_INT_MAX); |
|
574 | 574 | $total = $file->key() + 1; |
575 | 575 | } |
576 | 576 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return array|bool $raw_data title of the CSV file fields |
591 | 591 | */ |
592 | - public function get_importer( $file_id, $index = 0, $delimiter = 'csv' ) { |
|
592 | + public function get_importer($file_id, $index = 0, $delimiter = 'csv') { |
|
593 | 593 | /** |
594 | 594 | * Filter to modify delimiter of Import. |
595 | 595 | * |
@@ -597,16 +597,16 @@ discard block |
||
597 | 597 | * |
598 | 598 | * Return string $delimiter. |
599 | 599 | */ |
600 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
600 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
601 | 601 | |
602 | 602 | $raw_data = false; |
603 | - $file_dir = get_attached_file( $file_id ); |
|
604 | - if ( $file_dir ) { |
|
605 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
606 | - $raw_data = fgetcsv( $handle, $index, $delimiter ); |
|
603 | + $file_dir = get_attached_file($file_id); |
|
604 | + if ($file_dir) { |
|
605 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
606 | + $raw_data = fgetcsv($handle, $index, $delimiter); |
|
607 | 607 | // Remove BOM signature from the first item. |
608 | - if ( isset( $raw_data[0] ) ) { |
|
609 | - $raw_data[0] = $this->remove_utf8_bom( $raw_data[0] ); |
|
608 | + if (isset($raw_data[0])) { |
|
609 | + $raw_data[0] = $this->remove_utf8_bom($raw_data[0]); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | } |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public function remove_utf8_bom( $string ) { |
|
627 | - if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) { |
|
628 | - $string = substr( $string, 3 ); |
|
626 | + public function remove_utf8_bom($string) { |
|
627 | + if ('efbbbf' === substr(bin2hex($string), 0, 6)) { |
|
628 | + $string = substr($string, 3); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | return $string; |
@@ -641,17 +641,17 @@ discard block |
||
641 | 641 | $step = $this->get_step(); |
642 | 642 | ?> |
643 | 643 | <ol class="give-progress-steps"> |
644 | - <li class="<?php echo( 1 === $step ? 'active' : '' ); ?>"> |
|
645 | - <?php esc_html_e( 'Upload CSV file', 'give' ); ?> |
|
644 | + <li class="<?php echo(1 === $step ? 'active' : ''); ?>"> |
|
645 | + <?php esc_html_e('Upload CSV file', 'give'); ?> |
|
646 | 646 | </li> |
647 | - <li class="<?php echo( 2 === $step ? 'active' : '' ); ?>"> |
|
648 | - <?php esc_html_e( 'Column mapping', 'give' ); ?> |
|
647 | + <li class="<?php echo(2 === $step ? 'active' : ''); ?>"> |
|
648 | + <?php esc_html_e('Column mapping', 'give'); ?> |
|
649 | 649 | </li> |
650 | - <li class="<?php echo( 3 === $step ? 'active' : '' ); ?>"> |
|
651 | - <?php esc_html_e( 'Import', 'give' ); ?> |
|
650 | + <li class="<?php echo(3 === $step ? 'active' : ''); ?>"> |
|
651 | + <?php esc_html_e('Import', 'give'); ?> |
|
652 | 652 | </li> |
653 | - <li class="<?php echo( 4 === $step ? 'active' : '' ); ?>"> |
|
654 | - <?php esc_html_e( 'Done!', 'give' ); ?> |
|
653 | + <li class="<?php echo(4 === $step ? 'active' : ''); ?>"> |
|
654 | + <?php esc_html_e('Done!', 'give'); ?> |
|
655 | 655 | </li> |
656 | 656 | </ol> |
657 | 657 | <?php |
@@ -665,16 +665,16 @@ discard block |
||
665 | 665 | * @return int $step on which step doest the import is on. |
666 | 666 | */ |
667 | 667 | public function get_step() { |
668 | - $step = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 ); |
|
668 | + $step = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0); |
|
669 | 669 | $on_step = 1; |
670 | 670 | |
671 | - if ( empty( $step ) || 1 === $step ) { |
|
671 | + if (empty($step) || 1 === $step) { |
|
672 | 672 | $on_step = 1; |
673 | - } elseif ( $this->check_for_dropdown_or_import() ) { |
|
673 | + } elseif ($this->check_for_dropdown_or_import()) { |
|
674 | 674 | $on_step = 3; |
675 | - } elseif ( 2 === $step ) { |
|
675 | + } elseif (2 === $step) { |
|
676 | 676 | $on_step = 2; |
677 | - } elseif ( 4 === $step ) { |
|
677 | + } elseif (4 === $step) { |
|
678 | 678 | $on_step = 4; |
679 | 679 | } |
680 | 680 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | * @since 1.8.14 |
688 | 688 | */ |
689 | 689 | public function render_page() { |
690 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-donations.php'; |
|
690 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-donations.php'; |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -702,37 +702,34 @@ discard block |
||
702 | 702 | ?> |
703 | 703 | <tr valign="top"> |
704 | 704 | <th colspan="2"> |
705 | - <h2 id="give-import-title"><?php esc_html_e( 'Import donations from a CSV file', 'give' ) ?></h2> |
|
706 | - <p class="give-field-description"><?php esc_html_e( 'This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give' ) ?></p> |
|
705 | + <h2 id="give-import-title"><?php esc_html_e('Import donations from a CSV file', 'give') ?></h2> |
|
706 | + <p class="give-field-description"><?php esc_html_e('This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give') ?></p> |
|
707 | 707 | </th> |
708 | 708 | </tr> |
709 | 709 | <?php |
710 | - $csv = ( isset( $_POST['csv'] ) ? give_clean( $_POST['csv'] ) : '' ); |
|
711 | - $csv_id = ( isset( $_POST['csv_id'] ) ? give_clean( $_POST['csv_id'] ) : '' ); |
|
712 | - $delimiter = ( isset( $_POST['delimiter'] ) ? give_clean( $_POST['delimiter'] ) : 'csv' ); |
|
713 | - $mode = empty( $_POST['mode'] ) ? |
|
714 | - 'disabled' : |
|
715 | - ( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? 'enabled' : 'disabled' ); |
|
716 | - $create_user = empty( $_POST['create_user'] ) ? |
|
717 | - 'enabled' : |
|
718 | - ( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? 'enabled' : 'disabled' ); |
|
719 | - $delete_csv = empty( $_POST['delete_csv'] ) ? |
|
720 | - 'enabled' : |
|
721 | - ( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? 'enabled' : 'disabled' ); |
|
710 | + $csv = (isset($_POST['csv']) ? give_clean($_POST['csv']) : ''); |
|
711 | + $csv_id = (isset($_POST['csv_id']) ? give_clean($_POST['csv_id']) : ''); |
|
712 | + $delimiter = (isset($_POST['delimiter']) ? give_clean($_POST['delimiter']) : 'csv'); |
|
713 | + $mode = empty($_POST['mode']) ? |
|
714 | + 'disabled' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? 'enabled' : 'disabled'); |
|
715 | + $create_user = empty($_POST['create_user']) ? |
|
716 | + 'enabled' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? 'enabled' : 'disabled'); |
|
717 | + $delete_csv = empty($_POST['delete_csv']) ? |
|
718 | + 'enabled' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? 'enabled' : 'disabled'); |
|
722 | 719 | |
723 | 720 | // Reset csv and csv_id if csv |
724 | - if ( empty( $csv_id ) || ! $this->is_valid_csv( $csv_id, $csv ) ) { |
|
721 | + if (empty($csv_id) || ! $this->is_valid_csv($csv_id, $csv)) { |
|
725 | 722 | $csv_id = $csv = ''; |
726 | 723 | } |
727 | - $per_page = isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page; |
|
724 | + $per_page = isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page; |
|
728 | 725 | |
729 | 726 | $settings = array( |
730 | 727 | array( |
731 | 728 | 'id' => 'csv', |
732 | - 'name' => __( 'Choose a CSV file:', 'give' ), |
|
729 | + 'name' => __('Choose a CSV file:', 'give'), |
|
733 | 730 | 'type' => 'file', |
734 | - 'attributes' => array( 'editing' => 'false', 'library' => 'text' ), |
|
735 | - 'description' => __( 'The file must be a Comma Seperated Version (CSV) file type only.', 'give' ), |
|
731 | + 'attributes' => array('editing' => 'false', 'library' => 'text'), |
|
732 | + 'description' => __('The file must be a Comma Seperated Version (CSV) file type only.', 'give'), |
|
736 | 733 | 'fvalue' => 'url', |
737 | 734 | 'default' => $csv, |
738 | 735 | ), |
@@ -743,61 +740,61 @@ discard block |
||
743 | 740 | ), |
744 | 741 | array( |
745 | 742 | 'id' => 'delimiter', |
746 | - 'name' => __( 'CSV Delimiter:', 'give' ), |
|
747 | - 'description' => __( 'In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give' ), |
|
743 | + 'name' => __('CSV Delimiter:', 'give'), |
|
744 | + 'description' => __('In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give'), |
|
748 | 745 | 'default' => $delimiter, |
749 | 746 | 'type' => 'select', |
750 | 747 | 'options' => array( |
751 | - 'csv' => esc_html__( 'Comma', 'give' ), |
|
752 | - 'tab-separated-values' => esc_html__( 'Tab', 'give' ), |
|
748 | + 'csv' => esc_html__('Comma', 'give'), |
|
749 | + 'tab-separated-values' => esc_html__('Tab', 'give'), |
|
753 | 750 | ), |
754 | 751 | ), |
755 | 752 | array( |
756 | 753 | 'id' => 'mode', |
757 | - 'name' => __( 'Test Mode:', 'give' ), |
|
758 | - 'description' => __( 'Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give' ), |
|
754 | + 'name' => __('Test Mode:', 'give'), |
|
755 | + 'description' => __('Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give'), |
|
759 | 756 | 'default' => $mode, |
760 | 757 | 'type' => 'radio_inline', |
761 | 758 | 'options' => array( |
762 | - 'enabled' => __( 'Enabled', 'give' ), |
|
763 | - 'disabled' => __( 'Disabled', 'give' ), |
|
759 | + 'enabled' => __('Enabled', 'give'), |
|
760 | + 'disabled' => __('Disabled', 'give'), |
|
764 | 761 | ), |
765 | 762 | ), |
766 | 763 | array( |
767 | 764 | 'id' => 'create_user', |
768 | - 'name' => __( 'Create WP users for new donors:', 'give' ), |
|
769 | - 'description' => __( 'The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give' ), |
|
765 | + 'name' => __('Create WP users for new donors:', 'give'), |
|
766 | + 'description' => __('The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give'), |
|
770 | 767 | 'default' => $create_user, |
771 | 768 | 'type' => 'radio_inline', |
772 | 769 | 'options' => array( |
773 | - 'enabled' => __( 'Enabled', 'give' ), |
|
774 | - 'disabled' => __( 'Disabled', 'give' ), |
|
770 | + 'enabled' => __('Enabled', 'give'), |
|
771 | + 'disabled' => __('Disabled', 'give'), |
|
775 | 772 | ), |
776 | 773 | ), |
777 | 774 | array( |
778 | 775 | 'id' => 'delete_csv', |
779 | - 'name' => __( 'Delete CSV after import:', 'give' ), |
|
780 | - 'description' => __( 'Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give' ), |
|
776 | + 'name' => __('Delete CSV after import:', 'give'), |
|
777 | + 'description' => __('Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give'), |
|
781 | 778 | 'default' => $delete_csv, |
782 | 779 | 'type' => 'radio_inline', |
783 | 780 | 'options' => array( |
784 | - 'enabled' => __( 'Enabled', 'give' ), |
|
785 | - 'disabled' => __( 'Disabled', 'give' ), |
|
781 | + 'enabled' => __('Enabled', 'give'), |
|
782 | + 'disabled' => __('Disabled', 'give'), |
|
786 | 783 | ), |
787 | 784 | ), |
788 | 785 | array( |
789 | 786 | 'id' => 'per_page', |
790 | - 'name' => __( 'Process Rows Per Batch:', 'give' ), |
|
787 | + 'name' => __('Process Rows Per Batch:', 'give'), |
|
791 | 788 | 'type' => 'number', |
792 | - 'description' => __( 'Determine how many rows you would like to import per cycle.', 'give' ), |
|
789 | + 'description' => __('Determine how many rows you would like to import per cycle.', 'give'), |
|
793 | 790 | 'default' => $per_page, |
794 | 791 | 'class' => 'give-text-small', |
795 | 792 | ), |
796 | 793 | ); |
797 | 794 | |
798 | - $settings = apply_filters( 'give_import_file_upload_html', $settings ); |
|
795 | + $settings = apply_filters('give_import_file_upload_html', $settings); |
|
799 | 796 | |
800 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
797 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
801 | 798 | } |
802 | 799 | |
803 | 800 | /** |
@@ -810,27 +807,24 @@ discard block |
||
810 | 807 | $step = $this->get_step(); |
811 | 808 | |
812 | 809 | // Validation for first step. |
813 | - if ( 1 === $step ) { |
|
814 | - $csv_id = absint( $_POST['csv_id'] ); |
|
810 | + if (1 === $step) { |
|
811 | + $csv_id = absint($_POST['csv_id']); |
|
815 | 812 | |
816 | - if ( $this->is_valid_csv( $csv_id, esc_url( $_POST['csv'] ) ) ) { |
|
813 | + if ($this->is_valid_csv($csv_id, esc_url($_POST['csv']))) { |
|
817 | 814 | |
818 | - $url = give_import_page_url( (array) apply_filters( 'give_import_step_two_url', array( |
|
815 | + $url = give_import_page_url((array) apply_filters('give_import_step_two_url', array( |
|
819 | 816 | 'step' => '2', |
820 | 817 | 'importer-type' => $this->importer_type, |
821 | 818 | 'csv' => $csv_id, |
822 | - 'delimiter' => isset( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv', |
|
823 | - 'mode' => empty( $_POST['mode'] ) ? |
|
824 | - '0' : |
|
825 | - ( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? '1' : '0' ), |
|
826 | - 'create_user' => empty( $_POST['create_user'] ) ? |
|
827 | - '0' : |
|
828 | - ( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? '1' : '0' ), |
|
829 | - 'delete_csv' => empty( $_POST['delete_csv'] ) ? |
|
830 | - '1' : |
|
831 | - ( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? '1' : '0' ), |
|
832 | - 'per_page' => isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page, |
|
833 | - ) ) ); |
|
819 | + 'delimiter' => isset($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv', |
|
820 | + 'mode' => empty($_POST['mode']) ? |
|
821 | + '0' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? '1' : '0'), |
|
822 | + 'create_user' => empty($_POST['create_user']) ? |
|
823 | + '0' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? '1' : '0'), |
|
824 | + 'delete_csv' => empty($_POST['delete_csv']) ? |
|
825 | + '1' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? '1' : '0'), |
|
826 | + 'per_page' => isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page, |
|
827 | + ))); |
|
834 | 828 | ?> |
835 | 829 | <script type="text/javascript"> |
836 | 830 | window.location = "<?php echo $url; ?>" |
@@ -851,25 +845,25 @@ discard block |
||
851 | 845 | * |
852 | 846 | * @return bool $has_error CSV is valid or not. |
853 | 847 | */ |
854 | - private function is_valid_csv( $csv = false, $match_url = '' ) { |
|
848 | + private function is_valid_csv($csv = false, $match_url = '') { |
|
855 | 849 | $is_valid_csv = true; |
856 | 850 | |
857 | - if ( $csv ) { |
|
858 | - $csv_url = wp_get_attachment_url( $csv ); |
|
851 | + if ($csv) { |
|
852 | + $csv_url = wp_get_attachment_url($csv); |
|
859 | 853 | |
860 | - $delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' ); |
|
854 | + $delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv'); |
|
861 | 855 | |
862 | 856 | if ( |
863 | 857 | ! $csv_url || |
864 | - ( ! empty( $match_url ) && ( $csv_url !== $match_url ) ) || |
|
865 | - ( ( $mime_type = get_post_mime_type( $csv ) ) && ! strpos( $mime_type, $delimiter ) ) |
|
858 | + ( ! empty($match_url) && ($csv_url !== $match_url)) || |
|
859 | + (($mime_type = get_post_mime_type($csv)) && ! strpos($mime_type, $delimiter)) |
|
866 | 860 | ) { |
867 | 861 | $is_valid_csv = false; |
868 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) ); |
|
862 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give')); |
|
869 | 863 | } |
870 | 864 | } else { |
871 | 865 | $is_valid_csv = false; |
872 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) ); |
|
866 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give')); |
|
873 | 867 | } |
874 | 868 | |
875 | 869 | return $is_valid_csv; |
@@ -885,8 +879,8 @@ discard block |
||
885 | 879 | * @param $field |
886 | 880 | * @param $option_value |
887 | 881 | */ |
888 | - public function render_import_field( $field, $option_value ) { |
|
889 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php'; |
|
882 | + public function render_import_field($field, $option_value) { |
|
883 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php'; |
|
890 | 884 | } |
891 | 885 | |
892 | 886 | /** |
@@ -897,8 +891,8 @@ discard block |
||
897 | 891 | */ |
898 | 892 | private function is_donations_import_page() { |
899 | 893 | return 'import' === give_get_current_setting_tab() && |
900 | - isset( $_GET['importer-type'] ) && |
|
901 | - $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
894 | + isset($_GET['importer-type']) && |
|
895 | + $this->importer_type === give_clean($_GET['importer-type']); |
|
902 | 896 | } |
903 | 897 | } |
904 | 898 |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @access public |
903 | 903 | * |
904 | 904 | * @param string $meta_key Metadata key. Default is empty. |
905 | - * @param mixed $meta_value Metadata value. |
|
905 | + * @param integer $meta_value Metadata value. |
|
906 | 906 | * @param mixed $prev_value Optional. Previous value to check before removing. Default is empty. |
907 | 907 | * |
908 | 908 | * @return bool False on failure, true if success. |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | * @access public |
919 | 919 | * |
920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
@@ -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 | |
@@ -139,32 +139,32 @@ discard block |
||
139 | 139 | * @param bool $_id_or_email |
140 | 140 | * @param bool $by_user_id |
141 | 141 | */ |
142 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
142 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
143 | 143 | |
144 | 144 | $this->db = Give()->donors; |
145 | 145 | |
146 | 146 | if ( |
147 | 147 | false === $_id_or_email |
148 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
148 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
149 | 149 | ) { |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
153 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
154 | 154 | |
155 | - if ( is_numeric( $_id_or_email ) ) { |
|
155 | + if (is_numeric($_id_or_email)) { |
|
156 | 156 | $field = $by_user_id ? 'user_id' : 'id'; |
157 | 157 | } else { |
158 | 158 | $field = 'email'; |
159 | 159 | } |
160 | 160 | |
161 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
161 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
162 | 162 | |
163 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
163 | + if (empty($donor) || ! is_object($donor)) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
167 | - $this->setup_donor( $donor ); |
|
167 | + $this->setup_donor($donor); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return bool If the setup was successful or not. |
182 | 182 | */ |
183 | - private function setup_donor( $donor ) { |
|
183 | + private function setup_donor($donor) { |
|
184 | 184 | |
185 | - if ( ! is_object( $donor ) ) { |
|
185 | + if ( ! is_object($donor)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
189 | - foreach ( $donor as $key => $value ) { |
|
189 | + foreach ($donor as $key => $value) { |
|
190 | 190 | |
191 | - switch ( $key ) { |
|
191 | + switch ($key) { |
|
192 | 192 | |
193 | 193 | case 'notes': |
194 | 194 | $this->$key = $this->get_notes(); |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | // Get donor's all email including primary email. |
205 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
206 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
205 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
206 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
207 | 207 | |
208 | 208 | // Donor ID and email are the only things that are necessary, make sure they exist. |
209 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
209 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
210 | 210 | return true; |
211 | 211 | } |
212 | 212 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return mixed|\WP_Error |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '', |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Donor attributes. |
278 | 278 | */ |
279 | - do_action( 'give_donor_pre_create', $args ); |
|
279 | + do_action('give_donor_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the donor, reset the class vars with the new data |
287 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
287 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the donor data with the values from DB |
290 | - $this->setup_donor( $donor ); |
|
290 | + $this->setup_donor($donor); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
301 | 301 | * @param array $args Customer attributes. |
302 | 302 | */ |
303 | - do_action( 'give_donor_post_create', $created, $args ); |
|
303 | + do_action('give_donor_post_create', $created, $args); |
|
304 | 304 | |
305 | 305 | return $created; |
306 | 306 | |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return bool If the update was successful or not. |
318 | 318 | */ |
319 | - public function update( $data = array() ) { |
|
319 | + public function update($data = array()) { |
|
320 | 320 | |
321 | - if ( empty( $data ) ) { |
|
321 | + if (empty($data)) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | - $data = $this->sanitize_columns( $data ); |
|
325 | + $data = $this->sanitize_columns($data); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Fires before updating donors. |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * @param int $donor_id Donor id. |
333 | 333 | * @param array $data Donor attributes. |
334 | 334 | */ |
335 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
335 | + do_action('give_donor_pre_update', $this->id, $data); |
|
336 | 336 | |
337 | 337 | $updated = false; |
338 | 338 | |
339 | - if ( $this->db->update( $this->id, $data ) ) { |
|
339 | + if ($this->db->update($this->id, $data)) { |
|
340 | 340 | |
341 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
342 | - $this->setup_donor( $donor ); |
|
341 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
342 | + $this->setup_donor($donor); |
|
343 | 343 | |
344 | 344 | $updated = true; |
345 | 345 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param int $donor_id Donor id. |
354 | 354 | * @param array $data Donor attributes. |
355 | 355 | */ |
356 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
356 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
357 | 357 | |
358 | 358 | return $updated; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return bool If the attachment was successfully. |
373 | 373 | */ |
374 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
374 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - if ( empty( $this->payment_ids ) ) { |
|
380 | + if (empty($this->payment_ids)) { |
|
381 | 381 | |
382 | 382 | $new_payment_ids = $payment_id; |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
386 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
387 | 387 | |
388 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
388 | + if (in_array($payment_id, $payment_ids)) { |
|
389 | 389 | $update_stats = false; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $payment_ids[] = $payment_id; |
393 | 393 | |
394 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
394 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | * @param int $payment_id Payment id. |
404 | 404 | * @param int $donor_id Customer id. |
405 | 405 | */ |
406 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
406 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
407 | 407 | |
408 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
408 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
409 | 409 | |
410 | - if ( $payment_added ) { |
|
410 | + if ($payment_added) { |
|
411 | 411 | |
412 | 412 | $this->payment_ids = $new_payment_ids; |
413 | 413 | |
414 | 414 | // We added this payment successfully, increment the stats |
415 | - if ( $update_stats ) { |
|
416 | - $payment_amount = give_donation_amount( $payment_id ); |
|
415 | + if ($update_stats) { |
|
416 | + $payment_amount = give_donation_amount($payment_id); |
|
417 | 417 | |
418 | - if ( ! empty( $payment_amount ) ) { |
|
419 | - $this->increase_value( $payment_amount ); |
|
418 | + if ( ! empty($payment_amount)) { |
|
419 | + $this->increase_value($payment_amount); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $this->increase_purchase_count(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param int $payment_id Payment id. |
433 | 433 | * @param int $donor_id Donor id. |
434 | 434 | */ |
435 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
435 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
436 | 436 | |
437 | 437 | return $payment_added; |
438 | 438 | } |
@@ -450,33 +450,33 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return boolean If the removal was successful. |
452 | 452 | */ |
453 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
453 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
454 | 454 | |
455 | - if ( empty( $payment_id ) ) { |
|
455 | + if (empty($payment_id)) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | 458 | |
459 | - $payment = new Give_Payment( $payment_id ); |
|
459 | + $payment = new Give_Payment($payment_id); |
|
460 | 460 | |
461 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
461 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
462 | 462 | $update_stats = false; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_payment_ids = ''; |
466 | 466 | |
467 | - if ( ! empty( $this->payment_ids ) ) { |
|
467 | + if ( ! empty($this->payment_ids)) { |
|
468 | 468 | |
469 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
469 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
470 | 470 | |
471 | - $pos = array_search( $payment_id, $payment_ids ); |
|
472 | - if ( false === $pos ) { |
|
471 | + $pos = array_search($payment_id, $payment_ids); |
|
472 | + if (false === $pos) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - unset( $payment_ids[ $pos ] ); |
|
477 | - $payment_ids = array_filter( $payment_ids ); |
|
476 | + unset($payment_ids[$pos]); |
|
477 | + $payment_ids = array_filter($payment_ids); |
|
478 | 478 | |
479 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
479 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
480 | 480 | |
481 | 481 | } |
482 | 482 | |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | * @param int $payment_id Payment id. |
489 | 489 | * @param int $donor_id Customer id. |
490 | 490 | */ |
491 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
491 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
492 | 492 | |
493 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
493 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
494 | 494 | |
495 | - if ( $payment_removed ) { |
|
495 | + if ($payment_removed) { |
|
496 | 496 | |
497 | 497 | $this->payment_ids = $new_payment_ids; |
498 | 498 | |
499 | - if ( $update_stats ) { |
|
499 | + if ($update_stats) { |
|
500 | 500 | // We removed this payment successfully, decrement the stats |
501 | - $payment_amount = give_donation_amount( $payment_id ); |
|
501 | + $payment_amount = give_donation_amount($payment_id); |
|
502 | 502 | |
503 | - if ( ! empty( $payment_amount ) ) { |
|
504 | - $this->decrease_value( $payment_amount ); |
|
503 | + if ( ! empty($payment_amount)) { |
|
504 | + $this->decrease_value($payment_amount); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $this->decrease_donation_count(); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param int $payment_id Payment id. |
518 | 518 | * @param int $donor_id Donor id. |
519 | 519 | */ |
520 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
520 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
521 | 521 | |
522 | 522 | return $payment_removed; |
523 | 523 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return int The donation count. |
535 | 535 | */ |
536 | - public function increase_purchase_count( $count = 1 ) { |
|
536 | + public function increase_purchase_count($count = 1) { |
|
537 | 537 | |
538 | 538 | // Make sure it's numeric and not negative. |
539 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
539 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | * @param int $count The number to increase by. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
553 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
554 | 554 | |
555 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
555 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
556 | 556 | $this->purchase_count = $new_total; |
557 | 557 | } |
558 | 558 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @param int $count The number increased by. |
566 | 566 | * @param int $donor_id Donor id. |
567 | 567 | */ |
568 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
568 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
569 | 569 | |
570 | 570 | return $this->purchase_count; |
571 | 571 | } |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return mixed If successful, the new count, otherwise false. |
582 | 582 | */ |
583 | - public function decrease_donation_count( $count = 1 ) { |
|
583 | + public function decrease_donation_count($count = 1) { |
|
584 | 584 | |
585 | 585 | // Make sure it's numeric and not negative |
586 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
586 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $new_total = (int) $this->purchase_count - (int) $count; |
591 | 591 | |
592 | - if ( $new_total < 0 ) { |
|
592 | + if ($new_total < 0) { |
|
593 | 593 | $new_total = 0; |
594 | 594 | } |
595 | 595 | |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | * @param int $count The number to decrease by. |
602 | 602 | * @param int $donor_id Customer id. |
603 | 603 | */ |
604 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
604 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
605 | 605 | |
606 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
606 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
607 | 607 | $this->purchase_count = $new_total; |
608 | 608 | } |
609 | 609 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param int $count The number decreased by. |
617 | 617 | * @param int $donor_id Donor id. |
618 | 618 | */ |
619 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
619 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
620 | 620 | |
621 | 621 | return $this->purchase_count; |
622 | 622 | } |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return mixed If successful, the new value, otherwise false. |
633 | 633 | */ |
634 | - public function increase_value( $value = 0.00 ) { |
|
634 | + public function increase_value($value = 0.00) { |
|
635 | 635 | |
636 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
636 | + $new_value = floatval($this->purchase_value) + $value; |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Fires before increasing donor lifetime value. |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param float $value The value to increase by. |
644 | 644 | * @param int $donor_id Customer id. |
645 | 645 | */ |
646 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
646 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
647 | 647 | |
648 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
648 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
649 | 649 | $this->purchase_value = $new_value; |
650 | 650 | } |
651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @param float $value The value increased by. |
659 | 659 | * @param int $donor_id Donor id. |
660 | 660 | */ |
661 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
661 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
662 | 662 | |
663 | 663 | return $this->purchase_value; |
664 | 664 | } |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return mixed If successful, the new value, otherwise false. |
675 | 675 | */ |
676 | - public function decrease_value( $value = 0.00 ) { |
|
676 | + public function decrease_value($value = 0.00) { |
|
677 | 677 | |
678 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
678 | + $new_value = floatval($this->purchase_value) - $value; |
|
679 | 679 | |
680 | - if ( $new_value < 0 ) { |
|
680 | + if ($new_value < 0) { |
|
681 | 681 | $new_value = 0.00; |
682 | 682 | } |
683 | 683 | |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param float $value The value to decrease by. |
690 | 690 | * @param int $donor_id Donor id. |
691 | 691 | */ |
692 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
692 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
693 | 693 | |
694 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
694 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
695 | 695 | $this->purchase_value = $new_value; |
696 | 696 | } |
697 | 697 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param float $value The value decreased by. |
705 | 705 | * @param int $donor_id Donor id. |
706 | 706 | */ |
707 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
707 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
708 | 708 | |
709 | 709 | return $this->purchase_value; |
710 | 710 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return mixed If successful, the new donation stat value, otherwise false. |
725 | 725 | */ |
726 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
726 | + public function update_donation_value($curr_amount, $new_amount) { |
|
727 | 727 | /** |
728 | 728 | * Payment total difference value can be: |
729 | 729 | * zero (in case amount not change) |
@@ -733,15 +733,15 @@ discard block |
||
733 | 733 | $payment_total_diff = $new_amount - $curr_amount; |
734 | 734 | |
735 | 735 | // We do not need to update donation stat if donation did not change. |
736 | - if ( ! $payment_total_diff ) { |
|
736 | + if ( ! $payment_total_diff) { |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
740 | - if ( $payment_total_diff > 0 ) { |
|
741 | - $this->increase_value( $payment_total_diff ); |
|
740 | + if ($payment_total_diff > 0) { |
|
741 | + $this->increase_value($payment_total_diff); |
|
742 | 742 | } else { |
743 | 743 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
744 | - $this->decrease_value( - $payment_total_diff ); |
|
744 | + $this->decrease_value( -$payment_total_diff ); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | return $this->purchase_value; |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return array The notes requested. |
760 | 760 | */ |
761 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
761 | + public function get_notes($length = 20, $paged = 1) { |
|
762 | 762 | |
763 | - $length = is_numeric( $length ) ? $length : 20; |
|
764 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
763 | + $length = is_numeric($length) ? $length : 20; |
|
764 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
765 | 765 | |
766 | 766 | $all_notes = $this->get_raw_notes(); |
767 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
767 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
768 | 768 | |
769 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
769 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
770 | 770 | |
771 | 771 | return $desired_notes; |
772 | 772 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | public function get_notes_count() { |
784 | 784 | |
785 | 785 | $all_notes = $this->get_raw_notes(); |
786 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
786 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
787 | 787 | |
788 | - return count( $notes_array ); |
|
788 | + return count($notes_array); |
|
789 | 789 | |
790 | 790 | } |
791 | 791 | |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | * |
799 | 799 | * @return string|float |
800 | 800 | */ |
801 | - public function get_total_donation_amount( $args = array() ) { |
|
801 | + public function get_total_donation_amount($args = array()) { |
|
802 | 802 | |
803 | 803 | /** |
804 | 804 | * Filter total donation amount. |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @param integer $donor_id Donor ID. |
810 | 810 | * @param array $args Pass additional data. |
811 | 811 | */ |
812 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
812 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
@@ -822,22 +822,22 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @return string|boolean The new note if added successfully, false otherwise. |
824 | 824 | */ |
825 | - public function add_note( $note = '' ) { |
|
825 | + public function add_note($note = '') { |
|
826 | 826 | |
827 | - $note = trim( $note ); |
|
828 | - if ( empty( $note ) ) { |
|
827 | + $note = trim($note); |
|
828 | + if (empty($note)) { |
|
829 | 829 | return false; |
830 | 830 | } |
831 | 831 | |
832 | 832 | $notes = $this->get_raw_notes(); |
833 | 833 | |
834 | - if ( empty( $notes ) ) { |
|
834 | + if (empty($notes)) { |
|
835 | 835 | $notes = ''; |
836 | 836 | } |
837 | 837 | |
838 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
839 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
840 | - $notes .= "\n\n" . $new_note; |
|
838 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
839 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
840 | + $notes .= "\n\n".$new_note; |
|
841 | 841 | |
842 | 842 | /** |
843 | 843 | * Fires before donor note is added. |
@@ -847,11 +847,11 @@ discard block |
||
847 | 847 | * @param string $new_note New note to add. |
848 | 848 | * @param int $donor_id Donor id. |
849 | 849 | */ |
850 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
850 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
851 | 851 | |
852 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
852 | + $updated = $this->update(array('notes' => $notes)); |
|
853 | 853 | |
854 | - if ( $updated ) { |
|
854 | + if ($updated) { |
|
855 | 855 | $this->notes = $this->get_notes(); |
856 | 856 | } |
857 | 857 | |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @param string $new_note New note added. |
865 | 865 | * @param int $donor_id Donor id. |
866 | 866 | */ |
867 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
867 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
868 | 868 | |
869 | 869 | // Return the formatted note, so we can test, as well as update any displays |
870 | 870 | return $new_note; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | */ |
882 | 882 | private function get_raw_notes() { |
883 | 883 | |
884 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
884 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
885 | 885 | |
886 | 886 | return $all_notes; |
887 | 887 | |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | * |
899 | 899 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
900 | 900 | */ |
901 | - public function get_meta( $meta_key = '', $single = true ) { |
|
902 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
901 | + public function get_meta($meta_key = '', $single = true) { |
|
902 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -914,8 +914,8 @@ discard block |
||
914 | 914 | * |
915 | 915 | * @return bool False for failure. True for success. |
916 | 916 | */ |
917 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
918 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
917 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
918 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | * |
931 | 931 | * @return bool False on failure, true if success. |
932 | 932 | */ |
933 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
934 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
933 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
934 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | /** |
@@ -945,8 +945,8 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return bool False for failure. True for success. |
947 | 947 | */ |
948 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
949 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
948 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
949 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | /** |
@@ -959,51 +959,51 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @return array The sanitized data, based off column defaults. |
961 | 961 | */ |
962 | - private function sanitize_columns( $data ) { |
|
962 | + private function sanitize_columns($data) { |
|
963 | 963 | |
964 | 964 | $columns = $this->db->get_columns(); |
965 | 965 | $default_values = $this->db->get_column_defaults(); |
966 | 966 | |
967 | - foreach ( $columns as $key => $type ) { |
|
967 | + foreach ($columns as $key => $type) { |
|
968 | 968 | |
969 | 969 | // Only sanitize data that we were provided |
970 | - if ( ! array_key_exists( $key, $data ) ) { |
|
970 | + if ( ! array_key_exists($key, $data)) { |
|
971 | 971 | continue; |
972 | 972 | } |
973 | 973 | |
974 | - switch ( $type ) { |
|
974 | + switch ($type) { |
|
975 | 975 | |
976 | 976 | case '%s': |
977 | - if ( 'email' == $key ) { |
|
978 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
979 | - } elseif ( 'notes' == $key ) { |
|
980 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
977 | + if ('email' == $key) { |
|
978 | + $data[$key] = sanitize_email($data[$key]); |
|
979 | + } elseif ('notes' == $key) { |
|
980 | + $data[$key] = strip_tags($data[$key]); |
|
981 | 981 | } else { |
982 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
982 | + $data[$key] = sanitize_text_field($data[$key]); |
|
983 | 983 | } |
984 | 984 | break; |
985 | 985 | |
986 | 986 | case '%d': |
987 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
988 | - $data[ $key ] = $default_values[ $key ]; |
|
987 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
988 | + $data[$key] = $default_values[$key]; |
|
989 | 989 | } else { |
990 | - $data[ $key ] = absint( $data[ $key ] ); |
|
990 | + $data[$key] = absint($data[$key]); |
|
991 | 991 | } |
992 | 992 | break; |
993 | 993 | |
994 | 994 | case '%f': |
995 | 995 | // Convert what was given to a float |
996 | - $value = floatval( $data[ $key ] ); |
|
996 | + $value = floatval($data[$key]); |
|
997 | 997 | |
998 | - if ( ! is_float( $value ) ) { |
|
999 | - $data[ $key ] = $default_values[ $key ]; |
|
998 | + if ( ! is_float($value)) { |
|
999 | + $data[$key] = $default_values[$key]; |
|
1000 | 1000 | } else { |
1001 | - $data[ $key ] = $value; |
|
1001 | + $data[$key] = $value; |
|
1002 | 1002 | } |
1003 | 1003 | break; |
1004 | 1004 | |
1005 | 1005 | default: |
1006 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1006 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1007 | 1007 | break; |
1008 | 1008 | |
1009 | 1009 | } |
@@ -1023,33 +1023,33 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @return bool If the email was added successfully |
1025 | 1025 | */ |
1026 | - public function add_email( $email = '', $primary = false ) { |
|
1027 | - if ( ! is_email( $email ) ) { |
|
1026 | + public function add_email($email = '', $primary = false) { |
|
1027 | + if ( ! is_email($email)) { |
|
1028 | 1028 | return false; |
1029 | 1029 | } |
1030 | - $existing = new Give_Donor( $email ); |
|
1030 | + $existing = new Give_Donor($email); |
|
1031 | 1031 | |
1032 | - if ( $existing->id > 0 ) { |
|
1032 | + if ($existing->id > 0) { |
|
1033 | 1033 | // Email address already belongs to another donor |
1034 | 1034 | return false; |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - if ( email_exists( $email ) ) { |
|
1038 | - $user = get_user_by( 'email', $email ); |
|
1039 | - if ( $user->ID != $this->user_id ) { |
|
1037 | + if (email_exists($email)) { |
|
1038 | + $user = get_user_by('email', $email); |
|
1039 | + if ($user->ID != $this->user_id) { |
|
1040 | 1040 | return false; |
1041 | 1041 | } |
1042 | 1042 | } |
1043 | 1043 | |
1044 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1044 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1045 | 1045 | |
1046 | 1046 | // Add is used to ensure duplicate emails are not added |
1047 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1047 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1048 | 1048 | |
1049 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1049 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1050 | 1050 | |
1051 | - if ( $ret && true === $primary ) { |
|
1052 | - $this->set_primary_email( $email ); |
|
1051 | + if ($ret && true === $primary) { |
|
1052 | + $this->set_primary_email($email); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | return $ret; |
@@ -1065,16 +1065,16 @@ discard block |
||
1065 | 1065 | * |
1066 | 1066 | * @return bool If the email was removed successfully. |
1067 | 1067 | */ |
1068 | - public function remove_email( $email = '' ) { |
|
1069 | - if ( ! is_email( $email ) ) { |
|
1068 | + public function remove_email($email = '') { |
|
1069 | + if ( ! is_email($email)) { |
|
1070 | 1070 | return false; |
1071 | 1071 | } |
1072 | 1072 | |
1073 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1073 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1074 | 1074 | |
1075 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1075 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1076 | 1076 | |
1077 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1077 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1078 | 1078 | |
1079 | 1079 | return $ret; |
1080 | 1080 | } |
@@ -1091,16 +1091,16 @@ discard block |
||
1091 | 1091 | * |
1092 | 1092 | * @return bool If the email was set as primary successfully. |
1093 | 1093 | */ |
1094 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1095 | - if ( ! is_email( $new_primary_email ) ) { |
|
1094 | + public function set_primary_email($new_primary_email = '') { |
|
1095 | + if ( ! is_email($new_primary_email)) { |
|
1096 | 1096 | return false; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1099 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1100 | 1100 | |
1101 | - $existing = new Give_Donor( $new_primary_email ); |
|
1101 | + $existing = new Give_Donor($new_primary_email); |
|
1102 | 1102 | |
1103 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1103 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1104 | 1104 | // This email belongs to another donor. |
1105 | 1105 | return false; |
1106 | 1106 | } |
@@ -1108,21 +1108,21 @@ discard block |
||
1108 | 1108 | $old_email = $this->email; |
1109 | 1109 | |
1110 | 1110 | // Update donor record with new email. |
1111 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1111 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1112 | 1112 | |
1113 | 1113 | // Remove new primary from list of additional emails. |
1114 | - $remove = $this->remove_email( $new_primary_email ); |
|
1114 | + $remove = $this->remove_email($new_primary_email); |
|
1115 | 1115 | |
1116 | 1116 | // Add old email to additional emails list. |
1117 | - $add = $this->add_email( $old_email ); |
|
1117 | + $add = $this->add_email($old_email); |
|
1118 | 1118 | |
1119 | 1119 | $ret = $update && $remove && $add; |
1120 | 1120 | |
1121 | - if ( $ret ) { |
|
1121 | + if ($ret) { |
|
1122 | 1122 | $this->email = $new_primary_email; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1125 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1126 | 1126 | |
1127 | 1127 | return $ret; |
1128 | 1128 | } |
@@ -185,10 +185,13 @@ discard block |
||
185 | 185 | } |
186 | 186 | ?> |
187 | 187 | </select> |
188 | - <?php else : ?> |
|
188 | + <?php else { |
|
189 | + : ?> |
|
189 | 190 | <input type="text" size="6" name="give_address_state" id="give_address_state" |
190 | 191 | class="give_address_state give-input" |
191 | - placeholder="<?php echo $label; ?>" value="<?php echo $selected_state; ?>"/> |
|
192 | + placeholder="<?php echo $label; |
|
193 | +} |
|
194 | +?>" value="<?php echo $selected_state; ?>"/> |
|
192 | 195 | <?php endif; |
193 | 196 | ?> |
194 | 197 | </p> |
@@ -289,7 +292,9 @@ discard block |
||
289 | 292 | ?> |
290 | 293 | |
291 | 294 | <?php |
292 | -else: |
|
295 | +else { |
|
296 | + : |
|
293 | 297 | _e( 'You need to login to edit your profile.', 'give' ); |
298 | +} |
|
294 | 299 | echo give_login_form(); |
295 | 300 | endif; |
@@ -7,22 +7,22 @@ discard block |
||
7 | 7 | * @copyright Copyright (c) 2016, WordImpress |
8 | 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
9 | 9 | */ |
10 | -$current_user = wp_get_current_user(); |
|
10 | +$current_user = wp_get_current_user(); |
|
11 | 11 | |
12 | -if ( is_user_logged_in() ): |
|
12 | +if (is_user_logged_in()): |
|
13 | 13 | $user_id = get_current_user_id(); |
14 | - $first_name = get_user_meta( $user_id, 'first_name', true ); |
|
15 | - $last_name = get_user_meta( $user_id, 'last_name', true ); |
|
14 | + $first_name = get_user_meta($user_id, 'first_name', true); |
|
15 | + $last_name = get_user_meta($user_id, 'last_name', true); |
|
16 | 16 | $display_name = $current_user->display_name; |
17 | - $address = give_get_donor_address( $user_id ); |
|
17 | + $address = give_get_donor_address($user_id); |
|
18 | 18 | |
19 | - if ( isset( $_GET['updated'] ) && $_GET['updated'] == true && ! give_get_errors() ): ?> |
|
19 | + if (isset($_GET['updated']) && $_GET['updated'] == true && ! give_get_errors()): ?> |
|
20 | 20 | <p class="give_success"> |
21 | - <strong><?php esc_html_e( 'Success:', 'give' ); ?></strong> <?php esc_html_e( 'Your profile has been updated.', 'give' ); ?> |
|
21 | + <strong><?php esc_html_e('Success:', 'give'); ?></strong> <?php esc_html_e('Your profile has been updated.', 'give'); ?> |
|
22 | 22 | </p> |
23 | 23 | <?php endif; ?> |
24 | 24 | |
25 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
25 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
26 | 26 | |
27 | 27 | <?php |
28 | 28 | /** |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @since 1.0 |
34 | 34 | */ |
35 | - do_action( 'give_profile_editor_before' ); |
|
35 | + do_action('give_profile_editor_before'); |
|
36 | 36 | ?> |
37 | 37 | |
38 | 38 | <form id="give_profile_editor_form" class="give-form" action="<?php echo give_get_current_page_url(); ?>" method="post"> |
39 | 39 | |
40 | 40 | <fieldset> |
41 | - <legend id="give_profile_name_label"><?php _e( 'Profile', 'give' ); ?></legend> |
|
41 | + <legend id="give_profile_name_label"><?php _e('Profile', 'give'); ?></legend> |
|
42 | 42 | |
43 | - <h3 id="give_personal_information_label" class="give-section-break"><?php _e( 'Change your Name', 'give' ); ?></h3> |
|
43 | + <h3 id="give_personal_information_label" class="give-section-break"><?php _e('Change your Name', 'give'); ?></h3> |
|
44 | 44 | |
45 | 45 | <p id="give_profile_first_name_wrap" class="form-row form-row-first form-row-responsive"> |
46 | 46 | <label for="give_first_name"> |
47 | - <?php _e( 'First Name', 'give' ); ?> |
|
47 | + <?php _e('First Name', 'give'); ?> |
|
48 | 48 | <span class="give-required-indicator ">*</span> |
49 | 49 | </label> |
50 | - <input name="give_first_name" id="give_first_name" class="text give-input" type="text" value="<?php echo esc_attr( $first_name ); ?>"/> |
|
50 | + <input name="give_first_name" id="give_first_name" class="text give-input" type="text" value="<?php echo esc_attr($first_name); ?>"/> |
|
51 | 51 | </p> |
52 | 52 | |
53 | 53 | <p id="give_profile_last_name_wrap" class="form-row form-row-last form-row-responsive"> |
54 | - <label for="give_last_name"><?php _e( 'Last Name', 'give' ); ?></label> |
|
55 | - <input name="give_last_name" id="give_last_name" class="text give-input" type="text" value="<?php echo esc_attr( $last_name ); ?>"/> |
|
54 | + <label for="give_last_name"><?php _e('Last Name', 'give'); ?></label> |
|
55 | + <input name="give_last_name" id="give_last_name" class="text give-input" type="text" value="<?php echo esc_attr($last_name); ?>"/> |
|
56 | 56 | </p> |
57 | 57 | |
58 | 58 | <p id="give_profile_display_name_wrap" class="form-row form-row-first form-row-responsive"> |
59 | - <label for="give_display_name"><?php _e( 'Display Name', 'give' ); ?></label> |
|
59 | + <label for="give_display_name"><?php _e('Display Name', 'give'); ?></label> |
|
60 | 60 | <select name="give_display_name" id="give_display_name" class="select give-select"> |
61 | - <?php if ( ! empty( $current_user->first_name ) ): ?> |
|
62 | - <option <?php selected( $display_name, $current_user->first_name ); ?> value="<?php echo esc_attr( $current_user->first_name ); ?>"><?php echo esc_html( $current_user->first_name ); ?></option> |
|
61 | + <?php if ( ! empty($current_user->first_name)): ?> |
|
62 | + <option <?php selected($display_name, $current_user->first_name); ?> value="<?php echo esc_attr($current_user->first_name); ?>"><?php echo esc_html($current_user->first_name); ?></option> |
|
63 | 63 | <?php endif; ?> |
64 | - <option <?php selected( $display_name, $current_user->user_nicename ); ?> value="<?php echo esc_attr( $current_user->user_nicename ); ?>"><?php echo esc_html( $current_user->user_nicename ); ?></option> |
|
65 | - <?php if ( ! empty( $current_user->last_name ) ): ?> |
|
66 | - <option <?php selected( $display_name, $current_user->last_name ); ?> value="<?php echo esc_attr( $current_user->last_name ); ?>"><?php echo esc_html( $current_user->last_name ); ?></option> |
|
64 | + <option <?php selected($display_name, $current_user->user_nicename); ?> value="<?php echo esc_attr($current_user->user_nicename); ?>"><?php echo esc_html($current_user->user_nicename); ?></option> |
|
65 | + <?php if ( ! empty($current_user->last_name)): ?> |
|
66 | + <option <?php selected($display_name, $current_user->last_name); ?> value="<?php echo esc_attr($current_user->last_name); ?>"><?php echo esc_html($current_user->last_name); ?></option> |
|
67 | 67 | <?php endif; ?> |
68 | - <?php if ( ! empty( $current_user->first_name ) && ! empty( $current_user->last_name ) ): ?> |
|
69 | - <option <?php selected( $display_name, $current_user->first_name . ' ' . $current_user->last_name ); ?> value="<?php echo esc_attr( $current_user->first_name . ' ' . $current_user->last_name ); ?>"><?php echo esc_html( $current_user->first_name . ' ' . $current_user->last_name ); ?></option> |
|
70 | - <option <?php selected( $display_name, $current_user->last_name . ' ' . $current_user->first_name ); ?> value="<?php echo esc_attr( $current_user->last_name . ' ' . $current_user->first_name ); ?>"><?php echo esc_html( $current_user->last_name . ' ' . $current_user->first_name ); ?></option> |
|
68 | + <?php if ( ! empty($current_user->first_name) && ! empty($current_user->last_name)): ?> |
|
69 | + <option <?php selected($display_name, $current_user->first_name.' '.$current_user->last_name); ?> value="<?php echo esc_attr($current_user->first_name.' '.$current_user->last_name); ?>"><?php echo esc_html($current_user->first_name.' '.$current_user->last_name); ?></option> |
|
70 | + <option <?php selected($display_name, $current_user->last_name.' '.$current_user->first_name); ?> value="<?php echo esc_attr($current_user->last_name.' '.$current_user->first_name); ?>"><?php echo esc_html($current_user->last_name.' '.$current_user->first_name); ?></option> |
|
71 | 71 | <?php endif; ?> |
72 | 72 | </select> |
73 | 73 | <?php |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.0 |
80 | 80 | */ |
81 | - do_action( 'give_profile_editor_name' ); |
|
81 | + do_action('give_profile_editor_name'); |
|
82 | 82 | ?> |
83 | 83 | </p> |
84 | 84 | |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 1.0 |
92 | 92 | */ |
93 | - do_action( 'give_profile_editor_after_name' ); |
|
93 | + do_action('give_profile_editor_after_name'); |
|
94 | 94 | ?> |
95 | 95 | |
96 | 96 | <p class="form-row form-row-last form-row-responsive"> |
97 | 97 | <label for="give_email"> |
98 | - <?php _e( 'Email Address', 'give' ); ?> |
|
98 | + <?php _e('Email Address', 'give'); ?> |
|
99 | 99 | <span class="give-required-indicator ">*</span> |
100 | 100 | </label> |
101 | - <input name="give_email" id="give_email" class="text give-input required" type="email" value="<?php echo esc_attr( $current_user->user_email ); ?>" required aria-required="true"/> |
|
101 | + <input name="give_email" id="give_email" class="text give-input required" type="email" value="<?php echo esc_attr($current_user->user_email); ?>" required aria-required="true"/> |
|
102 | 102 | <?php |
103 | 103 | /** |
104 | 104 | * Fires in the profile editor shortcode, to the email section. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @since 1.0 |
109 | 109 | */ |
110 | - do_action( 'give_profile_editor_email' ); |
|
110 | + do_action('give_profile_editor_email'); |
|
111 | 111 | ?> |
112 | 112 | </p> |
113 | 113 | |
@@ -119,33 +119,33 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @since 1.0 |
121 | 121 | */ |
122 | - do_action( 'give_profile_editor_after_email' ); |
|
122 | + do_action('give_profile_editor_after_email'); |
|
123 | 123 | ?> |
124 | 124 | |
125 | - <h3 id="give_profile_billing_address_label" class="give-section-break"><?php _e( 'Change your Billing Address', 'give' ); ?></h3> |
|
125 | + <h3 id="give_profile_billing_address_label" class="give-section-break"><?php _e('Change your Billing Address', 'give'); ?></h3> |
|
126 | 126 | |
127 | 127 | <div id="give_profile_billing_address_wrap"> |
128 | 128 | <?php |
129 | 129 | // Get selected country from address. |
130 | - $selected_country = ( ! empty( $address['country'] ) ? $address['country'] : give_get_option('base_country') ); |
|
130 | + $selected_country = ( ! empty($address['country']) ? $address['country'] : give_get_option('base_country')); |
|
131 | 131 | |
132 | 132 | $selected_state = ''; |
133 | - if ( $selected_country === give_get_country() ) { |
|
133 | + if ($selected_country === give_get_country()) { |
|
134 | 134 | // Get default selected state by admin. |
135 | 135 | $selected_state = give_get_state(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Get selected state from address. |
139 | - $selected_state = ! empty( $address['state'] ) ? $address['state'] : $selected_state; |
|
139 | + $selected_state = ! empty($address['state']) ? $address['state'] : $selected_state; |
|
140 | 140 | |
141 | - $label = __( 'State', 'give' ); |
|
141 | + $label = __('State', 'give'); |
|
142 | 142 | $states_label = give_get_states_label(); |
143 | 143 | // Check if $country code exists in the array key for states label. |
144 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
145 | - $label = $states_label[ $selected_country ]; |
|
144 | + if (array_key_exists($selected_country, $states_label)) { |
|
145 | + $label = $states_label[$selected_country]; |
|
146 | 146 | } |
147 | 147 | |
148 | - $states = give_get_states( $selected_country ); |
|
148 | + $states = give_get_states($selected_country); |
|
149 | 149 | |
150 | 150 | // Get the country list that do not have any states init. |
151 | 151 | $no_states_country = give_no_states_country_list(); |
@@ -156,55 +156,55 @@ discard block |
||
156 | 156 | |
157 | 157 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
158 | 158 | <label for="give_address_country"> |
159 | - <?php _e( 'Country', 'give' ); ?> |
|
159 | + <?php _e('Country', 'give'); ?> |
|
160 | 160 | <span class="give-required-indicator ">*</span> |
161 | 161 | </label> |
162 | 162 | <select name="give_address_country" id="give_address_country" class="select give-select"> |
163 | - <?php foreach ( give_get_country_list() as $key => $country ) : ?> |
|
164 | - <option value="<?php echo $key; ?>"<?php selected( $selected_country, $key ); ?>><?php echo esc_html( $country ); ?></option> |
|
163 | + <?php foreach (give_get_country_list() as $key => $country) : ?> |
|
164 | + <option value="<?php echo $key; ?>"<?php selected($selected_country, $key); ?>><?php echo esc_html($country); ?></option> |
|
165 | 165 | <?php endforeach; ?> |
166 | 166 | </select> |
167 | 167 | </p> |
168 | 168 | |
169 | 169 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
170 | 170 | <label for="give_address_line1"> |
171 | - <?php _e( 'Address 1', 'give' ); ?> |
|
171 | + <?php _e('Address 1', 'give'); ?> |
|
172 | 172 | <span class="give-required-indicator ">*</span> |
173 | 173 | </label> |
174 | 174 | <input name="give_address_line1" id="give_address_line1" class="text give-input" type="text" |
175 | - value="<?php echo esc_attr( $address['line1'] ); ?>"/> |
|
175 | + value="<?php echo esc_attr($address['line1']); ?>"/> |
|
176 | 176 | </p> |
177 | 177 | |
178 | 178 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
179 | - <label for="give_address_line2"><?php _e( 'Address 2', 'give' ); ?></label> |
|
179 | + <label for="give_address_line2"><?php _e('Address 2', 'give'); ?></label> |
|
180 | 180 | <input name="give_address_line2" id="give_address_line2" class="text give-input" type="text" |
181 | - value="<?php echo esc_attr( $address['line2'] ); ?>"/> |
|
181 | + value="<?php echo esc_attr($address['line2']); ?>"/> |
|
182 | 182 | </p> |
183 | 183 | |
184 | 184 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
185 | 185 | <label for="give_address_city"> |
186 | - <?php _e( 'City', 'give' ); ?> |
|
186 | + <?php _e('City', 'give'); ?> |
|
187 | 187 | <span class="give-required-indicator ">*</span> |
188 | 188 | </label> |
189 | 189 | <input name="give_address_city" id="give_address_city" class="text give-input" type="text" |
190 | - value="<?php echo esc_attr( $address['city'] ); ?>"/> |
|
190 | + value="<?php echo esc_attr($address['city']); ?>"/> |
|
191 | 191 | </p> |
192 | 192 | |
193 | 193 | <p id="give-card-state-wrap" |
194 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?>"> |
|
194 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?>"> |
|
195 | 195 | <label for="give_address_state"> |
196 | - <?php _e( 'State / Province / County', 'give' ); ?> |
|
196 | + <?php _e('State / Province / County', 'give'); ?> |
|
197 | 197 | <span class="give-required-indicator ">*</span> |
198 | 198 | </label> |
199 | 199 | <?php |
200 | - if ( ! empty( $states ) ) : ?> |
|
200 | + if ( ! empty($states)) : ?> |
|
201 | 201 | <select |
202 | 202 | name="give_address_state" |
203 | 203 | id="give_address_state" |
204 | 204 | class="give_address_state" |
205 | 205 | <?php |
206 | - foreach ( $states as $state_code => $state ) { |
|
207 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
206 | + foreach ($states as $state_code => $state) { |
|
207 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
208 | 208 | } |
209 | 209 | ?> |
210 | 210 | </select> |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | ?> |
217 | 217 | </p> |
218 | 218 | |
219 | - <p id="give-card-zip-wrap" class="form-row <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'form-row-wide' : 'form-row-last'; ?> form-row-responsive"> |
|
219 | + <p id="give-card-zip-wrap" class="form-row <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'form-row-wide' : 'form-row-last'; ?> form-row-responsive"> |
|
220 | 220 | <label for="give_address_zip"> |
221 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
221 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
222 | 222 | <span class="give-required-indicator ">*</span> |
223 | 223 | </label> |
224 | 224 | <input name="give_address_zip" id="give_address_zip" class="text give-input" type="text" |
225 | - value="<?php echo esc_attr( $address['zip'] ); ?>"/> |
|
225 | + value="<?php echo esc_attr($address['zip']); ?>"/> |
|
226 | 226 | </p> |
227 | 227 | |
228 | 228 | <?php |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @since 1.0 |
235 | 235 | */ |
236 | - do_action( 'give_profile_editor_address' ); |
|
236 | + do_action('give_profile_editor_address'); |
|
237 | 237 | ?> |
238 | 238 | |
239 | 239 | </div> |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @since 1.0 |
248 | 248 | */ |
249 | - do_action( 'give_profile_editor_after_address' ); |
|
249 | + do_action('give_profile_editor_after_address'); |
|
250 | 250 | ?> |
251 | 251 | |
252 | - <h3 id="give_profile_password_label" class="give-section-break"><?php _e( 'Change your Password', 'give' ); ?></h3> |
|
252 | + <h3 id="give_profile_password_label" class="give-section-break"><?php _e('Change your Password', 'give'); ?></h3> |
|
253 | 253 | |
254 | 254 | <div id="give_profile_password_wrap" class="give-clearfix"> |
255 | 255 | <p id="give_profile_password_wrap_1" class="form-row form-row-first form-row-responsive"> |
256 | - <label for="give_new_user_pass1"><?php _e( 'New Password', 'give' ); ?></label> |
|
256 | + <label for="give_new_user_pass1"><?php _e('New Password', 'give'); ?></label> |
|
257 | 257 | <input name="give_new_user_pass1" id="give_new_user_pass1" class="password give-input" type="password"/> |
258 | 258 | </p> |
259 | 259 | |
260 | 260 | <p id="give_profile_password_wrap_2" class="form-row form-row-last form-row-responsive"> |
261 | - <label for="give_new_user_pass2"><?php _e( 'Re-enter Password', 'give' ); ?></label> |
|
261 | + <label for="give_new_user_pass2"><?php _e('Re-enter Password', 'give'); ?></label> |
|
262 | 262 | <input name="give_new_user_pass2" id="give_new_user_pass2" class="password give-input" type="password"/> |
263 | 263 | <?php |
264 | 264 | /** |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @since 1.0 |
270 | 270 | */ |
271 | - do_action( 'give_profile_editor_password' ); |
|
271 | + do_action('give_profile_editor_password'); |
|
272 | 272 | ?> |
273 | 273 | </p> |
274 | 274 | </div> |
275 | 275 | |
276 | - <p class="give_password_change_notice"><?php _e( 'Please note after changing your password, you must log back in.', 'give' ); ?></p> |
|
276 | + <p class="give_password_change_notice"><?php _e('Please note after changing your password, you must log back in.', 'give'); ?></p> |
|
277 | 277 | |
278 | 278 | <?php |
279 | 279 | /** |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @since 1.0 |
285 | 285 | */ |
286 | - do_action( 'give_profile_editor_after_password' ); |
|
286 | + do_action('give_profile_editor_after_password'); |
|
287 | 287 | ?> |
288 | 288 | |
289 | 289 | <p id="give_profile_submit_wrap"> |
290 | - <input type="hidden" name="give_profile_editor_nonce" value="<?php echo wp_create_nonce( 'give-profile-editor-nonce' ); ?>"/> |
|
290 | + <input type="hidden" name="give_profile_editor_nonce" value="<?php echo wp_create_nonce('give-profile-editor-nonce'); ?>"/> |
|
291 | 291 | <input type="hidden" name="give_action" value="edit_user_profile"/> |
292 | - <input type="hidden" name="give_redirect" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
293 | - <input name="give_profile_editor_submit" id="give_profile_editor_submit" type="submit" class="give_submit" value="<?php _e( 'Save Changes', 'give' ); ?>"/> |
|
292 | + <input type="hidden" name="give_redirect" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
293 | + <input name="give_profile_editor_submit" id="give_profile_editor_submit" type="submit" class="give_submit" value="<?php _e('Save Changes', 'give'); ?>"/> |
|
294 | 294 | </p> |
295 | 295 | |
296 | 296 | </fieldset> |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @since 1.0 |
307 | 307 | */ |
308 | - do_action( 'give_profile_editor_after' ); |
|
308 | + do_action('give_profile_editor_after'); |
|
309 | 309 | ?> |
310 | 310 | |
311 | 311 | <?php |
312 | 312 | else: |
313 | - _e( 'You need to login to edit your profile.', 'give' ); |
|
313 | + _e('You need to login to edit your profile.', 'give'); |
|
314 | 314 | echo give_login_form(); |
315 | 315 | endif; |
@@ -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,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The altered list of views. |
25 | 25 | */ |
26 | -function give_register_default_donor_views( $views ) { |
|
26 | +function give_register_default_donor_views($views) { |
|
27 | 27 | |
28 | 28 | $default_views = array( |
29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'notes' => 'give_donor_notes_view', |
32 | 32 | ); |
33 | 33 | |
34 | - return array_merge( $views, $default_views ); |
|
34 | + return array_merge($views, $default_views); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The altered list of tabs |
48 | 48 | */ |
49 | -function give_register_default_donor_tabs( $tabs ) { |
|
49 | +function give_register_default_donor_tabs($tabs) { |
|
50 | 50 | |
51 | 51 | $default_tabs = array( |
52 | 52 | 'overview' => array( |
53 | 53 | 'dashicon' => 'dashicons-admin-users', |
54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
54 | + 'title' => __('Donor Profile', 'give'), |
|
55 | 55 | ), |
56 | 56 | 'notes' => array( |
57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
58 | + 'title' => __('Donor Notes', 'give'), |
|
59 | 59 | ), |
60 | 60 | ); |
61 | 61 | |
62 | - return array_merge( $tabs, $default_tabs ); |
|
62 | + return array_merge($tabs, $default_tabs); |
|
63 | 63 | } |
64 | 64 | |
65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
75 | 75 | */ |
76 | -function give_register_delete_donor_tab( $tabs ) { |
|
76 | +function give_register_delete_donor_tab($tabs) { |
|
77 | 77 | |
78 | 78 | $tabs['delete'] = array( |
79 | 79 | 'dashicon' => 'dashicons-trash', |
80 | - 'title' => __( 'Delete Donor', 'give' ), |
|
80 | + 'title' => __('Delete Donor', 'give'), |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | return $tabs; |
84 | 84 | } |
85 | 85 | |
86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Connect and Reconnect Donor with User profile. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return array |
98 | 98 | */ |
99 | -function give_connect_user_donor_profile( $donor, $donor_data, $address ) { |
|
99 | +function give_connect_user_donor_profile($donor, $donor_data, $address) { |
|
100 | 100 | |
101 | 101 | $donor_id = $donor->id; |
102 | 102 | $previous_user_id = $donor->user_id; |
@@ -110,40 +110,40 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @since 1.0 |
112 | 112 | */ |
113 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
113 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
114 | 114 | |
115 | 115 | $output = array(); |
116 | 116 | |
117 | - if ( $donor->update( $donor_data ) ) { |
|
117 | + if ($donor->update($donor_data)) { |
|
118 | 118 | |
119 | - if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) { |
|
120 | - update_user_meta( $donor->user_id, '_give_user_address', $address ); |
|
119 | + if ( ! empty($donor->user_id) && $donor->user_id > 0) { |
|
120 | + update_user_meta($donor->user_id, '_give_user_address', $address); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Update some donation meta if we need to. |
124 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
124 | + $payments_array = explode(',', $donor->payment_ids); |
|
125 | 125 | |
126 | - if ( $donor->user_id !== $previous_user_id ) { |
|
127 | - foreach ( $payments_array as $payment_id ) { |
|
128 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id ); |
|
126 | + if ($donor->user_id !== $previous_user_id) { |
|
127 | + foreach ($payments_array as $payment_id) { |
|
128 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Fetch disconnected user id, if exists. |
133 | - $disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true ); |
|
133 | + $disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true); |
|
134 | 134 | |
135 | 135 | // Flag User and Donor Disconnection. |
136 | - delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' ); |
|
136 | + delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected'); |
|
137 | 137 | |
138 | 138 | // Check whether the disconnected user id and the reconnected user id are same or not. |
139 | 139 | // If both are same then delete user id store in donor meta. |
140 | - if( $donor_data['user_id'] === $disconnected_user_id ) { |
|
141 | - delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' ); |
|
142 | - $donor->delete_meta( '_give_disconnected_user_id' ); |
|
140 | + if ($donor_data['user_id'] === $disconnected_user_id) { |
|
141 | + delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id'); |
|
142 | + $donor->delete_meta('_give_disconnected_user_id'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $output['success'] = true; |
146 | - $donor_data = array_merge( $donor_data, $address ); |
|
146 | + $donor_data = array_merge($donor_data, $address); |
|
147 | 147 | $output['customer_info'] = $donor_data; |
148 | 148 | |
149 | 149 | } else { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @since 1.0 |
162 | 162 | */ |
163 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
163 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | return $output; |
@@ -10,17 +10,17 @@ |
||
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 | ?> |
17 | 17 | <div class="wrap" id="poststuff"> |
18 | 18 | <div id="give-updates"> |
19 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates Complete', 'give' ); ?></h1> |
|
19 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates Complete', 'give'); ?></h1> |
|
20 | 20 | <hr class="wp-header-end"> |
21 | 21 | |
22 | 22 | <div class="give-update-panel-content"> |
23 | - <p><?php esc_html_e( 'Congratulations! You are running the latest versions of Give and it\'s add-ons.', 'give' ); ?></p> |
|
23 | + <p><?php esc_html_e('Congratulations! You are running the latest versions of Give and it\'s add-ons.', 'give'); ?></p> |
|
24 | 24 | </div> |
25 | 25 | |
26 | 26 | </div> |
@@ -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 | |
@@ -18,33 +18,33 @@ discard block |
||
18 | 18 | ?> |
19 | 19 | <div class="wrap" id="poststuff"> |
20 | 20 | <div id="give-updates"> |
21 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1> |
|
21 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1> |
|
22 | 22 | <hr class="wp-header-end"> |
23 | 23 | |
24 | 24 | <div class="give-update-panel-content"> |
25 | - <p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p> |
|
25 | + <p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p> |
|
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <?php $update_counter = 1; ?> |
29 | 29 | |
30 | 30 | <?php $db_updates = $give_updates->get_db_update_count(); ?> |
31 | - <?php if ( ! empty( $db_updates ) ) : ?> |
|
32 | - <?php $db_update_url = add_query_arg( array( |
|
31 | + <?php if ( ! empty($db_updates)) : ?> |
|
32 | + <?php $db_update_url = add_query_arg(array( |
|
33 | 33 | 'type' => 'database', |
34 | - ) ); ?> |
|
34 | + )); ?> |
|
35 | 35 | <div id="give-db-updates"> |
36 | 36 | <div class="postbox-container"> |
37 | 37 | <div class="postbox"> |
38 | - <h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2> |
|
38 | + <h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2> |
|
39 | 39 | <div class="inside"> |
40 | 40 | <div class="panel-content"> |
41 | - <p class="give-update-button"><?php echo sprintf( __( 'Give needs to update the database. <a href="%s">Update now</a>', 'give' ), $db_update_url ); ?></p> |
|
41 | + <p class="give-update-button"><?php echo sprintf(__('Give needs to update the database. <a href="%s">Update now</a>', 'give'), $db_update_url); ?></p> |
|
42 | 42 | </div> |
43 | 43 | <div class="progress-container give-hidden"> |
44 | 44 | <p class="update-message" |
45 | 45 | data-update-count="<?php echo $db_updates; ?>" |
46 | 46 | data-resume-update="<?php echo $give_updates->resume_updates(); ?>"> |
47 | - <strong><?php echo sprintf( __( 'Update 1 of %s', 'give' ), $db_updates ); ?></strong> |
|
47 | + <strong><?php echo sprintf(__('Update 1 of %s', 'give'), $db_updates); ?></strong> |
|
48 | 48 | </p> |
49 | 49 | <div class="progress-content"></div> |
50 | 50 | </div> |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | <?php endif; ?> |
62 | 62 | |
63 | 63 | <?php $plugin_updates = $give_updates->get_plugin_update_count(); ?> |
64 | - <?php if ( ! empty( $plugin_updates ) ) : ?> |
|
65 | - <?php $plugin_update_url = add_query_arg( array( |
|
64 | + <?php if ( ! empty($plugin_updates)) : ?> |
|
65 | + <?php $plugin_update_url = add_query_arg(array( |
|
66 | 66 | 's' => 'Give', |
67 | - ), admin_url( '/plugins.php' ) ); ?> |
|
67 | + ), admin_url('/plugins.php')); ?> |
|
68 | 68 | <div id="give-plugin-updates"> |
69 | 69 | <div class="postbox-container"> |
70 | 70 | <div class="postbox"> |
71 | - <h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2> |
|
71 | + <h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2> |
|
72 | 72 | <div class="inside"> |
73 | 73 | <div class="panel-content"> |
74 | - <p><?php echo sprintf( __( 'There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give' ), _n( 'is', 'are', $plugin_updates, 'give' ), $plugin_updates, _n( 'add-on', 'add-ons', $plugin_updates, 'give' ), _n( 'needs', 'need', $plugin_updates, 'give' ), $plugin_update_url ); ?></p> |
|
74 | + <p><?php echo sprintf(__('There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give'), _n('is', 'are', $plugin_updates, 'give'), $plugin_updates, _n('add-on', 'add-ons', $plugin_updates, 'give'), _n('needs', 'need', $plugin_updates, 'give'), $plugin_update_url); ?></p> |
|
75 | 75 | <?php include_once 'plugins-update-section.php'; ?> |
76 | 76 | </div> |
77 | 77 | </div> |
@@ -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,12 +25,12 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_payment_history_page() { |
27 | 27 | |
28 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
28 | + $give_payment = get_post_type_object('give_payment'); |
|
29 | 29 | |
30 | - if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) { |
|
31 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php'; |
|
30 | + if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) { |
|
31 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php'; |
|
32 | 32 | } else { |
33 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php'; |
|
33 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php'; |
|
34 | 34 | $payments_table = new Give_Payment_History_Table(); |
35 | 35 | $payments_table->prepare_items(); |
36 | 36 | ?> |
@@ -44,18 +44,18 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @since 1.7 |
46 | 46 | */ |
47 | - do_action( 'give_payments_page_top' ); |
|
47 | + do_action('give_payments_page_top'); |
|
48 | 48 | ?> |
49 | 49 | <hr class="wp-header-end"> |
50 | 50 | |
51 | - <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
51 | + <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
52 | 52 | <input type="hidden" name="post_type" value="give_forms" /> |
53 | 53 | <input type="hidden" name="page" value="give-payment-history" /> |
54 | 54 | <?php $payments_table->views() ?> |
55 | 55 | <?php $payments_table->advanced_filters(); ?> |
56 | 56 | </form> |
57 | 57 | |
58 | - <form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
58 | + <form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
59 | 59 | <input type="hidden" name="post_type" value="give_forms" /> |
60 | 60 | <input type="hidden" name="page" value="give-payment-history" /> |
61 | 61 | <?php $payments_table->display() ?> |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.7 |
69 | 69 | */ |
70 | - do_action( 'give_payments_page_bottom' ); |
|
70 | + do_action('give_payments_page_bottom'); |
|
71 | 71 | ?> |
72 | 72 | |
73 | 73 | </div> |
@@ -84,29 +84,29 @@ discard block |
||
84 | 84 | * @param $title |
85 | 85 | * @return string |
86 | 86 | */ |
87 | -function give_view_order_details_title( $admin_title, $title ) { |
|
87 | +function give_view_order_details_title($admin_title, $title) { |
|
88 | 88 | |
89 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) { |
|
89 | + if ('give_forms_page_give-payment-history' != get_current_screen()->base) { |
|
90 | 90 | return $admin_title; |
91 | 91 | } |
92 | 92 | |
93 | - if( ! isset( $_GET['give-action'] ) ) { |
|
93 | + if ( ! isset($_GET['give-action'])) { |
|
94 | 94 | return $admin_title; |
95 | 95 | } |
96 | 96 | |
97 | - switch( $_GET['give-action'] ) : |
|
97 | + switch ($_GET['give-action']) : |
|
98 | 98 | |
99 | 99 | case 'view-payment-details' : |
100 | 100 | $title = sprintf( |
101 | 101 | /* translators: %s: admin title */ |
102 | - esc_html__( 'View Donation Details - %s', 'give' ), |
|
102 | + esc_html__('View Donation Details - %s', 'give'), |
|
103 | 103 | $admin_title |
104 | 104 | ); |
105 | 105 | break; |
106 | 106 | case 'edit-payment' : |
107 | 107 | $title = sprintf( |
108 | 108 | /* translators: %s: admin title */ |
109 | - esc_html__( 'Edit Donation - %s', 'give' ), |
|
109 | + esc_html__('Edit Donation - %s', 'give'), |
|
110 | 110 | $admin_title |
111 | 111 | ); |
112 | 112 | break; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | return $title; |
119 | 119 | } |
120 | -add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 ); |
|
120 | +add_filter('admin_title', 'give_view_order_details_title', 10, 2); |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen. |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | * @param $context |
130 | 130 | * @return string |
131 | 131 | */ |
132 | -function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
|
132 | +function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) { |
|
133 | 133 | |
134 | - $post = get_post( $post_id ); |
|
134 | + $post = get_post($post_id); |
|
135 | 135 | |
136 | - if( ! $post ) { |
|
136 | + if ( ! $post) { |
|
137 | 137 | return $url; |
138 | 138 | } |
139 | 139 | |
140 | - if( 'give_payment' != $post->post_type ) { |
|
140 | + if ('give_payment' != $post->post_type) { |
|
141 | 141 | return $url; |
142 | 142 | } |
143 | 143 | |
144 | - $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id ); |
|
144 | + $url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id); |
|
145 | 145 | |
146 | 146 | return $url; |
147 | 147 | } |
148 | -add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 ); |
|
148 | +add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | ob_start(); ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | 28 | <h1><?php echo get_admin_page_title(); ?> |
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h1> |
32 | 32 | |
33 | 33 | <hr class="wp-header-end"> |
34 | 34 | |
35 | - <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
35 | + <p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
36 | 36 | <?php echo give_add_ons_get_feed(); ?> |
37 | 37 | </div> |
38 | 38 | <?php |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | function give_add_ons_get_feed() { |
51 | 51 | |
52 | 52 | $addons_debug = false; //set to true to debug |
53 | - $cache = Give_Cache::get( 'give_add_ons_feed', true ); |
|
53 | + $cache = Give_Cache::get('give_add_ons_feed', true); |
|
54 | 54 | |
55 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
56 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
55 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
56 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
57 | 57 | |
58 | - if ( ! is_wp_error( $feed ) ) { |
|
59 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
60 | - $cache = wp_remote_retrieve_body( $feed ); |
|
61 | - Give_Cache::set( 'give_add_ons_feed', $cache, HOUR_IN_SECONDS, true ); |
|
58 | + if ( ! is_wp_error($feed)) { |
|
59 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
60 | + $cache = wp_remote_retrieve_body($feed); |
|
61 | + Give_Cache::set('give_add_ons_feed', $cache, HOUR_IN_SECONDS, true); |
|
62 | 62 | } |
63 | 63 | } else { |
64 | 64 | $cache = sprintf( |
65 | 65 | '<div class="error"><p>%s</p></div>', |
66 | - esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) |
|
66 | + esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | } |
@@ -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,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|bool Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array Variable prices |
67 | 67 | */ |
68 | -function give_get_variable_price_ids( $form_id = 0 ) { |
|
69 | - if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) { |
|
68 | +function give_get_variable_price_ids($form_id = 0) { |
|
69 | + if ( ! ($prices = give_get_variable_prices($form_id))) { |
|
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $price_ids = array(); |
74 | - foreach ( $prices as $price ){ |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | $price_ids[] = $price['_give_id']['level_id']; |
76 | 76 | } |
77 | 77 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string $default_price |
91 | 91 | */ |
92 | -function give_get_default_multilevel_amount( $form_id ) { |
|
92 | +function give_get_default_multilevel_amount($form_id) { |
|
93 | 93 | $default_price = '1.00'; |
94 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
94 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
95 | 95 | |
96 | - foreach ( $prices as $price ) { |
|
96 | + foreach ($prices as $price) { |
|
97 | 97 | |
98 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
98 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
99 | 99 | $default_price = $price['_give_amount']; |
100 | 100 | } |
101 | 101 | |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | * @return string $default_price |
117 | 117 | * @since 1.0 |
118 | 118 | */ |
119 | -function give_get_default_form_amount( $form_id ) { |
|
119 | +function give_get_default_form_amount($form_id) { |
|
120 | 120 | |
121 | - if ( give_has_variable_prices( $form_id ) ) { |
|
121 | + if (give_has_variable_prices($form_id)) { |
|
122 | 122 | |
123 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
123 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
124 | 124 | |
125 | 125 | } else { |
126 | 126 | |
127 | - $default_amount = give_get_meta( $form_id, '_give_set_price', true ); |
|
127 | + $default_amount = give_get_meta($form_id, '_give_set_price', true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_default_form_amount', $default_amount, $form_id ); |
|
131 | + return apply_filters('give_default_form_amount', $default_amount, $form_id); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
149 | +function give_is_custom_price_mode($form_id = 0) { |
|
150 | 150 | |
151 | - if ( empty( $form_id ) ) { |
|
151 | + if (empty($form_id)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $form = new Give_Donate_Form( $form_id ); |
|
155 | + $form = new Give_Donate_Form($form_id); |
|
156 | 156 | |
157 | 157 | return $form->is_custom_price_mode(); |
158 | 158 | } |
159 | 159 | \ No newline at end of file |