Filter
uncanny-automator-pro
edd_sl_plugin_updater_api_params
Filters the parameters sent in the API request. Filters the parameters for the plugin updater API request before it's sent to the server.
add_filter( 'edd_sl_plugin_updater_api_params', $callback, 10, 1 );
Description
Allow developers to modify the parameters sent to the plugin update API. This filter fires just before the API request is made, enabling customization of the data payload, including license keys, plugin details, and site information. Use it to conditionally alter or add parameters for advanced update logic.
Usage
add_filter( 'edd_sl_plugin_updater_api_params', 'your_function_name', 10, 1 );
Parameters
-
$api_params(array) - The array of data sent in the request.
Return Value
The filtered value.
Examples
/**
* Add custom parameters to the EDD Software Licensing API request.
*
* This function hooks into the 'edd_sl_plugin_updater_api_params' filter
* to add or modify parameters sent to the Easy Digital Downloads
* Software Licensing API for plugin updates.
*
* @param array $api_params The existing array of data sent in the request.
* @param array $api_data The data set up in the EDD_SL_Plugin_Updater class constructor.
* @param string $plugin_file The full path and filename of the plugin being updated.
*
* @return array The modified array of API parameters.
*/
function my_custom_edd_sl_api_params( $api_params, $api_data, $plugin_file ) {
// Example: Add a custom parameter to check for a specific feature.
$api_params['my_custom_feature_check'] = 'enabled';
// Example: Conditionally modify a parameter based on the plugin file.
if ( strpos( $plugin_file, 'my-specific-plugin.php' ) !== false ) {
$api_params['license_status_check'] = 'detailed';
}
// Example: Log the parameters for debugging purposes (optional).
// error_log( 'EDD SL API Params: ' . print_r( $api_params, true ) );
// Always return the modified or original $api_params array.
return $api_params;
}
add_filter( 'edd_sl_plugin_updater_api_params', 'my_custom_edd_sl_api_params', 10, 3 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/core/admin/licensing/EDD_SL_Plugin_Updater.php:603
private function get_version_from_remote() {
$api_params = array(
'edd_action' => 'get_version',
'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '',
'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false,
'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false,
'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false,
'slug' => $this->slug,
'author' => $this->api_data['author'],
'url' => home_url(),
'beta' => $this->beta,
'php_version' => phpversion(),
'wp_version' => get_bloginfo( 'version' ),
);
/**
* Filters the parameters sent in the API request.
*
* @param array $api_params The array of data sent in the request.
* @param array $this->api_data The array of data set up in the class constructor.
* @param string $this->plugin_file The full path and filename of the file.
*/
$api_params = apply_filters( 'edd_sl_plugin_updater_api_params', $api_params, $this->api_data, $this->plugin_file );
$request = wp_remote_post(
$this->api_url,
array(
'timeout' => 15,
'sslverify' => $this->verify_ssl(),
'body' => $api_params,
)
);
if ( is_wp_error( $request ) || ( 200 !== wp_remote_retrieve_response_code( $request ) ) ) {
$this->log_failed_request();
return false;
}
$request = json_decode( wp_remote_retrieve_body( $request ) );
if ( $request && isset( $request->sections ) ) {
$request->sections = maybe_unserialize( $request->sections );
} else {
$request = false;
}
if ( $request && isset( $request->banners ) ) {
$request->banners = maybe_unserialize( $request->banners );
}
if ( $request && isset( $request->icons ) ) {
$request->icons = maybe_unserialize( $request->icons );
}
if ( ! empty( $request->sections ) ) {
foreach ( $request->sections as $key => $section ) {
$request->$key = (array) $section;
}
}
return $request;
}