@@ -89,14 +89,51 @@ public function make_request( $api_params = array() ) {
89
89
* @return array
90
90
*/
91
91
private function get_body ( array $ api_params ) {
92
- return wp_parse_args (
93
- $ api_params ,
94
- array (
95
- 'url ' => rawurlencode ( home_url () ),
96
- )
92
+
93
+ /**
94
+ * Filters the API parameters. The hook is specific to the API URL.
95
+ * For example, if the API URL is https://example.com, the hook will be `edd_sl_sdk_api_params_example`.
96
+ *
97
+ * @since <next-version>
98
+ * @param array $api_params The parameters for the specific request.
99
+ * @param string $api_url The API URL.
100
+ * @return array
101
+ */
102
+ return apply_filters (
103
+ $ this ->get_api_filter_hook (),
104
+ wp_parse_args (
105
+ $ api_params ,
106
+ array (
107
+ 'url ' => rawurlencode ( home_url () ),
108
+ 'environment ' => wp_get_environment_type (),
109
+ )
110
+ ),
111
+ $ this ->api_url
97
112
);
98
113
}
99
114
115
+ /**
116
+ * Gets the API hook.
117
+ *
118
+ * @since <next-version>
119
+ * @return string
120
+ */
121
+ private function get_api_filter_hook () {
122
+ $ url = wp_parse_url ( $ this ->api_url );
123
+ if ( empty ( $ url ['host ' ] ) ) {
124
+ return 'edd_sl_sdk_api_params ' ;
125
+ }
126
+
127
+ $ base = explode ( '. ' , $ url ['host ' ] );
128
+
129
+ // If the base is a subdomain, use the main domain.
130
+ if ( count ( $ base ) > 2 ) {
131
+ $ base = array_slice ( $ base , 1 );
132
+ }
133
+
134
+ return 'edd_sl_sdk_api_params_ ' . reset ( $ base );
135
+ }
136
+
100
137
/**
101
138
* Determines if a request has recently failed.
102
139
*
0 commit comments