Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Oct 8, 2024
1 parent 23b3829 commit f171e94
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Common/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,14 @@ public function get_data( string $endpoint, string $transient ): array {
return $data;
}

$url = $this->api_host . $this->api_namespace . $endpoint;

$url = add_query_arg(
'plugins',
[
'woo' => \is_plugin_active( 'woocommerce/woocommerce.php' ),
'cf7' => \is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ),
'edd' => ( \is_plugin_active( 'easy-digital-downloads/easy-digital-downloads.php' ) || \is_plugin_active( 'easy-digital-downloads-pro/easy-digital-downloads.php' ) ),
],
$url
$this->get_api_url( $endpoint )
);

$response = wp_remote_get( $url );
Expand All @@ -394,6 +392,17 @@ public function get_data( string $endpoint, string $transient ): array {
return $data;
}

/**
* Get API Url
*
* @param string $endpoint The endpoint.
*
* @return string The API Url.
*/
public function get_api_url( string $endpoint ): string {
return $this->api_host . $this->api_namespace . $endpoint;
}

/**
* Normalize and hash a string.
*
Expand Down

0 comments on commit f171e94

Please sign in to comment.