Skip to content

Commit

Permalink
Enhancement: adds the ability to override GiveWP website urls (#7690)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Waldstein <jon@givewp.com>
  • Loading branch information
JasonTheAdams and jonwaldstein authored Jan 27, 2025
1 parent 3fe9f4d commit 6a9d676
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions includes/class-give-license-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.

0 comments on commit 6a9d676

Please sign in to comment.