@@ -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 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->includes(); |
218 | 218 | $this->init_hooks(); |
219 | 219 | |
220 | - do_action( 'give_loaded' ); |
|
220 | + do_action('give_loaded'); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @since 1.8.9 |
227 | 227 | */ |
228 | 228 | private function init_hooks() { |
229 | - register_activation_hook( __FILE__, 'give_install' ); |
|
230 | - add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
|
229 | + register_activation_hook(__FILE__, 'give_install'); |
|
230 | + add_action('plugins_loaded', array($this, 'init'), 0); |
|
231 | 231 | } |
232 | 232 | /** |
233 | 233 | * Init Give when WordPress Initializes. |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @since 1.8.9 |
243 | 243 | */ |
244 | - do_action( 'before_give_init' ); |
|
244 | + do_action('before_give_init'); |
|
245 | 245 | |
246 | 246 | // Set up localization. |
247 | 247 | $this->load_textdomain(); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @since 1.8.7 |
268 | 268 | */ |
269 | - do_action( 'give_init', $this ); |
|
269 | + do_action('give_init', $this); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function __clone() { |
285 | 285 | // Cloning instances of the class is forbidden. |
286 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
286 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function __wakeup() { |
298 | 298 | // Unserializing 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 | /** |
@@ -310,38 +310,38 @@ discard block |
||
310 | 310 | private function setup_constants() { |
311 | 311 | |
312 | 312 | // Plugin version |
313 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
314 | - define( 'GIVE_VERSION', '1.8.10' ); |
|
313 | + if ( ! defined('GIVE_VERSION')) { |
|
314 | + define('GIVE_VERSION', '1.8.10'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | // Plugin Folder Path |
318 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
319 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
318 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
319 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // Plugin Folder URL |
323 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
324 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
323 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
324 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | // Plugin Basename aka: "give/give.php" |
328 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
329 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
328 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
329 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Plugin Root File |
333 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
334 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
333 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
334 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | // Make sure CAL_GREGORIAN is defined |
338 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
339 | - define( 'CAL_GREGORIAN', 1 ); |
|
338 | + if ( ! defined('CAL_GREGORIAN')) { |
|
339 | + define('CAL_GREGORIAN', 1); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | // PHP version |
343 | - if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) { |
|
344 | - define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' ); |
|
343 | + if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) { |
|
344 | + define('GIVE_REQUIRED_PHP_VERSION', '5.3'); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -356,128 +356,128 @@ discard block |
||
356 | 356 | private function includes() { |
357 | 357 | global $give_options; |
358 | 358 | |
359 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
359 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
361 | 361 | $give_options = give_get_settings(); |
362 | 362 | |
363 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
364 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; |
|
365 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
366 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
367 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
368 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
369 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
370 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
371 | - require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php'; |
|
372 | - |
|
373 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
376 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
387 | - |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
395 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
402 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php'; |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
406 | - |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
411 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
412 | - |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
414 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
415 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
416 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
417 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
418 | - |
|
419 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
420 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
421 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
422 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
423 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
424 | - |
|
425 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
426 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
364 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php'; |
|
365 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
366 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
368 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
369 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
370 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
371 | + require_once GIVE_PLUGIN_DIR.'includes/class-notices.php'; |
|
372 | + |
|
373 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
376 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
387 | + |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
395 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
402 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php'; |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
406 | + |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
411 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
412 | + |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
414 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
415 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
416 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
417 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
418 | + |
|
419 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
420 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
421 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
422 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
423 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
424 | + |
|
425 | + if (defined('WP_CLI') && WP_CLI) { |
|
426 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
427 | 427 | } |
428 | 428 | |
429 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
430 | - |
|
431 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
432 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
433 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
434 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
435 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
436 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
437 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
438 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
439 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
440 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
441 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
442 | - |
|
443 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
444 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
445 | - |
|
446 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php'; |
|
447 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php'; |
|
448 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php'; |
|
449 | - |
|
450 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
451 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
452 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
453 | - |
|
454 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php'; |
|
455 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php'; |
|
456 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php'; |
|
457 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php'; |
|
458 | - |
|
459 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
460 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
461 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
462 | - |
|
463 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php'; |
|
464 | - |
|
465 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
466 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
467 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
468 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
469 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
470 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
471 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
472 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
473 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
474 | - |
|
475 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
476 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
429 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
430 | + |
|
431 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
432 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
433 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
434 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
435 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
436 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
437 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
438 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
439 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
440 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
441 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
442 | + |
|
443 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
444 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
445 | + |
|
446 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php'; |
|
447 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php'; |
|
448 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php'; |
|
449 | + |
|
450 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
451 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
452 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
453 | + |
|
454 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php'; |
|
455 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php'; |
|
456 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php'; |
|
457 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php'; |
|
458 | + |
|
459 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
460 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
461 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
462 | + |
|
463 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php'; |
|
464 | + |
|
465 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
466 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
467 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
468 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
469 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
470 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
471 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
472 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
473 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
474 | + |
|
475 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
476 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
477 | 477 | |
478 | 478 | }// End if(). |
479 | 479 | |
480 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
480 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
481 | 481 | |
482 | 482 | } |
483 | 483 | |
@@ -492,16 +492,16 @@ discard block |
||
492 | 492 | public function load_textdomain() { |
493 | 493 | |
494 | 494 | // Set filter for Give's languages directory |
495 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
496 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
495 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
496 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
497 | 497 | |
498 | 498 | // Traditional WordPress plugin locale filter. |
499 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
500 | - $locale = apply_filters( 'plugin_locale', $locale, 'give' ); |
|
499 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
500 | + $locale = apply_filters('plugin_locale', $locale, 'give'); |
|
501 | 501 | |
502 | - unload_textdomain( 'give' ); |
|
503 | - load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' ); |
|
504 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
502 | + unload_textdomain('give'); |
|
503 | + load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo'); |
|
504 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
505 | 505 | |
506 | 506 | } |
507 | 507 |
@@ -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,18 +97,18 @@ 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'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $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']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $donation_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $donation_data['price'] ) { |
|
134 | + if ( ! $donation_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $donation_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
145 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $donation_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
158 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
163 | +add_action('give_purchase', 'give_process_donation_form'); |
|
164 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,29 +175,29 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
178 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer. |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | - $submitted_email = $valid_data['logged_in_user']['user_email']; |
|
184 | - $customer = new Give_Donor( get_current_user_id(), true ); |
|
183 | + $submitted_email = $valid_data['logged_in_user']['user_email']; |
|
184 | + $customer = new Give_Donor(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | 187 | if ( |
188 | 188 | $submitted_email !== $customer->email |
189 | - && ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) ) |
|
189 | + && (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails)) |
|
190 | 190 | ) { |
191 | - $found_customer = new Give_Donor( $submitted_email ); |
|
191 | + $found_customer = new Give_Donor($submitted_email); |
|
192 | 192 | |
193 | - if ( $found_customer->id > 0 ) { |
|
194 | - 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' ), $customer->email, $submitted_email ) ); |
|
193 | + if ($found_customer->id > 0) { |
|
194 | + 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'), $customer->email, $submitted_email)); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
200 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Process the checkout login form |
@@ -207,49 +207,49 @@ discard block |
||
207 | 207 | * @return void |
208 | 208 | */ |
209 | 209 | function give_process_form_login() { |
210 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
210 | + $is_ajax = isset($_POST['give_ajax']); |
|
211 | 211 | |
212 | 212 | $user_data = give_donation_form_validate_user_login(); |
213 | 213 | |
214 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
215 | - if ( $is_ajax ) { |
|
214 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
215 | + if ($is_ajax) { |
|
216 | 216 | /** |
217 | 217 | * Fires when AJAX sends back errors from the donation form. |
218 | 218 | * |
219 | 219 | * @since 1.0 |
220 | 220 | */ |
221 | 221 | ob_start(); |
222 | - do_action( 'give_ajax_donation_errors' ); |
|
222 | + do_action('give_ajax_donation_errors'); |
|
223 | 223 | $message = ob_get_contents(); |
224 | 224 | ob_end_clean(); |
225 | - wp_send_json_error( $message ); |
|
225 | + wp_send_json_error($message); |
|
226 | 226 | } else { |
227 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
227 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
232 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
233 | 233 | |
234 | - if ( $is_ajax ) { |
|
234 | + if ($is_ajax) { |
|
235 | 235 | $message = Give()->notices->print_frontend_notice( |
236 | 236 | sprintf( |
237 | 237 | /* translators: %s: user first name */ |
238 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
239 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
238 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
239 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
240 | 240 | ), |
241 | 241 | false, |
242 | 242 | 'success' |
243 | 243 | ); |
244 | 244 | |
245 | - wp_send_json_success( $message ); |
|
245 | + wp_send_json_success($message); |
|
246 | 246 | } else { |
247 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
247 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
252 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
251 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
252 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Donation Form Validate Fields. |
@@ -261,55 +261,55 @@ discard block |
||
261 | 261 | function give_donation_form_validate_fields() { |
262 | 262 | |
263 | 263 | // Check if there is $_POST |
264 | - if ( empty( $_POST ) ) { |
|
264 | + if (empty($_POST)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
268 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
269 | 269 | |
270 | 270 | // Start an array to collect valid data |
271 | 271 | $valid_data = array( |
272 | 272 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
273 | - 'need_new_user' => false, // New user flag |
|
274 | - 'need_user_login' => false, // Login user flag |
|
275 | - 'logged_user_data' => array(), // Logged user collected data |
|
276 | - 'new_user_data' => array(), // New user collected data |
|
277 | - 'login_user_data' => array(), // Login user collected data |
|
278 | - 'guest_user_data' => array(), // Guest user collected data |
|
279 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
273 | + 'need_new_user' => false, // New user flag |
|
274 | + 'need_user_login' => false, // Login user flag |
|
275 | + 'logged_user_data' => array(), // Logged user collected data |
|
276 | + 'new_user_data' => array(), // New user collected data |
|
277 | + 'login_user_data' => array(), // Login user collected data |
|
278 | + 'guest_user_data' => array(), // Guest user collected data |
|
279 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
280 | 280 | ); |
281 | 281 | |
282 | 282 | // Validate Honeypot First |
283 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
284 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
283 | + if ( ! empty($_POST['give-honeypot'])) { |
|
284 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Validate agree to terms |
288 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
288 | + if (give_is_terms_enabled($form_id)) { |
|
289 | 289 | give_donation_form_validate_agree_to_terms(); |
290 | 290 | } |
291 | 291 | |
292 | 292 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
293 | 293 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
294 | 294 | if ( |
295 | - ! give_logged_in_only( $form_id ) |
|
296 | - && isset( $_POST['give-purchase-var'] ) |
|
295 | + ! give_logged_in_only($form_id) |
|
296 | + && isset($_POST['give-purchase-var']) |
|
297 | 297 | && $_POST['give-purchase-var'] == 'needs-to-register' |
298 | - && empty( $_POST['give_user_login'] ) |
|
298 | + && empty($_POST['give_user_login']) |
|
299 | 299 | ) { |
300 | - unset( $_POST['give-purchase-var'] ); |
|
300 | + unset($_POST['give-purchase-var']); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( is_user_logged_in() ) { |
|
303 | + if (is_user_logged_in()) { |
|
304 | 304 | // Collect logged in user data. |
305 | 305 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
306 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
306 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
307 | 307 | // Set new user registration as required. |
308 | 308 | $valid_data['need_new_user'] = true; |
309 | 309 | // Validate new user data. |
310 | 310 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
311 | 311 | // Check if login validation is needed. |
312 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
312 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
313 | 313 | // Set user login as required. |
314 | 314 | $valid_data['need_user_login'] = true; |
315 | 315 | // Validate users login info. |
@@ -334,41 +334,41 @@ discard block |
||
334 | 334 | */ |
335 | 335 | function give_donation_form_validate_gateway() { |
336 | 336 | |
337 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
338 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
339 | - $gateway = give_get_default_gateway( $form_id ); |
|
337 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
338 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
339 | + $gateway = give_get_default_gateway($form_id); |
|
340 | 340 | |
341 | 341 | // Check if a gateway value is present. |
342 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
342 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
343 | 343 | |
344 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
344 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
345 | 345 | |
346 | 346 | // Is amount being donated in LIVE mode 0.00? If so, error: |
347 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
347 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
348 | 348 | |
349 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
349 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
350 | 350 | |
351 | 351 | } // End if(). |
352 | - elseif ( ! give_verify_minimum_price() ) { |
|
352 | + elseif ( ! give_verify_minimum_price()) { |
|
353 | 353 | // translators: %s: minimum donation amount. |
354 | 354 | give_set_error( |
355 | 355 | 'invalid_donation_minimum', |
356 | 356 | sprintf( |
357 | 357 | /* translators: %s: minimum donation amount */ |
358 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
359 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
358 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
359 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
360 | 360 | ) |
361 | 361 | ); |
362 | 362 | |
363 | 363 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
364 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
364 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
365 | 365 | |
366 | 366 | $gateway = 'manual'; |
367 | 367 | |
368 | 368 | } //Check if this gateway is active. |
369 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
369 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
370 | 370 | |
371 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
371 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
372 | 372 | |
373 | 373 | } |
374 | 374 | } |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | */ |
387 | 387 | function give_verify_minimum_price() { |
388 | 388 | |
389 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
390 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
391 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
392 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
389 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
390 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
391 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
392 | + $variable_prices = give_has_variable_prices($form_id); |
|
393 | 393 | |
394 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
394 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
395 | 395 | |
396 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
396 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
397 | 397 | |
398 | - if ( $price_level_amount == $amount ) { |
|
398 | + if ($price_level_amount == $amount) { |
|
399 | 399 | return true; |
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
403 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
403 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
@@ -416,9 +416,9 @@ discard block |
||
416 | 416 | */ |
417 | 417 | function give_donation_form_validate_agree_to_terms() { |
418 | 418 | // Validate agree to terms. |
419 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
419 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
420 | 420 | // User did not agree. |
421 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
421 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -432,43 +432,43 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @return array |
434 | 434 | */ |
435 | -function give_get_required_fields( $form_id ) { |
|
435 | +function give_get_required_fields($form_id) { |
|
436 | 436 | |
437 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
437 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
438 | 438 | |
439 | 439 | $required_fields = array( |
440 | 440 | 'give_email' => array( |
441 | 441 | 'error_id' => 'invalid_email', |
442 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
442 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
443 | 443 | ), |
444 | 444 | 'give_first' => array( |
445 | 445 | 'error_id' => 'invalid_first_name', |
446 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
446 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
447 | 447 | ), |
448 | 448 | ); |
449 | 449 | |
450 | - $require_address = give_require_billing_address( $payment_mode ); |
|
450 | + $require_address = give_require_billing_address($payment_mode); |
|
451 | 451 | |
452 | - if ( $require_address ) { |
|
453 | - $required_fields['card_address'] = array( |
|
452 | + if ($require_address) { |
|
453 | + $required_fields['card_address'] = array( |
|
454 | 454 | 'error_id' => 'invalid_card_address', |
455 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
455 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
456 | 456 | ); |
457 | - $required_fields['card_zip'] = array( |
|
457 | + $required_fields['card_zip'] = array( |
|
458 | 458 | 'error_id' => 'invalid_zip_code', |
459 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
459 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
460 | 460 | ); |
461 | - $required_fields['card_city'] = array( |
|
461 | + $required_fields['card_city'] = array( |
|
462 | 462 | 'error_id' => 'invalid_city', |
463 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
463 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
464 | 464 | ); |
465 | 465 | $required_fields['billing_country'] = array( |
466 | 466 | 'error_id' => 'invalid_country', |
467 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
467 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
468 | 468 | ); |
469 | - $required_fields['card_state'] = array( |
|
469 | + $required_fields['card_state'] = array( |
|
470 | 470 | 'error_id' => 'invalid_state', |
471 | - 'error_message' => __( 'Please enter billing state / province.', 'give' ), |
|
471 | + 'error_message' => __('Please enter billing state / province.', 'give'), |
|
472 | 472 | ); |
473 | 473 | } |
474 | 474 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @since 1.7 |
479 | 479 | */ |
480 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
480 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
481 | 481 | |
482 | 482 | return $required_fields; |
483 | 483 | |
@@ -492,16 +492,16 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return bool |
494 | 494 | */ |
495 | -function give_require_billing_address( $payment_mode ) { |
|
495 | +function give_require_billing_address($payment_mode) { |
|
496 | 496 | |
497 | 497 | $return = false; |
498 | 498 | |
499 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
499 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
500 | 500 | $return = true; |
501 | 501 | } |
502 | 502 | |
503 | 503 | // Let payment gateways and other extensions determine if address fields should be required. |
504 | - return apply_filters( 'give_require_billing_address', $return ); |
|
504 | + return apply_filters('give_require_billing_address', $return); |
|
505 | 505 | |
506 | 506 | } |
507 | 507 | |
@@ -515,42 +515,42 @@ discard block |
||
515 | 515 | function give_donation_form_validate_logged_in_user() { |
516 | 516 | global $user_ID; |
517 | 517 | |
518 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
518 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
519 | 519 | |
520 | 520 | // Start empty array to collect valid user data. |
521 | 521 | $valid_user_data = array( |
522 | 522 | // Assume there will be errors. |
523 | - 'user_id' => - 1, |
|
523 | + 'user_id' => -1, |
|
524 | 524 | ); |
525 | 525 | |
526 | 526 | // Verify there is a user_ID. |
527 | - if ( $user_ID > 0 ) { |
|
527 | + if ($user_ID > 0) { |
|
528 | 528 | // Get the logged in user data. |
529 | - $user_data = get_userdata( $user_ID ); |
|
529 | + $user_data = get_userdata($user_ID); |
|
530 | 530 | |
531 | 531 | // Loop through required fields and show error messages. |
532 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
533 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
534 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
532 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
533 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
534 | + give_set_error($value['error_id'], $value['error_message']); |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | 538 | // Verify data. |
539 | - if ( $user_data ) { |
|
539 | + if ($user_data) { |
|
540 | 540 | // Collected logged in user data. |
541 | 541 | $valid_user_data = array( |
542 | 542 | 'user_id' => $user_ID, |
543 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
544 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
545 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
543 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
544 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
545 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
546 | 546 | ); |
547 | 547 | |
548 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
549 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
548 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
549 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
550 | 550 | } |
551 | 551 | } else { |
552 | 552 | // Set invalid user error. |
553 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
553 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | // Default user data. |
570 | 570 | $default_user_data = array( |
571 | 571 | 'give-form-id' => '', |
572 | - 'user_id' => - 1, // Assume there will be errors. |
|
572 | + 'user_id' => -1, // Assume there will be errors. |
|
573 | 573 | 'user_first' => '', |
574 | 574 | 'user_last' => '', |
575 | 575 | 'give_user_login' => false, |
@@ -579,14 +579,14 @@ discard block |
||
579 | 579 | ); |
580 | 580 | |
581 | 581 | // Get user data. |
582 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
582 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
583 | 583 | $registering_new_user = false; |
584 | - $form_id = absint( $user_data['give-form-id'] ); |
|
584 | + $form_id = absint($user_data['give-form-id']); |
|
585 | 585 | |
586 | 586 | // Start an empty array to collect valid user data. |
587 | 587 | $valid_user_data = array( |
588 | 588 | // Assume there will be errors. |
589 | - 'user_id' => - 1, |
|
589 | + 'user_id' => -1, |
|
590 | 590 | |
591 | 591 | // Get first name. |
592 | 592 | 'user_first' => $user_data['give_first'], |
@@ -596,25 +596,25 @@ discard block |
||
596 | 596 | ); |
597 | 597 | |
598 | 598 | // Loop through required fields and show error messages. |
599 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
600 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
601 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
599 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
600 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
601 | + give_set_error($value['error_id'], $value['error_message']); |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
605 | 605 | // Check if we have an username to register. |
606 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
606 | + if (give_validate_username($user_data['give_user_login'])) { |
|
607 | 607 | $registering_new_user = true; |
608 | 608 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // Check if we have an email to verify. |
612 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
612 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
613 | 613 | $valid_user_data['user_email'] = $user_data['give_email']; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Check password. |
617 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
617 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
618 | 618 | // All is good to go. |
619 | 619 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
620 | 620 | } |
@@ -634,36 +634,36 @@ discard block |
||
634 | 634 | // Start an array to collect valid user data. |
635 | 635 | $valid_user_data = array( |
636 | 636 | // Assume there will be errors. |
637 | - 'user_id' => - 1, |
|
637 | + 'user_id' => -1, |
|
638 | 638 | ); |
639 | 639 | |
640 | 640 | // Username. |
641 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
642 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
641 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
642 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
643 | 643 | |
644 | 644 | return $valid_user_data; |
645 | 645 | } |
646 | 646 | |
647 | 647 | // Get the user by login. |
648 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
648 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
649 | 649 | |
650 | 650 | // Check if user exists. |
651 | - if ( $user_data ) { |
|
651 | + if ($user_data) { |
|
652 | 652 | // Get password. |
653 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
653 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
654 | 654 | |
655 | 655 | // Check user_pass. |
656 | - if ( $user_pass ) { |
|
656 | + if ($user_pass) { |
|
657 | 657 | // Check if password is valid. |
658 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
658 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
659 | 659 | // Incorrect password. |
660 | 660 | give_set_error( |
661 | 661 | 'password_incorrect', |
662 | 662 | sprintf( |
663 | 663 | '%1$s <a href="%2$s">%3$s</a>', |
664 | - __( 'The password you entered is incorrect.', 'give' ), |
|
665 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
666 | - __( 'Reset Password', 'give' ) |
|
664 | + __('The password you entered is incorrect.', 'give'), |
|
665 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
666 | + __('Reset Password', 'give') |
|
667 | 667 | ) |
668 | 668 | ); |
669 | 669 | // All is correct. |
@@ -680,11 +680,11 @@ discard block |
||
680 | 680 | } |
681 | 681 | } else { |
682 | 682 | // Empty password. |
683 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
683 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
684 | 684 | } |
685 | 685 | } else { |
686 | 686 | // No username. |
687 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
687 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
688 | 688 | }// End if(). |
689 | 689 | |
690 | 690 | return $valid_user_data; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | */ |
700 | 700 | function give_donation_form_validate_guest_user() { |
701 | 701 | |
702 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
702 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
703 | 703 | |
704 | 704 | // Start an array to collect valid user data. |
705 | 705 | $valid_user_data = array( |
@@ -708,38 +708,38 @@ discard block |
||
708 | 708 | ); |
709 | 709 | |
710 | 710 | // Show error message if user must be logged in. |
711 | - if ( give_logged_in_only( $form_id ) ) { |
|
712 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
711 | + if (give_logged_in_only($form_id)) { |
|
712 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | // Get the guest email. |
716 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
716 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
717 | 717 | |
718 | 718 | // Check email. |
719 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
719 | + if ($guest_email && strlen($guest_email) > 0) { |
|
720 | 720 | // Validate email. |
721 | - if ( ! is_email( $guest_email ) ) { |
|
721 | + if ( ! is_email($guest_email)) { |
|
722 | 722 | // Invalid email. |
723 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
723 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
724 | 724 | } else { |
725 | 725 | // All is good to go. |
726 | 726 | $valid_user_data['user_email'] = $guest_email; |
727 | 727 | |
728 | 728 | // Get user_id from donor if exist. |
729 | - $donor = new Give_Donor( $guest_email ); |
|
730 | - if ( $donor->id && $donor->user_id ) { |
|
729 | + $donor = new Give_Donor($guest_email); |
|
730 | + if ($donor->id && $donor->user_id) { |
|
731 | 731 | $valid_user_data['user_id'] = $donor->user_id; |
732 | 732 | } |
733 | 733 | } |
734 | 734 | } else { |
735 | 735 | // No email. |
736 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
736 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | // Loop through required fields and show error messages. |
740 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
741 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
742 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
740 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
741 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
742 | + give_set_error($value['error_id'], $value['error_message']); |
|
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
@@ -755,36 +755,36 @@ discard block |
||
755 | 755 | * @since 1.0 |
756 | 756 | * @return integer |
757 | 757 | */ |
758 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
758 | +function give_register_and_login_new_user($user_data = array()) { |
|
759 | 759 | // Verify the array. |
760 | - if ( empty( $user_data ) ) { |
|
761 | - return - 1; |
|
760 | + if (empty($user_data)) { |
|
761 | + return -1; |
|
762 | 762 | } |
763 | 763 | |
764 | - if ( give_get_errors() ) { |
|
765 | - return - 1; |
|
764 | + if (give_get_errors()) { |
|
765 | + return -1; |
|
766 | 766 | } |
767 | 767 | |
768 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
769 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
770 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
771 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
772 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
773 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
774 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
775 | - 'role' => get_option( 'default_role' ), |
|
776 | - ), $user_data ); |
|
768 | + $user_args = apply_filters('give_insert_user_args', array( |
|
769 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
770 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
771 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
772 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
773 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
774 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
775 | + 'role' => get_option('default_role'), |
|
776 | + ), $user_data); |
|
777 | 777 | |
778 | 778 | // Insert new user. |
779 | - $user_id = wp_insert_user( $user_args ); |
|
779 | + $user_id = wp_insert_user($user_args); |
|
780 | 780 | |
781 | 781 | // Validate inserted user. |
782 | - if ( is_wp_error( $user_id ) ) { |
|
783 | - return - 1; |
|
782 | + if (is_wp_error($user_id)) { |
|
783 | + return -1; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | // Allow themes and plugins to filter the user data. |
787 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
787 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
788 | 788 | |
789 | 789 | /** |
790 | 790 | * Fires after inserting user. |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | * @param int $user_id User id. |
795 | 795 | * @param array $user_data Array containing user data. |
796 | 796 | */ |
797 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
797 | + do_action('give_insert_user', $user_id, $user_data); |
|
798 | 798 | |
799 | 799 | // Login new user. |
800 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
800 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
801 | 801 | |
802 | 802 | // Return user id. |
803 | 803 | return $user_id; |
@@ -812,27 +812,27 @@ discard block |
||
812 | 812 | * @since 1.0 |
813 | 813 | * @return array|bool |
814 | 814 | */ |
815 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
815 | +function give_get_donation_form_user($valid_data = array()) { |
|
816 | 816 | |
817 | 817 | // Initialize user. |
818 | 818 | $user = false; |
819 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
819 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
820 | 820 | |
821 | - if ( $is_ajax ) { |
|
821 | + if ($is_ajax) { |
|
822 | 822 | // Do not create or login the user during the ajax submission (check for errors only). |
823 | 823 | return true; |
824 | - } elseif ( is_user_logged_in() ) { |
|
824 | + } elseif (is_user_logged_in()) { |
|
825 | 825 | // Set the valid user as the logged in collected data. |
826 | 826 | $user = $valid_data['logged_in_user']; |
827 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
827 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
828 | 828 | // New user registration. |
829 | - if ( $valid_data['need_new_user'] === true ) { |
|
829 | + if ($valid_data['need_new_user'] === true) { |
|
830 | 830 | // Set user. |
831 | 831 | $user = $valid_data['new_user_data']; |
832 | 832 | // Register and login new user. |
833 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
833 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
834 | 834 | // User login |
835 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
835 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
836 | 836 | |
837 | 837 | /** |
838 | 838 | * The login form is now processed in the give_process_donation_login() function. |
@@ -844,48 +844,48 @@ discard block |
||
844 | 844 | // Set user. |
845 | 845 | $user = $valid_data['login_user_data']; |
846 | 846 | // Login user. |
847 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
847 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
848 | 848 | } |
849 | 849 | } |
850 | 850 | |
851 | 851 | // Check guest checkout. |
852 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
852 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
853 | 853 | // Set user |
854 | 854 | $user = $valid_data['guest_user_data']; |
855 | 855 | } |
856 | 856 | |
857 | 857 | // Verify we have an user. |
858 | - if ( false === $user || empty( $user ) ) { |
|
858 | + if (false === $user || empty($user)) { |
|
859 | 859 | // Return false. |
860 | 860 | return false; |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Get user first name. |
864 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
865 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
864 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
865 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | // Get user last name. |
869 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
870 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
869 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
870 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | // Get the user's billing address details. |
874 | 874 | $user['address'] = array(); |
875 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
876 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
877 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
878 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
879 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
880 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
881 | - |
|
882 | - if ( empty( $user['address']['country'] ) ) { |
|
875 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
876 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
877 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
878 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
879 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
880 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
881 | + |
|
882 | + if (empty($user['address']['country'])) { |
|
883 | 883 | $user['address'] = false; |
884 | 884 | } // End if(). |
885 | 885 | |
886 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
886 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
887 | 887 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
888 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
888 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | // Return valid user. |
@@ -904,16 +904,16 @@ discard block |
||
904 | 904 | $card_data = give_get_donation_cc_info(); |
905 | 905 | |
906 | 906 | // Validate the card zip. |
907 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
908 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
909 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
907 | + if ( ! empty($card_data['card_zip'])) { |
|
908 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
909 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | 913 | // Ensure no spaces. |
914 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
915 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
916 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
914 | + if ( ! empty($card_data['card_number'])) { |
|
915 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
916 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | // This should validate card numbers at some point too. |
@@ -930,17 +930,17 @@ discard block |
||
930 | 930 | function give_get_donation_cc_info() { |
931 | 931 | |
932 | 932 | $cc_info = array(); |
933 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
934 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
935 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
936 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
937 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
938 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
939 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
940 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
941 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
942 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
943 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
933 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
934 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
935 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
936 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
937 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
938 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
939 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
940 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
941 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
942 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
943 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
944 | 944 | |
945 | 945 | // Return cc info. |
946 | 946 | return $cc_info; |
@@ -956,14 +956,14 @@ discard block |
||
956 | 956 | * |
957 | 957 | * @return bool|mixed |
958 | 958 | */ |
959 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
959 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
960 | 960 | $ret = false; |
961 | 961 | |
962 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
962 | + if (empty($zip) || empty($country_code)) { |
|
963 | 963 | return $ret; |
964 | 964 | } |
965 | 965 | |
966 | - $country_code = strtoupper( $country_code ); |
|
966 | + $country_code = strtoupper($country_code); |
|
967 | 967 | |
968 | 968 | $zip_regex = array( |
969 | 969 | 'AD' => 'AD\d{3}', |
@@ -1123,11 +1123,11 @@ discard block |
||
1123 | 1123 | 'ZM' => '\d{5}', |
1124 | 1124 | ); |
1125 | 1125 | |
1126 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1126 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1127 | 1127 | $ret = true; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1130 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1141,36 +1141,36 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return bool |
1143 | 1143 | */ |
1144 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1144 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1145 | 1145 | /* @var Give_Donate_Form $form */ |
1146 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1146 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1147 | 1147 | |
1148 | 1148 | $donation_level_matched = false; |
1149 | 1149 | |
1150 | - if ( $form->is_multi_type_donation_form() ) { |
|
1150 | + if ($form->is_multi_type_donation_form()) { |
|
1151 | 1151 | |
1152 | 1152 | // Bailout. |
1153 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1153 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1154 | 1154 | return false; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | // Sanitize donation amount. |
1158 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1158 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1159 | 1159 | |
1160 | 1160 | // Get number of decimals. |
1161 | 1161 | $default_decimals = give_get_price_decimals(); |
1162 | 1162 | |
1163 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1163 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1164 | 1164 | return true; |
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | // Find correct donation level from all donation levels. |
1168 | - foreach ( $variable_prices as $variable_price ) { |
|
1168 | + foreach ($variable_prices as $variable_price) { |
|
1169 | 1169 | // Sanitize level amount. |
1170 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1170 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1171 | 1171 | |
1172 | 1172 | // Set first match donation level ID. |
1173 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1173 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1174 | 1174 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1175 | 1175 | $donation_level_matched = true; |
1176 | 1176 | break; |
@@ -1181,19 +1181,19 @@ discard block |
||
1181 | 1181 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1182 | 1182 | if ( |
1183 | 1183 | ! $donation_level_matched |
1184 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1184 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1185 | 1185 | ) { |
1186 | 1186 | // Sanitize custom minimum amount. |
1187 | - $custom_minimum_amount = give_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1187 | + $custom_minimum_amount = give_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1188 | 1188 | |
1189 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1189 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1190 | 1190 | $_POST['give-price-id'] = 'custom'; |
1191 | 1191 | $donation_level_matched = true; |
1192 | 1192 | } |
1193 | 1193 | } |
1194 | 1194 | }// End if(). |
1195 | 1195 | |
1196 | - return ( $donation_level_matched ? true : false ); |
|
1196 | + return ($donation_level_matched ? true : false); |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1199 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param string $description Email tag description text |
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | */ |
58 | - public function add( $tag, $description, $func ) { |
|
59 | - if ( is_callable( $func ) ) { |
|
60 | - $this->tags[ $tag ] = array( |
|
58 | + public function add($tag, $description, $func) { |
|
59 | + if (is_callable($func)) { |
|
60 | + $this->tags[$tag] = array( |
|
61 | 61 | 'tag' => $tag, |
62 | 62 | 'description' => $description, |
63 | 63 | 'func' => $func |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param string $tag Email tag to remove hook from |
74 | 74 | */ |
75 | - public function remove( $tag ) { |
|
76 | - unset( $this->tags[ $tag ] ); |
|
75 | + public function remove($tag) { |
|
76 | + unset($this->tags[$tag]); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return bool |
87 | 87 | */ |
88 | - public function email_tag_exists( $tag ) { |
|
89 | - return array_key_exists( $tag, $this->tags ); |
|
88 | + public function email_tag_exists($tag) { |
|
89 | + return array_key_exists($tag, $this->tags); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Content with email tags filtered out. |
112 | 112 | */ |
113 | - public function do_tags( $content, $payment_id ) { |
|
113 | + public function do_tags($content, $payment_id) { |
|
114 | 114 | |
115 | 115 | // Check if there is at least one tag added. |
116 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
116 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
117 | 117 | return $content; |
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->payment_id = $payment_id; |
121 | 121 | |
122 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
122 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
123 | 123 | |
124 | 124 | $this->payment_id = null; |
125 | 125 | |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | - public function do_tag( $m ) { |
|
138 | + public function do_tag($m) { |
|
139 | 139 | |
140 | 140 | // Get tag |
141 | 141 | $tag = $m[1]; |
142 | 142 | |
143 | 143 | // Return tag if tag not set |
144 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
144 | + if ( ! $this->email_tag_exists($tag)) { |
|
145 | 145 | return $m[0]; |
146 | 146 | } |
147 | 147 | |
148 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
148 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * @param string $description Description of the email tag added |
160 | 160 | * @param callable $func Hook to run when email tag is found |
161 | 161 | */ |
162 | -function give_add_email_tag( $tag, $description, $func ) { |
|
163 | - Give()->email_tags->add( $tag, $description, $func ); |
|
162 | +function give_add_email_tag($tag, $description, $func) { |
|
163 | + Give()->email_tags->add($tag, $description, $func); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param string $tag Email tag to remove hook from |
172 | 172 | */ |
173 | -function give_remove_email_tag( $tag ) { |
|
174 | - Give()->email_tags->remove( $tag ); |
|
173 | +function give_remove_email_tag($tag) { |
|
174 | + Give()->email_tags->remove($tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return bool |
185 | 185 | */ |
186 | -function give_email_tag_exists( $tag ) { |
|
187 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
186 | +function give_email_tag_exists($tag) { |
|
187 | + return Give()->email_tags->email_tag_exists($tag); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | $email_tags = give_get_email_tags(); |
212 | 212 | |
213 | 213 | ob_start(); |
214 | - if ( count( $email_tags ) > 0 ) : ?> |
|
214 | + if (count($email_tags) > 0) : ?> |
|
215 | 215 | <div class="give-email-tags-wrap"> |
216 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
216 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
217 | 217 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
218 | 218 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
219 | 219 | </span> |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return string Content with email tags filtered out. |
237 | 237 | */ |
238 | -function give_do_email_tags( $content, $payment_id ) { |
|
238 | +function give_do_email_tags($content, $payment_id) { |
|
239 | 239 | |
240 | 240 | // Replace all tags |
241 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
241 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
242 | 242 | |
243 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
243 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
244 | 244 | |
245 | 245 | // Return content |
246 | 246 | return $content; |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @since 1.0 |
261 | 261 | */ |
262 | - do_action( 'give_add_email_tags' ); |
|
262 | + do_action('give_add_email_tags'); |
|
263 | 263 | } |
264 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
264 | +add_action('init', 'give_load_email_tags', - 999); |
|
265 | 265 | |
266 | 266 | |
267 | 267 | /** |
@@ -275,97 +275,97 @@ discard block |
||
275 | 275 | $email_tags = array( |
276 | 276 | array( |
277 | 277 | 'tag' => 'donation', |
278 | - 'description' => __( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
278 | + 'description' => __('The donation form name, and the donation level (if applicable).', 'give'), |
|
279 | 279 | 'function' => 'give_email_tag_donation' |
280 | 280 | ), |
281 | 281 | array( |
282 | 282 | 'tag' => 'form_title', |
283 | - 'description' => __( 'The donation form name.', 'give' ), |
|
283 | + 'description' => __('The donation form name.', 'give'), |
|
284 | 284 | 'function' => 'give_email_tag_form_title' |
285 | 285 | ), |
286 | 286 | array( |
287 | 287 | 'tag' => 'amount', |
288 | - 'description' => __( 'The total donation amount with currency sign.', 'give' ), |
|
288 | + 'description' => __('The total donation amount with currency sign.', 'give'), |
|
289 | 289 | 'function' => 'give_email_tag_amount' |
290 | 290 | ), |
291 | 291 | array( |
292 | 292 | 'tag' => 'price', |
293 | - 'description' => __( 'The total donation amount with currency sign.', 'give' ), |
|
293 | + 'description' => __('The total donation amount with currency sign.', 'give'), |
|
294 | 294 | 'function' => 'give_email_tag_price' |
295 | 295 | ), |
296 | 296 | array( |
297 | 297 | 'tag' => 'name', |
298 | - 'description' => __( 'The donor\'s first name.', 'give' ), |
|
298 | + 'description' => __('The donor\'s first name.', 'give'), |
|
299 | 299 | 'function' => 'give_email_tag_first_name' |
300 | 300 | ), |
301 | 301 | array( |
302 | 302 | 'tag' => 'fullname', |
303 | - 'description' => __( 'The donor\'s full name, first and last.', 'give' ), |
|
303 | + 'description' => __('The donor\'s full name, first and last.', 'give'), |
|
304 | 304 | 'function' => 'give_email_tag_fullname' |
305 | 305 | ), |
306 | 306 | array( |
307 | 307 | 'tag' => 'username', |
308 | - 'description' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
308 | + 'description' => __('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
309 | 309 | 'function' => 'give_email_tag_username' |
310 | 310 | ), |
311 | 311 | array( |
312 | 312 | 'tag' => 'user_email', |
313 | - 'description' => __( 'The donor\'s email address.', 'give' ), |
|
313 | + 'description' => __('The donor\'s email address.', 'give'), |
|
314 | 314 | 'function' => 'give_email_tag_user_email' |
315 | 315 | ), |
316 | 316 | array( |
317 | 317 | 'tag' => 'billing_address', |
318 | - 'description' => __( 'The donor\'s billing address.', 'give' ), |
|
318 | + 'description' => __('The donor\'s billing address.', 'give'), |
|
319 | 319 | 'function' => 'give_email_tag_billing_address' |
320 | 320 | ), |
321 | 321 | array( |
322 | 322 | 'tag' => 'date', |
323 | - 'description' => __( 'The date of the donation.', 'give' ), |
|
323 | + 'description' => __('The date of the donation.', 'give'), |
|
324 | 324 | 'function' => 'give_email_tag_date' |
325 | 325 | ), |
326 | 326 | array( |
327 | 327 | 'tag' => 'payment_id', |
328 | - 'description' => __( 'The unique ID number for this donation.', 'give' ), |
|
328 | + 'description' => __('The unique ID number for this donation.', 'give'), |
|
329 | 329 | 'function' => 'give_email_tag_payment_id' |
330 | 330 | ), |
331 | 331 | array( |
332 | 332 | 'tag' => 'receipt_id', |
333 | - 'description' => __( 'The unique ID number for this donation receipt.', 'give' ), |
|
333 | + 'description' => __('The unique ID number for this donation receipt.', 'give'), |
|
334 | 334 | 'function' => 'give_email_tag_receipt_id' |
335 | 335 | ), |
336 | 336 | array( |
337 | 337 | 'tag' => 'payment_method', |
338 | - 'description' => __( 'The method of payment used for this donation.', 'give' ), |
|
338 | + 'description' => __('The method of payment used for this donation.', 'give'), |
|
339 | 339 | 'function' => 'give_email_tag_payment_method' |
340 | 340 | ), |
341 | 341 | array( |
342 | 342 | 'tag' => 'sitename', |
343 | - 'description' => __( 'The name of your site.', 'give' ), |
|
343 | + 'description' => __('The name of your site.', 'give'), |
|
344 | 344 | 'function' => 'give_email_tag_sitename' |
345 | 345 | ), |
346 | 346 | array( |
347 | 347 | 'tag' => 'receipt_link', |
348 | - 'description' => __( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
348 | + 'description' => __('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
349 | 349 | 'function' => 'give_email_tag_receipt_link' |
350 | 350 | ), |
351 | 351 | array( |
352 | 352 | 'tag' => 'receipt_link_url', |
353 | - 'description' => __( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
353 | + 'description' => __('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
354 | 354 | 'function' => 'give_email_tag_receipt_link_url' |
355 | 355 | ), |
356 | 356 | ); |
357 | 357 | |
358 | 358 | // Apply give_email_tags filter |
359 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
359 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
360 | 360 | |
361 | 361 | // Add email tags |
362 | - foreach ( $email_tags as $email_tag ) { |
|
363 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
362 | + foreach ($email_tags as $email_tag) { |
|
363 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
368 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return string name |
379 | 379 | */ |
380 | -function give_email_tag_first_name( $payment_id ) { |
|
381 | - $payment = new Give_Payment( $payment_id ); |
|
380 | +function give_email_tag_first_name($payment_id) { |
|
381 | + $payment = new Give_Payment($payment_id); |
|
382 | 382 | $user_info = $payment->user_info; |
383 | 383 | |
384 | - if ( empty( $user_info ) ) { |
|
384 | + if (empty($user_info)) { |
|
385 | 385 | return ''; |
386 | 386 | } |
387 | 387 | |
388 | - $email_name = give_get_email_names( $user_info ); |
|
388 | + $email_name = give_get_email_names($user_info); |
|
389 | 389 | |
390 | 390 | return $email_name['name']; |
391 | 391 | } |
@@ -399,15 +399,15 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string fullname |
401 | 401 | */ |
402 | -function give_email_tag_fullname( $payment_id ) { |
|
403 | - $payment = new Give_Payment( $payment_id ); |
|
402 | +function give_email_tag_fullname($payment_id) { |
|
403 | + $payment = new Give_Payment($payment_id); |
|
404 | 404 | $user_info = $payment->user_info; |
405 | 405 | |
406 | - if ( empty( $user_info ) ) { |
|
406 | + if (empty($user_info)) { |
|
407 | 407 | return ''; |
408 | 408 | } |
409 | 409 | |
410 | - $email_name = give_get_email_names( $user_info ); |
|
410 | + $email_name = give_get_email_names($user_info); |
|
411 | 411 | |
412 | 412 | return $email_name['fullname']; |
413 | 413 | } |
@@ -421,15 +421,15 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string username. |
423 | 423 | */ |
424 | -function give_email_tag_username( $payment_id ) { |
|
425 | - $payment = new Give_Payment( $payment_id ); |
|
424 | +function give_email_tag_username($payment_id) { |
|
425 | + $payment = new Give_Payment($payment_id); |
|
426 | 426 | $user_info = $payment->user_info; |
427 | 427 | |
428 | - if ( empty( $user_info ) ) { |
|
428 | + if (empty($user_info)) { |
|
429 | 429 | return ''; |
430 | 430 | } |
431 | 431 | |
432 | - $email_name = give_get_email_names( $user_info ); |
|
432 | + $email_name = give_get_email_names($user_info); |
|
433 | 433 | |
434 | 434 | return $email_name['username']; |
435 | 435 | } |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return string user_email |
445 | 445 | */ |
446 | -function give_email_tag_user_email( $payment_id ) { |
|
447 | - $payment = new Give_Payment( $payment_id ); |
|
446 | +function give_email_tag_user_email($payment_id) { |
|
447 | + $payment = new Give_Payment($payment_id); |
|
448 | 448 | |
449 | 449 | return $payment->email; |
450 | 450 | } |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return string billing_address |
460 | 460 | */ |
461 | -function give_email_tag_billing_address( $payment_id ) { |
|
462 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
463 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
461 | +function give_email_tag_billing_address($payment_id) { |
|
462 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
463 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
464 | 464 | 'line1' => '', |
465 | 465 | 'line2' => '', |
466 | 466 | 'city' => '', |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | 'zip' => '' |
470 | 470 | ); |
471 | 471 | |
472 | - $return = $user_address['line1'] . "\n"; |
|
473 | - if ( ! empty( $user_address['line2'] ) ) { |
|
474 | - $return .= $user_address['line2'] . "\n"; |
|
472 | + $return = $user_address['line1']."\n"; |
|
473 | + if ( ! empty($user_address['line2'])) { |
|
474 | + $return .= $user_address['line2']."\n"; |
|
475 | 475 | } |
476 | - $return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
476 | + $return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
477 | 477 | $return .= $user_address['country']; |
478 | 478 | |
479 | 479 | return $return; |
@@ -488,10 +488,10 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return string date |
490 | 490 | */ |
491 | -function give_email_tag_date( $payment_id ) { |
|
492 | - $payment = new Give_Payment( $payment_id ); |
|
491 | +function give_email_tag_date($payment_id) { |
|
492 | + $payment = new Give_Payment($payment_id); |
|
493 | 493 | |
494 | - return date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
494 | + return date_i18n(give_date_format(), strtotime($payment->date)); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return string amount |
505 | 505 | */ |
506 | -function give_email_tag_amount( $payment_id ) { |
|
507 | - $payment = new Give_Payment( $payment_id ); |
|
508 | - $give_amount = give_currency_filter( give_format_amount( $payment->total ), $payment->currency ); |
|
506 | +function give_email_tag_amount($payment_id) { |
|
507 | + $payment = new Give_Payment($payment_id); |
|
508 | + $give_amount = give_currency_filter(give_format_amount($payment->total), $payment->currency); |
|
509 | 509 | |
510 | - return html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
510 | + return html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string price |
521 | 521 | */ |
522 | -function give_email_tag_price( $payment_id ) { |
|
523 | - return give_email_tag_amount( $payment_id ); |
|
522 | +function give_email_tag_price($payment_id) { |
|
523 | + return give_email_tag_amount($payment_id); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return int payment_id |
534 | 534 | */ |
535 | -function give_email_tag_payment_id( $payment_id ) { |
|
536 | - $payment = new Give_Payment( $payment_id ); |
|
535 | +function give_email_tag_payment_id($payment_id) { |
|
536 | + $payment = new Give_Payment($payment_id); |
|
537 | 537 | |
538 | 538 | return $payment->number; |
539 | 539 | } |
@@ -547,8 +547,8 @@ discard block |
||
547 | 547 | * |
548 | 548 | * @return string receipt_id |
549 | 549 | */ |
550 | -function give_email_tag_receipt_id( $payment_id ) { |
|
551 | - $payment = new Give_Payment( $payment_id ); |
|
550 | +function give_email_tag_receipt_id($payment_id) { |
|
551 | + $payment = new Give_Payment($payment_id); |
|
552 | 552 | |
553 | 553 | return $payment->key; |
554 | 554 | } |
@@ -562,14 +562,14 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @return string $form_title |
564 | 564 | */ |
565 | -function give_email_tag_donation( $payment_id ) { |
|
566 | - $payment = new Give_Payment( $payment_id ); |
|
565 | +function give_email_tag_donation($payment_id) { |
|
566 | + $payment = new Give_Payment($payment_id); |
|
567 | 567 | $payment_meta = $payment->payment_meta; |
568 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
568 | + $level_title = give_has_variable_prices($payment->form_id); |
|
569 | 569 | $separator = $level_title ? '-' : ''; |
570 | - $form_title = strip_tags( give_get_payment_form_title( $payment_meta, false, $separator ) ); |
|
570 | + $form_title = strip_tags(give_get_payment_form_title($payment_meta, false, $separator)); |
|
571 | 571 | |
572 | - return ! empty( $form_title ) ? $form_title : ''; |
|
572 | + return ! empty($form_title) ? $form_title : ''; |
|
573 | 573 | |
574 | 574 | } |
575 | 575 | |
@@ -582,11 +582,11 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return string $form_title |
584 | 584 | */ |
585 | -function give_email_tag_form_title( $payment_id ) { |
|
586 | - $payment = new Give_Payment( $payment_id ); |
|
585 | +function give_email_tag_form_title($payment_id) { |
|
586 | + $payment = new Give_Payment($payment_id); |
|
587 | 587 | $payment_meta = $payment->payment_meta; |
588 | 588 | |
589 | - return isset( $payment_meta['form_title'] ) ? strip_tags( $payment_meta['form_title'] ) : ''; |
|
589 | + return isset($payment_meta['form_title']) ? strip_tags($payment_meta['form_title']) : ''; |
|
590 | 590 | |
591 | 591 | } |
592 | 592 | |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | * |
600 | 600 | * @return string gateway |
601 | 601 | */ |
602 | -function give_email_tag_payment_method( $payment_id ) { |
|
603 | - $payment = new Give_Payment( $payment_id ); |
|
602 | +function give_email_tag_payment_method($payment_id) { |
|
603 | + $payment = new Give_Payment($payment_id); |
|
604 | 604 | |
605 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
605 | + return give_get_gateway_checkout_label($payment->gateway); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | * |
615 | 615 | * @return string sitename |
616 | 616 | */ |
617 | -function give_email_tag_sitename( $payment_id ) { |
|
618 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
617 | +function give_email_tag_sitename($payment_id) { |
|
618 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -627,19 +627,19 @@ discard block |
||
627 | 627 | * |
628 | 628 | * @return string receipt_link |
629 | 629 | */ |
630 | -function give_email_tag_receipt_link( $payment_id ) { |
|
630 | +function give_email_tag_receipt_link($payment_id) { |
|
631 | 631 | |
632 | - $receipt_url = esc_url( add_query_arg( array( |
|
633 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
632 | + $receipt_url = esc_url(add_query_arg(array( |
|
633 | + 'payment_key' => give_get_payment_key($payment_id), |
|
634 | 634 | 'give_action' => 'view_receipt' |
635 | - ), home_url() ) ); |
|
636 | - $formatted = sprintf( |
|
635 | + ), home_url())); |
|
636 | + $formatted = sprintf( |
|
637 | 637 | '<a href="%1$s">%2$s</a>', |
638 | 638 | $receipt_url, |
639 | - esc_html__( 'View it in your browser', 'give' ) |
|
639 | + esc_html__('View it in your browser', 'give') |
|
640 | 640 | ); |
641 | 641 | |
642 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
642 | + if (give_get_option('email_template') !== 'none') { |
|
643 | 643 | return $formatted; |
644 | 644 | } else { |
645 | 645 | return $receipt_url; |
@@ -658,12 +658,12 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @return string receipt_url |
660 | 660 | */ |
661 | -function give_email_tag_receipt_link_url( $payment_id ) { |
|
661 | +function give_email_tag_receipt_link_url($payment_id) { |
|
662 | 662 | |
663 | - $receipt_url = esc_url( add_query_arg( array( |
|
664 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
663 | + $receipt_url = esc_url(add_query_arg(array( |
|
664 | + 'payment_key' => give_get_payment_key($payment_id), |
|
665 | 665 | 'give_action' => 'view_receipt' |
666 | - ), home_url() ) ); |
|
666 | + ), home_url())); |
|
667 | 667 | |
668 | 668 | return $receipt_url; |
669 | 669 |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | - 'ajax' => false,// Does this table support ajax? |
|
51 | - ) ); |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | + 'ajax' => false, // Does this table support ajax? |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,39 +64,39 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - $form_title = get_the_title( $item[ $column_name ] ); |
|
74 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title; |
|
75 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>'; |
|
73 | + $form_title = get_the_title($item[$column_name]); |
|
74 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title; |
|
75 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>'; |
|
76 | 76 | |
77 | 77 | case 'user_id' : |
78 | - return '<a href="' . |
|
79 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
80 | - '">' . $item['user_name'] . '</a>'; |
|
78 | + return '<a href="'. |
|
79 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
80 | + '">'.$item['user_name'].'</a>'; |
|
81 | 81 | |
82 | 82 | case 'amount' : |
83 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
83 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
84 | 84 | |
85 | 85 | case 'status' : |
86 | 86 | |
87 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
87 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
88 | 88 | |
89 | - if ( $payment->mode == 'test' ) { |
|
90 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>'; |
|
89 | + if ($payment->mode == 'test') { |
|
90 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>'; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $value; |
94 | 94 | |
95 | 95 | case 'payment_id' : |
96 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
96 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
97 | 97 | |
98 | 98 | default: |
99 | - return $item[ $column_name ]; |
|
99 | + return $item[$column_name]; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function get_columns() { |
111 | 111 | $columns = array( |
112 | - 'ID' => __( 'Log ID', 'give' ), |
|
113 | - 'user_id' => __( 'Donor', 'give' ), |
|
114 | - 'form' => __( 'Form', 'give' ), |
|
115 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
116 | - 'status' => __( 'Status', 'give' ), |
|
117 | - 'payment_id' => __( 'Donation ID', 'give' ), |
|
118 | - 'date' => __( 'Date', 'give' ), |
|
112 | + 'ID' => __('Log ID', 'give'), |
|
113 | + 'user_id' => __('Donor', 'give'), |
|
114 | + 'form' => __('Form', 'give'), |
|
115 | + 'amount' => __('Donation Amount', 'give'), |
|
116 | + 'status' => __('Status', 'give'), |
|
117 | + 'payment_id' => __('Donation ID', 'give'), |
|
118 | + 'date' => __('Date', 'give'), |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | return $columns; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return int Current page number |
130 | 130 | */ |
131 | 131 | public function get_paged() { |
132 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
132 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return mixed int If User ID, string If Email/Login |
141 | 141 | */ |
142 | 142 | public function get_filtered_user() { |
143 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
143 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return int Download ID |
152 | 152 | */ |
153 | 153 | public function get_filtered_give_form() { |
154 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
154 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @return string|bool string If search is present, false otherwise |
163 | 163 | */ |
164 | 164 | public function get_search() { |
165 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
165 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -178,20 +178,20 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param string $which |
180 | 180 | */ |
181 | - protected function display_tablenav( $which ) { |
|
181 | + protected function display_tablenav($which) { |
|
182 | 182 | |
183 | - if ( 'top' === $which ) { |
|
184 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
183 | + if ('top' === $which) { |
|
184 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
185 | 185 | } |
186 | 186 | ?> |
187 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
187 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
188 | 188 | |
189 | 189 | <div class="alignleft actions bulkactions"> |
190 | - <?php $this->bulk_actions( $which ); ?> |
|
190 | + <?php $this->bulk_actions($which); ?> |
|
191 | 191 | </div> |
192 | 192 | <?php |
193 | - $this->extra_tablenav( $which ); |
|
194 | - $this->pagination( $which ); |
|
193 | + $this->extra_tablenav($which); |
|
194 | + $this->pagination($which); |
|
195 | 195 | ?> |
196 | 196 | |
197 | 197 | <br class="clear"/> |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $meta_query = array(); |
217 | 217 | |
218 | - if ( $user ) { |
|
218 | + if ($user) { |
|
219 | 219 | // Show only logs from a specific user. |
220 | 220 | $meta_query[] = array( |
221 | 221 | 'key' => '_give_log_user_id', |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | $search = $this->get_search(); |
227 | - if ( $search ) { |
|
228 | - if ( is_email( $search ) ) { |
|
227 | + if ($search) { |
|
228 | + if (is_email($search)) { |
|
229 | 229 | // This is an email search. We use this to ensure it works for guest users and logged-in users. |
230 | 230 | $key = '_give_log_user_info'; |
231 | 231 | $compare = 'LIKE'; |
@@ -234,32 +234,32 @@ discard block |
||
234 | 234 | $key = '_give_log_user_id'; |
235 | 235 | $compare = 'LIKE'; |
236 | 236 | |
237 | - if ( ! is_numeric( $search ) ) { |
|
237 | + if ( ! is_numeric($search)) { |
|
238 | 238 | // Searching for user by username |
239 | - $user = get_user_by( 'login', $search ); |
|
239 | + $user = get_user_by('login', $search); |
|
240 | 240 | |
241 | - if ( $user ) { |
|
241 | + if ($user) { |
|
242 | 242 | // Found one, set meta value to user's ID. |
243 | 243 | $search = $user->ID; |
244 | 244 | } else { |
245 | 245 | // No user found so let's do a real search query. |
246 | - $users = new WP_User_Query( array( |
|
246 | + $users = new WP_User_Query(array( |
|
247 | 247 | 'search' => $search, |
248 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
248 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
249 | 249 | 'number' => 1, |
250 | 250 | 'fields' => 'ids', |
251 | - ) ); |
|
251 | + )); |
|
252 | 252 | |
253 | 253 | $found_user = $users->get_results(); |
254 | 254 | |
255 | - if ( $found_user ) { |
|
255 | + if ($found_user) { |
|
256 | 256 | $search = $found_user[0]; |
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | - if ( ! $this->file_search ) { |
|
262 | + if ( ! $this->file_search) { |
|
263 | 263 | // Meta query only works for non file name search. |
264 | 264 | $meta_query[] = array( |
265 | 265 | 'key' => $key, |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @since 1.0 |
281 | 281 | * @return void |
282 | 282 | */ |
283 | - function bulk_actions( $which = '' ) { |
|
283 | + function bulk_actions($which = '') { |
|
284 | 284 | give_log_views(); |
285 | 285 | } |
286 | 286 | |
@@ -292,24 +292,24 @@ discard block |
||
292 | 292 | * @return void |
293 | 293 | */ |
294 | 294 | public function give_forms_filter() { |
295 | - $give_forms = get_posts( array( |
|
295 | + $give_forms = get_posts(array( |
|
296 | 296 | 'post_type' => 'give_forms', |
297 | 297 | 'post_status' => 'any', |
298 | - 'posts_per_page' => - 1, |
|
298 | + 'posts_per_page' => -1, |
|
299 | 299 | 'orderby' => 'title', |
300 | 300 | 'order' => 'ASC', |
301 | 301 | 'fields' => 'ids', |
302 | 302 | 'update_post_meta_cache' => false, |
303 | 303 | 'update_post_term_cache' => false, |
304 | - ) ); |
|
304 | + )); |
|
305 | 305 | |
306 | - if ( $give_forms ) { |
|
306 | + if ($give_forms) { |
|
307 | 307 | echo '<select name="form" id="give-log-form-filter">'; |
308 | - echo '<option value="0">' . __( 'All', 'give' ) . '</option>'; |
|
309 | - foreach ( $give_forms as $form ) { |
|
310 | - $form_title = get_the_title( $form ); |
|
311 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title; |
|
312 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>'; |
|
308 | + echo '<option value="0">'.__('All', 'give').'</option>'; |
|
309 | + foreach ($give_forms as $form) { |
|
310 | + $form_title = get_the_title($form); |
|
311 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title; |
|
312 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>'; |
|
313 | 313 | } |
314 | 314 | echo '</select>'; |
315 | 315 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $logs_data = array(); |
331 | 331 | $paged = $this->get_paged(); |
332 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
332 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
333 | 333 | $user = $this->get_filtered_user(); |
334 | 334 | |
335 | 335 | $log_query = array( |
@@ -340,38 +340,38 @@ discard block |
||
340 | 340 | 'posts_per_page' => $this->per_page, |
341 | 341 | ); |
342 | 342 | |
343 | - $cache_key = Give_Cache::get_key( 'get_logs', $log_query ); |
|
343 | + $cache_key = Give_Cache::get_key('get_logs', $log_query); |
|
344 | 344 | |
345 | 345 | // Return result from cache if exist. |
346 | - if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) { |
|
347 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
346 | + if ( ! ($logs_data = Give_Cache::get($cache_key))) { |
|
347 | + $logs = $give_logs->get_connected_logs($log_query); |
|
348 | 348 | |
349 | - if ( $logs ) { |
|
350 | - foreach ( $logs as $log ) { |
|
351 | - $payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
349 | + if ($logs) { |
|
350 | + foreach ($logs as $log) { |
|
351 | + $payment_id = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
352 | 352 | |
353 | 353 | // Make sure this payment hasn't been deleted. |
354 | - if ( get_post( $payment_id ) ) : |
|
355 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
356 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
357 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
354 | + if (get_post($payment_id)) : |
|
355 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
356 | + $payment_meta = give_get_payment_meta($payment_id); |
|
357 | + $payment_amount = give_get_payment_amount($payment_id); |
|
358 | 358 | |
359 | 359 | $logs_data[] = array( |
360 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
360 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
361 | 361 | 'payment_id' => $payment_id, |
362 | 362 | 'form' => $log->post_parent, |
363 | 363 | 'amount' => $payment_amount, |
364 | 364 | 'user_id' => $user_info['id'], |
365 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
366 | - 'date' => get_post_field( 'post_date', $payment_id ), |
|
365 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
366 | + 'date' => get_post_field('post_date', $payment_id), |
|
367 | 367 | ); |
368 | 368 | |
369 | 369 | endif; |
370 | 370 | } |
371 | 371 | |
372 | 372 | // Cache results. |
373 | - if ( ! empty( $logs_data ) ) { |
|
374 | - Give_Cache::set( $cache_key, $logs_data ); |
|
373 | + if ( ! empty($logs_data)) { |
|
374 | + Give_Cache::set($cache_key, $logs_data); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | } |
@@ -399,15 +399,15 @@ discard block |
||
399 | 399 | $columns = $this->get_columns(); |
400 | 400 | $hidden = array(); |
401 | 401 | $sortable = $this->get_sortable_columns(); |
402 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
402 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
403 | 403 | $current_page = $this->get_pagenum(); |
404 | 404 | $this->items = $this->get_logs(); |
405 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
405 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
406 | 406 | |
407 | - $this->set_pagination_args( array( |
|
407 | + $this->set_pagination_args(array( |
|
408 | 408 | 'total_items' => $total_items, |
409 | 409 | 'per_page' => $this->per_page, |
410 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
410 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
411 | 411 | ) |
412 | 412 | ); |
413 | 413 | } |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | - 'ajax' => false,// Does this table support ajax? |
|
52 | - ) ); |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | + 'ajax' => false, // Does this table support ajax? |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
67 | - $input_id = $input_id . '-search-input'; |
|
66 | + public function search_box($text, $input_id) { |
|
67 | + $input_id = $input_id.'-search-input'; |
|
68 | 68 | |
69 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
70 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
69 | + if ( ! empty($_REQUEST['orderby'])) { |
|
70 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
71 | 71 | } |
72 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
73 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
72 | + if ( ! empty($_REQUEST['order'])) { |
|
73 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
74 | 74 | } |
75 | 75 | ?> |
76 | 76 | <p class="search-box" role="search"> |
77 | 77 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
78 | 78 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
79 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
79 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
80 | 80 | </p> |
81 | 81 | <?php |
82 | 82 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_columns() { |
92 | 92 | $columns = array( |
93 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
94 | - 'details' => esc_html__( 'Request Details', 'give' ), |
|
95 | - 'ip' => esc_html__( 'Request IP', 'give' ), |
|
96 | - 'date' => esc_html__( 'Date', 'give' ), |
|
93 | + 'ID' => esc_html__('Log ID', 'give'), |
|
94 | + 'details' => esc_html__('Request Details', 'give'), |
|
95 | + 'ip' => esc_html__('Request IP', 'give'), |
|
96 | + 'date' => esc_html__('Date', 'give'), |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | return $columns; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Column Name |
112 | 112 | */ |
113 | - public function column_default( $item, $column_name ) { |
|
114 | - switch ( $column_name ) { |
|
113 | + public function column_default($item, $column_name) { |
|
114 | + switch ($column_name) { |
|
115 | 115 | default: |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function column_details( $item ) { |
|
130 | + public function column_details($item) { |
|
131 | 131 | ?> |
132 | - <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a> |
|
132 | + <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a> |
|
133 | 133 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
134 | 134 | <?php |
135 | 135 | |
136 | - $request = get_post_field( 'post_excerpt', $item['ID'] ); |
|
137 | - $error = get_post_field( 'post_content', $item['ID'] ); |
|
138 | - echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>'; |
|
139 | - echo '<div>' . $request . '</div>'; |
|
140 | - if ( ! empty( $error ) ) { |
|
141 | - echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>'; |
|
142 | - echo '<div>' . esc_html( $error ) . '</div>'; |
|
136 | + $request = get_post_field('post_excerpt', $item['ID']); |
|
137 | + $error = get_post_field('post_content', $item['ID']); |
|
138 | + echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>'; |
|
139 | + echo '<div>'.$request.'</div>'; |
|
140 | + if ( ! empty($error)) { |
|
141 | + echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>'; |
|
142 | + echo '<div>'.esc_html($error).'</div>'; |
|
143 | 143 | } |
144 | - echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>'; |
|
145 | - echo '<div>' . give_get_meta( $item['ID'], '_give_log_user', true ) . '</div>'; |
|
146 | - echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>'; |
|
147 | - echo '<div>' . give_get_meta( $item['ID'], '_give_log_key', true ) . '</div>'; |
|
148 | - echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>'; |
|
149 | - echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>'; |
|
144 | + echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>'; |
|
145 | + echo '<div>'.give_get_meta($item['ID'], '_give_log_user', true).'</div>'; |
|
146 | + echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>'; |
|
147 | + echo '<div>'.give_get_meta($item['ID'], '_give_log_key', true).'</div>'; |
|
148 | + echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>'; |
|
149 | + echo '<div>'.get_post_field('post_date', $item['ID']).'</div>'; |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | <?php |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string|bool String if search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
180 | - if ( 'top' === $which ) { |
|
181 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
179 | + protected function display_tablenav($which) { |
|
180 | + if ('top' === $which) { |
|
181 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
182 | 182 | } |
183 | 183 | ?> |
184 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
184 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
185 | 185 | |
186 | 186 | <div class="alignleft actions bulkactions"> |
187 | - <?php $this->bulk_actions( $which ); ?> |
|
187 | + <?php $this->bulk_actions($which); ?> |
|
188 | 188 | </div> |
189 | 189 | <?php |
190 | - $this->extra_tablenav( $which ); |
|
191 | - $this->pagination( $which ); |
|
190 | + $this->extra_tablenav($which); |
|
191 | + $this->pagination($which); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <br class="clear"/> |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | |
211 | 211 | $search = $this->get_search(); |
212 | 212 | |
213 | - if ( $search ) { |
|
214 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
213 | + if ($search) { |
|
214 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
215 | 215 | // This is an IP address search |
216 | 216 | $key = '_give_log_request_ip'; |
217 | - } elseif ( is_email( $search ) ) { |
|
217 | + } elseif (is_email($search)) { |
|
218 | 218 | // This is an email search |
219 | - $userdata = get_user_by( 'email', $search ); |
|
219 | + $userdata = get_user_by('email', $search); |
|
220 | 220 | |
221 | - if ( $userdata ) { |
|
221 | + if ($userdata) { |
|
222 | 222 | $search = $userdata->ID; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $key = '_give_log_user'; |
226 | - } elseif ( strlen( $search ) == 32 ) { |
|
226 | + } elseif (strlen($search) == 32) { |
|
227 | 227 | // Look for an API key |
228 | 228 | $key = '_give_log_key'; |
229 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
229 | + } elseif (stristr($search, 'token:')) { |
|
230 | 230 | // Look for an API token |
231 | - $search = str_ireplace( 'token:', '', $search ); |
|
231 | + $search = str_ireplace('token:', '', $search); |
|
232 | 232 | $key = '_give_log_token'; |
233 | 233 | } else { |
234 | 234 | // This is (probably) a user ID search |
235 | - $userdata = get_userdata( $search ); |
|
235 | + $userdata = get_userdata($search); |
|
236 | 236 | |
237 | - if ( $userdata ) { |
|
237 | + if ($userdata) { |
|
238 | 238 | $search = $userdata->ID; |
239 | 239 | } |
240 | 240 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return int Current page number |
261 | 261 | */ |
262 | 262 | public function get_paged() { |
263 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
263 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @since 1.0 |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - function bulk_actions( $which = '' ) { |
|
273 | + function bulk_actions($which = '') { |
|
274 | 274 | give_log_views(); |
275 | 275 | } |
276 | 276 | |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | 'posts_per_page' => $this->per_page, |
295 | 295 | ); |
296 | 296 | |
297 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
297 | + $logs = $give_logs->get_connected_logs($log_query); |
|
298 | 298 | |
299 | - if ( $logs ) { |
|
300 | - foreach ( $logs as $log ) { |
|
299 | + if ($logs) { |
|
300 | + foreach ($logs as $log) { |
|
301 | 301 | |
302 | 302 | $logs_data[] = array( |
303 | 303 | 'ID' => $log->ID, |
304 | - 'ip' => give_get_meta( $log->ID, '_give_log_request_ip', true ), |
|
304 | + 'ip' => give_get_meta($log->ID, '_give_log_request_ip', true), |
|
305 | 305 | 'date' => $log->post_date, |
306 | 306 | ); |
307 | 307 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | $columns = $this->get_columns(); |
330 | 330 | $hidden = array(); // No hidden columns |
331 | 331 | $sortable = $this->get_sortable_columns(); |
332 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
332 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
333 | 333 | $this->items = $this->get_logs(); |
334 | - $total_items = $give_logs->get_log_count( 0, 'api_request' ); |
|
334 | + $total_items = $give_logs->get_log_count(0, 'api_request'); |
|
335 | 335 | |
336 | - $this->set_pagination_args( array( |
|
336 | + $this->set_pagination_args(array( |
|
337 | 337 | 'total_items' => $total_items, |
338 | 338 | 'per_page' => $this->per_page, |
339 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
339 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
340 | 340 | ) |
341 | 341 | ); |
342 | 342 | } |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | // Set parent defaults. |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
50 | 50 | 'ajax' => false // Does this table support ajax?. |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Column Name. |
64 | 64 | */ |
65 | - public function column_default( $item, $column_name ) { |
|
65 | + public function column_default($item, $column_name) { |
|
66 | 66 | |
67 | - switch ( $column_name ) { |
|
67 | + switch ($column_name) { |
|
68 | 68 | case 'ID' : |
69 | 69 | return $item['ID_label']; |
70 | 70 | case 'payment_id' : |
71 | - return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) ); |
|
71 | + return empty($item['payment_id']) ? esc_html__('n/a', 'give') : sprintf("<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link($item['payment_id'])); |
|
72 | 72 | case 'gateway' : |
73 | - return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway']; |
|
73 | + return empty($item['gateway']) ? esc_html__('n/a', 'give') : $item['gateway']; |
|
74 | 74 | case 'error' : |
75 | - return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' ); |
|
75 | + return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give'); |
|
76 | 76 | default: |
77 | - return $item[ $column_name ]; |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function column_message( $item ) { ?> |
|
92 | - <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
91 | + public function column_message($item) { ?> |
|
92 | + <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
93 | 93 | <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;"> |
94 | 94 | <?php |
95 | 95 | |
96 | - $log_message = get_post_field( 'post_content', $item['ID'] ); |
|
96 | + $log_message = get_post_field('post_content', $item['ID']); |
|
97 | 97 | |
98 | - $serialized = strpos( $log_message, '{"' ); |
|
98 | + $serialized = strpos($log_message, '{"'); |
|
99 | 99 | |
100 | 100 | // Check to see if the log message contains serialized information |
101 | - if ( $serialized !== false ) { |
|
102 | - $length = strlen( $log_message ) - $serialized; |
|
103 | - $intro = substr( $log_message, 0, - $length ); |
|
104 | - $data = substr( $log_message, $serialized, strlen( $log_message ) - 1 ); |
|
101 | + if ($serialized !== false) { |
|
102 | + $length = strlen($log_message) - $serialized; |
|
103 | + $intro = substr($log_message, 0, - $length); |
|
104 | + $data = substr($log_message, $serialized, strlen($log_message) - 1); |
|
105 | 105 | |
106 | - echo wpautop( $intro ); |
|
107 | - echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' ); |
|
108 | - echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>'; |
|
106 | + echo wpautop($intro); |
|
107 | + echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>'); |
|
108 | + echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>'; |
|
109 | 109 | } else { |
110 | 110 | // No serialized data found |
111 | - echo wpautop( $log_message ); |
|
111 | + echo wpautop($log_message); |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | </div> |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function get_columns() { |
126 | 126 | $columns = array( |
127 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
128 | - 'error' => esc_html__( 'Error', 'give' ), |
|
129 | - 'gateway' => esc_html__( 'Gateway', 'give' ), |
|
130 | - 'payment_id' => esc_html__( 'Donation ID', 'give' ), |
|
131 | - 'date' => esc_html__( 'Date', 'give' ), |
|
132 | - 'message' => esc_html__( 'Details', 'give' ) |
|
127 | + 'ID' => esc_html__('Log ID', 'give'), |
|
128 | + 'error' => esc_html__('Error', 'give'), |
|
129 | + 'gateway' => esc_html__('Gateway', 'give'), |
|
130 | + 'payment_id' => esc_html__('Donation ID', 'give'), |
|
131 | + 'date' => esc_html__('Date', 'give'), |
|
132 | + 'message' => esc_html__('Details', 'give') |
|
133 | 133 | ); |
134 | 134 | |
135 | 135 | return $columns; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return int Current page number |
144 | 144 | */ |
145 | 145 | public function get_paged() { |
146 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
146 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @since 1.0 |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - public function bulk_actions( $which = '' ) { |
|
156 | + public function bulk_actions($which = '') { |
|
157 | 157 | give_log_views(); |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | // Prevent the queries from getting cached. |
173 | 173 | // Without this there are occasional memory issues for some installs. |
174 | - wp_suspend_cache_addition( true ); |
|
174 | + wp_suspend_cache_addition(true); |
|
175 | 175 | |
176 | 176 | $logs_data = array(); |
177 | 177 | $paged = $this->get_paged(); |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | 'posts_per_page' => $this->per_page, |
182 | 182 | ); |
183 | 183 | |
184 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
184 | + $logs = $give_logs->get_connected_logs($log_query); |
|
185 | 185 | |
186 | - if ( $logs ) { |
|
187 | - foreach ( $logs as $log ) { |
|
186 | + if ($logs) { |
|
187 | + foreach ($logs as $log) { |
|
188 | 188 | |
189 | 189 | $logs_data[] = array( |
190 | 190 | 'ID' => $log->ID, |
191 | - 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', |
|
191 | + 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>', |
|
192 | 192 | 'payment_id' => $log->post_parent, |
193 | 193 | 'error' => 'error', |
194 | - 'gateway' => give_get_payment_gateway( $log->post_parent ), |
|
194 | + 'gateway' => give_get_payment_gateway($log->post_parent), |
|
195 | 195 | 'date' => $log->post_date |
196 | 196 | ); |
197 | 197 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @param string $which |
215 | 215 | */ |
216 | - protected function display_tablenav( $which ) { |
|
217 | - if ( 'top' === $which ) { |
|
218 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
216 | + protected function display_tablenav($which) { |
|
217 | + if ('top' === $which) { |
|
218 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
219 | 219 | } |
220 | 220 | ?> |
221 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
221 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
222 | 222 | |
223 | 223 | <div class="alignleft actions bulkactions"> |
224 | - <?php $this->bulk_actions( $which ); ?> |
|
224 | + <?php $this->bulk_actions($which); ?> |
|
225 | 225 | </div> |
226 | 226 | <?php |
227 | - $this->extra_tablenav( $which ); |
|
228 | - $this->pagination( $which ); |
|
227 | + $this->extra_tablenav($which); |
|
228 | + $this->pagination($which); |
|
229 | 229 | ?> |
230 | 230 | |
231 | 231 | <br class="clear"/> |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | $columns = $this->get_columns(); |
253 | 253 | $hidden = array(); // No hidden columns |
254 | 254 | $sortable = $this->get_sortable_columns(); |
255 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
255 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
256 | 256 | $this->items = $this->get_logs(); |
257 | - $total_items = $give_logs->get_log_count( 0, 'gateway_error' ); |
|
257 | + $total_items = $give_logs->get_log_count(0, 'gateway_error'); |
|
258 | 258 | |
259 | - $this->set_pagination_args( array( |
|
259 | + $this->set_pagination_args(array( |
|
260 | 260 | 'total_items' => $total_items, |
261 | 261 | 'per_page' => $this->per_page, |
262 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
262 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | } |