@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly. |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Main Give Class |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return Give |
203 | 203 | */ |
204 | 204 | public static function instance() { |
205 | - if ( is_null( self::$_instance ) ) { |
|
205 | + if (is_null(self::$_instance)) { |
|
206 | 206 | self::$_instance = new self(); |
207 | 207 | } |
208 | 208 | |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function __construct() { |
216 | 216 | // PHP version |
217 | - if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) { |
|
218 | - define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' ); |
|
217 | + if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) { |
|
218 | + define('GIVE_REQUIRED_PHP_VERSION', '5.3'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // Bailout: Need minimum php version to load plugin. |
222 | - if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
|
223 | - add_action( 'admin_notices', array( $this, 'minmum_phpversion_notice' ) ); |
|
222 | + if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) { |
|
223 | + add_action('admin_notices', array($this, 'minmum_phpversion_notice')); |
|
224 | 224 | |
225 | 225 | return; |
226 | 226 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $this->includes(); |
231 | 231 | $this->init_hooks(); |
232 | 232 | |
233 | - do_action( 'give_loaded' ); |
|
233 | + do_action('give_loaded'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @since 1.8.9 |
240 | 240 | */ |
241 | 241 | private function init_hooks() { |
242 | - register_activation_hook( __FILE__, 'give_install' ); |
|
243 | - add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
|
242 | + register_activation_hook(__FILE__, 'give_install'); |
|
243 | + add_action('plugins_loaded', array($this, 'init'), 0); |
|
244 | 244 | } |
245 | 245 | /** |
246 | 246 | * Init Give when WordPress Initializes. |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @since 1.8.9 |
256 | 256 | */ |
257 | - do_action( 'before_give_init' ); |
|
257 | + do_action('before_give_init'); |
|
258 | 258 | |
259 | 259 | // Set up localization. |
260 | 260 | $this->load_textdomain(); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @since 1.8.7 |
281 | 281 | */ |
282 | - do_action( 'give_init', $this ); |
|
282 | + do_action('give_init', $this); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function __clone() { |
298 | 298 | // Cloning instances of the class is forbidden. |
299 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
299 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function __wakeup() { |
311 | 311 | // Unserializing instances of the class is forbidden. |
312 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
312 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -323,33 +323,33 @@ discard block |
||
323 | 323 | private function setup_constants() { |
324 | 324 | |
325 | 325 | // Plugin version |
326 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
327 | - define( 'GIVE_VERSION', '1.8.13' ); |
|
326 | + if ( ! defined('GIVE_VERSION')) { |
|
327 | + define('GIVE_VERSION', '1.8.13'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // Plugin Folder Path |
331 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
332 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
331 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
332 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // Plugin Folder URL |
336 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
337 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
336 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
337 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Plugin Basename aka: "give/give.php" |
341 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
342 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
341 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
342 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Plugin Root File |
346 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
347 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
346 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
347 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Make sure CAL_GREGORIAN is defined |
351 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
352 | - define( 'CAL_GREGORIAN', 1 ); |
|
351 | + if ( ! defined('CAL_GREGORIAN')) { |
|
352 | + define('CAL_GREGORIAN', 1); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -364,128 +364,128 @@ discard block |
||
364 | 364 | private function includes() { |
365 | 365 | global $give_options; |
366 | 366 | |
367 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
368 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
368 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
369 | 369 | $give_options = give_get_settings(); |
370 | 370 | |
371 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; |
|
373 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
376 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php'; |
|
380 | - |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php'; |
|
387 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php'; |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
395 | - |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
402 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php'; |
|
411 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
412 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
414 | - |
|
415 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
416 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
417 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
418 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
419 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
420 | - |
|
421 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
422 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
423 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
424 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
425 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
426 | - |
|
427 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
428 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
429 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
430 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
431 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
432 | - |
|
433 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
434 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
371 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php'; |
|
373 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
376 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/class-notices.php'; |
|
380 | + |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php'; |
|
387 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php'; |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
395 | + |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
402 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php'; |
|
411 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
412 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
414 | + |
|
415 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
416 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
417 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
418 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
419 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
420 | + |
|
421 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
422 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
423 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
424 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
425 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
426 | + |
|
427 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
428 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
429 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
430 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
431 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
432 | + |
|
433 | + if (defined('WP_CLI') && WP_CLI) { |
|
434 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
435 | 435 | } |
436 | 436 | |
437 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
437 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
438 | 438 | |
439 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
440 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
441 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
442 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
443 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
444 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
445 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
446 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
447 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
448 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
439 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
440 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
441 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
442 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
443 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
444 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
445 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
446 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
447 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
448 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
449 | 449 | |
450 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
451 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
450 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
451 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
452 | 452 | |
453 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php'; |
|
454 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php'; |
|
455 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php'; |
|
453 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php'; |
|
454 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php'; |
|
455 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php'; |
|
456 | 456 | |
457 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
458 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
459 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
457 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
458 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
459 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
460 | 460 | |
461 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php'; |
|
462 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php'; |
|
463 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php'; |
|
464 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php'; |
|
461 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php'; |
|
462 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php'; |
|
463 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php'; |
|
464 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php'; |
|
465 | 465 | |
466 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php'; |
|
467 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php'; |
|
468 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php'; |
|
466 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php'; |
|
467 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php'; |
|
468 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php'; |
|
469 | 469 | |
470 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
470 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
471 | 471 | |
472 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php'; |
|
472 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php'; |
|
473 | 473 | |
474 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
475 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
476 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
477 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
478 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
479 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
480 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
481 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
482 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
474 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
475 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
476 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
477 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
478 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
479 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
480 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
481 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
482 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
483 | 483 | |
484 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php'; |
|
484 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php'; |
|
485 | 485 | |
486 | 486 | }// End if(). |
487 | 487 | |
488 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
488 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
489 | 489 | |
490 | 490 | } |
491 | 491 | |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | public function load_textdomain() { |
501 | 501 | |
502 | 502 | // Set filter for Give's languages directory |
503 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
504 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
503 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
504 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
505 | 505 | |
506 | 506 | // Traditional WordPress plugin locale filter. |
507 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
508 | - $locale = apply_filters( 'plugin_locale', $locale, 'give' ); |
|
507 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
508 | + $locale = apply_filters('plugin_locale', $locale, 'give'); |
|
509 | 509 | |
510 | - unload_textdomain( 'give' ); |
|
511 | - load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' ); |
|
512 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
510 | + unload_textdomain('give'); |
|
511 | + load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo'); |
|
512 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
513 | 513 | |
514 | 514 | } |
515 | 515 | |
@@ -522,17 +522,17 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function minmum_phpversion_notice() { |
524 | 524 | // Bailout. |
525 | - if ( ! is_admin() ) { |
|
525 | + if ( ! is_admin()) { |
|
526 | 526 | return; |
527 | 527 | } |
528 | 528 | |
529 | - $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
|
530 | - $notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>'; |
|
531 | - $notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>'; |
|
532 | - $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
|
533 | - $notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>'; |
|
534 | - $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
|
535 | - $notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>'; |
|
529 | + $notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>'; |
|
530 | + $notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>'; |
|
531 | + $notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>'; |
|
532 | + $notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>'; |
|
533 | + $notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>'; |
|
534 | + $notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>'; |
|
535 | + $notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>'; |
|
536 | 536 | |
537 | 537 | echo sprintf( |
538 | 538 | '<div class="notice notice-error">%1$s</div>', |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
52 | - $payment_id = give_create_payment( $payment_data ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | + $payment_id = give_create_payment($payment_data); |
|
53 | 53 | |
54 | 54 | // Check payment. |
55 | - if ( empty( $payment_id ) ) { |
|
55 | + if (empty($payment_id)) { |
|
56 | 56 | // Record the error. |
57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
59 | 59 | // Problems? Send back. |
60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Redirect to PayPal. |
64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function give_listen_for_paypal_ipn() { |
77 | 77 | // Regular PayPal IPN |
78 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
78 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
79 | 79 | /** |
80 | 80 | * Fires while verifying PayPal IPN |
81 | 81 | * |
82 | 82 | * @since 1.0 |
83 | 83 | */ |
84 | - do_action( 'give_verify_paypal_ipn' ); |
|
84 | + do_action('give_verify_paypal_ipn'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function give_process_paypal_ipn() { |
97 | 97 | |
98 | 98 | // Check the request method is POST. |
99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $post_data = ''; |
105 | 105 | |
106 | 106 | // Fallback just in case post_max_size is lower than needed. |
107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
108 | - $post_data = file_get_contents( 'php://input' ); |
|
107 | + if (ini_get('allow_url_fopen')) { |
|
108 | + $post_data = file_get_contents('php://input'); |
|
109 | 109 | } else { |
110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
111 | - ini_set( 'post_max_size', '12M' ); |
|
111 | + ini_set('post_max_size', '12M'); |
|
112 | 112 | } |
113 | 113 | // Start the encoded data collection with notification command. |
114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
118 | 118 | |
119 | 119 | // Verify there is a post_data. |
120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
120 | + if ($post_data || strlen($post_data) > 0) { |
|
121 | 121 | // Append the data. |
122 | - $encoded_data .= $arg_separator . $post_data; |
|
122 | + $encoded_data .= $arg_separator.$post_data; |
|
123 | 123 | } else { |
124 | 124 | // Check if POST is empty. |
125 | - if ( empty( $_POST ) ) { |
|
125 | + if (empty($_POST)) { |
|
126 | 126 | // Nothing to do. |
127 | 127 | return; |
128 | 128 | } else { |
129 | 129 | // Loop through each POST. |
130 | - foreach ( $_POST as $key => $value ) { |
|
130 | + foreach ($_POST as $key => $value) { |
|
131 | 131 | // Encode the value and append the data. |
132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Convert collected post data to an array. |
138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
138 | + parse_str($encoded_data, $encoded_data_array); |
|
139 | 139 | |
140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
140 | + foreach ($encoded_data_array as $key => $value) { |
|
141 | 141 | |
142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
143 | - $new_key = str_replace( '&', '&', $key ); |
|
144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
142 | + if (false !== strpos($key, 'amp;')) { |
|
143 | + $new_key = str_replace('&', '&', $key); |
|
144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
145 | 145 | |
146 | - unset( $encoded_data_array[ $key ] ); |
|
147 | - $encoded_data_array[ $new_key ] = $value; |
|
146 | + unset($encoded_data_array[$key]); |
|
147 | + $encoded_data_array[$new_key] = $value; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
153 | 153 | |
154 | 154 | $remote_post_vars = array( |
155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Validate the IPN. |
172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
173 | 173 | |
174 | - if ( is_wp_error( $api_response ) ) { |
|
175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
174 | + if (is_wp_error($api_response)) { |
|
175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
177 | 177 | |
178 | 178 | return; // Something went wrong |
179 | 179 | } |
180 | 180 | |
181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
181 | + if ('VERIFIED' !== $api_response['body']) { |
|
182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
184 | 184 | |
185 | 185 | return; // Response not okay. |
186 | 186 | } |
187 | 187 | }// End if(). |
188 | 188 | |
189 | 189 | // Check if $post_data_array has been populated. |
190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,28 +196,28 @@ discard block |
||
196 | 196 | 'payment_status' => '', |
197 | 197 | ); |
198 | 198 | |
199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
200 | 200 | |
201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
203 | 203 | |
204 | 204 | // Check for PayPal IPN Notifications and update data based on it. |
205 | - $current_timestamp = current_time( 'timestamp' ); |
|
205 | + $current_timestamp = current_time('timestamp'); |
|
206 | 206 | $paypal_ipn_vars = array( |
207 | - 'auth_status' => ( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
207 | + 'auth_status' => ($api_response['body']) ? $api_response['body'] : 'N/A', |
|
208 | 208 | 'transaction_id' => $encoded_data_array['txn_id'], |
209 | 209 | 'payment_id' => $payment_id, |
210 | 210 | ); |
211 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars ); |
|
212 | - give_insert_payment_note( $payment_id, sprintf( |
|
213 | - __( 'Last IPN received on %s at %s', 'give' ), |
|
214 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
215 | - date_i18n( 'H:i', $current_timestamp ) |
|
211 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars); |
|
212 | + give_insert_payment_note($payment_id, sprintf( |
|
213 | + __('Last IPN received on %s at %s', 'give'), |
|
214 | + date_i18n('m/d/Y', $current_timestamp), |
|
215 | + date_i18n('H:i', $current_timestamp) |
|
216 | 216 | ) |
217 | 217 | ); |
218 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
218 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
219 | 219 | |
220 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
220 | + if (has_action('give_paypal_'.$txn_type)) { |
|
221 | 221 | /** |
222 | 222 | * Fires while processing PayPal IPN $txn_type. |
223 | 223 | * |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $encoded_data_array Encoded data. |
229 | 229 | * @param int $payment_id Payment id. |
230 | 230 | */ |
231 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
231 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
232 | 232 | } else { |
233 | 233 | /** |
234 | 234 | * Fires while process PayPal IPN. |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | * @param array $encoded_data_array Encoded data. |
241 | 241 | * @param int $payment_id Payment id. |
242 | 242 | */ |
243 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
243 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
244 | 244 | } |
245 | 245 | exit; |
246 | 246 | } |
247 | 247 | |
248 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
248 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Process web accept (one time) payment IPNs. |
@@ -257,99 +257,99 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return void |
259 | 259 | */ |
260 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
260 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
261 | 261 | |
262 | 262 | // Only allow through these transaction types. |
263 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
263 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Need $payment_id to continue. |
268 | - if ( empty( $payment_id ) ) { |
|
268 | + if (empty($payment_id)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Collect donation payment details. |
273 | 273 | $paypal_amount = $data['mc_gross']; |
274 | - $payment_status = strtolower( $data['payment_status'] ); |
|
275 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
276 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
277 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
274 | + $payment_status = strtolower($data['payment_status']); |
|
275 | + $currency_code = strtolower($data['mc_currency']); |
|
276 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
277 | + $payment_meta = give_get_payment_meta($payment_id); |
|
278 | 278 | |
279 | 279 | // Must be a PayPal standard IPN. |
280 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
280 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | 284 | // Verify payment recipient |
285 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
285 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
286 | 286 | |
287 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
289 | - give_update_payment_status( $payment_id, 'failed' ); |
|
290 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
287 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
289 | + give_update_payment_status($payment_id, 'failed'); |
|
290 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
291 | 291 | |
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Verify payment currency. |
296 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
296 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
297 | 297 | |
298 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
300 | - give_update_payment_status( $payment_id, 'failed' ); |
|
301 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
298 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
300 | + give_update_payment_status($payment_id, 'failed'); |
|
301 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
302 | 302 | |
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Process refunds & reversed. |
307 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
308 | - give_process_paypal_refund( $data, $payment_id ); |
|
307 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
308 | + give_process_paypal_refund($data, $payment_id); |
|
309 | 309 | |
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // Only complete payments once. |
314 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
314 | + if ('publish' === get_post_status($payment_id)) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Retrieve the total donation amount (before PayPal). |
319 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
319 | + $payment_amount = give_get_payment_amount($payment_id); |
|
320 | 320 | |
321 | 321 | // Check that the donation PP and local db amounts match. |
322 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
322 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
323 | 323 | // The prices don't match |
324 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
326 | - give_update_payment_status( $payment_id, 'failed' ); |
|
327 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
324 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
326 | + give_update_payment_status($payment_id, 'failed'); |
|
327 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
328 | 328 | |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Process completed donations. |
333 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
333 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
334 | 334 | |
335 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
337 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
338 | - give_update_payment_status( $payment_id, 'publish' ); |
|
335 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
337 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
338 | + give_update_payment_status($payment_id, 'publish'); |
|
339 | 339 | |
340 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
340 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
341 | 341 | |
342 | 342 | // Look for possible pending reasons, such as an echeck. |
343 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
343 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
344 | 344 | |
345 | - if ( ! empty( $note ) ) { |
|
346 | - give_insert_payment_note( $payment_id, $note ); |
|
345 | + if ( ! empty($note)) { |
|
346 | + give_insert_payment_note($payment_id, $note); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
352 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Process PayPal IPN Refunds |
@@ -361,35 +361,35 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return void |
363 | 363 | */ |
364 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
364 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
365 | 365 | |
366 | 366 | // Collect payment details. |
367 | - if ( empty( $payment_id ) ) { |
|
367 | + if (empty($payment_id)) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Only refund payments once. |
372 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
372 | + if ('refunded' === get_post_status($payment_id)) { |
|
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | $refund_amount = $data['payment_gross'] * - 1; |
378 | 378 | |
379 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
379 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
380 | 380 | |
381 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
381 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
383 | 383 | |
384 | 384 | return; // This is a partial refund |
385 | 385 | |
386 | 386 | } |
387 | 387 | |
388 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
390 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
392 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
388 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
390 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
392 | + give_update_payment_status($payment_id, 'refunded'); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return string |
403 | 403 | */ |
404 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
404 | +function give_get_paypal_redirect($ssl_check = false) { |
|
405 | 405 | |
406 | - if ( is_ssl() || ! $ssl_check ) { |
|
406 | + if (is_ssl() || ! $ssl_check) { |
|
407 | 407 | $protocol = 'https://'; |
408 | 408 | } else { |
409 | 409 | $protocol = 'http://'; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Check the current payment mode |
413 | - if ( give_is_test_mode() ) { |
|
413 | + if (give_is_test_mode()) { |
|
414 | 414 | // Test mode |
415 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
415 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
416 | 416 | } else { |
417 | 417 | // Live mode |
418 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
418 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
419 | 419 | } |
420 | 420 | |
421 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
421 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | * @return string |
429 | 429 | */ |
430 | 430 | function give_get_paypal_page_style() { |
431 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
431 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
432 | 432 | |
433 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
433 | + return apply_filters('give_paypal_page_style', $page_style); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -444,26 +444,26 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string |
446 | 446 | */ |
447 | -function give_paypal_success_page_content( $content ) { |
|
447 | +function give_paypal_success_page_content($content) { |
|
448 | 448 | |
449 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
449 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
450 | 450 | return $content; |
451 | 451 | } |
452 | 452 | |
453 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
453 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
454 | 454 | |
455 | - if ( ! $payment_id ) { |
|
455 | + if ( ! $payment_id) { |
|
456 | 456 | $session = give_get_purchase_session(); |
457 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
457 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
458 | 458 | } |
459 | 459 | |
460 | - $payment = get_post( $payment_id ); |
|
461 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
460 | + $payment = get_post($payment_id); |
|
461 | + if ($payment && 'pending' === $payment->post_status) { |
|
462 | 462 | |
463 | 463 | // Payment is still pending so show processing indicator to fix the race condition. |
464 | 464 | ob_start(); |
465 | 465 | |
466 | - give_get_template_part( 'payment', 'processing' ); |
|
466 | + give_get_template_part('payment', 'processing'); |
|
467 | 467 | |
468 | 468 | $content = ob_get_clean(); |
469 | 469 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
476 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return string A link to the PayPal transaction details |
487 | 487 | */ |
488 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
488 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
489 | 489 | |
490 | 490 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
491 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
491 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
492 | 492 | |
493 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
493 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
497 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
498 | 498 | |
499 | 499 | |
500 | 500 | /** |
@@ -506,64 +506,64 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string |
508 | 508 | */ |
509 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
509 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
510 | 510 | |
511 | 511 | $note = ''; |
512 | 512 | |
513 | - switch ( $pending_reason ) { |
|
513 | + switch ($pending_reason) { |
|
514 | 514 | |
515 | 515 | case 'echeck' : |
516 | 516 | |
517 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
517 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
518 | 518 | |
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'address' : |
522 | 522 | |
523 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
523 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
524 | 524 | |
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'intl' : |
528 | 528 | |
529 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
529 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
530 | 530 | |
531 | 531 | break; |
532 | 532 | |
533 | 533 | case 'multi-currency' : |
534 | 534 | |
535 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
535 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
536 | 536 | |
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'paymentreview' : |
540 | 540 | case 'regulatory_review' : |
541 | 541 | |
542 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
542 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
543 | 543 | |
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'unilateral' : |
547 | 547 | |
548 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
548 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
549 | 549 | |
550 | 550 | break; |
551 | 551 | |
552 | 552 | case 'upgrade' : |
553 | 553 | |
554 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
554 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
555 | 555 | |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case 'verify' : |
559 | 559 | |
560 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
560 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
561 | 561 | |
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'other' : |
565 | 565 | |
566 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
566 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
567 | 567 | |
568 | 568 | break; |
569 | 569 | |
@@ -581,49 +581,49 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return mixed|string |
583 | 583 | */ |
584 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
584 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
585 | 585 | // Only send to PayPal if the pending payment is created successfully. |
586 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
586 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
587 | 587 | |
588 | 588 | // Get the success url. |
589 | - $return_url = add_query_arg( array( |
|
589 | + $return_url = add_query_arg(array( |
|
590 | 590 | 'payment-confirmation' => 'paypal', |
591 | 591 | 'payment-id' => $payment_id, |
592 | 592 | |
593 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
593 | + ), get_permalink(give_get_option('success_page'))); |
|
594 | 594 | |
595 | 595 | // Get the PayPal redirect uri. |
596 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
596 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
597 | 597 | |
598 | 598 | // Item name. |
599 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
599 | + $item_name = give_build_paypal_item_title($payment_data); |
|
600 | 600 | |
601 | 601 | // Setup PayPal API params. |
602 | 602 | $paypal_args = array( |
603 | - 'business' => give_get_option( 'paypal_email', false ), |
|
603 | + 'business' => give_get_option('paypal_email', false), |
|
604 | 604 | 'first_name' => $payment_data['user_info']['first_name'], |
605 | 605 | 'last_name' => $payment_data['user_info']['last_name'], |
606 | 606 | 'email' => $payment_data['user_email'], |
607 | 607 | 'invoice' => $payment_data['purchase_key'], |
608 | 608 | 'amount' => $payment_data['price'], |
609 | - 'item_name' => stripslashes( $item_name ), |
|
609 | + 'item_name' => stripslashes($item_name), |
|
610 | 610 | 'no_shipping' => '1', |
611 | 611 | 'shipping' => '0', |
612 | 612 | 'no_note' => '1', |
613 | 613 | 'currency_code' => give_get_currency(), |
614 | - 'charset' => get_bloginfo( 'charset' ), |
|
614 | + 'charset' => get_bloginfo('charset'), |
|
615 | 615 | 'custom' => $payment_id, |
616 | 616 | 'rm' => '2', |
617 | 617 | 'return' => $return_url, |
618 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
618 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
619 | 619 | 'notify_url' => $listener_url, |
620 | 620 | 'page_style' => give_get_paypal_page_style(), |
621 | - 'cbt' => get_bloginfo( 'name' ), |
|
621 | + 'cbt' => get_bloginfo('name'), |
|
622 | 622 | 'bn' => 'givewp_SP', |
623 | 623 | ); |
624 | 624 | |
625 | 625 | // Add user address if present. |
626 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
626 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
627 | 627 | $default_address = array( |
628 | 628 | 'line1' => '', |
629 | 629 | 'line2' => '', |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'country' => '', |
634 | 634 | ); |
635 | 635 | |
636 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
636 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
637 | 637 | |
638 | 638 | $paypal_args['address1'] = $address['line1']; |
639 | 639 | $paypal_args['address2'] = $address['line2']; |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * @param array $paypal_args |
655 | 655 | * @param array $payment_data |
656 | 656 | */ |
657 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
657 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
658 | 658 | |
659 | 659 | // Build query. |
660 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
660 | + $paypal_redirect .= http_build_query($paypal_args); |
|
661 | 661 | |
662 | 662 | // Fix for some sites that encode the entities. |
663 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
663 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
664 | 664 | |
665 | 665 | return $paypal_redirect; |
666 | 666 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function give_get_paypal_button_type() { |
676 | 676 | // paypal_button_type can be donation or standard. |
677 | 677 | $paypal_button_type = '_donations'; |
678 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
678 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
679 | 679 | $paypal_button_type = '_xclick'; |
680 | 680 | } |
681 | 681 | |
@@ -692,30 +692,30 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return string |
694 | 694 | */ |
695 | -function give_build_paypal_item_title( $payment_data ) { |
|
696 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
695 | +function give_build_paypal_item_title($payment_data) { |
|
696 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
697 | 697 | $item_name = $payment_data['post_data']['give-form-title']; |
698 | 698 | |
699 | 699 | // Verify has variable prices. |
700 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
700 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
701 | 701 | |
702 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
703 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
702 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
703 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
704 | 704 | |
705 | 705 | // Donation given doesn't match selected level (must be a custom amount). |
706 | - if ( $price_level_amount != give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
707 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
706 | + if ($price_level_amount != give_maybe_sanitize_amount($payment_data['price'])) { |
|
707 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
708 | 708 | // user custom amount text if any, fallback to default if not. |
709 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
709 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
710 | 710 | |
711 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
712 | - $item_name .= ' - ' . $item_price_level_text; |
|
711 | + } elseif ( ! empty($item_price_level_text)) { |
|
712 | + $item_name .= ' - '.$item_price_level_text; |
|
713 | 713 | } |
714 | 714 | } // End if(). |
715 | - elseif ( give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
716 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
715 | + elseif (give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['price'])) { |
|
716 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
717 | 717 | // user custom amount text if any, fallback to default if not. |
718 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
718 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | return $item_name; |
@@ -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 | |
@@ -74,57 +74,57 @@ discard block |
||
74 | 74 | public function __construct() { |
75 | 75 | |
76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
78 | 78 | |
79 | 79 | // PHP Sessions. |
80 | - if ( $this->use_php_sessions ) { |
|
80 | + if ($this->use_php_sessions) { |
|
81 | 81 | |
82 | - if ( is_multisite() ) { |
|
82 | + if (is_multisite()) { |
|
83 | 83 | |
84 | - $this->prefix = '_' . get_current_blog_id(); |
|
84 | + $this->prefix = '_'.get_current_blog_id(); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - if ( ! $this->should_start_session() ) { |
|
92 | + if ( ! $this->should_start_session()) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Use WP_Session. |
97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Include utilities class |
106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
108 | 108 | } |
109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
109 | + if ( ! class_exists('WP_Session')) { |
|
110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
112 | 112 | } |
113 | 113 | |
114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Init Session. |
120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
121 | 121 | $this->init(); |
122 | 122 | } else { |
123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
123 | + add_action('init', array($this, 'init'), - 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set cookie on Donation Completion page. |
127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function init() { |
142 | 142 | |
143 | - if ( $this->use_php_sessions ) { |
|
144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
143 | + if ($this->use_php_sessions) { |
|
144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
145 | 145 | } else { |
146 | 146 | $this->session = WP_Session::get_instance(); |
147 | 147 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string|array Session variable. |
178 | 178 | */ |
179 | - public function get( $key ) { |
|
180 | - $key = sanitize_key( $key ); |
|
179 | + public function get($key) { |
|
180 | + $key = sanitize_key($key); |
|
181 | 181 | |
182 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
182 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; |
|
183 | 183 | |
184 | 184 | } |
185 | 185 | |
@@ -196,21 +196,21 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return string Session variable. |
198 | 198 | */ |
199 | - public function set( $key, $value ) { |
|
199 | + public function set($key, $value) { |
|
200 | 200 | |
201 | - $key = sanitize_key( $key ); |
|
201 | + $key = sanitize_key($key); |
|
202 | 202 | |
203 | - if ( is_array( $value ) ) { |
|
204 | - $this->session[ $key ] = serialize( $value ); |
|
203 | + if (is_array($value)) { |
|
204 | + $this->session[$key] = serialize($value); |
|
205 | 205 | } else { |
206 | - $this->session[ $key ] = $value; |
|
206 | + $this->session[$key] = $value; |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( $this->use_php_sessions ) { |
|
210 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
209 | + if ($this->use_php_sessions) { |
|
210 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
211 | 211 | } |
212 | 212 | |
213 | - return $this->session[ $key ]; |
|
213 | + return $this->session[$key]; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | * @hook |
225 | 225 | */ |
226 | 226 | public function set_session_cookies() { |
227 | - if ( ! headers_sent() ) { |
|
228 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
229 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
230 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
227 | + if ( ! headers_sent()) { |
|
228 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
229 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
230 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function set_expiration_variant_time() { |
245 | 245 | |
246 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
246 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function set_expiration_time() { |
260 | 260 | |
261 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
261 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -276,21 +276,21 @@ discard block |
||
276 | 276 | $ret = false; |
277 | 277 | |
278 | 278 | // If the database variable is already set, no need to run auto detection. |
279 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
279 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
280 | 280 | |
281 | - if ( ! $give_use_php_sessions ) { |
|
281 | + if ( ! $give_use_php_sessions) { |
|
282 | 282 | |
283 | 283 | // Attempt to detect if the server supports PHP sessions. |
284 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
284 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
285 | 285 | |
286 | - $this->set( 'give_use_php_sessions', 1 ); |
|
286 | + $this->set('give_use_php_sessions', 1); |
|
287 | 287 | |
288 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
288 | + if ($this->get('give_use_php_sessions')) { |
|
289 | 289 | |
290 | 290 | $ret = true; |
291 | 291 | |
292 | 292 | // Set the database option. |
293 | - update_option( 'give_use_php_sessions', true ); |
|
293 | + update_option('give_use_php_sessions', true); |
|
294 | 294 | |
295 | 295 | } |
296 | 296 | } |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
303 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
303 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
304 | 304 | $ret = true; |
305 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
305 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
306 | 306 | $ret = false; |
307 | 307 | } |
308 | 308 | |
309 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
309 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | |
324 | 324 | $start_session = true; |
325 | 325 | |
326 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
326 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
327 | 327 | |
328 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
328 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
329 | 329 | 'feed', |
330 | 330 | 'feed', |
331 | 331 | 'feed/rss', |
@@ -333,21 +333,21 @@ discard block |
||
333 | 333 | 'feed/rdf', |
334 | 334 | 'feed/atom', |
335 | 335 | 'comments/feed/', |
336 | - ) ); |
|
337 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
338 | - $uri = untrailingslashit( $uri ); |
|
339 | - if ( in_array( $uri, $blacklist ) ) { |
|
336 | + )); |
|
337 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
338 | + $uri = untrailingslashit($uri); |
|
339 | + if (in_array($uri, $blacklist)) { |
|
340 | 340 | $start_session = false; |
341 | 341 | } |
342 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
342 | + if (false !== strpos($uri, 'feed=')) { |
|
343 | 343 | $start_session = false; |
344 | 344 | } |
345 | - if ( is_admin() ) { |
|
345 | + if (is_admin()) { |
|
346 | 346 | $start_session = false; |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - return apply_filters( 'give_start_session', $start_session ); |
|
350 | + return apply_filters('give_start_session', $start_session); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function maybe_start_session() { |
365 | 365 | |
366 | - if ( ! $this->should_start_session() ) { |
|
366 | + if ( ! $this->should_start_session()) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | - if ( ! session_id() && ! headers_sent() ) { |
|
370 | + if ( ! session_id() && ! headers_sent()) { |
|
371 | 371 | session_start(); |
372 | 372 | } |
373 | 373 | |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | |
387 | 387 | $expiration = false; |
388 | 388 | |
389 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
389 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
390 | 390 | |
391 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
391 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
392 | 392 | |
393 | 393 | } |
394 | 394 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
57 | 57 | |
58 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
58 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
59 | 59 | |
60 | - if ( ! is_array( $items ) ) { |
|
60 | + if ( ! is_array($items)) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
64 | + $offset = ($this->step - 1) * $this->per_step; |
|
65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
66 | 66 | |
67 | - if ( $step_items ) { |
|
67 | + if ($step_items) { |
|
68 | 68 | |
69 | 69 | $step_ids = array( |
70 | 70 | 'other' => array(), |
71 | 71 | ); |
72 | 72 | |
73 | - foreach ( $step_items as $item ) { |
|
73 | + foreach ($step_items as $item) { |
|
74 | 74 | |
75 | 75 | $step_ids['other'][] = $item['id']; |
76 | 76 | |
@@ -78,31 +78,31 @@ discard block |
||
78 | 78 | |
79 | 79 | $sql = array(); |
80 | 80 | |
81 | - foreach ( $step_ids as $type => $ids ) { |
|
81 | + foreach ($step_ids as $type => $ids) { |
|
82 | 82 | |
83 | - if ( empty( $ids ) ) { |
|
83 | + if (empty($ids)) { |
|
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | |
87 | 87 | $parent_query = ''; |
88 | 88 | |
89 | - switch ( $type ) { |
|
89 | + switch ($type) { |
|
90 | 90 | case 'other': |
91 | 91 | |
92 | - $temp_ids = implode( ',', $ids ); |
|
92 | + $temp_ids = implode(',', $ids); |
|
93 | 93 | |
94 | 94 | // Get all the test logs of the donations ids. |
95 | 95 | $parent_query = "SELECT DISTINCT post_id as id FROM $wpdb->postmeta WHERE meta_key = '_give_log_payment_id' AND meta_value IN ( $temp_ids )"; |
96 | - $parent_ids = $wpdb->get_results( $parent_query, 'ARRAY_A' ); |
|
96 | + $parent_ids = $wpdb->get_results($parent_query, 'ARRAY_A'); |
|
97 | 97 | |
98 | 98 | // List of all test logs. |
99 | - if ( $parent_ids ) { |
|
100 | - foreach ( $parent_ids as $parent_id ) { |
|
99 | + if ($parent_ids) { |
|
100 | + foreach ($parent_ids as $parent_id) { |
|
101 | 101 | // Adding all the test log in post ids that are going to get deleted. |
102 | 102 | $ids[] = $parent_id['id']; |
103 | 103 | } |
104 | 104 | } |
105 | - $ids = implode( ',', $ids ); |
|
105 | + $ids = implode(',', $ids); |
|
106 | 106 | |
107 | 107 | $sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)"; |
108 | 108 | $sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)"; |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | - if ( ! empty( $sql ) ) { |
|
117 | - foreach ( $sql as $query ) { |
|
118 | - $wpdb->query( $query ); |
|
116 | + if ( ! empty($sql)) { |
|
117 | + foreach ($sql as $query) { |
|
118 | + $wpdb->query($query); |
|
119 | 119 | } |
120 | - do_action( 'give_delete_log_cache' ); |
|
120 | + do_action('give_delete_log_cache'); |
|
121 | 121 | } |
122 | 122 | return true; |
123 | 123 | } |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function get_percentage_complete() { |
134 | 134 | |
135 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
136 | - $total = count( $items ); |
|
135 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
136 | + $total = count($items); |
|
137 | 137 | |
138 | 138 | $percentage = 100; |
139 | 139 | |
140 | - if ( $total > 0 ) { |
|
141 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
140 | + if ($total > 0) { |
|
141 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
142 | 142 | } |
143 | 143 | |
144 | - if ( $percentage > 100 ) { |
|
144 | + if ($percentage > 100) { |
|
145 | 145 | $percentage = 100; |
146 | 146 | } |
147 | 147 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param array $request The Form Data passed into the batch processing |
157 | 157 | */ |
158 | - public function set_properties( $request ) { |
|
158 | + public function set_properties($request) { |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -166,29 +166,29 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function process_step() { |
168 | 168 | |
169 | - if ( ! $this->can_export() ) { |
|
170 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
169 | + if ( ! $this->can_export()) { |
|
170 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | $had_data = $this->get_data(); |
174 | 174 | |
175 | - if ( $had_data ) { |
|
175 | + if ($had_data) { |
|
176 | 176 | $this->done = false; |
177 | 177 | |
178 | 178 | return true; |
179 | 179 | } else { |
180 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
181 | - Give_Cache::delete( Give_Cache::get_key('give_estimated_monthly_stats' ) ); |
|
180 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
181 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
182 | 182 | |
183 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
183 | + $this->delete_data('give_temp_delete_test_ids'); |
|
184 | 184 | |
185 | 185 | // Reset the sequential order numbers |
186 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
187 | - delete_option( 'give_last_payment_number' ); |
|
186 | + if (give_get_option('enable_sequential')) { |
|
187 | + delete_option('give_last_payment_number'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $this->done = true; |
191 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
191 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
192 | 192 | |
193 | 193 | return false; |
194 | 194 | } |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * Headers |
199 | 199 | */ |
200 | 200 | public function headers() { |
201 | - ignore_user_abort( true ); |
|
201 | + ignore_user_abort(true); |
|
202 | 202 | |
203 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
204 | - set_time_limit( 0 ); |
|
203 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
204 | + set_time_limit(0); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -225,26 +225,26 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function pre_fetch() { |
227 | 227 | |
228 | - if ( $this->step == 1 ) { |
|
229 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
228 | + if ($this->step == 1) { |
|
229 | + $this->delete_data('give_temp_delete_test_ids'); |
|
230 | 230 | } |
231 | 231 | |
232 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
232 | + $items = get_option('give_temp_delete_test_ids', false); |
|
233 | 233 | |
234 | - if ( false === $items ) { |
|
234 | + if (false === $items) { |
|
235 | 235 | $items = array(); |
236 | 236 | |
237 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
237 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
238 | 238 | 'post_type' => 'give_payment', |
239 | 239 | 'post_status' => 'any', |
240 | - 'posts_per_page' => - 1, |
|
240 | + 'posts_per_page' => -1, |
|
241 | 241 | // ONLY TEST MODE TRANSACTIONS!!! |
242 | 242 | 'meta_key' => '_give_payment_mode', |
243 | 243 | 'meta_value' => 'test' |
244 | - ) ); |
|
244 | + )); |
|
245 | 245 | |
246 | - $posts = get_posts( $args ); |
|
247 | - foreach ( $posts as $post ) { |
|
246 | + $posts = get_posts($args); |
|
247 | + foreach ($posts as $post) { |
|
248 | 248 | $items[] = array( |
249 | 249 | 'id' => (int) $post->ID, |
250 | 250 | 'type' => $post->post_type, |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | |
254 | 254 | // Allow filtering of items to remove with an unassociative array for each item. |
255 | 255 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
256 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
256 | + $items = apply_filters('give_delete_test_items', $items); |
|
257 | 257 | |
258 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
258 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | } |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return mixed Returns the data from the database |
271 | 271 | */ |
272 | - private function get_stored_data( $key ) { |
|
272 | + private function get_stored_data($key) { |
|
273 | 273 | global $wpdb; |
274 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
274 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
275 | 275 | |
276 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
276 | + return empty($value) ? false : maybe_unserialize($value); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return void |
288 | 288 | */ |
289 | - private function store_data( $key, $value ) { |
|
289 | + private function store_data($key, $value) { |
|
290 | 290 | global $wpdb; |
291 | 291 | |
292 | - $value = maybe_serialize( $value ); |
|
292 | + $value = maybe_serialize($value); |
|
293 | 293 | |
294 | 294 | $data = array( |
295 | 295 | 'option_name' => $key, |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | '%s', |
304 | 304 | ); |
305 | 305 | |
306 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
306 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - private function delete_data( $key ) { |
|
318 | + private function delete_data($key) { |
|
319 | 319 | global $wpdb; |
320 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
320 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | } |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | * Admin View: Exports |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
10 | -if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
10 | +if ( ! current_user_can('manage_give_settings')) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -16,28 +16,28 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @since 1.5 |
18 | 18 | */ |
19 | -do_action( 'give_tools_recount_stats_before' ); |
|
19 | +do_action('give_tools_recount_stats_before'); |
|
20 | 20 | ?> |
21 | 21 | <div id="poststuff"> |
22 | 22 | <div class="postbox"> |
23 | 23 | |
24 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
24 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
25 | 25 | |
26 | 26 | <div class="inside recount-stats-controls"> |
27 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
27 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
28 | 28 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
29 | 29 | |
30 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
30 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
31 | 31 | |
32 | 32 | <select name="give-export-class" id="recount-stats-type"> |
33 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
34 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
35 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
36 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
37 | - <option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
38 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Payments', 'give' ); ?></option> |
|
39 | - <option data-type="delete-test-donors" value="Give_Tools_Delete_Donors"><?php esc_html_e( 'Delete Test Donors and Payments', 'give' ); ?></option> |
|
40 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
33 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
34 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
35 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
36 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
37 | + <option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
38 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Payments', 'give'); ?></option> |
|
39 | + <option data-type="delete-test-donors" value="Give_Tools_Delete_Donors"><?php esc_html_e('Delete Test Donors and Payments', 'give'); ?></option> |
|
40 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
41 | 41 | <?php |
42 | 42 | /** |
43 | 43 | * Fires in the recount stats selectbox. |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @since 1.5 |
48 | 48 | */ |
49 | - do_action( 'give_recount_tool_options' ); |
|
49 | + do_action('give_recount_tool_options'); |
|
50 | 50 | ?> |
51 | 51 | </select> |
52 | 52 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | <?php |
55 | 55 | $args = array( |
56 | 56 | 'name' => 'form_id', |
57 | - 'number' => - 1, |
|
57 | + 'number' => -1, |
|
58 | 58 | 'chosen' => true, |
59 | 59 | ); |
60 | - echo Give()->html->forms_dropdown( $args ); |
|
60 | + echo Give()->html->forms_dropdown($args); |
|
61 | 61 | ?> |
62 | 62 | </span> |
63 | 63 | |
64 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
64 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
65 | 65 | |
66 | 66 | <br/> |
67 | 67 | |
68 | 68 | <span class="give-recount-stats-descriptions"> |
69 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
70 | - <span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span> |
|
71 | - <span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span> |
|
72 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
69 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
70 | + <span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span> |
|
71 | + <span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span> |
|
72 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
73 | 73 | <?php |
74 | 74 | /** |
75 | 75 | * Fires in the recount stats description area. |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.5 |
80 | 80 | */ |
81 | - do_action( 'give_recount_tool_descriptions' ); |
|
81 | + do_action('give_recount_tool_descriptions'); |
|
82 | 82 | ?> |
83 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
84 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
83 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
84 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
85 | 85 | </span> |
86 | 86 | |
87 | 87 | <span class="spinner"></span> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @since 1.5 |
97 | 97 | */ |
98 | - do_action( 'give_tools_recount_forms' ); |
|
98 | + do_action('give_tools_recount_forms'); |
|
99 | 99 | ?> |
100 | 100 | </div><!-- .inside --> |
101 | 101 | </div><!-- .postbox --> |
@@ -106,4 +106,4 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @since 1.5 |
108 | 108 | */ |
109 | -do_action( 'give_tools_recount_stats_after' ); |
|
109 | +do_action('give_tools_recount_stats_after'); |
@@ -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 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_donation_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_donation_form_user( $valid_data ); |
|
58 | + $user = give_get_donation_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,20 +97,19 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? |
|
103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
104 | - '0.00'; |
|
105 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? |
|
103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
106 | 105 | |
107 | 106 | // Setup donation information |
108 | 107 | $donation_data = array( |
109 | 108 | 'price' => $price, |
110 | 109 | 'purchase_key' => $purchase_key, |
111 | 110 | 'user_email' => $user['user_email'], |
112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
112 | + 'user_info' => stripslashes_deep($user_info), |
|
114 | 113 | 'post_data' => $_POST, |
115 | 114 | 'gateway' => $valid_data['gateway'], |
116 | 115 | 'card_info' => $valid_data['cc_info'], |
@@ -130,10 +129,10 @@ discard block |
||
130 | 129 | * @param array $user_info Array containing basic user information. |
131 | 130 | * @param bool|array $valid_data Validate fields. |
132 | 131 | */ |
133 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
132 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
134 | 133 | |
135 | 134 | // Sanity check for price |
136 | - if ( ! $donation_data['price'] ) { |
|
135 | + if ( ! $donation_data['price']) { |
|
137 | 136 | // Revert to manual |
138 | 137 | $donation_data['gateway'] = 'manual'; |
139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
144 | 143 | * |
145 | 144 | * @since 1.7 |
146 | 145 | */ |
147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
148 | 147 | |
149 | 148 | // Setup the data we're storing in the donation session |
150 | 149 | $session_data = $donation_data; |
151 | 150 | |
152 | 151 | // Make sure credit card numbers are never stored in sessions |
153 | - unset( $session_data['card_info']['card_number'] ); |
|
154 | - unset( $session_data['post_data']['card_number'] ); |
|
152 | + unset($session_data['card_info']['card_number']); |
|
153 | + unset($session_data['post_data']['card_number']); |
|
155 | 154 | |
156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
157 | - give_set_purchase_session( $session_data ); |
|
156 | + give_set_purchase_session($session_data); |
|
158 | 157 | |
159 | 158 | // Send info to the gateway for payment processing |
160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
161 | 160 | give_die(); |
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
168 | 167 | |
169 | 168 | |
170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return void |
179 | 178 | */ |
180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
181 | 180 | |
182 | 181 | // Verify that the email address belongs to this customer. |
183 | - if ( is_user_logged_in() ) { |
|
182 | + if (is_user_logged_in()) { |
|
184 | 183 | |
185 | - $submitted_email = $valid_data['logged_in_user']['user_email']; |
|
186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
184 | + $submitted_email = $valid_data['logged_in_user']['user_email']; |
|
185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
187 | 186 | |
188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer |
189 | 188 | if ( |
190 | 189 | $submitted_email !== $donor->email |
191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
192 | 191 | ) { |
193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
192 | + $found_donor = new Give_Donor($submitted_email); |
|
194 | 193 | |
195 | - if ( $found_donor->id > 0 ) { |
|
196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.' ,'give' ), $donor->email, $submitted_email ) ); |
|
194 | + if ($found_donor->id > 0) { |
|
195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
197 | 196 | } |
198 | 197 | } |
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
203 | 202 | |
204 | 203 | /** |
205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
209 | 208 | * @return void |
210 | 209 | */ |
211 | 210 | function give_process_form_login() { |
212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
211 | + $is_ajax = isset($_POST['give_ajax']); |
|
213 | 212 | |
214 | 213 | $user_data = give_donation_form_validate_user_login(); |
215 | 214 | |
216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
217 | - if ( $is_ajax ) { |
|
215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
216 | + if ($is_ajax) { |
|
218 | 217 | /** |
219 | 218 | * Fires when AJAX sends back errors from the donation form. |
220 | 219 | * |
221 | 220 | * @since 1.0 |
222 | 221 | */ |
223 | 222 | ob_start(); |
224 | - do_action( 'give_ajax_donation_errors' ); |
|
223 | + do_action('give_ajax_donation_errors'); |
|
225 | 224 | $message = ob_get_contents(); |
226 | 225 | ob_end_clean(); |
227 | - wp_send_json_error( $message ); |
|
226 | + wp_send_json_error($message); |
|
228 | 227 | } else { |
229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
230 | 229 | exit; |
231 | 230 | } |
232 | 231 | } |
233 | 232 | |
234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
235 | 234 | |
236 | - if ( $is_ajax ) { |
|
235 | + if ($is_ajax) { |
|
237 | 236 | $message = Give()->notices->print_frontend_notice( |
238 | 237 | sprintf( |
239 | 238 | /* translators: %s: user first name */ |
240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
242 | 241 | ), |
243 | 242 | false, |
244 | 243 | 'success' |
245 | 244 | ); |
246 | 245 | |
247 | - wp_send_json_success( $message ); |
|
246 | + wp_send_json_success($message); |
|
248 | 247 | } else { |
249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
250 | 249 | } |
251 | 250 | } |
252 | 251 | |
253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
255 | 254 | |
256 | 255 | /** |
257 | 256 | * Donation Form Validate Fields. |
@@ -263,55 +262,55 @@ discard block |
||
263 | 262 | function give_donation_form_validate_fields() { |
264 | 263 | |
265 | 264 | // Check if there is $_POST |
266 | - if ( empty( $_POST ) ) { |
|
265 | + if (empty($_POST)) { |
|
267 | 266 | return false; |
268 | 267 | } |
269 | 268 | |
270 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
269 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
271 | 270 | |
272 | 271 | // Start an array to collect valid data |
273 | 272 | $valid_data = array( |
274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
275 | - 'need_new_user' => false, // New user flag |
|
276 | - 'need_user_login' => false, // Login user flag |
|
277 | - 'logged_user_data' => array(), // Logged user collected data |
|
278 | - 'new_user_data' => array(), // New user collected data |
|
279 | - 'login_user_data' => array(), // Login user collected data |
|
280 | - 'guest_user_data' => array(), // Guest user collected data |
|
281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
274 | + 'need_new_user' => false, // New user flag |
|
275 | + 'need_user_login' => false, // Login user flag |
|
276 | + 'logged_user_data' => array(), // Logged user collected data |
|
277 | + 'new_user_data' => array(), // New user collected data |
|
278 | + 'login_user_data' => array(), // Login user collected data |
|
279 | + 'guest_user_data' => array(), // Guest user collected data |
|
280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
282 | 281 | ); |
283 | 282 | |
284 | 283 | // Validate Honeypot First |
285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
287 | 286 | } |
288 | 287 | |
289 | 288 | // Validate agree to terms |
290 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
289 | + if (give_is_terms_enabled($form_id)) { |
|
291 | 290 | give_donation_form_validate_agree_to_terms(); |
292 | 291 | } |
293 | 292 | |
294 | 293 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
295 | 294 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
296 | 295 | if ( |
297 | - ! give_logged_in_only( $form_id ) |
|
298 | - && isset( $_POST['give-purchase-var'] ) |
|
296 | + ! give_logged_in_only($form_id) |
|
297 | + && isset($_POST['give-purchase-var']) |
|
299 | 298 | && $_POST['give-purchase-var'] == 'needs-to-register' |
300 | - && empty( $_POST['give_user_login'] ) |
|
299 | + && empty($_POST['give_user_login']) |
|
301 | 300 | ) { |
302 | - unset( $_POST['give-purchase-var'] ); |
|
301 | + unset($_POST['give-purchase-var']); |
|
303 | 302 | } |
304 | 303 | |
305 | - if ( is_user_logged_in() ) { |
|
304 | + if (is_user_logged_in()) { |
|
306 | 305 | // Collect logged in user data. |
307 | 306 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
308 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
307 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
309 | 308 | // Set new user registration as required. |
310 | 309 | $valid_data['need_new_user'] = true; |
311 | 310 | // Validate new user data. |
312 | 311 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
313 | 312 | // Check if login validation is needed. |
314 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
313 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
315 | 314 | // Set user login as required. |
316 | 315 | $valid_data['need_user_login'] = true; |
317 | 316 | // Validate users login info. |
@@ -336,41 +335,41 @@ discard block |
||
336 | 335 | */ |
337 | 336 | function give_donation_form_validate_gateway() { |
338 | 337 | |
339 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
340 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
341 | - $gateway = give_get_default_gateway( $form_id ); |
|
338 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
339 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
340 | + $gateway = give_get_default_gateway($form_id); |
|
342 | 341 | |
343 | 342 | // Check if a gateway value is present. |
344 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
343 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
345 | 344 | |
346 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
345 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
347 | 346 | |
348 | 347 | // Is amount being donated in LIVE mode 0.00? If so, error: |
349 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
348 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
350 | 349 | |
351 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
350 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
352 | 351 | |
353 | 352 | } // End if(). |
354 | - elseif ( ! give_verify_minimum_price() ) { |
|
353 | + elseif ( ! give_verify_minimum_price()) { |
|
355 | 354 | // translators: %s: minimum donation amount. |
356 | 355 | give_set_error( |
357 | 356 | 'invalid_donation_minimum', |
358 | 357 | sprintf( |
359 | 358 | /* translators: %s: minimum donation amount */ |
360 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
361 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
359 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
360 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
362 | 361 | ) |
363 | 362 | ); |
364 | 363 | |
365 | 364 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
366 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
365 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
367 | 366 | |
368 | 367 | $gateway = 'manual'; |
369 | 368 | |
370 | 369 | } //Check if this gateway is active. |
371 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
370 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
372 | 371 | |
373 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
372 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
374 | 373 | |
375 | 374 | } |
376 | 375 | } |
@@ -388,21 +387,21 @@ discard block |
||
388 | 387 | */ |
389 | 388 | function give_verify_minimum_price() { |
390 | 389 | |
391 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
392 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
393 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
394 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
390 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
391 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
392 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
393 | + $variable_prices = give_has_variable_prices($form_id); |
|
395 | 394 | |
396 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
395 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
397 | 396 | |
398 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
397 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
399 | 398 | |
400 | - if ( $price_level_amount == $amount ) { |
|
399 | + if ($price_level_amount == $amount) { |
|
401 | 400 | return true; |
402 | 401 | } |
403 | 402 | } |
404 | 403 | |
405 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
404 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
406 | 405 | return false; |
407 | 406 | } |
408 | 407 | |
@@ -418,9 +417,9 @@ discard block |
||
418 | 417 | */ |
419 | 418 | function give_donation_form_validate_agree_to_terms() { |
420 | 419 | // Validate agree to terms. |
421 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
420 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
422 | 421 | // User did not agree. |
423 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
422 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
424 | 423 | } |
425 | 424 | } |
426 | 425 | |
@@ -434,59 +433,59 @@ discard block |
||
434 | 433 | * |
435 | 434 | * @return array |
436 | 435 | */ |
437 | -function give_get_required_fields( $form_id ) { |
|
436 | +function give_get_required_fields($form_id) { |
|
438 | 437 | |
439 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
438 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
440 | 439 | |
441 | 440 | $required_fields = array( |
442 | 441 | 'give_email' => array( |
443 | 442 | 'error_id' => 'invalid_email', |
444 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
443 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
445 | 444 | ), |
446 | 445 | 'give_first' => array( |
447 | 446 | 'error_id' => 'invalid_first_name', |
448 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
447 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
449 | 448 | ), |
450 | 449 | ); |
451 | 450 | |
452 | - $require_address = give_require_billing_address( $payment_mode ); |
|
451 | + $require_address = give_require_billing_address($payment_mode); |
|
453 | 452 | |
454 | - if ( $require_address ) { |
|
455 | - $required_fields['card_address'] = array( |
|
453 | + if ($require_address) { |
|
454 | + $required_fields['card_address'] = array( |
|
456 | 455 | 'error_id' => 'invalid_card_address', |
457 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
456 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
458 | 457 | ); |
459 | - $required_fields['card_zip'] = array( |
|
458 | + $required_fields['card_zip'] = array( |
|
460 | 459 | 'error_id' => 'invalid_zip_code', |
461 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
460 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
462 | 461 | ); |
463 | - $required_fields['card_city'] = array( |
|
462 | + $required_fields['card_city'] = array( |
|
464 | 463 | 'error_id' => 'invalid_city', |
465 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
464 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
466 | 465 | ); |
467 | 466 | $required_fields['billing_country'] = array( |
468 | 467 | 'error_id' => 'invalid_country', |
469 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
468 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
470 | 469 | ); |
471 | 470 | |
472 | 471 | |
473 | - $required_fields['card_state'] = array( |
|
472 | + $required_fields['card_state'] = array( |
|
474 | 473 | 'error_id' => 'invalid_state', |
475 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
474 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
476 | 475 | ); |
477 | 476 | |
478 | 477 | // Check if billing country alredy exists. |
479 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
478 | + if ( ! empty($_POST['billing_country'])) { |
|
480 | 479 | // Get the value from $_POST. |
481 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
480 | + $country = sanitize_text_field($_POST['billing_country']); |
|
482 | 481 | |
483 | 482 | // Get the country list that does not required any states init. |
484 | 483 | $states_country = give_states_not_required_country_list(); |
485 | 484 | |
486 | 485 | // Check if states is empty or not. |
487 | - if ( array_key_exists( $country, $states_country ) ) { |
|
486 | + if (array_key_exists($country, $states_country)) { |
|
488 | 487 | // If states is empty remove the required feilds of state in billing cart. |
489 | - unset( $required_fields['card_state'] ); |
|
488 | + unset($required_fields['card_state']); |
|
490 | 489 | } |
491 | 490 | } |
492 | 491 | } |
@@ -496,7 +495,7 @@ discard block |
||
496 | 495 | * |
497 | 496 | * @since 1.7 |
498 | 497 | */ |
499 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
498 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
500 | 499 | |
501 | 500 | return $required_fields; |
502 | 501 | |
@@ -511,16 +510,16 @@ discard block |
||
511 | 510 | * |
512 | 511 | * @return bool |
513 | 512 | */ |
514 | -function give_require_billing_address( $payment_mode ) { |
|
513 | +function give_require_billing_address($payment_mode) { |
|
515 | 514 | |
516 | 515 | $return = false; |
517 | 516 | |
518 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
517 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
519 | 518 | $return = true; |
520 | 519 | } |
521 | 520 | |
522 | 521 | // Let payment gateways and other extensions determine if address fields should be required. |
523 | - return apply_filters( 'give_require_billing_address', $return ); |
|
522 | + return apply_filters('give_require_billing_address', $return); |
|
524 | 523 | |
525 | 524 | } |
526 | 525 | |
@@ -534,42 +533,42 @@ discard block |
||
534 | 533 | function give_donation_form_validate_logged_in_user() { |
535 | 534 | global $user_ID; |
536 | 535 | |
537 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
536 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
538 | 537 | |
539 | 538 | // Start empty array to collect valid user data. |
540 | 539 | $valid_user_data = array( |
541 | 540 | // Assume there will be errors. |
542 | - 'user_id' => - 1, |
|
541 | + 'user_id' => -1, |
|
543 | 542 | ); |
544 | 543 | |
545 | 544 | // Verify there is a user_ID. |
546 | - if ( $user_ID > 0 ) { |
|
545 | + if ($user_ID > 0) { |
|
547 | 546 | // Get the logged in user data. |
548 | - $user_data = get_userdata( $user_ID ); |
|
547 | + $user_data = get_userdata($user_ID); |
|
549 | 548 | |
550 | 549 | // Loop through required fields and show error messages. |
551 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
552 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
553 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
550 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
551 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
552 | + give_set_error($value['error_id'], $value['error_message']); |
|
554 | 553 | } |
555 | 554 | } |
556 | 555 | |
557 | 556 | // Verify data. |
558 | - if ( $user_data ) { |
|
557 | + if ($user_data) { |
|
559 | 558 | // Collected logged in user data. |
560 | 559 | $valid_user_data = array( |
561 | 560 | 'user_id' => $user_ID, |
562 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
563 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
564 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
561 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
562 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
563 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
565 | 564 | ); |
566 | 565 | |
567 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
568 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
566 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
567 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
569 | 568 | } |
570 | 569 | } else { |
571 | 570 | // Set invalid user error. |
572 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
571 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
573 | 572 | } |
574 | 573 | } |
575 | 574 | |
@@ -588,7 +587,7 @@ discard block |
||
588 | 587 | // Default user data. |
589 | 588 | $default_user_data = array( |
590 | 589 | 'give-form-id' => '', |
591 | - 'user_id' => - 1, // Assume there will be errors. |
|
590 | + 'user_id' => -1, // Assume there will be errors. |
|
592 | 591 | 'user_first' => '', |
593 | 592 | 'user_last' => '', |
594 | 593 | 'give_user_login' => false, |
@@ -598,14 +597,14 @@ discard block |
||
598 | 597 | ); |
599 | 598 | |
600 | 599 | // Get user data. |
601 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
600 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
602 | 601 | $registering_new_user = false; |
603 | - $form_id = absint( $user_data['give-form-id'] ); |
|
602 | + $form_id = absint($user_data['give-form-id']); |
|
604 | 603 | |
605 | 604 | // Start an empty array to collect valid user data. |
606 | 605 | $valid_user_data = array( |
607 | 606 | // Assume there will be errors. |
608 | - 'user_id' => - 1, |
|
607 | + 'user_id' => -1, |
|
609 | 608 | |
610 | 609 | // Get first name. |
611 | 610 | 'user_first' => $user_data['give_first'], |
@@ -615,25 +614,25 @@ discard block |
||
615 | 614 | ); |
616 | 615 | |
617 | 616 | // Loop through required fields and show error messages. |
618 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
619 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
620 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
617 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
618 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
619 | + give_set_error($value['error_id'], $value['error_message']); |
|
621 | 620 | } |
622 | 621 | } |
623 | 622 | |
624 | 623 | // Check if we have an username to register. |
625 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
624 | + if (give_validate_username($user_data['give_user_login'])) { |
|
626 | 625 | $registering_new_user = true; |
627 | 626 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
628 | 627 | } |
629 | 628 | |
630 | 629 | // Check if we have an email to verify. |
631 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
630 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
632 | 631 | $valid_user_data['user_email'] = $user_data['give_email']; |
633 | 632 | } |
634 | 633 | |
635 | 634 | // Check password. |
636 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
635 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
637 | 636 | // All is good to go. |
638 | 637 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
639 | 638 | } |
@@ -653,36 +652,36 @@ discard block |
||
653 | 652 | // Start an array to collect valid user data. |
654 | 653 | $valid_user_data = array( |
655 | 654 | // Assume there will be errors. |
656 | - 'user_id' => - 1, |
|
655 | + 'user_id' => -1, |
|
657 | 656 | ); |
658 | 657 | |
659 | 658 | // Username. |
660 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
661 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
659 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
660 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
662 | 661 | |
663 | 662 | return $valid_user_data; |
664 | 663 | } |
665 | 664 | |
666 | 665 | // Get the user by login. |
667 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
666 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
668 | 667 | |
669 | 668 | // Check if user exists. |
670 | - if ( $user_data ) { |
|
669 | + if ($user_data) { |
|
671 | 670 | // Get password. |
672 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
671 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
673 | 672 | |
674 | 673 | // Check user_pass. |
675 | - if ( $user_pass ) { |
|
674 | + if ($user_pass) { |
|
676 | 675 | // Check if password is valid. |
677 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
676 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
678 | 677 | // Incorrect password. |
679 | 678 | give_set_error( |
680 | 679 | 'password_incorrect', |
681 | 680 | sprintf( |
682 | 681 | '%1$s <a href="%2$s">%3$s</a>', |
683 | - __( 'The password you entered is incorrect.', 'give' ), |
|
684 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
685 | - __( 'Reset Password', 'give' ) |
|
682 | + __('The password you entered is incorrect.', 'give'), |
|
683 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
684 | + __('Reset Password', 'give') |
|
686 | 685 | ) |
687 | 686 | ); |
688 | 687 | // All is correct. |
@@ -699,11 +698,11 @@ discard block |
||
699 | 698 | } |
700 | 699 | } else { |
701 | 700 | // Empty password. |
702 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
701 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
703 | 702 | } |
704 | 703 | } else { |
705 | 704 | // No username. |
706 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
705 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
707 | 706 | }// End if(). |
708 | 707 | |
709 | 708 | return $valid_user_data; |
@@ -718,7 +717,7 @@ discard block |
||
718 | 717 | */ |
719 | 718 | function give_donation_form_validate_guest_user() { |
720 | 719 | |
721 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
720 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
722 | 721 | |
723 | 722 | // Start an array to collect valid user data. |
724 | 723 | $valid_user_data = array( |
@@ -727,38 +726,38 @@ discard block |
||
727 | 726 | ); |
728 | 727 | |
729 | 728 | // Show error message if user must be logged in. |
730 | - if ( give_logged_in_only( $form_id ) ) { |
|
731 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
729 | + if (give_logged_in_only($form_id)) { |
|
730 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
732 | 731 | } |
733 | 732 | |
734 | 733 | // Get the guest email. |
735 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
734 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
736 | 735 | |
737 | 736 | // Check email. |
738 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
737 | + if ($guest_email && strlen($guest_email) > 0) { |
|
739 | 738 | // Validate email. |
740 | - if ( ! is_email( $guest_email ) ) { |
|
739 | + if ( ! is_email($guest_email)) { |
|
741 | 740 | // Invalid email. |
742 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
741 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
743 | 742 | } else { |
744 | 743 | // All is good to go. |
745 | 744 | $valid_user_data['user_email'] = $guest_email; |
746 | 745 | |
747 | 746 | // Get user_id from donor if exist. |
748 | - $donor = new Give_Donor( $guest_email ); |
|
749 | - if ( $donor->id && $donor->user_id ) { |
|
747 | + $donor = new Give_Donor($guest_email); |
|
748 | + if ($donor->id && $donor->user_id) { |
|
750 | 749 | $valid_user_data['user_id'] = $donor->user_id; |
751 | 750 | } |
752 | 751 | } |
753 | 752 | } else { |
754 | 753 | // No email. |
755 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
754 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
756 | 755 | } |
757 | 756 | |
758 | 757 | // Loop through required fields and show error messages. |
759 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
760 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
761 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
758 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
759 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
760 | + give_set_error($value['error_id'], $value['error_message']); |
|
762 | 761 | } |
763 | 762 | } |
764 | 763 | |
@@ -774,36 +773,36 @@ discard block |
||
774 | 773 | * @since 1.0 |
775 | 774 | * @return integer |
776 | 775 | */ |
777 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
776 | +function give_register_and_login_new_user($user_data = array()) { |
|
778 | 777 | // Verify the array. |
779 | - if ( empty( $user_data ) ) { |
|
780 | - return - 1; |
|
778 | + if (empty($user_data)) { |
|
779 | + return -1; |
|
781 | 780 | } |
782 | 781 | |
783 | - if ( give_get_errors() ) { |
|
784 | - return - 1; |
|
782 | + if (give_get_errors()) { |
|
783 | + return -1; |
|
785 | 784 | } |
786 | 785 | |
787 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
788 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
789 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
790 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
791 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
792 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
793 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
794 | - 'role' => get_option( 'default_role' ), |
|
795 | - ), $user_data ); |
|
786 | + $user_args = apply_filters('give_insert_user_args', array( |
|
787 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
788 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
789 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
790 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
791 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
792 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
793 | + 'role' => get_option('default_role'), |
|
794 | + ), $user_data); |
|
796 | 795 | |
797 | 796 | // Insert new user. |
798 | - $user_id = wp_insert_user( $user_args ); |
|
797 | + $user_id = wp_insert_user($user_args); |
|
799 | 798 | |
800 | 799 | // Validate inserted user. |
801 | - if ( is_wp_error( $user_id ) ) { |
|
802 | - return - 1; |
|
800 | + if (is_wp_error($user_id)) { |
|
801 | + return -1; |
|
803 | 802 | } |
804 | 803 | |
805 | 804 | // Allow themes and plugins to filter the user data. |
806 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
805 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
807 | 806 | |
808 | 807 | /** |
809 | 808 | * Fires after inserting user. |
@@ -813,10 +812,10 @@ discard block |
||
813 | 812 | * @param int $user_id User id. |
814 | 813 | * @param array $user_data Array containing user data. |
815 | 814 | */ |
816 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
815 | + do_action('give_insert_user', $user_id, $user_data); |
|
817 | 816 | |
818 | 817 | // Login new user. |
819 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
818 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
820 | 819 | |
821 | 820 | // Return user id. |
822 | 821 | return $user_id; |
@@ -831,27 +830,27 @@ discard block |
||
831 | 830 | * @since 1.0 |
832 | 831 | * @return array|bool |
833 | 832 | */ |
834 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
833 | +function give_get_donation_form_user($valid_data = array()) { |
|
835 | 834 | |
836 | 835 | // Initialize user. |
837 | 836 | $user = false; |
838 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
837 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
839 | 838 | |
840 | - if ( $is_ajax ) { |
|
839 | + if ($is_ajax) { |
|
841 | 840 | // Do not create or login the user during the ajax submission (check for errors only). |
842 | 841 | return true; |
843 | - } elseif ( is_user_logged_in() ) { |
|
842 | + } elseif (is_user_logged_in()) { |
|
844 | 843 | // Set the valid user as the logged in collected data. |
845 | 844 | $user = $valid_data['logged_in_user']; |
846 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
845 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
847 | 846 | // New user registration. |
848 | - if ( $valid_data['need_new_user'] === true ) { |
|
847 | + if ($valid_data['need_new_user'] === true) { |
|
849 | 848 | // Set user. |
850 | 849 | $user = $valid_data['new_user_data']; |
851 | 850 | // Register and login new user. |
852 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
851 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
853 | 852 | // User login |
854 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
853 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
855 | 854 | |
856 | 855 | /** |
857 | 856 | * The login form is now processed in the give_process_donation_login() function. |
@@ -863,48 +862,48 @@ discard block |
||
863 | 862 | // Set user. |
864 | 863 | $user = $valid_data['login_user_data']; |
865 | 864 | // Login user. |
866 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
865 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
867 | 866 | } |
868 | 867 | } |
869 | 868 | |
870 | 869 | // Check guest checkout. |
871 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
870 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
872 | 871 | // Set user |
873 | 872 | $user = $valid_data['guest_user_data']; |
874 | 873 | } |
875 | 874 | |
876 | 875 | // Verify we have an user. |
877 | - if ( false === $user || empty( $user ) ) { |
|
876 | + if (false === $user || empty($user)) { |
|
878 | 877 | // Return false. |
879 | 878 | return false; |
880 | 879 | } |
881 | 880 | |
882 | 881 | // Get user first name. |
883 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
884 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
882 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
883 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
885 | 884 | } |
886 | 885 | |
887 | 886 | // Get user last name. |
888 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
889 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
887 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
888 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
890 | 889 | } |
891 | 890 | |
892 | 891 | // Get the user's billing address details. |
893 | 892 | $user['address'] = array(); |
894 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
895 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
896 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
897 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
898 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
899 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
900 | - |
|
901 | - if ( empty( $user['address']['country'] ) ) { |
|
893 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
894 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
895 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
896 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
897 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
898 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
899 | + |
|
900 | + if (empty($user['address']['country'])) { |
|
902 | 901 | $user['address'] = false; |
903 | 902 | } // End if(). |
904 | 903 | |
905 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
904 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
906 | 905 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
907 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
906 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
908 | 907 | } |
909 | 908 | |
910 | 909 | // Return valid user. |
@@ -923,16 +922,16 @@ discard block |
||
923 | 922 | $card_data = give_get_donation_cc_info(); |
924 | 923 | |
925 | 924 | // Validate the card zip. |
926 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
927 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
928 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
925 | + if ( ! empty($card_data['card_zip'])) { |
|
926 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
927 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
929 | 928 | } |
930 | 929 | } |
931 | 930 | |
932 | 931 | // Ensure no spaces. |
933 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
934 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
935 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
932 | + if ( ! empty($card_data['card_number'])) { |
|
933 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
934 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
936 | 935 | } |
937 | 936 | |
938 | 937 | // This should validate card numbers at some point too. |
@@ -949,17 +948,17 @@ discard block |
||
949 | 948 | function give_get_donation_cc_info() { |
950 | 949 | |
951 | 950 | $cc_info = array(); |
952 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
953 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
954 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
955 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
956 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
957 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
958 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
959 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
960 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
961 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
962 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
951 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
952 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
953 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
954 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
955 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
956 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
957 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
958 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
959 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
960 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
961 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
963 | 962 | |
964 | 963 | // Return cc info. |
965 | 964 | return $cc_info; |
@@ -975,14 +974,14 @@ discard block |
||
975 | 974 | * |
976 | 975 | * @return bool|mixed |
977 | 976 | */ |
978 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
977 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
979 | 978 | $ret = false; |
980 | 979 | |
981 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
980 | + if (empty($zip) || empty($country_code)) { |
|
982 | 981 | return $ret; |
983 | 982 | } |
984 | 983 | |
985 | - $country_code = strtoupper( $country_code ); |
|
984 | + $country_code = strtoupper($country_code); |
|
986 | 985 | |
987 | 986 | $zip_regex = array( |
988 | 987 | 'AD' => 'AD\d{3}', |
@@ -1142,11 +1141,11 @@ discard block |
||
1142 | 1141 | 'ZM' => '\d{5}', |
1143 | 1142 | ); |
1144 | 1143 | |
1145 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1144 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1146 | 1145 | $ret = true; |
1147 | 1146 | } |
1148 | 1147 | |
1149 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1148 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1150 | 1149 | } |
1151 | 1150 | |
1152 | 1151 | |
@@ -1160,33 +1159,33 @@ discard block |
||
1160 | 1159 | * |
1161 | 1160 | * @return bool |
1162 | 1161 | */ |
1163 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1162 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1164 | 1163 | /* @var Give_Donate_Form $form */ |
1165 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1164 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1166 | 1165 | |
1167 | 1166 | $donation_level_matched = false; |
1168 | 1167 | |
1169 | - if ( $form->is_multi_type_donation_form() ) { |
|
1168 | + if ($form->is_multi_type_donation_form()) { |
|
1170 | 1169 | |
1171 | 1170 | // Bailout. |
1172 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1171 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1173 | 1172 | return false; |
1174 | 1173 | } |
1175 | 1174 | |
1176 | 1175 | // Sanitize donation amount. |
1177 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1176 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1178 | 1177 | |
1179 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1178 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1180 | 1179 | return true; |
1181 | 1180 | } |
1182 | 1181 | |
1183 | 1182 | // Find correct donation level from all donation levels. |
1184 | - foreach ( $variable_prices as $variable_price ) { |
|
1183 | + foreach ($variable_prices as $variable_price) { |
|
1185 | 1184 | // Sanitize level amount. |
1186 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1185 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1187 | 1186 | |
1188 | 1187 | // Set first match donation level ID. |
1189 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1188 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1190 | 1189 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1191 | 1190 | $donation_level_matched = true; |
1192 | 1191 | break; |
@@ -1197,19 +1196,19 @@ discard block |
||
1197 | 1196 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1198 | 1197 | if ( |
1199 | 1198 | ! $donation_level_matched |
1200 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1199 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1201 | 1200 | ) { |
1202 | 1201 | // Sanitize custom minimum amount. |
1203 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
1202 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
1204 | 1203 | |
1205 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1204 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1206 | 1205 | $_POST['give-price-id'] = 'custom'; |
1207 | 1206 | $donation_level_matched = true; |
1208 | 1207 | } |
1209 | 1208 | } |
1210 | 1209 | }// End if(). |
1211 | 1210 | |
1212 | - return ( $donation_level_matched ? true : false ); |
|
1211 | + return ($donation_level_matched ? true : false); |
|
1213 | 1212 | } |
1214 | 1213 | |
1215 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1214 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return array $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | }// End switch(). |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
@@ -170,22 +170,22 @@ discard block |
||
170 | 170 | 'price_id' => $payment->price_id, |
171 | 171 | ); |
172 | 172 | |
173 | - $payment->add_donation( $payment->form_id, $args ); |
|
173 | + $payment->add_donation($payment->form_id, $args); |
|
174 | 174 | |
175 | 175 | // Set date if present. |
176 | - if ( isset( $payment_data['post_date'] ) ) { |
|
176 | + if (isset($payment_data['post_date'])) { |
|
177 | 177 | $payment->date = $payment_data['post_date']; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Handle sequential payments. |
181 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
181 | + if (give_get_option('enable_sequential')) { |
|
182 | 182 | $number = give_get_next_payment_number(); |
183 | - $payment->number = give_format_payment_number( $number ); |
|
184 | - update_option( 'give_last_payment_number', $number ); |
|
183 | + $payment->number = give_format_payment_number($number); |
|
184 | + update_option('give_last_payment_number', $number); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | // Clear the user's donation cache. |
188 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
188 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
189 | 189 | |
190 | 190 | // Save payment. |
191 | 191 | $payment->save(); |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * @param int $payment_id The payment ID. |
199 | 199 | * @param array $payment_data Arguments passed. |
200 | 200 | */ |
201 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
201 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
202 | 202 | |
203 | 203 | // Return payment ID upon success. |
204 | - if ( ! empty( $payment->ID ) ) { |
|
204 | + if ( ! empty($payment->ID)) { |
|
205 | 205 | return $payment->ID; |
206 | 206 | } |
207 | 207 | |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return bool|int |
219 | 219 | */ |
220 | -function give_create_payment( $payment_data ) { |
|
220 | +function give_create_payment($payment_data) { |
|
221 | 221 | |
222 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
223 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
222 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
223 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
224 | 224 | |
225 | 225 | // Collect payment data. |
226 | 226 | $insert_payment_data = array( |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @param array $insert_payment_data |
246 | 246 | */ |
247 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
247 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
248 | 248 | |
249 | 249 | // Record the pending payment. |
250 | - return give_insert_payment( $insert_payment_data ); |
|
250 | + return give_insert_payment($insert_payment_data); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return bool |
262 | 262 | */ |
263 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
263 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
264 | 264 | |
265 | 265 | $updated = false; |
266 | - $payment = new Give_Payment( $payment_id ); |
|
266 | + $payment = new Give_Payment($payment_id); |
|
267 | 267 | |
268 | - if( $payment && $payment->ID > 0 ) { |
|
268 | + if ($payment && $payment->ID > 0) { |
|
269 | 269 | |
270 | 270 | $payment->status = $new_status; |
271 | 271 | $updated = $payment->save(); |
@@ -287,38 +287,38 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return void |
289 | 289 | */ |
290 | -function give_delete_donation( $payment_id = 0, $update_donor = true ) { |
|
290 | +function give_delete_donation($payment_id = 0, $update_donor = true) { |
|
291 | 291 | global $give_logs; |
292 | 292 | |
293 | - $payment = new Give_Payment( $payment_id ); |
|
294 | - $amount = give_get_payment_amount( $payment_id ); |
|
293 | + $payment = new Give_Payment($payment_id); |
|
294 | + $amount = give_get_payment_amount($payment_id); |
|
295 | 295 | $status = $payment->post_status; |
296 | - $donor_id = give_get_payment_donor_id( $payment_id ); |
|
297 | - $donor = new Give_Donor( $donor_id ); |
|
296 | + $donor_id = give_get_payment_donor_id($payment_id); |
|
297 | + $donor = new Give_Donor($donor_id); |
|
298 | 298 | |
299 | 299 | // Only undo donations that aren't these statuses. |
300 | - $dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array( |
|
300 | + $dont_undo_statuses = apply_filters('give_undo_donation_statuses', array( |
|
301 | 301 | 'pending', |
302 | 302 | 'cancelled', |
303 | - ) ); |
|
303 | + )); |
|
304 | 304 | |
305 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
306 | - give_undo_donation( $payment_id ); |
|
305 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
306 | + give_undo_donation($payment_id); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( $status == 'publish' ) { |
|
309 | + if ($status == 'publish') { |
|
310 | 310 | |
311 | 311 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
312 | - give_decrease_total_earnings( $amount ); |
|
312 | + give_decrease_total_earnings($amount); |
|
313 | 313 | |
314 | 314 | // @todo: Refresh only range related stat cache |
315 | 315 | give_delete_donation_stats(); |
316 | 316 | |
317 | - if ( $donor->id && $update_donor ) { |
|
317 | + if ($donor->id && $update_donor) { |
|
318 | 318 | |
319 | 319 | // Decrement the stats for the donor. |
320 | 320 | $donor->decrease_donation_count(); |
321 | - $donor->decrease_value( $amount ); |
|
321 | + $donor->decrease_value($amount); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | } |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @param int $payment_id Payment ID. |
332 | 332 | */ |
333 | - do_action( 'give_payment_delete', $payment_id ); |
|
333 | + do_action('give_payment_delete', $payment_id); |
|
334 | 334 | |
335 | - if ( $donor->id && $update_donor ) { |
|
335 | + if ($donor->id && $update_donor) { |
|
336 | 336 | |
337 | 337 | // Remove the payment ID from the donor. |
338 | - $donor->remove_payment( $payment_id ); |
|
338 | + $donor->remove_payment($payment_id); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | 342 | // Remove the payment. |
343 | - wp_delete_post( $payment_id, true ); |
|
343 | + wp_delete_post($payment_id, true); |
|
344 | 344 | |
345 | 345 | // Remove related sale log entries. |
346 | - $give_logs->delete_logs( null, 'sale', array( |
|
346 | + $give_logs->delete_logs(null, 'sale', array( |
|
347 | 347 | array( |
348 | 348 | 'key' => '_give_log_payment_id', |
349 | 349 | 'value' => $payment_id, |
350 | 350 | ), |
351 | - ) ); |
|
351 | + )); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Fires after payment deleted. |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @param int $payment_id Payment ID. |
359 | 359 | */ |
360 | - do_action( 'give_payment_deleted', $payment_id ); |
|
360 | + do_action('give_payment_deleted', $payment_id); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return void |
374 | 374 | */ |
375 | -function give_undo_donation( $payment_id ) { |
|
375 | +function give_undo_donation($payment_id) { |
|
376 | 376 | |
377 | - $payment = new Give_Payment( $payment_id ); |
|
377 | + $payment = new Give_Payment($payment_id); |
|
378 | 378 | |
379 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
380 | - if ( true === $maybe_decrease_earnings ) { |
|
379 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
380 | + if (true === $maybe_decrease_earnings) { |
|
381 | 381 | // Decrease earnings. |
382 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
382 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
383 | 383 | } |
384 | 384 | |
385 | - $maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id ); |
|
386 | - if ( true === $maybe_decrease_donations ) { |
|
385 | + $maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id); |
|
386 | + if (true === $maybe_decrease_donations) { |
|
387 | 387 | // Decrease donation count. |
388 | - give_decrease_donation_count( $payment->form_id ); |
|
388 | + give_decrease_donation_count($payment->form_id); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return object $stats Contains the number of payments per payment status. |
404 | 404 | */ |
405 | -function give_count_payments( $args = array() ) { |
|
405 | +function give_count_payments($args = array()) { |
|
406 | 406 | |
407 | 407 | global $wpdb; |
408 | 408 | |
@@ -414,18 +414,18 @@ discard block |
||
414 | 414 | 'form_id' => null, |
415 | 415 | ); |
416 | 416 | |
417 | - $args = wp_parse_args( $args, $defaults ); |
|
417 | + $args = wp_parse_args($args, $defaults); |
|
418 | 418 | |
419 | 419 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
420 | 420 | $join = ''; |
421 | - $where = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('". implode( "','", give_get_payment_status_keys() ). "')"; |
|
421 | + $where = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')"; |
|
422 | 422 | |
423 | 423 | // Count payments for a specific user. |
424 | - if ( ! empty( $args['user'] ) ) { |
|
424 | + if ( ! empty($args['user'])) { |
|
425 | 425 | |
426 | - if ( is_email( $args['user'] ) ) { |
|
426 | + if (is_email($args['user'])) { |
|
427 | 427 | $field = 'email'; |
428 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
428 | + } elseif (is_numeric($args['user'])) { |
|
429 | 429 | $field = 'id'; |
430 | 430 | } else { |
431 | 431 | $field = ''; |
@@ -433,107 +433,107 @@ discard block |
||
433 | 433 | |
434 | 434 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
435 | 435 | |
436 | - if ( ! empty( $field ) ) { |
|
436 | + if ( ! empty($field)) { |
|
437 | 437 | $where .= " |
438 | 438 | AND m.meta_key = '_give_payment_user_{$field}' |
439 | 439 | AND m.meta_value = '{$args['user']}'"; |
440 | 440 | } |
441 | - } elseif ( ! empty( $args['donor'] ) ) { |
|
441 | + } elseif ( ! empty($args['donor'])) { |
|
442 | 442 | |
443 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
443 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
444 | 444 | $where .= " |
445 | 445 | AND m.meta_key = '_give_payment_customer_id' |
446 | 446 | AND m.meta_value = '{$args['donor']}'"; |
447 | 447 | |
448 | 448 | // Count payments for a search. |
449 | - } elseif ( ! empty( $args['s'] ) ) { |
|
449 | + } elseif ( ! empty($args['s'])) { |
|
450 | 450 | |
451 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
451 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
452 | 452 | |
453 | - if ( is_email( $args['s'] ) ) { |
|
453 | + if (is_email($args['s'])) { |
|
454 | 454 | $field = '_give_payment_user_email'; |
455 | 455 | } else { |
456 | 456 | $field = '_give_payment_purchase_key'; |
457 | 457 | } |
458 | 458 | |
459 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
460 | - $where .= $wpdb->prepare( ' |
|
459 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
460 | + $where .= $wpdb->prepare(' |
|
461 | 461 | AND m.meta_key = %s |
462 | - AND m.meta_value = %s', $field, $args['s'] ); |
|
462 | + AND m.meta_value = %s', $field, $args['s']); |
|
463 | 463 | |
464 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
464 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
465 | 465 | |
466 | - $search = str_replace( '#:', '', $args['s'] ); |
|
467 | - $search = str_replace( '#', '', $search ); |
|
466 | + $search = str_replace('#:', '', $args['s']); |
|
467 | + $search = str_replace('#', '', $search); |
|
468 | 468 | |
469 | 469 | $select = 'SELECT p.post_status,count( * ) AS num_posts '; |
470 | 470 | $join = ''; |
471 | - $where = $wpdb->prepare( 'WHERE p.post_type=%s AND p.ID = %d ', 'give_payment', $search ); |
|
471 | + $where = $wpdb->prepare('WHERE p.post_type=%s AND p.ID = %d ', 'give_payment', $search); |
|
472 | 472 | |
473 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
473 | + } elseif (is_numeric($args['s'])) { |
|
474 | 474 | |
475 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
476 | - $where .= $wpdb->prepare( " |
|
475 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
476 | + $where .= $wpdb->prepare(" |
|
477 | 477 | AND m.meta_key = '_give_payment_user_id' |
478 | - AND m.meta_value = %d", $args['s'] ); |
|
478 | + AND m.meta_value = %d", $args['s']); |
|
479 | 479 | |
480 | 480 | } else { |
481 | - $search = $wpdb->esc_like( $args['s'] ); |
|
482 | - $search = '%' . $search . '%'; |
|
481 | + $search = $wpdb->esc_like($args['s']); |
|
482 | + $search = '%'.$search.'%'; |
|
483 | 483 | |
484 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
484 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
485 | 485 | }// End if(). |
486 | 486 | }// End if(). |
487 | 487 | |
488 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
488 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
489 | 489 | |
490 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
491 | - $where .= $wpdb->prepare( ' |
|
490 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
491 | + $where .= $wpdb->prepare(' |
|
492 | 492 | AND m.meta_key = %s |
493 | - AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] ); |
|
493 | + AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | // Limit payments count by date. |
497 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
497 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
498 | 498 | |
499 | - $date_parts = explode( '/', $args['start-date'] ); |
|
500 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
501 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
502 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
499 | + $date_parts = explode('/', $args['start-date']); |
|
500 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
501 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
502 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
503 | 503 | |
504 | - $is_date = checkdate( $month, $day, $year ); |
|
505 | - if ( false !== $is_date ) { |
|
504 | + $is_date = checkdate($month, $day, $year); |
|
505 | + if (false !== $is_date) { |
|
506 | 506 | |
507 | - $date = new DateTime( $args['start-date'] ); |
|
508 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
507 | + $date = new DateTime($args['start-date']); |
|
508 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
509 | 509 | |
510 | 510 | } |
511 | 511 | |
512 | 512 | // Fixes an issue with the payments list table counts when no end date is specified (with stats class). |
513 | - if ( empty( $args['end-date'] ) ) { |
|
513 | + if (empty($args['end-date'])) { |
|
514 | 514 | $args['end-date'] = $args['start-date']; |
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
518 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
518 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
519 | 519 | |
520 | - $date_parts = explode( '/', $args['end-date'] ); |
|
520 | + $date_parts = explode('/', $args['end-date']); |
|
521 | 521 | |
522 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
523 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
524 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
522 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
523 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
524 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
525 | 525 | |
526 | - $is_date = checkdate( $month, $day, $year ); |
|
527 | - if ( false !== $is_date ) { |
|
526 | + $is_date = checkdate($month, $day, $year); |
|
527 | + if (false !== $is_date) { |
|
528 | 528 | |
529 | - $date = new DateTime( $args['end-date'] ); |
|
530 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
529 | + $date = new DateTime($args['end-date']); |
|
530 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
535 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
536 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
535 | + $where = apply_filters('give_count_payments_where', $where); |
|
536 | + $join = apply_filters('give_count_payments_join', $join); |
|
537 | 537 | |
538 | 538 | $query = "$select |
539 | 539 | FROM $wpdb->posts p |
@@ -542,36 +542,36 @@ discard block |
||
542 | 542 | GROUP BY p.post_status |
543 | 543 | "; |
544 | 544 | |
545 | - $cache_key = md5( $query ); |
|
545 | + $cache_key = md5($query); |
|
546 | 546 | |
547 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
548 | - if ( false !== $count ) { |
|
547 | + $count = wp_cache_get($cache_key, 'counts'); |
|
548 | + if (false !== $count) { |
|
549 | 549 | return $count; |
550 | 550 | } |
551 | 551 | |
552 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
552 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
553 | 553 | |
554 | 554 | $stats = array(); |
555 | 555 | $statuses = get_post_stati(); |
556 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
557 | - unset( $statuses['private'] ); |
|
556 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
557 | + unset($statuses['private']); |
|
558 | 558 | } |
559 | 559 | |
560 | - foreach ( $statuses as $state ) { |
|
561 | - $stats[ $state ] = 0; |
|
560 | + foreach ($statuses as $state) { |
|
561 | + $stats[$state] = 0; |
|
562 | 562 | } |
563 | 563 | |
564 | - foreach ( (array) $count as $row ) { |
|
564 | + foreach ((array) $count as $row) { |
|
565 | 565 | |
566 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
566 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
567 | 567 | continue; |
568 | 568 | } |
569 | 569 | |
570 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
570 | + $stats[$row['post_status']] = $row['num_posts']; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | $stats = (object) $stats; |
574 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
574 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
575 | 575 | |
576 | 576 | return $stats; |
577 | 577 | } |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | * |
587 | 587 | * @return bool $exists True if payment exists, false otherwise. |
588 | 588 | */ |
589 | -function give_check_for_existing_payment( $payment_id ) { |
|
589 | +function give_check_for_existing_payment($payment_id) { |
|
590 | 590 | $exists = false; |
591 | - $payment = new Give_Payment( $payment_id ); |
|
591 | + $payment = new Give_Payment($payment_id); |
|
592 | 592 | |
593 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
593 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
594 | 594 | $exists = true; |
595 | 595 | } |
596 | 596 | |
@@ -608,41 +608,41 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return bool|mixed True if payment status exists, false otherwise. |
610 | 610 | */ |
611 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
611 | +function give_get_payment_status($payment, $return_label = false) { |
|
612 | 612 | |
613 | - if( is_numeric( $payment ) ) { |
|
613 | + if (is_numeric($payment)) { |
|
614 | 614 | |
615 | - $payment = new Give_Payment( $payment ); |
|
615 | + $payment = new Give_Payment($payment); |
|
616 | 616 | |
617 | - if( ! $payment->ID > 0 ) { |
|
617 | + if ( ! $payment->ID > 0) { |
|
618 | 618 | return false; |
619 | 619 | } |
620 | 620 | |
621 | 621 | } |
622 | 622 | |
623 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
623 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
627 | 627 | $statuses = give_get_payment_statuses(); |
628 | 628 | |
629 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
629 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
630 | 630 | return false; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Get payment object if not already given. |
634 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
634 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
635 | 635 | |
636 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
637 | - if ( true === $return_label ) { |
|
636 | + if (array_key_exists($payment->status, $statuses)) { |
|
637 | + if (true === $return_label) { |
|
638 | 638 | // Return translated status label. |
639 | - return $statuses[ $payment->status ]; |
|
639 | + return $statuses[$payment->status]; |
|
640 | 640 | } else { |
641 | 641 | // Account that our 'publish' status is labeled 'Complete' |
642 | 642 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
643 | 643 | |
644 | 644 | // Make sure we're matching cases, since they matter |
645 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
645 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
646 | 646 | } |
647 | 647 | } |
648 | 648 | |
@@ -658,18 +658,18 @@ discard block |
||
658 | 658 | */ |
659 | 659 | function give_get_payment_statuses() { |
660 | 660 | $payment_statuses = array( |
661 | - 'pending' => __( 'Pending', 'give' ), |
|
662 | - 'publish' => __( 'Complete', 'give' ), |
|
663 | - 'refunded' => __( 'Refunded', 'give' ), |
|
664 | - 'failed' => __( 'Failed', 'give' ), |
|
665 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
666 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
667 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
668 | - 'processing' => __( 'Processing', 'give' ), |
|
669 | - 'revoked' => __( 'Revoked', 'give' ), |
|
661 | + 'pending' => __('Pending', 'give'), |
|
662 | + 'publish' => __('Complete', 'give'), |
|
663 | + 'refunded' => __('Refunded', 'give'), |
|
664 | + 'failed' => __('Failed', 'give'), |
|
665 | + 'cancelled' => __('Cancelled', 'give'), |
|
666 | + 'abandoned' => __('Abandoned', 'give'), |
|
667 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
668 | + 'processing' => __('Processing', 'give'), |
|
669 | + 'revoked' => __('Revoked', 'give'), |
|
670 | 670 | ); |
671 | 671 | |
672 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
672 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | * @return array $payment_status All the available payment statuses. |
683 | 683 | */ |
684 | 684 | function give_get_payment_status_keys() { |
685 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
686 | - asort( $statuses ); |
|
685 | + $statuses = array_keys(give_get_payment_statuses()); |
|
686 | + asort($statuses); |
|
687 | 687 | |
688 | - return array_values( $statuses ); |
|
688 | + return array_values($statuses); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return int $earnings Earnings |
702 | 702 | */ |
703 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
703 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
704 | 704 | |
705 | 705 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
706 | 706 | global $wpdb; |
@@ -710,41 +710,41 @@ discard block |
||
710 | 710 | 'nopaging' => true, |
711 | 711 | 'year' => $year, |
712 | 712 | 'monthnum' => $month_num, |
713 | - 'post_status' => array( 'publish' ), |
|
713 | + 'post_status' => array('publish'), |
|
714 | 714 | 'fields' => 'ids', |
715 | 715 | 'update_post_term_cache' => false, |
716 | 716 | ); |
717 | - if ( ! empty( $day ) ) { |
|
717 | + if ( ! empty($day)) { |
|
718 | 718 | $args['day'] = $day; |
719 | 719 | } |
720 | 720 | |
721 | - if ( ! empty( $hour ) ) { |
|
721 | + if ( ! empty($hour)) { |
|
722 | 722 | $args['hour'] = $hour; |
723 | 723 | } |
724 | 724 | |
725 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
726 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
725 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
726 | + $key = Give_Cache::get_key('give_stats', $args); |
|
727 | 727 | |
728 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
728 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
729 | 729 | $earnings = false; |
730 | 730 | } else { |
731 | - $earnings = Give_Cache::get( $key ); |
|
731 | + $earnings = Give_Cache::get($key); |
|
732 | 732 | } |
733 | 733 | |
734 | - if ( false === $earnings ) { |
|
735 | - $donations = get_posts( $args ); |
|
734 | + if (false === $earnings) { |
|
735 | + $donations = get_posts($args); |
|
736 | 736 | $earnings = 0; |
737 | - if ( $donations ) { |
|
738 | - $donations = implode( ',', $donations ); |
|
737 | + if ($donations) { |
|
738 | + $donations = implode(',', $donations); |
|
739 | 739 | |
740 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" ); |
|
740 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})"); |
|
741 | 741 | |
742 | 742 | } |
743 | 743 | // Cache the results for one hour. |
744 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
744 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
745 | 745 | } |
746 | 746 | |
747 | - return round( $earnings, 2 ); |
|
747 | + return round($earnings, 2); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * |
760 | 760 | * @return int $count Sales |
761 | 761 | */ |
762 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
762 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
763 | 763 | |
764 | 764 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
765 | 765 | $args = array( |
@@ -767,14 +767,14 @@ discard block |
||
767 | 767 | 'nopaging' => true, |
768 | 768 | 'year' => $year, |
769 | 769 | 'fields' => 'ids', |
770 | - 'post_status' => array( 'publish' ), |
|
770 | + 'post_status' => array('publish'), |
|
771 | 771 | 'update_post_meta_cache' => false, |
772 | 772 | 'update_post_term_cache' => false, |
773 | 773 | ); |
774 | 774 | |
775 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
775 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
776 | 776 | |
777 | - if ( false === $show_free ) { |
|
777 | + if (false === $show_free) { |
|
778 | 778 | $args['meta_query'] = array( |
779 | 779 | array( |
780 | 780 | 'key' => '_give_payment_total', |
@@ -785,33 +785,33 @@ discard block |
||
785 | 785 | ); |
786 | 786 | } |
787 | 787 | |
788 | - if ( ! empty( $month_num ) ) { |
|
788 | + if ( ! empty($month_num)) { |
|
789 | 789 | $args['monthnum'] = $month_num; |
790 | 790 | } |
791 | 791 | |
792 | - if ( ! empty( $day ) ) { |
|
792 | + if ( ! empty($day)) { |
|
793 | 793 | $args['day'] = $day; |
794 | 794 | } |
795 | 795 | |
796 | - if ( ! empty( $hour ) ) { |
|
796 | + if ( ! empty($hour)) { |
|
797 | 797 | $args['hour'] = $hour; |
798 | 798 | } |
799 | 799 | |
800 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
800 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
801 | 801 | |
802 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
802 | + $key = Give_Cache::get_key('give_stats', $args); |
|
803 | 803 | |
804 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
804 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
805 | 805 | $count = false; |
806 | 806 | } else { |
807 | - $count = Give_Cache::get( $key ); |
|
807 | + $count = Give_Cache::get($key); |
|
808 | 808 | } |
809 | 809 | |
810 | - if ( false === $count ) { |
|
811 | - $donations = new WP_Query( $args ); |
|
810 | + if (false === $count) { |
|
811 | + $donations = new WP_Query($args); |
|
812 | 812 | $count = (int) $donations->post_count; |
813 | 813 | // Cache the results for one hour. |
814 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
814 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | return $count; |
@@ -826,19 +826,19 @@ discard block |
||
826 | 826 | * |
827 | 827 | * @return bool $ret True if complete, false otherwise. |
828 | 828 | */ |
829 | -function give_is_payment_complete( $payment_id ) { |
|
830 | - $payment = new Give_Payment( $payment_id ); |
|
829 | +function give_is_payment_complete($payment_id) { |
|
830 | + $payment = new Give_Payment($payment_id); |
|
831 | 831 | |
832 | 832 | $ret = false; |
833 | 833 | |
834 | - if ( $payment->ID > 0 ) { |
|
834 | + if ($payment->ID > 0) { |
|
835 | 835 | |
836 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
836 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
837 | 837 | $ret = true; |
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
841 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -864,49 +864,49 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return float $total Total earnings. |
866 | 866 | */ |
867 | -function give_get_total_earnings( $recalculate = false ) { |
|
867 | +function give_get_total_earnings($recalculate = false) { |
|
868 | 868 | |
869 | - $total = get_option( 'give_earnings_total', 0 ); |
|
869 | + $total = get_option('give_earnings_total', 0); |
|
870 | 870 | |
871 | 871 | // Calculate total earnings. |
872 | - if ( ! $total || $recalculate ) { |
|
872 | + if ( ! $total || $recalculate) { |
|
873 | 873 | global $wpdb; |
874 | 874 | |
875 | 875 | $total = (float) 0; |
876 | 876 | |
877 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
877 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
878 | 878 | 'offset' => 0, |
879 | - 'number' => - 1, |
|
880 | - 'status' => array( 'publish' ), |
|
879 | + 'number' => -1, |
|
880 | + 'status' => array('publish'), |
|
881 | 881 | 'fields' => 'ids', |
882 | - ) ); |
|
882 | + )); |
|
883 | 883 | |
884 | - $payments = give_get_payments( $args ); |
|
885 | - if ( $payments ) { |
|
884 | + $payments = give_get_payments($args); |
|
885 | + if ($payments) { |
|
886 | 886 | |
887 | 887 | /** |
888 | 888 | * If performing a donation, we need to skip the very last payment in the database, |
889 | 889 | * since it calls give_increase_total_earnings() on completion, |
890 | 890 | * which results in duplicated earnings for the very first donation. |
891 | 891 | */ |
892 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
893 | - array_pop( $payments ); |
|
892 | + if (did_action('give_update_payment_status')) { |
|
893 | + array_pop($payments); |
|
894 | 894 | } |
895 | 895 | |
896 | - if ( ! empty( $payments ) ) { |
|
897 | - $payments = implode( ',', $payments ); |
|
898 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
896 | + if ( ! empty($payments)) { |
|
897 | + $payments = implode(',', $payments); |
|
898 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
902 | + update_option('give_earnings_total', $total, 'no'); |
|
903 | 903 | } |
904 | 904 | |
905 | - if ( $total < 0 ) { |
|
905 | + if ($total < 0) { |
|
906 | 906 | $total = 0; // Don't ever show negative earnings. |
907 | 907 | } |
908 | 908 | |
909 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
909 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -919,10 +919,10 @@ discard block |
||
919 | 919 | * |
920 | 920 | * @return float $total Total earnings. |
921 | 921 | */ |
922 | -function give_increase_total_earnings( $amount = 0 ) { |
|
922 | +function give_increase_total_earnings($amount = 0) { |
|
923 | 923 | $total = give_get_total_earnings(); |
924 | 924 | $total += $amount; |
925 | - update_option( 'give_earnings_total', $total ); |
|
925 | + update_option('give_earnings_total', $total); |
|
926 | 926 | |
927 | 927 | return $total; |
928 | 928 | } |
@@ -936,13 +936,13 @@ discard block |
||
936 | 936 | * |
937 | 937 | * @return float $total Total earnings. |
938 | 938 | */ |
939 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
939 | +function give_decrease_total_earnings($amount = 0) { |
|
940 | 940 | $total = give_get_total_earnings(); |
941 | 941 | $total -= $amount; |
942 | - if ( $total < 0 ) { |
|
942 | + if ($total < 0) { |
|
943 | 943 | $total = 0; |
944 | 944 | } |
945 | - update_option( 'give_earnings_total', $total ); |
|
945 | + update_option('give_earnings_total', $total); |
|
946 | 946 | |
947 | 947 | return $total; |
948 | 948 | } |
@@ -958,10 +958,10 @@ discard block |
||
958 | 958 | * |
959 | 959 | * @return mixed $meta Payment Meta. |
960 | 960 | */ |
961 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
962 | - $payment = new Give_Payment( $payment_id ); |
|
961 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
962 | + $payment = new Give_Payment($payment_id); |
|
963 | 963 | |
964 | - return $payment->get_meta( $meta_key, $single ); |
|
964 | + return $payment->get_meta($meta_key, $single); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | /** |
@@ -974,10 +974,10 @@ discard block |
||
974 | 974 | * |
975 | 975 | * @return mixed Meta ID if successful, false if unsuccessful. |
976 | 976 | */ |
977 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
978 | - $payment = new Give_Payment( $payment_id ); |
|
977 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
978 | + $payment = new Give_Payment($payment_id); |
|
979 | 979 | |
980 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
980 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | /** |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | * |
990 | 990 | * @return array $user_info User Info Meta Values. |
991 | 991 | */ |
992 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
993 | - $payment = new Give_Payment( $payment_id ); |
|
992 | +function give_get_payment_meta_user_info($payment_id) { |
|
993 | + $payment = new Give_Payment($payment_id); |
|
994 | 994 | |
995 | 995 | return $payment->user_info; |
996 | 996 | } |
@@ -1006,8 +1006,8 @@ discard block |
||
1006 | 1006 | * |
1007 | 1007 | * @return int $form_id Form ID. |
1008 | 1008 | */ |
1009 | -function give_get_payment_form_id( $payment_id ) { |
|
1010 | - $payment = new Give_Payment( $payment_id ); |
|
1009 | +function give_get_payment_form_id($payment_id) { |
|
1010 | + $payment = new Give_Payment($payment_id); |
|
1011 | 1011 | |
1012 | 1012 | return $payment->form_id; |
1013 | 1013 | } |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | * |
1022 | 1022 | * @return string $email User email. |
1023 | 1023 | */ |
1024 | -function give_get_payment_user_email( $payment_id ) { |
|
1025 | - $payment = new Give_Payment( $payment_id ); |
|
1024 | +function give_get_payment_user_email($payment_id) { |
|
1025 | + $payment = new Give_Payment($payment_id); |
|
1026 | 1026 | |
1027 | 1027 | return $payment->email; |
1028 | 1028 | } |
@@ -1036,11 +1036,11 @@ discard block |
||
1036 | 1036 | * |
1037 | 1037 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
1038 | 1038 | */ |
1039 | -function give_is_guest_payment( $payment_id ) { |
|
1040 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1041 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1039 | +function give_is_guest_payment($payment_id) { |
|
1040 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1041 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1042 | 1042 | |
1043 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1043 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | /** |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | * |
1053 | 1053 | * @return int $user_id User ID. |
1054 | 1054 | */ |
1055 | -function give_get_payment_user_id( $payment_id ) { |
|
1056 | - $payment = new Give_Payment( $payment_id ); |
|
1055 | +function give_get_payment_user_id($payment_id) { |
|
1056 | + $payment = new Give_Payment($payment_id); |
|
1057 | 1057 | |
1058 | 1058 | return $payment->user_id; |
1059 | 1059 | } |
@@ -1067,8 +1067,8 @@ discard block |
||
1067 | 1067 | * |
1068 | 1068 | * @return int $payment->customer_id Donor ID. |
1069 | 1069 | */ |
1070 | -function give_get_payment_donor_id( $payment_id ) { |
|
1071 | - $payment = new Give_Payment( $payment_id ); |
|
1070 | +function give_get_payment_donor_id($payment_id) { |
|
1071 | + $payment = new Give_Payment($payment_id); |
|
1072 | 1072 | |
1073 | 1073 | return $payment->customer_id; |
1074 | 1074 | } |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return string $ip User IP. |
1084 | 1084 | */ |
1085 | -function give_get_payment_user_ip( $payment_id ) { |
|
1086 | - $payment = new Give_Payment( $payment_id ); |
|
1085 | +function give_get_payment_user_ip($payment_id) { |
|
1086 | + $payment = new Give_Payment($payment_id); |
|
1087 | 1087 | |
1088 | 1088 | return $payment->ip; |
1089 | 1089 | } |
@@ -1097,8 +1097,8 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return string $date The date the payment was completed. |
1099 | 1099 | */ |
1100 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1101 | - $payment = new Give_Payment( $payment_id ); |
|
1100 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1101 | + $payment = new Give_Payment($payment_id); |
|
1102 | 1102 | |
1103 | 1103 | return $payment->completed_date; |
1104 | 1104 | } |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | * |
1113 | 1113 | * @return string $gateway Gateway. |
1114 | 1114 | */ |
1115 | -function give_get_payment_gateway( $payment_id ) { |
|
1116 | - $payment = new Give_Payment( $payment_id ); |
|
1115 | +function give_get_payment_gateway($payment_id) { |
|
1116 | + $payment = new Give_Payment($payment_id); |
|
1117 | 1117 | |
1118 | 1118 | return $payment->gateway; |
1119 | 1119 | } |
@@ -1127,8 +1127,8 @@ discard block |
||
1127 | 1127 | * |
1128 | 1128 | * @return string $currency The currency code. |
1129 | 1129 | */ |
1130 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1131 | - $payment = new Give_Payment( $payment_id ); |
|
1130 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1131 | + $payment = new Give_Payment($payment_id); |
|
1132 | 1132 | |
1133 | 1133 | return $payment->currency; |
1134 | 1134 | } |
@@ -1142,10 +1142,10 @@ discard block |
||
1142 | 1142 | * |
1143 | 1143 | * @return string $currency The currency name. |
1144 | 1144 | */ |
1145 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1146 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1145 | +function give_get_payment_currency($payment_id = 0) { |
|
1146 | + $currency = give_get_payment_currency_code($payment_id); |
|
1147 | 1147 | |
1148 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1148 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | /** |
@@ -1157,8 +1157,8 @@ discard block |
||
1157 | 1157 | * |
1158 | 1158 | * @return string $key Donation key. |
1159 | 1159 | */ |
1160 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1161 | - $payment = new Give_Payment( $payment_id ); |
|
1160 | +function give_get_payment_key($payment_id = 0) { |
|
1161 | + $payment = new Give_Payment($payment_id); |
|
1162 | 1162 | |
1163 | 1163 | return $payment->key; |
1164 | 1164 | } |
@@ -1174,8 +1174,8 @@ discard block |
||
1174 | 1174 | * |
1175 | 1175 | * @return string $number Payment order number. |
1176 | 1176 | */ |
1177 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1178 | - $payment = new Give_Payment( $payment_id ); |
|
1177 | +function give_get_payment_number($payment_id = 0) { |
|
1178 | + $payment = new Give_Payment($payment_id); |
|
1179 | 1179 | |
1180 | 1180 | return $payment->number; |
1181 | 1181 | } |
@@ -1189,23 +1189,23 @@ discard block |
||
1189 | 1189 | * |
1190 | 1190 | * @return string The formatted payment number. |
1191 | 1191 | */ |
1192 | -function give_format_payment_number( $number ) { |
|
1192 | +function give_format_payment_number($number) { |
|
1193 | 1193 | |
1194 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1194 | + if ( ! give_get_option('enable_sequential')) { |
|
1195 | 1195 | return $number; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | - if ( ! is_numeric( $number ) ) { |
|
1198 | + if ( ! is_numeric($number)) { |
|
1199 | 1199 | return $number; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1203 | - $number = absint( $number ); |
|
1204 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1202 | + $prefix = give_get_option('sequential_prefix'); |
|
1203 | + $number = absint($number); |
|
1204 | + $postfix = give_get_option('sequential_postfix'); |
|
1205 | 1205 | |
1206 | - $formatted_number = $prefix . $number . $postfix; |
|
1206 | + $formatted_number = $prefix.$number.$postfix; |
|
1207 | 1207 | |
1208 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1208 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | /** |
@@ -1218,17 +1218,17 @@ discard block |
||
1218 | 1218 | */ |
1219 | 1219 | function give_get_next_payment_number() { |
1220 | 1220 | |
1221 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1221 | + if ( ! give_get_option('enable_sequential')) { |
|
1222 | 1222 | return false; |
1223 | 1223 | } |
1224 | 1224 | |
1225 | - $number = get_option( 'give_last_payment_number' ); |
|
1226 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1225 | + $number = get_option('give_last_payment_number'); |
|
1226 | + $start = give_get_option('sequential_start', 1); |
|
1227 | 1227 | $increment_number = true; |
1228 | 1228 | |
1229 | - if ( false !== $number ) { |
|
1229 | + if (false !== $number) { |
|
1230 | 1230 | |
1231 | - if ( empty( $number ) ) { |
|
1231 | + if (empty($number)) { |
|
1232 | 1232 | |
1233 | 1233 | $number = $start; |
1234 | 1234 | $increment_number = false; |
@@ -1237,24 +1237,24 @@ discard block |
||
1237 | 1237 | } else { |
1238 | 1238 | |
1239 | 1239 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1240 | - $payments = new Give_Payments_Query( array( |
|
1240 | + $payments = new Give_Payments_Query(array( |
|
1241 | 1241 | 'number' => 1, |
1242 | 1242 | 'order' => 'DESC', |
1243 | 1243 | 'orderby' => 'ID', |
1244 | 1244 | 'output' => 'posts', |
1245 | 1245 | 'fields' => 'ids', |
1246 | - ) ); |
|
1246 | + )); |
|
1247 | 1247 | $last_payment = $payments->get_payments(); |
1248 | 1248 | |
1249 | - if ( ! empty( $last_payment ) ) { |
|
1249 | + if ( ! empty($last_payment)) { |
|
1250 | 1250 | |
1251 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1251 | + $number = give_get_payment_number($last_payment[0]); |
|
1252 | 1252 | |
1253 | 1253 | } |
1254 | 1254 | |
1255 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1255 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1256 | 1256 | |
1257 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1257 | + $number = give_remove_payment_prefix_postfix($number); |
|
1258 | 1258 | |
1259 | 1259 | } else { |
1260 | 1260 | |
@@ -1263,13 +1263,13 @@ discard block |
||
1263 | 1263 | } |
1264 | 1264 | }// End if(). |
1265 | 1265 | |
1266 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1266 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1267 | 1267 | |
1268 | - if ( $increment_number ) { |
|
1269 | - $number ++; |
|
1268 | + if ($increment_number) { |
|
1269 | + $number++; |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1272 | + return apply_filters('give_get_next_payment_number', $number); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | /** |
@@ -1281,25 +1281,25 @@ discard block |
||
1281 | 1281 | * |
1282 | 1282 | * @return string The new Payment number without prefix and postfix. |
1283 | 1283 | */ |
1284 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1284 | +function give_remove_payment_prefix_postfix($number) { |
|
1285 | 1285 | |
1286 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1287 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1286 | + $prefix = give_get_option('sequential_prefix'); |
|
1287 | + $postfix = give_get_option('sequential_postfix'); |
|
1288 | 1288 | |
1289 | 1289 | // Remove prefix. |
1290 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1290 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1291 | 1291 | |
1292 | 1292 | // Remove the postfix. |
1293 | - $length = strlen( $number ); |
|
1294 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1295 | - if ( false !== $postfix_pos ) { |
|
1296 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1293 | + $length = strlen($number); |
|
1294 | + $postfix_pos = strrpos($number, $postfix); |
|
1295 | + if (false !== $postfix_pos) { |
|
1296 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | // Ensure it's a whole number. |
1300 | - $number = intval( $number ); |
|
1300 | + $number = intval($number); |
|
1301 | 1301 | |
1302 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1302 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1303 | 1303 | |
1304 | 1304 | } |
1305 | 1305 | |
@@ -1316,10 +1316,10 @@ discard block |
||
1316 | 1316 | * |
1317 | 1317 | * @return string $amount Fully formatted payment amount. |
1318 | 1318 | */ |
1319 | -function give_payment_amount( $payment_id = 0 ) { |
|
1320 | - $amount = give_get_payment_amount( $payment_id ); |
|
1319 | +function give_payment_amount($payment_id = 0) { |
|
1320 | + $amount = give_get_payment_amount($payment_id); |
|
1321 | 1321 | |
1322 | - return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) ); |
|
1322 | + return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id)); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | /** |
@@ -1332,11 +1332,11 @@ discard block |
||
1332 | 1332 | * |
1333 | 1333 | * @return mixed |
1334 | 1334 | */ |
1335 | -function give_get_payment_amount( $payment_id ) { |
|
1335 | +function give_get_payment_amount($payment_id) { |
|
1336 | 1336 | |
1337 | - $payment = new Give_Payment( $payment_id ); |
|
1337 | + $payment = new Give_Payment($payment_id); |
|
1338 | 1338 | |
1339 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1339 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | /** |
@@ -1353,10 +1353,10 @@ discard block |
||
1353 | 1353 | * |
1354 | 1354 | * @return array Fully formatted payment subtotal. |
1355 | 1355 | */ |
1356 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1357 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1356 | +function give_payment_subtotal($payment_id = 0) { |
|
1357 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1358 | 1358 | |
1359 | - return give_currency_filter( give_format_amount( $subtotal , array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) ); |
|
1359 | + return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id)); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
@@ -1370,8 +1370,8 @@ discard block |
||
1370 | 1370 | * |
1371 | 1371 | * @return float $subtotal Subtotal for payment (non formatted). |
1372 | 1372 | */ |
1373 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1374 | - $payment = new Give_Payment( $payment_id ); |
|
1373 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1374 | + $payment = new Give_Payment($payment_id); |
|
1375 | 1375 | |
1376 | 1376 | return $payment->subtotal; |
1377 | 1377 | } |
@@ -1385,8 +1385,8 @@ discard block |
||
1385 | 1385 | * |
1386 | 1386 | * @return string The donation ID. |
1387 | 1387 | */ |
1388 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1389 | - $payment = new Give_Payment( $payment_id ); |
|
1388 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1389 | + $payment = new Give_Payment($payment_id); |
|
1390 | 1390 | |
1391 | 1391 | return $payment->transaction_id; |
1392 | 1392 | } |
@@ -1401,15 +1401,15 @@ discard block |
||
1401 | 1401 | * |
1402 | 1402 | * @return bool|mixed |
1403 | 1403 | */ |
1404 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1404 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1405 | 1405 | |
1406 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1406 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1407 | 1407 | return false; |
1408 | 1408 | } |
1409 | 1409 | |
1410 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1410 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1411 | 1411 | |
1412 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1412 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | /** |
@@ -1422,12 +1422,12 @@ discard block |
||
1422 | 1422 | * |
1423 | 1423 | * @return int $purchase Donation ID. |
1424 | 1424 | */ |
1425 | -function give_get_purchase_id_by_key( $key ) { |
|
1425 | +function give_get_purchase_id_by_key($key) { |
|
1426 | 1426 | global $wpdb; |
1427 | 1427 | |
1428 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1428 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1429 | 1429 | |
1430 | - if ( $purchase != null ) { |
|
1430 | + if ($purchase != null) { |
|
1431 | 1431 | return $purchase; |
1432 | 1432 | } |
1433 | 1433 | |
@@ -1445,12 +1445,12 @@ discard block |
||
1445 | 1445 | * |
1446 | 1446 | * @return int $purchase Donation ID. |
1447 | 1447 | */ |
1448 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1448 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1449 | 1449 | global $wpdb; |
1450 | 1450 | |
1451 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1451 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1452 | 1452 | |
1453 | - if ( $purchase != null ) { |
|
1453 | + if ($purchase != null) { |
|
1454 | 1454 | return $purchase; |
1455 | 1455 | } |
1456 | 1456 | |
@@ -1467,23 +1467,23 @@ discard block |
||
1467 | 1467 | * |
1468 | 1468 | * @return array $notes Donation Notes |
1469 | 1469 | */ |
1470 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1470 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1471 | 1471 | |
1472 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1472 | + if (empty($payment_id) && empty($search)) { |
|
1473 | 1473 | return false; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1477 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1476 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1477 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1478 | 1478 | |
1479 | - $notes = get_comments( array( |
|
1479 | + $notes = get_comments(array( |
|
1480 | 1480 | 'post_id' => $payment_id, |
1481 | 1481 | 'order' => 'ASC', |
1482 | 1482 | 'search' => $search, |
1483 | - ) ); |
|
1483 | + )); |
|
1484 | 1484 | |
1485 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1486 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1485 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1486 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1487 | 1487 | |
1488 | 1488 | return $notes; |
1489 | 1489 | } |
@@ -1499,8 +1499,8 @@ discard block |
||
1499 | 1499 | * |
1500 | 1500 | * @return int The new note ID |
1501 | 1501 | */ |
1502 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1503 | - if ( empty( $payment_id ) ) { |
|
1502 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1503 | + if (empty($payment_id)) { |
|
1504 | 1504 | return false; |
1505 | 1505 | } |
1506 | 1506 | |
@@ -1512,14 +1512,14 @@ discard block |
||
1512 | 1512 | * @param int $payment_id Payment ID. |
1513 | 1513 | * @param string $note The note. |
1514 | 1514 | */ |
1515 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1515 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1516 | 1516 | |
1517 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1517 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1518 | 1518 | 'comment_post_ID' => $payment_id, |
1519 | 1519 | 'comment_content' => $note, |
1520 | 1520 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1521 | - 'comment_date' => current_time( 'mysql' ), |
|
1522 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1521 | + 'comment_date' => current_time('mysql'), |
|
1522 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1523 | 1523 | 'comment_approved' => 1, |
1524 | 1524 | 'comment_parent' => 0, |
1525 | 1525 | 'comment_author' => '', |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | 'comment_author_email' => '', |
1529 | 1529 | 'comment_type' => 'give_payment_note', |
1530 | 1530 | |
1531 | - ) ) ); |
|
1531 | + ))); |
|
1532 | 1532 | |
1533 | 1533 | /** |
1534 | 1534 | * Fires after payment note inserted. |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | * @param int $payment_id Payment ID. |
1540 | 1540 | * @param string $note The note. |
1541 | 1541 | */ |
1542 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1542 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1543 | 1543 | |
1544 | 1544 | return $note_id; |
1545 | 1545 | } |
@@ -1554,8 +1554,8 @@ discard block |
||
1554 | 1554 | * |
1555 | 1555 | * @return bool True on success, false otherwise. |
1556 | 1556 | */ |
1557 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1558 | - if ( empty( $comment_id ) ) { |
|
1557 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1558 | + if (empty($comment_id)) { |
|
1559 | 1559 | return false; |
1560 | 1560 | } |
1561 | 1561 | |
@@ -1567,9 +1567,9 @@ discard block |
||
1567 | 1567 | * @param int $comment_id Note ID. |
1568 | 1568 | * @param int $payment_id Payment ID. |
1569 | 1569 | */ |
1570 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1570 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1571 | 1571 | |
1572 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1572 | + $ret = wp_delete_comment($comment_id, true); |
|
1573 | 1573 | |
1574 | 1574 | /** |
1575 | 1575 | * Fires after donation note deleted. |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | * @param int $comment_id Note ID. |
1580 | 1580 | * @param int $payment_id Payment ID. |
1581 | 1581 | */ |
1582 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1582 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1583 | 1583 | |
1584 | 1584 | return $ret; |
1585 | 1585 | } |
@@ -1594,32 +1594,32 @@ discard block |
||
1594 | 1594 | * |
1595 | 1595 | * @return string |
1596 | 1596 | */ |
1597 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1597 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1598 | 1598 | |
1599 | - if ( is_numeric( $note ) ) { |
|
1600 | - $note = get_comment( $note ); |
|
1599 | + if (is_numeric($note)) { |
|
1600 | + $note = get_comment($note); |
|
1601 | 1601 | } |
1602 | 1602 | |
1603 | - if ( ! empty( $note->user_id ) ) { |
|
1604 | - $user = get_userdata( $note->user_id ); |
|
1603 | + if ( ! empty($note->user_id)) { |
|
1604 | + $user = get_userdata($note->user_id); |
|
1605 | 1605 | $user = $user->display_name; |
1606 | 1606 | } else { |
1607 | - $user = esc_html__( 'System', 'give' ); |
|
1607 | + $user = esc_html__('System', 'give'); |
|
1608 | 1608 | } |
1609 | 1609 | |
1610 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1610 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1611 | 1611 | |
1612 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1612 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1613 | 1613 | 'give-action' => 'delete_payment_note', |
1614 | 1614 | 'note_id' => $note->comment_ID, |
1615 | 1615 | 'payment_id' => $payment_id, |
1616 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
1616 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
1617 | 1617 | |
1618 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1618 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1619 | 1619 | $note_html .= '<p>'; |
1620 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1620 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1621 | 1621 | $note_html .= $note->comment_content; |
1622 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1622 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1623 | 1623 | $note_html .= '</p>'; |
1624 | 1624 | $note_html .= '</div>'; |
1625 | 1625 | |
@@ -1637,18 +1637,18 @@ discard block |
||
1637 | 1637 | * |
1638 | 1638 | * @return void |
1639 | 1639 | */ |
1640 | -function give_hide_payment_notes( $query ) { |
|
1641 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1642 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1643 | - if ( ! is_array( $types ) ) { |
|
1644 | - $types = array( $types ); |
|
1640 | +function give_hide_payment_notes($query) { |
|
1641 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1642 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1643 | + if ( ! is_array($types)) { |
|
1644 | + $types = array($types); |
|
1645 | 1645 | } |
1646 | 1646 | $types[] = 'give_payment_note'; |
1647 | 1647 | $query->query_vars['type__not_in'] = $types; |
1648 | 1648 | } |
1649 | 1649 | } |
1650 | 1650 | |
1651 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1651 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1652 | 1652 | |
1653 | 1653 | /** |
1654 | 1654 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1660,15 +1660,15 @@ discard block |
||
1660 | 1660 | * |
1661 | 1661 | * @return array $clauses Updated comment clauses. |
1662 | 1662 | */ |
1663 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1664 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1663 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1664 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1665 | 1665 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | return $clauses; |
1669 | 1669 | } |
1670 | 1670 | |
1671 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1671 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1672 | 1672 | |
1673 | 1673 | |
1674 | 1674 | /** |
@@ -1681,15 +1681,15 @@ discard block |
||
1681 | 1681 | * |
1682 | 1682 | * @return string $where |
1683 | 1683 | */ |
1684 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1684 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1685 | 1685 | global $wpdb; |
1686 | 1686 | |
1687 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1687 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1688 | 1688 | |
1689 | 1689 | return $where; |
1690 | 1690 | } |
1691 | 1691 | |
1692 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1692 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1693 | 1693 | |
1694 | 1694 | |
1695 | 1695 | /** |
@@ -1703,32 +1703,32 @@ discard block |
||
1703 | 1703 | * |
1704 | 1704 | * @return array Array of comment counts. |
1705 | 1705 | */ |
1706 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1706 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1707 | 1707 | global $wpdb, $pagenow; |
1708 | 1708 | |
1709 | - if ( 'index.php' != $pagenow ) { |
|
1709 | + if ('index.php' != $pagenow) { |
|
1710 | 1710 | return $stats; |
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | $post_id = (int) $post_id; |
1714 | 1714 | |
1715 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1715 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1716 | 1716 | return $stats; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1719 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1720 | 1720 | |
1721 | - if ( false !== $stats ) { |
|
1721 | + if (false !== $stats) { |
|
1722 | 1722 | return $stats; |
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | $where = 'WHERE comment_type != "give_payment_note"'; |
1726 | 1726 | |
1727 | - if ( $post_id > 0 ) { |
|
1728 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1727 | + if ($post_id > 0) { |
|
1728 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1729 | 1729 | } |
1730 | 1730 | |
1731 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1731 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1732 | 1732 | |
1733 | 1733 | $total = 0; |
1734 | 1734 | $approved = array( |
@@ -1738,30 +1738,30 @@ discard block |
||
1738 | 1738 | 'trash' => 'trash', |
1739 | 1739 | 'post-trashed' => 'post-trashed', |
1740 | 1740 | ); |
1741 | - foreach ( (array) $count as $row ) { |
|
1741 | + foreach ((array) $count as $row) { |
|
1742 | 1742 | // Don't count post-trashed toward totals. |
1743 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1743 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1744 | 1744 | $total += $row['num_comments']; |
1745 | 1745 | } |
1746 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1747 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1746 | + if (isset($approved[$row['comment_approved']])) { |
|
1747 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1748 | 1748 | } |
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | $stats['total_comments'] = $total; |
1752 | - foreach ( $approved as $key ) { |
|
1753 | - if ( empty( $stats[ $key ] ) ) { |
|
1754 | - $stats[ $key ] = 0; |
|
1752 | + foreach ($approved as $key) { |
|
1753 | + if (empty($stats[$key])) { |
|
1754 | + $stats[$key] = 0; |
|
1755 | 1755 | } |
1756 | 1756 | } |
1757 | 1757 | |
1758 | 1758 | $stats = (object) $stats; |
1759 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1759 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1760 | 1760 | |
1761 | 1761 | return $stats; |
1762 | 1762 | } |
1763 | 1763 | |
1764 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1764 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1765 | 1765 | |
1766 | 1766 | |
1767 | 1767 | /** |
@@ -1774,9 +1774,9 @@ discard block |
||
1774 | 1774 | * |
1775 | 1775 | * @return string $where Modified where clause. |
1776 | 1776 | */ |
1777 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1777 | +function give_filter_where_older_than_week($where = '') { |
|
1778 | 1778 | // Payments older than one week. |
1779 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1779 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1780 | 1780 | $where .= " AND post_date <= '{$start}'"; |
1781 | 1781 | |
1782 | 1782 | return $where; |
@@ -1796,38 +1796,38 @@ discard block |
||
1796 | 1796 | * |
1797 | 1797 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1798 | 1798 | */ |
1799 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1799 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1800 | 1800 | |
1801 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1802 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1803 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1801 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1802 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1803 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1804 | 1804 | |
1805 | - if ( $only_level == true ) { |
|
1805 | + if ($only_level == true) { |
|
1806 | 1806 | $form_title = ''; |
1807 | 1807 | } |
1808 | 1808 | |
1809 | 1809 | // If multi-level, append to the form title. |
1810 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1810 | + if (give_has_variable_prices($form_id)) { |
|
1811 | 1811 | |
1812 | 1812 | // Only add separator if there is a form title. |
1813 | - if ( ! empty( $form_title ) ) { |
|
1814 | - $form_title .= ' ' . $separator . ' '; |
|
1813 | + if ( ! empty($form_title)) { |
|
1814 | + $form_title .= ' '.$separator.' '; |
|
1815 | 1815 | } |
1816 | 1816 | |
1817 | 1817 | $form_title .= '<span class="donation-level-text-wrap">'; |
1818 | 1818 | |
1819 | - if ( $price_id == 'custom' ) { |
|
1820 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
1821 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1819 | + if ($price_id == 'custom') { |
|
1820 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
1821 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1822 | 1822 | } else { |
1823 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1823 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | $form_title .= '</span>'; |
1827 | 1827 | |
1828 | 1828 | } |
1829 | 1829 | |
1830 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1830 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1831 | 1831 | |
1832 | 1832 | } |
1833 | 1833 | |
@@ -1841,20 +1841,20 @@ discard block |
||
1841 | 1841 | * |
1842 | 1842 | * @return string $price_id |
1843 | 1843 | */ |
1844 | -function give_get_price_id( $form_id, $price ) { |
|
1844 | +function give_get_price_id($form_id, $price) { |
|
1845 | 1845 | |
1846 | 1846 | $price_id = 0; |
1847 | 1847 | |
1848 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1848 | + if (give_has_variable_prices($form_id)) { |
|
1849 | 1849 | |
1850 | - $levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) ); |
|
1850 | + $levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true)); |
|
1851 | 1851 | |
1852 | - foreach ( $levels as $level ) { |
|
1852 | + foreach ($levels as $level) { |
|
1853 | 1853 | |
1854 | - $level_amount = (float) give_maybe_sanitize_amount( $level['_give_amount'] ); |
|
1854 | + $level_amount = (float) give_maybe_sanitize_amount($level['_give_amount']); |
|
1855 | 1855 | |
1856 | 1856 | // Check that this indeed the recurring price. |
1857 | - if ( $level_amount == $price ) { |
|
1857 | + if ($level_amount == $price) { |
|
1858 | 1858 | |
1859 | 1859 | $price_id = $level['_give_id']['level_id']; |
1860 | 1860 | |
@@ -1879,10 +1879,10 @@ discard block |
||
1879 | 1879 | * |
1880 | 1880 | * @return string |
1881 | 1881 | */ |
1882 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1883 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1882 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1883 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1884 | 1884 | |
1885 | - if ( ! $echo ) { |
|
1885 | + if ( ! $echo) { |
|
1886 | 1886 | return $form_dropdown_html; |
1887 | 1887 | } |
1888 | 1888 | |
@@ -1899,17 +1899,17 @@ discard block |
||
1899 | 1899 | * |
1900 | 1900 | * @return string|bool |
1901 | 1901 | */ |
1902 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1902 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1903 | 1903 | |
1904 | 1904 | // Check for give form id. |
1905 | - if ( empty( $args['id'] ) ) { |
|
1905 | + if (empty($args['id'])) { |
|
1906 | 1906 | return false; |
1907 | 1907 | } |
1908 | 1908 | |
1909 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1909 | + $form = new Give_Donate_Form($args['id']); |
|
1910 | 1910 | |
1911 | 1911 | // Check if form has variable prices or not. |
1912 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1912 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1913 | 1913 | return false; |
1914 | 1914 | } |
1915 | 1915 | |
@@ -1917,24 +1917,24 @@ discard block |
||
1917 | 1917 | $variable_price_options = array(); |
1918 | 1918 | |
1919 | 1919 | // Check if multi donation form support custom donation or not. |
1920 | - if ( $form->is_custom_price_mode() ) { |
|
1921 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1920 | + if ($form->is_custom_price_mode()) { |
|
1921 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1922 | 1922 | } |
1923 | 1923 | |
1924 | 1924 | // Get variable price and ID from variable price array. |
1925 | - foreach ( $variable_prices as $variable_price ) { |
|
1926 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
1925 | + foreach ($variable_prices as $variable_price) { |
|
1926 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false))); |
|
1927 | 1927 | } |
1928 | 1928 | |
1929 | 1929 | // Update options. |
1930 | - $args = array_merge( $args, array( |
|
1930 | + $args = array_merge($args, array( |
|
1931 | 1931 | 'options' => $variable_price_options, |
1932 | - ) ); |
|
1932 | + )); |
|
1933 | 1933 | |
1934 | 1934 | // Generate select html. |
1935 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1935 | + $form_dropdown_html = Give()->html->select($args); |
|
1936 | 1936 | |
1937 | - if ( ! $echo ) { |
|
1937 | + if ( ! $echo) { |
|
1938 | 1938 | return $form_dropdown_html; |
1939 | 1939 | } |
1940 | 1940 | |
@@ -1953,16 +1953,16 @@ discard block |
||
1953 | 1953 | * |
1954 | 1954 | * @return string |
1955 | 1955 | */ |
1956 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
1956 | +function give_get_payment_meta_price_id($payment_meta) { |
|
1957 | 1957 | |
1958 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
1958 | + if (isset($payment_meta['give_price_id'])) { |
|
1959 | 1959 | $price_id = $payment_meta['give_price_id']; |
1960 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
1960 | + } elseif (isset($payment_meta['price_id'])) { |
|
1961 | 1961 | $price_id = $payment_meta['price_id']; |
1962 | 1962 | } else { |
1963 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
1963 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
1964 | 1964 | } |
1965 | 1965 | |
1966 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id ); |
|
1966 | + return apply_filters('give_get_payment_meta_price_id', $price_id); |
|
1967 | 1967 | |
1968 | 1968 | } |