@@ -165,10 +165,9 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @since 1.0 |
| 167 | 167 | * |
| 168 | - * @param $key $_SESSION key |
|
| 169 | - * @param $value $_SESSION variable |
|
| 170 | 168 | * |
| 171 | - * @return mixed Session variable |
|
| 169 | + * @param string $key |
|
| 170 | + * @return string Session variable |
|
| 172 | 171 | */ |
| 173 | 172 | public function set( $key, $value ) { |
| 174 | 173 | |
@@ -220,12 +219,12 @@ discard block |
||
| 220 | 219 | /** |
| 221 | 220 | * Starts a new session if one hasn't started yet. |
| 222 | 221 | * |
| 223 | - * @return null |
|
| 222 | + * @return boolean |
|
| 224 | 223 | * Checks to see if the server supports PHP sessions or if the GIVE_USE_PHP_SESSIONS constant is defined |
| 225 | 224 | * |
| 226 | 225 | * @access public |
| 227 | 226 | * @since 1.0 |
| 228 | - * @return bool $ret True if we are using PHP sessions, false otherwise |
|
| 227 | + * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
| 229 | 228 | */ |
| 230 | 229 | public function use_php_sessions() { |
| 231 | 230 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -70,49 +70,49 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function __construct() { |
| 72 | 72 | |
| 73 | - if ( is_admin() ) { |
|
| 73 | + if (is_admin()) { |
|
| 74 | 74 | return false; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $this->use_php_sessions = $this->use_php_sessions(); |
| 78 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
| 78 | + $this->exp_option = give_get_option('session_lifetime'); |
|
| 79 | 79 | |
| 80 | 80 | //PHP Sessions |
| 81 | - if ( $this->use_php_sessions ) { |
|
| 81 | + if ($this->use_php_sessions) { |
|
| 82 | 82 | |
| 83 | - if ( is_multisite() ) { |
|
| 83 | + if (is_multisite()) { |
|
| 84 | 84 | |
| 85 | - $this->prefix = '_' . get_current_blog_id(); |
|
| 85 | + $this->prefix = '_'.get_current_blog_id(); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - add_action( 'give_pre_process_purchase', array( $this, 'maybe_start_session' ), - 2 ); |
|
| 89 | + add_action('give_pre_process_purchase', array($this, 'maybe_start_session'), - 2); |
|
| 90 | 90 | |
| 91 | 91 | } else { |
| 92 | 92 | |
| 93 | 93 | // Use WP_Session |
| 94 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 95 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
| 94 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
| 95 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 99 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
| 98 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
| 99 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
| 103 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
| 104 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
| 102 | + if ( ! class_exists('WP_Session')) { |
|
| 103 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
| 104 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 108 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 107 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
| 108 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 113 | - add_action( 'plugins_loaded', array( $this, 'init' ), - 1 ); |
|
| 112 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
| 113 | + add_action('plugins_loaded', array($this, 'init'), - 1); |
|
| 114 | 114 | } else { |
| 115 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
| 115 | + add_action('init', array($this, 'init'), - 1); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | } |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function init() { |
| 128 | 128 | |
| 129 | - if ( $this->use_php_sessions ) { |
|
| 130 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
| 129 | + if ($this->use_php_sessions) { |
|
| 130 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
| 131 | 131 | } else { |
| 132 | 132 | $this->session = WP_Session::get_instance(); |
| 133 | 133 | } |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return string Session variable |
| 160 | 160 | */ |
| 161 | - public function get( $key ) { |
|
| 162 | - $key = sanitize_key( $key ); |
|
| 161 | + public function get($key) { |
|
| 162 | + $key = sanitize_key($key); |
|
| 163 | 163 | |
| 164 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
| 164 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return mixed Session variable |
| 177 | 177 | */ |
| 178 | - public function set( $key, $value ) { |
|
| 178 | + public function set($key, $value) { |
|
| 179 | 179 | |
| 180 | - $key = sanitize_key( $key ); |
|
| 180 | + $key = sanitize_key($key); |
|
| 181 | 181 | |
| 182 | - if ( is_array( $value ) ) { |
|
| 183 | - $this->session[ $key ] = serialize( $value ); |
|
| 182 | + if (is_array($value)) { |
|
| 183 | + $this->session[$key] = serialize($value); |
|
| 184 | 184 | } else { |
| 185 | - $this->session[ $key ] = $value; |
|
| 185 | + $this->session[$key] = $value; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if ( $this->use_php_sessions ) { |
|
| 189 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
| 188 | + if ($this->use_php_sessions) { |
|
| 189 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return $this->session[ $key ]; |
|
| 192 | + return $this->session[$key]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function set_expiration_variant_time() { |
| 206 | 206 | |
| 207 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
| 207 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function set_expiration_time() { |
| 221 | 221 | |
| 222 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
| 222 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -237,21 +237,21 @@ discard block |
||
| 237 | 237 | $ret = false; |
| 238 | 238 | |
| 239 | 239 | // If the database variable is already set, no need to run autodetection |
| 240 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
| 240 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
| 241 | 241 | |
| 242 | - if ( ! $give_use_php_sessions ) { |
|
| 242 | + if ( ! $give_use_php_sessions) { |
|
| 243 | 243 | |
| 244 | 244 | // Attempt to detect if the server supports PHP sessions |
| 245 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 245 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
| 246 | 246 | |
| 247 | - $this->set( 'give_use_php_sessions', 1 ); |
|
| 247 | + $this->set('give_use_php_sessions', 1); |
|
| 248 | 248 | |
| 249 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
| 249 | + if ($this->get('give_use_php_sessions')) { |
|
| 250 | 250 | |
| 251 | 251 | $ret = true; |
| 252 | 252 | |
| 253 | 253 | // Set the database option |
| 254 | - update_option( 'give_use_php_sessions', true ); |
|
| 254 | + update_option('give_use_php_sessions', true); |
|
| 255 | 255 | |
| 256 | 256 | } |
| 257 | 257 | |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant |
| 266 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
| 266 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
| 267 | 267 | $ret = true; |
| 268 | - } else if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
| 268 | + } else if (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
| 269 | 269 | $ret = false; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
| 272 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | // session_destroy(); //Uncomment for testing ONLY |
| 284 | 284 | |
| 285 | - if ( ! session_id() && ! headers_sent() ) { |
|
| 286 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
| 285 | + if ( ! session_id() && ! headers_sent()) { |
|
| 286 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
| 287 | 287 | session_start(); |
| 288 | - setcookie( session_name(), session_id(), $lifetime ); // |
|
| 289 | - setcookie( session_name() . '_expiration', $lifetime, $lifetime ); |
|
| 288 | + setcookie(session_name(), session_id(), $lifetime); // |
|
| 289 | + setcookie(session_name().'_expiration', $lifetime, $lifetime); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $expiration = false; |
| 303 | 303 | |
| 304 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
| 304 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
| 305 | 305 | |
| 306 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
| 306 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
@@ -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 | |
@@ -28,68 +28,68 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
| 31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
| 32 | 32 | |
| 33 | 33 | // Make sure that payments are only completed once |
| 34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
| 34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Make sure the payment completion is only processed when new status is complete |
| 39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
| 39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 44 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
| 45 | - $completed_date = give_get_payment_completed_date( $payment_id ); |
|
| 46 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 47 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
| 48 | - $amount = give_get_payment_amount( $payment_id ); |
|
| 43 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 44 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
| 45 | + $completed_date = give_get_payment_completed_date($payment_id); |
|
| 46 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 47 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
| 48 | + $amount = give_get_payment_amount($payment_id); |
|
| 49 | 49 | |
| 50 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
| 50 | + do_action('give_pre_complete_purchase', $payment_id); |
|
| 51 | 51 | |
| 52 | - $price_id = isset( $_POST['give-price-id'] ) ? (int) $_POST['give-price-id'] : false; |
|
| 52 | + $price_id = isset($_POST['give-price-id']) ? (int) $_POST['give-price-id'] : false; |
|
| 53 | 53 | |
| 54 | 54 | // Ensure these actions only run once, ever |
| 55 | - if ( empty( $completed_date ) ) { |
|
| 55 | + if (empty($completed_date)) { |
|
| 56 | 56 | |
| 57 | - if ( ! give_is_test_mode() || apply_filters( 'give_log_test_payment_stats', false ) ) { |
|
| 57 | + if ( ! give_is_test_mode() || apply_filters('give_log_test_payment_stats', false)) { |
|
| 58 | 58 | |
| 59 | - give_record_sale_in_log( $payment_meta['form_id'], $payment_id, $price_id, $creation_date ); |
|
| 60 | - give_increase_purchase_count( $payment_meta['form_id'] ); |
|
| 61 | - give_increase_earnings( $payment_meta['form_id'], $amount ); |
|
| 59 | + give_record_sale_in_log($payment_meta['form_id'], $payment_id, $price_id, $creation_date); |
|
| 60 | + give_increase_purchase_count($payment_meta['form_id']); |
|
| 61 | + give_increase_earnings($payment_meta['form_id'], $amount); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - do_action( 'give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta ); |
|
| 65 | + do_action('give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | // Clear the total earnings cache |
| 70 | - delete_transient( 'give_earnings_total' ); |
|
| 70 | + delete_transient('give_earnings_total'); |
|
| 71 | 71 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 72 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 73 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
| 72 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 73 | + delete_transient(md5('give_earnings_todaytoday')); |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | // Increase the donor's purchase stats |
| 77 | - Give()->customers->increment_stats( $donor_id, $amount ); |
|
| 77 | + Give()->customers->increment_stats($donor_id, $amount); |
|
| 78 | 78 | |
| 79 | - give_increase_total_earnings( $amount ); |
|
| 79 | + give_increase_total_earnings($amount); |
|
| 80 | 80 | |
| 81 | 81 | // Ensure this action only runs once ever |
| 82 | - if ( empty( $completed_date ) ) { |
|
| 82 | + if (empty($completed_date)) { |
|
| 83 | 83 | |
| 84 | 84 | // Save the completed date |
| 85 | - give_update_payment_meta( $payment_id, '_give_completed_date', current_time( 'mysql' ) ); |
|
| 85 | + give_update_payment_meta($payment_id, '_give_completed_date', current_time('mysql')); |
|
| 86 | 86 | |
| 87 | - do_action( 'give_complete_purchase', $payment_id ); |
|
| 87 | + do_action('give_complete_purchase', $payment_id); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
| 92 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -103,19 +103,19 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
| 106 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
| 107 | 107 | |
| 108 | 108 | // Get the list of statuses so that status in the payment note can be translated |
| 109 | 109 | $stati = give_get_payment_statuses(); |
| 110 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
| 111 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
| 110 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
| 111 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
| 112 | 112 | |
| 113 | - $status_change = sprintf( __( 'Status changed from %s to %s', 'give' ), $old_status, $new_status ); |
|
| 113 | + $status_change = sprintf(__('Status changed from %s to %s', 'give'), $old_status, $new_status); |
|
| 114 | 114 | |
| 115 | - give_insert_payment_note( $payment_id, $status_change ); |
|
| 115 | + give_insert_payment_note($payment_id, $status_change); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
| 118 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Reduces earnings and donation stats when a donation is refunded |
@@ -128,40 +128,40 @@ discard block |
||
| 128 | 128 | * |
| 129 | 129 | * @return void |
| 130 | 130 | */ |
| 131 | -function give_undo_donation_on_refund( $payment_id, $new_status, $old_status ) { |
|
| 131 | +function give_undo_donation_on_refund($payment_id, $new_status, $old_status) { |
|
| 132 | 132 | |
| 133 | - if ( 'publish' != $old_status && 'revoked' != $old_status ) { |
|
| 133 | + if ('publish' != $old_status && 'revoked' != $old_status) { |
|
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( 'refunded' != $new_status ) { |
|
| 137 | + if ('refunded' != $new_status) { |
|
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Set necessary vars |
| 142 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 143 | - $amount = give_get_payment_amount( $payment_id ); |
|
| 142 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 143 | + $amount = give_get_payment_amount($payment_id); |
|
| 144 | 144 | |
| 145 | 145 | // Undo this purchase |
| 146 | - give_undo_purchase( $payment_meta['form_id'], $payment_id ); |
|
| 146 | + give_undo_purchase($payment_meta['form_id'], $payment_id); |
|
| 147 | 147 | |
| 148 | 148 | // Decrease total earnings |
| 149 | - give_decrease_total_earnings( $amount ); |
|
| 149 | + give_decrease_total_earnings($amount); |
|
| 150 | 150 | |
| 151 | 151 | // Decrement the stats for the donor |
| 152 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
| 152 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
| 153 | 153 | |
| 154 | - if ( $donor_id ) { |
|
| 154 | + if ($donor_id) { |
|
| 155 | 155 | |
| 156 | - Give()->customers->decrement_stats( $donor_id, $amount ); |
|
| 156 | + Give()->customers->decrement_stats($donor_id, $amount); |
|
| 157 | 157 | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
| 161 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 161 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -add_action( 'give_update_payment_status', 'give_undo_donation_on_refund', 100, 3 ); |
|
| 164 | +add_action('give_update_payment_status', 'give_undo_donation_on_refund', 100, 3); |
|
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | * @param $new_status the status of the payment, probably "publish" |
| 175 | 175 | * @param $old_status the status of the payment prior to being marked as "complete", probably "pending" |
| 176 | 176 | */ |
| 177 | -function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) { |
|
| 178 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 177 | +function give_clear_user_history_cache($payment_id, $new_status, $old_status) { |
|
| 178 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 179 | 179 | |
| 180 | - delete_transient( 'give_user_' . $user_info['id'] . '_purchases' ); |
|
| 180 | + delete_transient('give_user_'.$user_info['id'].'_purchases'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | -add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 ); |
|
| 183 | +add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3); |
|
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Updates all old payments, prior to 1.2, with new |
@@ -194,32 +194,32 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return void |
| 196 | 196 | */ |
| 197 | -function give_update_old_payments_with_totals( $data ) { |
|
| 198 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
| 197 | +function give_update_old_payments_with_totals($data) { |
|
| 198 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
| 199 | 199 | return; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
| 202 | + if (get_option('give_payment_totals_upgraded')) { |
|
| 203 | 203 | return; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $payments = give_get_payments( array( |
|
| 206 | + $payments = give_get_payments(array( |
|
| 207 | 207 | 'offset' => 0, |
| 208 | - 'number' => - 1, |
|
| 208 | + 'number' => -1, |
|
| 209 | 209 | 'mode' => 'all' |
| 210 | - ) ); |
|
| 210 | + )); |
|
| 211 | 211 | |
| 212 | - if ( $payments ) { |
|
| 213 | - foreach ( $payments as $payment ) { |
|
| 214 | - $meta = give_get_payment_meta( $payment->ID ); |
|
| 215 | - give_update_payment_meta( $payment->ID, '_give_payment_total', $meta['amount'] ); |
|
| 212 | + if ($payments) { |
|
| 213 | + foreach ($payments as $payment) { |
|
| 214 | + $meta = give_get_payment_meta($payment->ID); |
|
| 215 | + give_update_payment_meta($payment->ID, '_give_payment_total', $meta['amount']); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
| 219 | + add_option('give_payment_totals_upgraded', 1); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
| 222 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * Updates week-old+ 'pending' orders to 'abandoned' |
@@ -228,29 +228,29 @@ discard block |
||
| 228 | 228 | * @return void |
| 229 | 229 | */ |
| 230 | 230 | function give_mark_abandoned_donations() { |
| 231 | - $args = array( |
|
| 231 | + $args = array( |
|
| 232 | 232 | 'status' => 'pending', |
| 233 | - 'number' => - 1, |
|
| 233 | + 'number' => -1, |
|
| 234 | 234 | 'fields' => 'ids' |
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 237 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 238 | 238 | |
| 239 | - $payments = give_get_payments( $args ); |
|
| 239 | + $payments = give_get_payments($args); |
|
| 240 | 240 | |
| 241 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 241 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 242 | 242 | |
| 243 | - if ( $payments ) { |
|
| 244 | - foreach ( $payments as $payment ) { |
|
| 245 | - $gateway = give_get_payment_gateway( $payment ); |
|
| 243 | + if ($payments) { |
|
| 244 | + foreach ($payments as $payment) { |
|
| 245 | + $gateway = give_get_payment_gateway($payment); |
|
| 246 | 246 | //Skip offline gateway payments |
| 247 | - if ( $gateway == 'offline' ) { |
|
| 247 | + if ($gateway == 'offline') { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | //Non-offline get marked as 'abandoned' |
| 251 | - give_update_payment_status( $payment, 'abandoned' ); |
|
| 251 | + give_update_payment_status($payment, 'abandoned'); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
| 257 | 256 | \ No newline at end of file |
| 257 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
| 258 | 258 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_process_purchase_form() { |
| 27 | 27 | |
| 28 | - do_action( 'give_pre_process_purchase' ); |
|
| 28 | + do_action('give_pre_process_purchase'); |
|
| 29 | 29 | |
| 30 | 30 | // Validate the form $_POST data |
| 31 | 31 | $valid_data = give_purchase_form_validate_fields(); |
| 32 | 32 | |
| 33 | 33 | // Allow themes and plugins to hook to errors |
| 34 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
| 34 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
| 35 | 35 | |
| 36 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 36 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 37 | 37 | |
| 38 | 38 | // Process the login form |
| 39 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
| 39 | + if (isset($_POST['give_login_submit'])) { |
|
| 40 | 40 | give_process_form_login(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Validate the user |
| 44 | - $user = give_get_purchase_form_user( $valid_data ); |
|
| 44 | + $user = give_get_purchase_form_user($valid_data); |
|
| 45 | 45 | |
| 46 | - if ( give_get_errors() || ! $user ) { |
|
| 47 | - if ( $is_ajax ) { |
|
| 48 | - do_action( 'give_ajax_checkout_errors' ); |
|
| 46 | + if (give_get_errors() || ! $user) { |
|
| 47 | + if ($is_ajax) { |
|
| 48 | + do_action('give_ajax_checkout_errors'); |
|
| 49 | 49 | give_die(); |
| 50 | 50 | } else { |
| 51 | 51 | return false; |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | //If AJAX send back success to proceed with form submission |
| 56 | - if ( $is_ajax ) { |
|
| 56 | + if ($is_ajax) { |
|
| 57 | 57 | echo 'success'; |
| 58 | 58 | give_die(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | //After AJAX: Setup session if not using php_sessions |
| 62 | - if ( ! Give()->session->use_php_sessions() ) { |
|
| 62 | + if ( ! Give()->session->use_php_sessions()) { |
|
| 63 | 63 | //Double-check that set_cookie is publicly accessible; |
| 64 | 64 | // we're using a slightly modified class-wp-sessions.php |
| 65 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
| 66 | - if ( $session_reflection->isPublic() ) { |
|
| 65 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
| 66 | + if ($session_reflection->isPublic()) { |
|
| 67 | 67 | // Manually set the cookie. |
| 68 | 68 | Give()->session->init()->set_cookie(); |
| 69 | 69 | } |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | 'address' => $user['address'] |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 81 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 82 | 82 | |
| 83 | 83 | // Setup purchase information |
| 84 | 84 | $purchase_data = array( |
| 85 | - 'price' => ( isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00' ), |
|
| 86 | - 'purchase_key' => strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ), |
|
| 85 | + 'price' => (isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'), |
|
| 86 | + 'purchase_key' => strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))), |
|
| 87 | 87 | 'user_email' => $user['user_email'], |
| 88 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 89 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 88 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 89 | + 'user_info' => stripslashes_deep($user_info), |
|
| 90 | 90 | 'post_data' => $_POST, |
| 91 | 91 | 'gateway' => $valid_data['gateway'], |
| 92 | 92 | 'card_info' => $valid_data['cc_info'] |
@@ -96,36 +96,36 @@ discard block |
||
| 96 | 96 | $valid_data['user'] = $user; |
| 97 | 97 | |
| 98 | 98 | // Allow themes and plugins to hook before the gateway |
| 99 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
| 99 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
| 100 | 100 | |
| 101 | 101 | //Sanity check for price |
| 102 | - if ( ! $purchase_data['price'] ) { |
|
| 102 | + if ( ! $purchase_data['price']) { |
|
| 103 | 103 | // Revert to manual |
| 104 | 104 | $purchase_data['gateway'] = 'manual'; |
| 105 | 105 | $_POST['give-gateway'] = 'manual'; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Allow the purchase data to be modified before it is sent to the gateway |
| 109 | - $purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data ); |
|
| 109 | + $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data); |
|
| 110 | 110 | |
| 111 | 111 | // Setup the data we're storing in the purchase session |
| 112 | 112 | $session_data = $purchase_data; |
| 113 | 113 | |
| 114 | 114 | // Make sure credit card numbers are never stored in sessions |
| 115 | - unset( $session_data['card_info']['card_number'] ); |
|
| 115 | + unset($session_data['card_info']['card_number']); |
|
| 116 | 116 | |
| 117 | 117 | // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data. |
| 118 | - give_set_purchase_session( $session_data ); |
|
| 118 | + give_set_purchase_session($session_data); |
|
| 119 | 119 | |
| 120 | 120 | // Send info to the gateway for payment processing |
| 121 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
| 121 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
| 122 | 122 | give_die(); |
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
| 127 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
| 128 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
| 126 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
| 127 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
| 128 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Process the checkout login form |
@@ -136,32 +136,32 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function give_process_form_login() { |
| 138 | 138 | |
| 139 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 139 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 140 | 140 | |
| 141 | 141 | $user_data = give_purchase_form_validate_user_login(); |
| 142 | 142 | |
| 143 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
| 144 | - if ( $is_ajax ) { |
|
| 145 | - do_action( 'give_ajax_checkout_errors' ); |
|
| 143 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
| 144 | + if ($is_ajax) { |
|
| 145 | + do_action('give_ajax_checkout_errors'); |
|
| 146 | 146 | give_die(); |
| 147 | 147 | } else { |
| 148 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 148 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 149 | 149 | exit; |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
| 153 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
| 154 | 154 | |
| 155 | - if ( $is_ajax ) { |
|
| 155 | + if ($is_ajax) { |
|
| 156 | 156 | echo 'success'; |
| 157 | 157 | give_die(); |
| 158 | 158 | } else { |
| 159 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 159 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
| 164 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
| 163 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
| 164 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * Purchase Form Validate Fields |
@@ -173,40 +173,40 @@ discard block |
||
| 173 | 173 | function give_purchase_form_validate_fields() { |
| 174 | 174 | |
| 175 | 175 | // Check if there is $_POST |
| 176 | - if ( empty( $_POST ) ) { |
|
| 176 | + if (empty($_POST)) { |
|
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 180 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 181 | 181 | |
| 182 | 182 | // Start an array to collect valid data |
| 183 | 183 | $valid_data = array( |
| 184 | 184 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
| 185 | - 'need_new_user' => false, // New user flag |
|
| 186 | - 'need_user_login' => false, // Login user flag |
|
| 187 | - 'logged_user_data' => array(), // Logged user collected data |
|
| 188 | - 'new_user_data' => array(), // New user collected data |
|
| 189 | - 'login_user_data' => array(), // Login user collected data |
|
| 190 | - 'guest_user_data' => array(), // Guest user collected data |
|
| 185 | + 'need_new_user' => false, // New user flag |
|
| 186 | + 'need_user_login' => false, // Login user flag |
|
| 187 | + 'logged_user_data' => array(), // Logged user collected data |
|
| 188 | + 'new_user_data' => array(), // New user collected data |
|
| 189 | + 'login_user_data' => array(), // Login user collected data |
|
| 190 | + 'guest_user_data' => array(), // Guest user collected data |
|
| 191 | 191 | 'cc_info' => give_purchase_form_validate_cc() // Credit card info |
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | 194 | // Validate agree to terms |
| 195 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 196 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
| 195 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 196 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
| 197 | 197 | give_purchase_form_validate_agree_to_terms(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( is_user_logged_in() ) { |
|
| 200 | + if (is_user_logged_in()) { |
|
| 201 | 201 | // Collect logged in user data |
| 202 | 202 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
| 203 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
| 203 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
| 204 | 204 | // Set new user registration as required |
| 205 | 205 | $valid_data['need_new_user'] = true; |
| 206 | 206 | // Validate new user data |
| 207 | 207 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
| 208 | 208 | // Check if login validation is needed |
| 209 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
| 209 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
| 210 | 210 | // Set user login as required |
| 211 | 211 | $valid_data['need_user_login'] = true; |
| 212 | 212 | // Validate users login info |
@@ -229,35 +229,35 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | function give_purchase_form_validate_gateway() { |
| 231 | 231 | |
| 232 | - $gateway = give_get_default_gateway( $_REQUEST['give-form-id'] ); |
|
| 232 | + $gateway = give_get_default_gateway($_REQUEST['give-form-id']); |
|
| 233 | 233 | |
| 234 | 234 | // Check if a gateway value is present |
| 235 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
| 235 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
| 236 | 236 | |
| 237 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
| 237 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
| 238 | 238 | |
| 239 | 239 | //Is amount being donated in LIVE mode above 0.00? |
| 240 | - if ( '0.00' == $_REQUEST['give-amount'] && ! give_is_test_mode() ) { |
|
| 240 | + if ('0.00' == $_REQUEST['give-amount'] && ! give_is_test_mode()) { |
|
| 241 | 241 | |
| 242 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
| 242 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
| 243 | 243 | |
| 244 | 244 | } //Check for a minimum custom amount |
| 245 | - elseif ( ! give_verify_minimum_price() ) { |
|
| 245 | + elseif ( ! give_verify_minimum_price()) { |
|
| 246 | 246 | |
| 247 | - $minimum = give_currency_filter( give_format_amount( give_get_form_minimum_price( $_REQUEST['give-form-id'] ) ) ); |
|
| 248 | - $error_message = __( 'This form has a minimum donation amount of %s', 'give' ); |
|
| 247 | + $minimum = give_currency_filter(give_format_amount(give_get_form_minimum_price($_REQUEST['give-form-id']))); |
|
| 248 | + $error_message = __('This form has a minimum donation amount of %s', 'give'); |
|
| 249 | 249 | |
| 250 | - give_set_error( 'invalid_donation_minimum', sprintf( $error_message, $minimum ) ); |
|
| 250 | + give_set_error('invalid_donation_minimum', sprintf($error_message, $minimum)); |
|
| 251 | 251 | |
| 252 | 252 | } //Is this test mode zero donation? Let it through but set to manual gateway |
| 253 | - elseif ( '0.00' == $_REQUEST['give-amount'] && give_is_test_mode() ) { |
|
| 253 | + elseif ('0.00' == $_REQUEST['give-amount'] && give_is_test_mode()) { |
|
| 254 | 254 | |
| 255 | 255 | $gateway = 'manual'; |
| 256 | 256 | |
| 257 | 257 | } //Check if this gateway is active |
| 258 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
| 258 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
| 259 | 259 | |
| 260 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'give' ) ); |
|
| 260 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give')); |
|
| 261 | 261 | |
| 262 | 262 | } |
| 263 | 263 | |
@@ -276,23 +276,23 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | function give_verify_minimum_price() { |
| 278 | 278 | |
| 279 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
| 279 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
| 280 | 280 | $form_id = $_REQUEST['give-form-id']; |
| 281 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
| 282 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
| 281 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
| 282 | + $variable_prices = give_has_variable_prices($form_id); |
|
| 283 | 283 | |
| 284 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
| 284 | + if ($variable_prices && ! empty($price_id)) { |
|
| 285 | 285 | |
| 286 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
| 286 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
| 287 | 287 | |
| 288 | - if ( $price_level_amount == $amount ) { |
|
| 288 | + if ($price_level_amount == $amount) { |
|
| 289 | 289 | return true; |
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
| 293 | + $minimum = give_get_form_minimum_price($form_id); |
|
| 294 | 294 | |
| 295 | - if ( $minimum > $amount ) { |
|
| 295 | + if ($minimum > $amount) { |
|
| 296 | 296 | return false; |
| 297 | 297 | } |
| 298 | 298 | |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | function give_purchase_form_validate_agree_to_terms() { |
| 310 | 310 | // Validate agree to terms |
| 311 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
| 311 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
| 312 | 312 | // User did not agree |
| 313 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms of use', 'give' ) ) ); |
|
| 313 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms of use', 'give'))); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
@@ -324,47 +324,47 @@ discard block |
||
| 324 | 324 | * |
| 325 | 325 | * @return array |
| 326 | 326 | */ |
| 327 | -function give_purchase_form_required_fields( $form_id ) { |
|
| 327 | +function give_purchase_form_required_fields($form_id) { |
|
| 328 | 328 | |
| 329 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 329 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 330 | 330 | |
| 331 | 331 | $required_fields = array( |
| 332 | 332 | 'give_email' => array( |
| 333 | 333 | 'error_id' => 'invalid_email', |
| 334 | - 'error_message' => __( 'Please enter a valid email address', 'give' ) |
|
| 334 | + 'error_message' => __('Please enter a valid email address', 'give') |
|
| 335 | 335 | ), |
| 336 | 336 | 'give_first' => array( |
| 337 | 337 | 'error_id' => 'invalid_first_name', |
| 338 | - 'error_message' => __( 'Please enter your first name', 'give' ) |
|
| 338 | + 'error_message' => __('Please enter your first name', 'give') |
|
| 339 | 339 | ) |
| 340 | 340 | ); |
| 341 | 341 | |
| 342 | - $require_address = give_require_billing_address( $payment_mode ); |
|
| 342 | + $require_address = give_require_billing_address($payment_mode); |
|
| 343 | 343 | |
| 344 | - if ( $require_address ) { |
|
| 345 | - $required_fields['card_address'] = array( |
|
| 344 | + if ($require_address) { |
|
| 345 | + $required_fields['card_address'] = array( |
|
| 346 | 346 | 'error_id' => 'invalid_card_address', |
| 347 | - 'error_message' => __( 'Please enter your primary billing address', 'give' ) |
|
| 347 | + 'error_message' => __('Please enter your primary billing address', 'give') |
|
| 348 | 348 | ); |
| 349 | - $required_fields['card_zip'] = array( |
|
| 349 | + $required_fields['card_zip'] = array( |
|
| 350 | 350 | 'error_id' => 'invalid_zip_code', |
| 351 | - 'error_message' => __( 'Please enter your zip / postal code', 'give' ) |
|
| 351 | + 'error_message' => __('Please enter your zip / postal code', 'give') |
|
| 352 | 352 | ); |
| 353 | - $required_fields['card_city'] = array( |
|
| 353 | + $required_fields['card_city'] = array( |
|
| 354 | 354 | 'error_id' => 'invalid_city', |
| 355 | - 'error_message' => __( 'Please enter your billing city', 'give' ) |
|
| 355 | + 'error_message' => __('Please enter your billing city', 'give') |
|
| 356 | 356 | ); |
| 357 | 357 | $required_fields['billing_country'] = array( |
| 358 | 358 | 'error_id' => 'invalid_country', |
| 359 | - 'error_message' => __( 'Please select your billing country', 'give' ) |
|
| 359 | + 'error_message' => __('Please select your billing country', 'give') |
|
| 360 | 360 | ); |
| 361 | - $required_fields['card_state'] = array( |
|
| 361 | + $required_fields['card_state'] = array( |
|
| 362 | 362 | 'error_id' => 'invalid_state', |
| 363 | - 'error_message' => __( 'Please enter billing state / province', 'give' ) |
|
| 363 | + 'error_message' => __('Please enter billing state / province', 'give') |
|
| 364 | 364 | ); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id ); |
|
| 367 | + return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id); |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
@@ -377,16 +377,16 @@ discard block |
||
| 377 | 377 | * |
| 378 | 378 | * @return mixed|void |
| 379 | 379 | */ |
| 380 | -function give_require_billing_address( $payment_mode ) { |
|
| 380 | +function give_require_billing_address($payment_mode) { |
|
| 381 | 381 | |
| 382 | 382 | $return = false; |
| 383 | 383 | |
| 384 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
| 384 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
| 385 | 385 | $return = true; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | // Let payment gateways and other extensions determine if address fields should be required |
| 389 | - return apply_filters( 'give_require_billing_address', $return ); |
|
| 389 | + return apply_filters('give_require_billing_address', $return); |
|
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | |
@@ -400,43 +400,43 @@ discard block |
||
| 400 | 400 | function give_purchase_form_validate_logged_in_user() { |
| 401 | 401 | global $user_ID; |
| 402 | 402 | |
| 403 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 403 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 404 | 404 | |
| 405 | 405 | // Start empty array to collect valid user data |
| 406 | 406 | $valid_user_data = array( |
| 407 | 407 | // Assume there will be errors |
| 408 | - 'user_id' => - 1 |
|
| 408 | + 'user_id' => -1 |
|
| 409 | 409 | ); |
| 410 | 410 | |
| 411 | 411 | // Verify there is a user_ID |
| 412 | - if ( $user_ID > 0 ) { |
|
| 412 | + if ($user_ID > 0) { |
|
| 413 | 413 | // Get the logged in user data |
| 414 | - $user_data = get_userdata( $user_ID ); |
|
| 414 | + $user_data = get_userdata($user_ID); |
|
| 415 | 415 | |
| 416 | 416 | // Loop through required fields and show error messages |
| 417 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
| 418 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 419 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 417 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
| 418 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 419 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | // Verify data |
| 424 | - if ( $user_data ) { |
|
| 424 | + if ($user_data) { |
|
| 425 | 425 | // Collected logged in user data |
| 426 | 426 | $valid_user_data = array( |
| 427 | 427 | 'user_id' => $user_ID, |
| 428 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
| 429 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
| 430 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
| 428 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
| 429 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
| 430 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
| 431 | 431 | ); |
| 432 | 432 | |
| 433 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
| 434 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 433 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
| 434 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | } else { |
| 438 | 438 | // Set invalid user error |
| 439 | - give_set_error( 'invalid_user', __( 'The user information is invalid', 'give' ) ); |
|
| 439 | + give_set_error('invalid_user', __('The user information is invalid', 'give')); |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
@@ -454,92 +454,92 @@ discard block |
||
| 454 | 454 | function give_purchase_form_validate_new_user() { |
| 455 | 455 | |
| 456 | 456 | $registering_new_user = false; |
| 457 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 457 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 458 | 458 | |
| 459 | 459 | // Start an empty array to collect valid user data |
| 460 | 460 | $valid_user_data = array( |
| 461 | 461 | // Assume there will be errors |
| 462 | - 'user_id' => - 1, |
|
| 462 | + 'user_id' => -1, |
|
| 463 | 463 | // Get first name |
| 464 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
| 464 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
| 465 | 465 | // Get last name |
| 466 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
| 466 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
| 467 | 467 | ); |
| 468 | 468 | |
| 469 | 469 | // Check the new user's credentials against existing ones |
| 470 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
| 471 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
| 472 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
| 473 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
| 470 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
| 471 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
| 472 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
| 473 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
| 474 | 474 | |
| 475 | 475 | // Loop through required fields and show error messages |
| 476 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
| 477 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 478 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 476 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
| 477 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 478 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | // Check if we have an username to register |
| 483 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
| 483 | + if ($user_login && strlen($user_login) > 0) { |
|
| 484 | 484 | $registering_new_user = true; |
| 485 | 485 | |
| 486 | 486 | // We have an user name, check if it already exists |
| 487 | - if ( username_exists( $user_login ) ) { |
|
| 487 | + if (username_exists($user_login)) { |
|
| 488 | 488 | // Username already registered |
| 489 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
| 489 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
| 490 | 490 | // Check if it's valid |
| 491 | - } else if ( ! give_validate_username( $user_login ) ) { |
|
| 491 | + } else if ( ! give_validate_username($user_login)) { |
|
| 492 | 492 | // Invalid username |
| 493 | - if ( is_multisite() ) { |
|
| 494 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give' ) ); |
|
| 493 | + if (is_multisite()) { |
|
| 494 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give')); |
|
| 495 | 495 | } else { |
| 496 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
| 496 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
| 497 | 497 | } |
| 498 | 498 | } else { |
| 499 | 499 | // All the checks have run and it's good to go |
| 500 | 500 | $valid_user_data['user_login'] = $user_login; |
| 501 | 501 | } |
| 502 | 502 | } else { |
| 503 | - if ( give_no_guest_checkout( $form_id ) ) { |
|
| 504 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation', 'give' ) ); |
|
| 503 | + if (give_no_guest_checkout($form_id)) { |
|
| 504 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation', 'give')); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | // Check if we have an email to verify |
| 509 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
| 509 | + if ($user_email && strlen($user_email) > 0) { |
|
| 510 | 510 | // Validate email |
| 511 | - if ( ! is_email( $user_email ) ) { |
|
| 512 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 511 | + if ( ! is_email($user_email)) { |
|
| 512 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 513 | 513 | // Check if email exists |
| 514 | - } else if ( email_exists( $user_email ) && $registering_new_user ) { |
|
| 515 | - give_set_error( 'email_used', __( 'Email already used', 'give' ) ); |
|
| 514 | + } else if (email_exists($user_email) && $registering_new_user) { |
|
| 515 | + give_set_error('email_used', __('Email already used', 'give')); |
|
| 516 | 516 | } else { |
| 517 | 517 | // All the checks have run and it's good to go |
| 518 | 518 | $valid_user_data['user_email'] = $user_email; |
| 519 | 519 | } |
| 520 | 520 | } else { |
| 521 | 521 | // No email |
| 522 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
| 522 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | // Check password |
| 526 | - if ( $user_pass && $pass_confirm ) { |
|
| 526 | + if ($user_pass && $pass_confirm) { |
|
| 527 | 527 | // Verify confirmation matches |
| 528 | - if ( $user_pass != $pass_confirm ) { |
|
| 528 | + if ($user_pass != $pass_confirm) { |
|
| 529 | 529 | // Passwords do not match |
| 530 | - give_set_error( 'password_mismatch', __( 'Passwords don\'t match', 'give' ) ); |
|
| 530 | + give_set_error('password_mismatch', __('Passwords don\'t match', 'give')); |
|
| 531 | 531 | } else { |
| 532 | 532 | // All is good to go |
| 533 | 533 | $valid_user_data['user_pass'] = $user_pass; |
| 534 | 534 | } |
| 535 | 535 | } else { |
| 536 | 536 | // Password or confirmation missing |
| 537 | - if ( ! $user_pass && $registering_new_user ) { |
|
| 537 | + if ( ! $user_pass && $registering_new_user) { |
|
| 538 | 538 | // The password is invalid |
| 539 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
| 540 | - } else if ( ! $pass_confirm && $registering_new_user ) { |
|
| 539 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
| 540 | + } else if ( ! $pass_confirm && $registering_new_user) { |
|
| 541 | 541 | // Confirmation password is invalid |
| 542 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation', 'give' ) ); |
|
| 542 | + give_set_error('confirmation_empty', __('Enter the password confirmation', 'give')); |
|
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | |
@@ -558,34 +558,34 @@ discard block |
||
| 558 | 558 | // Start an array to collect valid user data |
| 559 | 559 | $valid_user_data = array( |
| 560 | 560 | // Assume there will be errors |
| 561 | - 'user_id' => - 1 |
|
| 561 | + 'user_id' => -1 |
|
| 562 | 562 | ); |
| 563 | 563 | |
| 564 | 564 | // Username |
| 565 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
| 566 | - give_set_error( 'must_log_in', __( 'You must login or register to complete your donation', 'give' ) ); |
|
| 565 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
| 566 | + give_set_error('must_log_in', __('You must login or register to complete your donation', 'give')); |
|
| 567 | 567 | |
| 568 | 568 | return $valid_user_data; |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | // Get the user by login |
| 572 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
| 572 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
| 573 | 573 | |
| 574 | 574 | // Check if user exists |
| 575 | - if ( $user_data ) { |
|
| 575 | + if ($user_data) { |
|
| 576 | 576 | // Get password |
| 577 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
| 577 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
| 578 | 578 | |
| 579 | 579 | // Check user_pass |
| 580 | - if ( $user_pass ) { |
|
| 580 | + if ($user_pass) { |
|
| 581 | 581 | // Check if password is valid |
| 582 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
| 582 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
| 583 | 583 | // Incorrect password |
| 584 | 584 | give_set_error( |
| 585 | 585 | 'password_incorrect', |
| 586 | 586 | sprintf( |
| 587 | - __( 'The password you entered is incorrect. %sReset Password%s', 'give' ), |
|
| 588 | - '<a href="' . wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) . '" title="' . __( 'Lost Password', 'give' ) . '">', |
|
| 587 | + __('The password you entered is incorrect. %sReset Password%s', 'give'), |
|
| 588 | + '<a href="'.wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]").'" title="'.__('Lost Password', 'give').'">', |
|
| 589 | 589 | '</a>' |
| 590 | 590 | ) |
| 591 | 591 | ); |
@@ -603,11 +603,11 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | } else { |
| 605 | 605 | // Empty password |
| 606 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
| 606 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
| 607 | 607 | } |
| 608 | 608 | } else { |
| 609 | 609 | // no username |
| 610 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
| 610 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | return $valid_user_data; |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | */ |
| 623 | 623 | function give_purchase_form_validate_guest_user() { |
| 624 | 624 | |
| 625 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 625 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 626 | 626 | |
| 627 | 627 | // Start an array to collect valid user data |
| 628 | 628 | $valid_user_data = array( |
@@ -631,32 +631,32 @@ discard block |
||
| 631 | 631 | ); |
| 632 | 632 | |
| 633 | 633 | // Show error message if user must be logged in |
| 634 | - if ( give_logged_in_only() ) { |
|
| 635 | - give_set_error( 'logged_in_only', __( 'You must be logged into an account to donation', 'give' ) ); |
|
| 634 | + if (give_logged_in_only()) { |
|
| 635 | + give_set_error('logged_in_only', __('You must be logged into an account to donation', 'give')); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | // Get the guest email |
| 639 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
| 639 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
| 640 | 640 | |
| 641 | 641 | // Check email |
| 642 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
| 642 | + if ($guest_email && strlen($guest_email) > 0) { |
|
| 643 | 643 | // Validate email |
| 644 | - if ( ! is_email( $guest_email ) ) { |
|
| 644 | + if ( ! is_email($guest_email)) { |
|
| 645 | 645 | // Invalid email |
| 646 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 646 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 647 | 647 | } else { |
| 648 | 648 | // All is good to go |
| 649 | 649 | $valid_user_data['user_email'] = $guest_email; |
| 650 | 650 | } |
| 651 | 651 | } else { |
| 652 | 652 | // No email |
| 653 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
| 653 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | // Loop through required fields and show error messages |
| 657 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
| 658 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 659 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 657 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
| 658 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 659 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
@@ -672,42 +672,42 @@ discard block |
||
| 672 | 672 | * @since 1.0 |
| 673 | 673 | * @return integer |
| 674 | 674 | */ |
| 675 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
| 675 | +function give_register_and_login_new_user($user_data = array()) { |
|
| 676 | 676 | // Verify the array |
| 677 | - if ( empty( $user_data ) ) { |
|
| 678 | - return - 1; |
|
| 677 | + if (empty($user_data)) { |
|
| 678 | + return -1; |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - if ( give_get_errors() ) { |
|
| 682 | - return - 1; |
|
| 681 | + if (give_get_errors()) { |
|
| 682 | + return -1; |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
| 686 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
| 687 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
| 688 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
| 689 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
| 690 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
| 691 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 692 | - 'role' => get_option( 'default_role' ) |
|
| 693 | - ), $user_data ); |
|
| 685 | + $user_args = apply_filters('give_insert_user_args', array( |
|
| 686 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
| 687 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
| 688 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
| 689 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
| 690 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
| 691 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 692 | + 'role' => get_option('default_role') |
|
| 693 | + ), $user_data); |
|
| 694 | 694 | |
| 695 | 695 | // Insert new user |
| 696 | - $user_id = wp_insert_user( $user_args ); |
|
| 696 | + $user_id = wp_insert_user($user_args); |
|
| 697 | 697 | |
| 698 | 698 | // Validate inserted user |
| 699 | - if ( is_wp_error( $user_id ) ) { |
|
| 700 | - return - 1; |
|
| 699 | + if (is_wp_error($user_id)) { |
|
| 700 | + return -1; |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | // Allow themes and plugins to filter the user data |
| 704 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
| 704 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
| 705 | 705 | |
| 706 | 706 | // Allow themes and plugins to hook |
| 707 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
| 707 | + do_action('give_insert_user', $user_id, $user_data); |
|
| 708 | 708 | |
| 709 | 709 | // Login new user |
| 710 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
| 710 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
| 711 | 711 | |
| 712 | 712 | // Return user id |
| 713 | 713 | return $user_id; |
@@ -722,26 +722,26 @@ discard block |
||
| 722 | 722 | * @since 1.0 |
| 723 | 723 | * @return array |
| 724 | 724 | */ |
| 725 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
| 725 | +function give_get_purchase_form_user($valid_data = array()) { |
|
| 726 | 726 | // Initialize user |
| 727 | 727 | $user = false; |
| 728 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 728 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 729 | 729 | |
| 730 | - if ( $is_ajax ) { |
|
| 730 | + if ($is_ajax) { |
|
| 731 | 731 | // Do not create or login the user during the ajax submission (check for errors only) |
| 732 | 732 | return true; |
| 733 | - } else if ( is_user_logged_in() ) { |
|
| 733 | + } else if (is_user_logged_in()) { |
|
| 734 | 734 | // Set the valid user as the logged in collected data |
| 735 | 735 | $user = $valid_data['logged_in_user']; |
| 736 | - } else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
| 736 | + } else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
| 737 | 737 | // New user registration |
| 738 | - if ( $valid_data['need_new_user'] === true ) { |
|
| 738 | + if ($valid_data['need_new_user'] === true) { |
|
| 739 | 739 | // Set user |
| 740 | 740 | $user = $valid_data['new_user_data']; |
| 741 | 741 | // Register and login new user |
| 742 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
| 742 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
| 743 | 743 | // User login |
| 744 | - } else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
| 744 | + } else if ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
| 745 | 745 | |
| 746 | 746 | /* |
| 747 | 747 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -756,48 +756,48 @@ discard block |
||
| 756 | 756 | // Set user |
| 757 | 757 | $user = $valid_data['login_user_data']; |
| 758 | 758 | // Login user |
| 759 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
| 759 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | // Check guest checkout |
| 764 | - if ( false === $user && false === give_no_guest_checkout( $_POST['give-form-id'] ) ) { |
|
| 764 | + if (false === $user && false === give_no_guest_checkout($_POST['give-form-id'])) { |
|
| 765 | 765 | // Set user |
| 766 | 766 | $user = $valid_data['guest_user_data']; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | // Verify we have an user |
| 770 | - if ( false === $user || empty( $user ) ) { |
|
| 770 | + if (false === $user || empty($user)) { |
|
| 771 | 771 | // Return false |
| 772 | 772 | return false; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | // Get user first name |
| 776 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
| 777 | - $user['user_first'] = isset( $_POST["give_first"] ) ? strip_tags( trim( $_POST["give_first"] ) ) : ''; |
|
| 776 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
| 777 | + $user['user_first'] = isset($_POST["give_first"]) ? strip_tags(trim($_POST["give_first"])) : ''; |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // Get user last name |
| 781 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
| 782 | - $user['user_last'] = isset( $_POST["give_last"] ) ? strip_tags( trim( $_POST["give_last"] ) ) : ''; |
|
| 781 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
| 782 | + $user['user_last'] = isset($_POST["give_last"]) ? strip_tags(trim($_POST["give_last"])) : ''; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // Get the user's billing address details |
| 786 | 786 | $user['address'] = array(); |
| 787 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
| 788 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
| 789 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
| 790 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
| 791 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
| 792 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
| 793 | - |
|
| 794 | - if ( empty( $user['address']['country'] ) ) { |
|
| 787 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
| 788 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
| 789 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
| 790 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
| 791 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
| 792 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
| 793 | + |
|
| 794 | + if (empty($user['address']['country'])) { |
|
| 795 | 795 | $user['address'] = false; |
| 796 | 796 | } // Country will always be set if address fields are present |
| 797 | 797 | |
| 798 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
| 798 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
| 799 | 799 | // Store the address in the user's meta so the cart can be pre-populated with it on return purchases |
| 800 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
| 800 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | // Return valid user |
@@ -816,16 +816,16 @@ discard block |
||
| 816 | 816 | $card_data = give_get_purchase_cc_info(); |
| 817 | 817 | |
| 818 | 818 | // Validate the card zip |
| 819 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
| 820 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
| 821 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid', 'give' ) ); |
|
| 819 | + if ( ! empty($card_data['card_zip'])) { |
|
| 820 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
| 821 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid', 'give')); |
|
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | //Ensure no spaces |
| 826 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
| 827 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs |
|
| 828 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
| 826 | + if ( ! empty($card_data['card_number'])) { |
|
| 827 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs |
|
| 828 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | // This should validate card numbers at some point too |
@@ -841,17 +841,17 @@ discard block |
||
| 841 | 841 | */ |
| 842 | 842 | function give_get_purchase_cc_info() { |
| 843 | 843 | $cc_info = array(); |
| 844 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 845 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 846 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 847 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 848 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 849 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
| 850 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
| 851 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
| 852 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
| 853 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
| 854 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
| 844 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 845 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 846 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 847 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 848 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 849 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
| 850 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
| 851 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
| 852 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
| 853 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
| 854 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
| 855 | 855 | |
| 856 | 856 | // Return cc info |
| 857 | 857 | return $cc_info; |
@@ -867,14 +867,14 @@ discard block |
||
| 867 | 867 | * |
| 868 | 868 | * @return bool|mixed|void |
| 869 | 869 | */ |
| 870 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 870 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 871 | 871 | $ret = false; |
| 872 | 872 | |
| 873 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 873 | + if (empty($zip) || empty($country_code)) { |
|
| 874 | 874 | return $ret; |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - $country_code = strtoupper( $country_code ); |
|
| 877 | + $country_code = strtoupper($country_code); |
|
| 878 | 878 | |
| 879 | 879 | $zip_regex = array( |
| 880 | 880 | "AD" => "AD\d{3}", |
@@ -1034,11 +1034,11 @@ discard block |
||
| 1034 | 1034 | "ZM" => "\d{5}" |
| 1035 | 1035 | ); |
| 1036 | 1036 | |
| 1037 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
| 1037 | + if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) { |
|
| 1038 | 1038 | $ret = true; |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
| 1041 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | |
@@ -1048,48 +1048,48 @@ discard block |
||
| 1048 | 1048 | * @since 1.0 |
| 1049 | 1049 | * @return void |
| 1050 | 1050 | */ |
| 1051 | -function give_check_purchase_email( $valid_data, $posted ) { |
|
| 1051 | +function give_check_purchase_email($valid_data, $posted) { |
|
| 1052 | 1052 | $is_banned = false; |
| 1053 | 1053 | $banned = give_get_banned_emails(); |
| 1054 | 1054 | |
| 1055 | - if ( empty( $banned ) ) { |
|
| 1055 | + if (empty($banned)) { |
|
| 1056 | 1056 | return; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - if ( is_user_logged_in() ) { |
|
| 1059 | + if (is_user_logged_in()) { |
|
| 1060 | 1060 | |
| 1061 | 1061 | // The user is logged in, check that their account email is not banned |
| 1062 | - $user_data = get_userdata( get_current_user_id() ); |
|
| 1063 | - if ( give_is_email_banned( $user_data->user_email ) ) { |
|
| 1062 | + $user_data = get_userdata(get_current_user_id()); |
|
| 1063 | + if (give_is_email_banned($user_data->user_email)) { |
|
| 1064 | 1064 | |
| 1065 | 1065 | $is_banned = true; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - if ( give_is_email_banned( $posted['give_email'] ) ) { |
|
| 1068 | + if (give_is_email_banned($posted['give_email'])) { |
|
| 1069 | 1069 | $is_banned = true; |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | - } elseif ( isset( $posted['give-purchase-var'] ) && $posted['give-purchase-var'] == 'needs-to-login' ) { |
|
| 1072 | + } elseif (isset($posted['give-purchase-var']) && $posted['give-purchase-var'] == 'needs-to-login') { |
|
| 1073 | 1073 | |
| 1074 | 1074 | // The user is logging in, check that their email is not banned |
| 1075 | - $user_data = get_user_by( 'login', $posted['give_user_login'] ); |
|
| 1076 | - if ( $user_data && give_is_email_banned( $user_data->user_email ) ) { |
|
| 1075 | + $user_data = get_user_by('login', $posted['give_user_login']); |
|
| 1076 | + if ($user_data && give_is_email_banned($user_data->user_email)) { |
|
| 1077 | 1077 | $is_banned = true; |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | } else { |
| 1081 | 1081 | |
| 1082 | 1082 | // Guest purchase, check that the email is not banned |
| 1083 | - if ( give_is_email_banned( $posted['give_email'] ) ) { |
|
| 1083 | + if (give_is_email_banned($posted['give_email'])) { |
|
| 1084 | 1084 | $is_banned = true; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | - if ( $is_banned ) { |
|
| 1089 | + if ($is_banned) { |
|
| 1090 | 1090 | // Set an error and give the donor a general error (don't alert them that they were banned) |
| 1091 | - give_set_error( 'email_banned', __( 'An internal error has occurred, please try again or contact support.', 'give' ) ); |
|
| 1091 | + give_set_error('email_banned', __('An internal error has occurred, please try again or contact support.', 'give')); |
|
| 1092 | 1092 | } |
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | -add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 ); |
|
| 1095 | +add_action('give_checkout_error_checks', 'give_check_purchase_email', 10, 2); |
|