From 6a9d6760c0f5d73232995ea5802c3c42ff6346e6 Mon Sep 17 00:00:00 2001 From: Jason Adams Date: Mon, 27 Jan 2025 13:29:55 -0700 Subject: [PATCH] Enhancement: adds the ability to override GiveWP website urls (#7690) Co-authored-by: Jon Waldstein --- includes/class-give-license-handler.php | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/includes/class-give-license-handler.php b/includes/class-give-license-handler.php index 6ed4eb990a..807486cdb6 100644 --- a/includes/class-give-license-handler.php +++ b/includes/class-give-license-handler.php @@ -380,7 +380,7 @@ public static function request_license_api($api_params = [], $response_in_array // Call the API. $response = wp_remote_post( - self::$api_url, + self::get_api_url(), apply_filters( 'give_request_license_api_args', [ @@ -399,7 +399,7 @@ public static function request_license_api($api_params = [], $response_in_array 'License Api request failed', [ 'category' => 'License', - 'api url' => self::$api_url, + 'api url' => self::get_api_url(), 'request' => $api_params, 'status code' => $statusCode, 'response' => $response @@ -486,10 +486,15 @@ public static function get_downloads_url() { /** * Get account url * - * @return string|null + * @unreleased allows to override the API URL via constant * @since 2.5.0 */ - public static function get_website_url() { + public static function get_website_url(): ?string + { + if (defined('GIVE_SITE_URL')) { + return GIVE_SITE_URL; + } + return self::$site_url; } @@ -990,6 +995,20 @@ public static function getAddonSlugsFromAllAccessPassLicense( $license ) { return $result; } + + /** + * Returns the API URL for license requests, checking for a constant first. + * + * @unreleased + */ + public static function get_api_url(): string + { + if (defined('GIVE_LICENSE_API_URL')) { + return GIVE_LICENSE_API_URL; + } + + return self::$api_url; + } } endif; // end class_exists check.