diff --git a/give.php b/give.php index 318b08575b..fa3aa3c5c0 100644 --- a/give.php +++ b/give.php @@ -391,7 +391,7 @@ private function setup_constants() { // Plugin version. if (!defined('GIVE_VERSION')) { - define('GIVE_VERSION', '3.0.0'); + define('GIVE_VERSION', '2.33.4'); } // Plugin Root File. diff --git a/includes/gateways/stripe/includes/give-stripe-helpers.php b/includes/gateways/stripe/includes/give-stripe-helpers.php index 1fbf6ca7fb..341365bf4f 100644 --- a/includes/gateways/stripe/includes/give-stripe-helpers.php +++ b/includes/gateways/stripe/includes/give-stripe-helpers.php @@ -10,9 +10,7 @@ * @license https://opensource.org/licenses/gpl-license GNU Public License */ -use Give\Log\Log; use Give\PaymentGateways\Exceptions\InvalidPropertyName; -use Give\PaymentGateways\Stripe\Models\AccountDetail; use Give\PaymentGateways\Stripe\Repositories\Settings; use Give\ValueObjects\Money; @@ -1475,15 +1473,14 @@ function give_stripe_get_account_options() { /** * This function is used to get single ip address for Stripe. * - * @since 2.7.0 + * @since 2.7.0 * * @return string + * + * @deprecated 2.33.5 Use give_get_ip method to get the single IP address. */ function give_stripe_get_ip_address() { - - $ip_address_details = explode( ',', give_get_ip() ); - - return $ip_address_details[0]; + return give_get_ip(); } /** diff --git a/includes/misc-functions.php b/includes/misc-functions.php index 96b7f925d7..9b4faac62a 100644 --- a/includes/misc-functions.php +++ b/includes/misc-functions.php @@ -145,40 +145,51 @@ function give_get_timezone_id() { * * Returns the IP address of the current visitor * + * @since 2.33.5 Add $single param. + * @since 1.0 + * * @return string $ip User's IP address - * @since 1.0 */ -function give_get_ip() { - - $ip = '127.0.0.1'; +function give_get_ip($single = true) +{ + $ip_addresses = '127.0.0.1'; + $header_type = ''; if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { // check ip from share internet - $ip = $_SERVER['HTTP_CLIENT_IP']; + $ip_addresses = $_SERVER['HTTP_CLIENT_IP']; + $header_type = 'HTTP_CLIENT_IP'; } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { // to check ip is pass from proxy - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + $ip_addresses = $_SERVER['HTTP_X_FORWARDED_FOR']; + $header_type = 'HTTP_X_FORWARDED_FOR'; } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { - $ip = $_SERVER['REMOTE_ADDR']; + $ip_addresses = $_SERVER['REMOTE_ADDR']; + $header_type = 'REMOTE_ADDR'; } /** * Filter the IP * - * @since 1.0 + * @since 2.33.5 Add $single and $header_type params. + * @since 1.0 */ - $ip = apply_filters( 'give_get_ip', $ip ); + $ip_addresses = apply_filters('give_get_ip', $ip_addresses, $single, $header_type); // Filter empty values. - if ( false !== strpos( $ip, ',' ) ) { - $ip = give_clean( explode( ',', $ip ) ); - $ip = array_filter( $ip ); - $ip = implode( ',', $ip ); + if (false !== strpos($ip_addresses, ',')) { + $ip_addresses = give_clean(explode(',', $ip_addresses)); + $ip_addresses = array_filter($ip_addresses); + $ip_addresses = implode(',', $ip_addresses); } else { - $ip = give_clean( $ip ); + $ip_addresses = give_clean($ip_addresses); } - return $ip; + if ($single && false !== strpos($ip_addresses, ',')) { + return explode(',', $ip_addresses)[0]; + } + + return $ip_addresses; } diff --git a/readme.txt b/readme.txt index 5aded6085b..31005143fb 100644 --- a/readme.txt +++ b/readme.txt @@ -258,6 +258,9 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri 8. GiveWP has a dedicated support team to help answer any questions you may have and help you through stumbling blocks. == Changelog == += 2.33.4: October 4th, 2023 = +* Fix: Update old sendwp buttons and remove unused Stripe disconnect function. + = 2.33.3: September 29th, 2023 = * Fix: Multi-site installations no longer produce an error on subsites. diff --git a/src/PaymentGateways/Gateways/Stripe/BECSGateway.php b/src/PaymentGateways/Gateways/Stripe/BECSGateway.php index 07978b0558..d6cbdf3fff 100644 --- a/src/PaymentGateways/Gateways/Stripe/BECSGateway.php +++ b/src/PaymentGateways/Gateways/Stripe/BECSGateway.php @@ -113,6 +113,7 @@ public function getLegacyFormFieldMarkup(int $formId, array $args): string } /** + * @since 2.33.5 Use give_get_ip() instead of give_stripe_get_ip_address() * @since 2.19.0 * @return array */ @@ -125,7 +126,7 @@ protected function getPaymentIntentArgs(): array 'customer_acceptance' => [ 'type' => 'online', 'online' => [ - 'ip_address' => give_stripe_get_ip_address(), + 'ip_address' => give_get_ip(), 'user_agent' => give_get_user_agent(), ], ], diff --git a/src/PaymentGateways/Gateways/Stripe/SEPAGateway.php b/src/PaymentGateways/Gateways/Stripe/SEPAGateway.php index 75dfb7c844..be52b751bb 100644 --- a/src/PaymentGateways/Gateways/Stripe/SEPAGateway.php +++ b/src/PaymentGateways/Gateways/Stripe/SEPAGateway.php @@ -115,6 +115,7 @@ public function getLegacyFormFieldMarkup(int $formId, array $args): string } /** + * @since 2.33.5 Use give_get_ip() instead of give_stripe_get_ip_address() * @since 2.19.0 * @return array */ @@ -127,7 +128,7 @@ protected function getPaymentIntentArgs(): array 'customer_acceptance' => [ 'type' => 'online', 'online' => [ - 'ip_address' => give_stripe_get_ip_address(), + 'ip_address' => give_get_ip(), 'user_agent' => give_get_user_agent(), ], ],