Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: adds the ability to override GiveWP website urls #7690

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading